From 4de558008131f3a2e998433544392132a15b4918 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Thu, 2 Nov 2017 10:43:21 -0400 Subject: [PATCH 001/582] Sync unity changes to mono from unity-2017-02-staging --- .gitmodules | 3 + Makefile.am | 4 +- autogen.sh | 12 + configure.ac | 66 +- external/bdwgc | 1 + .../monodistribution/bin/cli | 5 + .../monodistribution/bin/cli.bat | 7 + .../monodistribution/bin/cli_x86 | 4 + .../monodistribution/bin/ilasm | 3 + .../monodistribution/bin/ilasm.bat | 2 + .../monodistribution/bin/mcs | 3 + .../monodistribution/bin/mcs.bat | 2 + .../monodistribution/bin/mono-env | 7 + .../monodistribution/bin/monobin-env | 14 + .../monodistribution/bin/monolinker | 5 + .../monodistribution/bin/monolinker.bat | 2 + .../monodistribution/bin/nunit-console | 5 + .../monodistribution/bin/nunit-console.bat | 2 + .../monodistribution/bin/nunit-console2 | 5 + .../monodistribution/bin/resgen2 | 5 + .../monodistribution/bin/resgen2.bat | 2 + .../monodistribution/bin/xbuild | 5 + .../monodistribution/bin/xbuild.bat | 2 + external/buildscripts/build.pl | 1802 +++++++++++++++ external/buildscripts/build_all_linux.pl | 27 + external/buildscripts/build_all_osx.pl | 165 ++ external/buildscripts/build_all_win.pl | 27 + external/buildscripts/build_classlibs_osx.pl | 40 + external/buildscripts/build_classlibs_wsl.pl | 53 + external/buildscripts/build_ios_xwin.pl | 18 + external/buildscripts/build_ios_xwin.sh | 19 + .../buildscripts/build_runtime_android.pl | 30 + .../buildscripts/build_runtime_android.sh | 8 + external/buildscripts/build_runtime_iphone.pl | 67 + external/buildscripts/build_runtime_iphone.sh | 20 + external/buildscripts/build_runtime_linux.pl | 23 + external/buildscripts/build_runtime_osx.pl | 11 + external/buildscripts/build_runtime_qnx.sh | 13 + external/buildscripts/build_runtime_stv.sh | 14 + external/buildscripts/build_runtime_tizen.pl | 18 + external/buildscripts/build_runtime_tizen.sh | 8 + external/buildscripts/build_runtime_vs.pl | 52 + external/buildscripts/build_runtime_win.pl | 14 + external/buildscripts/build_runtime_win64.pl | 14 + external/buildscripts/build_runtime_wsl.pl | 13 + .../build_unityscript_bareminimum_win.pl | 159 ++ external/buildscripts/build_us_and_boo.pl | 140 ++ external/buildscripts/build_win_no_cygwin.pl | 294 +++ external/buildscripts/build_win_wrapper.pl | 231 ++ external/buildscripts/build_win_wrapper.sh | 12 + external/buildscripts/collect_allbuilds.pl | 46 + external/buildscripts/copy_il2cpp_sources.pl | 60 + .../perl_lib/File/Copy/Recursive.pm | 696 ++++++ external/buildscripts/perl_lib/Tools.pm | 40 + external/buildscripts/sources.txt | 535 +++++ external/buildscripts/test-driver | 100 + mcs/Makefile | 4 + mcs/build/common/Consts.cs.in | 4 +- mcs/build/profiles/net_4_x.make | 2 +- mcs/build/profiles/unityaot.make | 40 + mcs/build/profiles/unityjit.make | 17 + .../System.Drawing.Primitives/Makefile | 2 +- mcs/class/Facades/netstandard/Makefile | 4 +- mcs/class/Facades/subdirs.make | 6 + mcs/class/Makefile | 24 +- .../unityaot_System.Core.dll.sources | 1 + .../unityjit_System.Core.dll.sources | 1 + .../unityjit_System.Data.dll.sources | 4 + .../unityaot_System.Drawing.dll.sources | 1 + .../unityaot_System.IdentityModel.dll.sources | 1 + .../unityjit_System.IdentityModel.dll.sources | 1 + ...t_System.Runtime.Serialization.dll.sources | 1 + ...t_System.Runtime.Serialization.dll.sources | 1 + .../EventLogEntryType.cs | 7 +- ...ityaot_System.ServiceModel.Web.dll.sources | 1 + mcs/class/System.ServiceModel/Dummy_XM_4_5.cs | 4 + .../unityaot_System.ServiceModel.dll.sources | 1 + .../unityaot_System.Web.Services.dll.sources | 1 + .../unityaot_System.Xml.dll.sources | 1 + .../Mono.Util/MonoPInvokeCallbackAttribute.cs | 1 + mcs/class/System/System.Net.Sockets/Socket.cs | 9 +- .../System.Net/ServicePointManager.extra.cs | 2 +- mcs/class/System/unityaot_System.dll.sources | 4 + mcs/class/System/unityjit_System.dll.sources | 1 + mcs/class/corlib/Assembly/AssemblyInfo.cs | 2 +- mcs/class/corlib/System.IO/MonoIO.cs | 3 + mcs/class/corlib/System.IO/Path.cs | 3 + .../diagnostics/DiagnosticsConfiguration.cs | 6 +- .../monitoring/system/diagnosticts/Process.cs | 2 +- .../diagnosticts/ProcessModuleCollection.cs | 2 +- .../diagnosticts/ProcessThreadCollection.cs | 2 +- .../mscorlib/system/reflection/binder.cs | 2 +- .../threading/synchronizationcontext.cs | 2 +- mono/eglib/gdate-unity.c | 8 + mono/eglib/gdir-unity.c | 133 ++ mono/eglib/gfile-unity.c | 107 + mono/eglib/gmisc-unity.c | 77 + mono/metadata/Makefile.am | 44 +- mono/metadata/assembly.c | 54 +- mono/metadata/assembly.h | 1 + mono/metadata/boehm-gc.c | 39 +- mono/metadata/class-internals.h | 8 +- mono/metadata/class.c | 8 +- mono/metadata/cominterop.c | 21 +- mono/metadata/console-unity.c | 47 + mono/metadata/domain-internals.h | 2 +- mono/metadata/file-mmap-unity.c | 115 + mono/metadata/gc-internals.h | 3 +- mono/metadata/handle.h | 11 +- mono/metadata/icall-def.h | 7 +- mono/metadata/icall.c | 7 + mono/metadata/il2cpp-compat-metadata.h | 36 + mono/metadata/image.c | 9 + mono/metadata/loader.c | 6 + mono/metadata/metadata.c | 2 + mono/metadata/mono-hash.c | 1 + mono/metadata/null-gc.c | 5 + mono/metadata/object-internals.h | 2 +- mono/metadata/profiler.c | 102 + mono/metadata/profiler.h | 2 + mono/metadata/security-manager.h | 2 +- mono/metadata/sgen-mono.c | 5 + mono/metadata/threads-types.h | 8 +- mono/metadata/threads.c | 26 +- mono/metadata/unity-liveness.c | 646 ++++++ mono/metadata/unity-memory-info.c | 15 + mono/metadata/unity-memory-info.h | 100 + mono/metadata/unity-utils.c | 1281 +++++++++++ mono/metadata/unity-utils.h | 182 ++ mono/metadata/verify-internals.h | 2 +- mono/metadata/w32error-unity.c | 27 + mono/metadata/w32event-unity.c | 84 + mono/metadata/w32file-unity.c | 554 +++++ mono/metadata/w32file.c | 20 + mono/metadata/w32mutex-unity.c | 49 + mono/metadata/w32process-unity.c | 174 ++ mono/metadata/w32semaphore-unity.c | 42 + mono/metadata/w32socket-internals.h | 3 + mono/metadata/w32socket-unity.c | 190 ++ mono/metadata/w32socket-win32.c | 1 - mono/metadata/w32socket.c | 6 + mono/metadata/w32socket.h | 3 + mono/mini/.gitignore | 1 + mono/mini/Makefile.am.in | 88 +- mono/mini/debugger-agent.c | 1994 ++++++++++++++--- mono/mini/debugger-agent.h | 10 + mono/mini/exceptions-amd64.c | 2 +- mono/mini/il2cpp-c-types.h | 447 ++++ mono/mini/il2cpp-compat.h | 662 ++++++ mono/mini/il2cpp-stubs.cpp | 1722 ++++++++++++++ mono/mini/mini-unity.c | 32 + mono/mini/pmip_my_callstack.c | 134 ++ mono/mini/pmip_my_callstack.h | 17 + mono/utils/gc_wrapper.h | 23 + mono/utils/mono-compiler.h | 2 + mono/utils/mono-dl-unity.c | 75 + mono/utils/mono-error.c | 61 +- mono/utils/mono-log-unity.c | 24 + mono/utils/mono-path.c | 2 +- mono/utils/mono-publib.h | 2 + mono/utils/mono-threads-posix.c | 6 + mono/utils/mono-threads-unity.c | 171 ++ mono/utils/networking-unity.c | 47 + mono/utils/os-event-unity.c | 43 + mono/utils/unity-rand.c | 96 + mono/utils/unity-time.c | 45 + msvc/.gitignore | 1 + msvc/libgcbdwgc.vcxproj | 170 ++ msvc/libgcbdwgc.vcxproj.filters | 6 + msvc/libmini-unity.targets | 6 + msvc/libmini-unity.targets.filters | 13 + msvc/libmini.targets | 1 + msvc/libmini.targets.filters | 1 + msvc/libmono-dynamic.vcxproj | 8 +- msvc/libmono-static.vcxproj | 3 + msvc/libmonoruntime-unity.targets | 10 + msvc/libmonoruntime-unity.targets.filters | 28 + msvc/libmonoruntime.targets | 1 + msvc/libmonoruntime.targets.filters | 1 + msvc/mono.props | 18 +- msvc/mono.sln | 19 +- runtime/Makefile.am | 8 + 182 files changed, 15016 insertions(+), 366 deletions(-) create mode 160000 external/bdwgc create mode 100755 external/buildscripts/add_to_build_results/monodistribution/bin/cli create mode 100644 external/buildscripts/add_to_build_results/monodistribution/bin/cli.bat create mode 100755 external/buildscripts/add_to_build_results/monodistribution/bin/cli_x86 create mode 100755 external/buildscripts/add_to_build_results/monodistribution/bin/ilasm create mode 100644 external/buildscripts/add_to_build_results/monodistribution/bin/ilasm.bat create mode 100755 external/buildscripts/add_to_build_results/monodistribution/bin/mcs create mode 100644 external/buildscripts/add_to_build_results/monodistribution/bin/mcs.bat create mode 100755 external/buildscripts/add_to_build_results/monodistribution/bin/mono-env create mode 100644 external/buildscripts/add_to_build_results/monodistribution/bin/monobin-env create mode 100755 external/buildscripts/add_to_build_results/monodistribution/bin/monolinker create mode 100644 external/buildscripts/add_to_build_results/monodistribution/bin/monolinker.bat create mode 100755 external/buildscripts/add_to_build_results/monodistribution/bin/nunit-console create mode 100644 external/buildscripts/add_to_build_results/monodistribution/bin/nunit-console.bat create mode 100755 external/buildscripts/add_to_build_results/monodistribution/bin/nunit-console2 create mode 100755 external/buildscripts/add_to_build_results/monodistribution/bin/resgen2 create mode 100644 external/buildscripts/add_to_build_results/monodistribution/bin/resgen2.bat create mode 100755 external/buildscripts/add_to_build_results/monodistribution/bin/xbuild create mode 100644 external/buildscripts/add_to_build_results/monodistribution/bin/xbuild.bat create mode 100644 external/buildscripts/build.pl create mode 100644 external/buildscripts/build_all_linux.pl create mode 100644 external/buildscripts/build_all_osx.pl create mode 100644 external/buildscripts/build_all_win.pl create mode 100644 external/buildscripts/build_classlibs_osx.pl create mode 100644 external/buildscripts/build_classlibs_wsl.pl create mode 100644 external/buildscripts/build_ios_xwin.pl create mode 100644 external/buildscripts/build_ios_xwin.sh create mode 100644 external/buildscripts/build_runtime_android.pl create mode 100644 external/buildscripts/build_runtime_android.sh create mode 100644 external/buildscripts/build_runtime_iphone.pl create mode 100644 external/buildscripts/build_runtime_iphone.sh create mode 100644 external/buildscripts/build_runtime_linux.pl create mode 100644 external/buildscripts/build_runtime_osx.pl create mode 100644 external/buildscripts/build_runtime_qnx.sh create mode 100644 external/buildscripts/build_runtime_stv.sh create mode 100644 external/buildscripts/build_runtime_tizen.pl create mode 100644 external/buildscripts/build_runtime_tizen.sh create mode 100644 external/buildscripts/build_runtime_vs.pl create mode 100644 external/buildscripts/build_runtime_win.pl create mode 100644 external/buildscripts/build_runtime_win64.pl create mode 100644 external/buildscripts/build_runtime_wsl.pl create mode 100644 external/buildscripts/build_unityscript_bareminimum_win.pl create mode 100644 external/buildscripts/build_us_and_boo.pl create mode 100644 external/buildscripts/build_win_no_cygwin.pl create mode 100644 external/buildscripts/build_win_wrapper.pl create mode 100644 external/buildscripts/build_win_wrapper.sh create mode 100644 external/buildscripts/collect_allbuilds.pl create mode 100644 external/buildscripts/copy_il2cpp_sources.pl create mode 100644 external/buildscripts/perl_lib/File/Copy/Recursive.pm create mode 100644 external/buildscripts/perl_lib/Tools.pm create mode 100644 external/buildscripts/sources.txt create mode 100644 external/buildscripts/test-driver create mode 100644 mcs/build/profiles/unityaot.make create mode 100644 mcs/build/profiles/unityjit.make create mode 100644 mcs/class/System.Core/unityaot_System.Core.dll.sources create mode 100644 mcs/class/System.Core/unityjit_System.Core.dll.sources create mode 100644 mcs/class/System.Data/unityjit_System.Data.dll.sources create mode 100644 mcs/class/System.Drawing/unityaot_System.Drawing.dll.sources create mode 100644 mcs/class/System.IdentityModel/unityaot_System.IdentityModel.dll.sources create mode 100644 mcs/class/System.IdentityModel/unityjit_System.IdentityModel.dll.sources create mode 100644 mcs/class/System.Runtime.Serialization/unityaot_System.Runtime.Serialization.dll.sources create mode 100644 mcs/class/System.Runtime.Serialization/unityjit_System.Runtime.Serialization.dll.sources create mode 100644 mcs/class/System.ServiceModel.Web/unityaot_System.ServiceModel.Web.dll.sources create mode 100644 mcs/class/System.ServiceModel/unityaot_System.ServiceModel.dll.sources create mode 100644 mcs/class/System.Web.Services/unityaot_System.Web.Services.dll.sources create mode 100644 mcs/class/System.XML/unityaot_System.Xml.dll.sources create mode 100644 mcs/class/System/unityaot_System.dll.sources create mode 100644 mcs/class/System/unityjit_System.dll.sources create mode 100644 mono/eglib/gdate-unity.c create mode 100644 mono/eglib/gdir-unity.c create mode 100644 mono/eglib/gfile-unity.c create mode 100644 mono/eglib/gmisc-unity.c create mode 100644 mono/metadata/console-unity.c create mode 100644 mono/metadata/file-mmap-unity.c create mode 100644 mono/metadata/il2cpp-compat-metadata.h create mode 100644 mono/metadata/unity-liveness.c create mode 100644 mono/metadata/unity-memory-info.c create mode 100644 mono/metadata/unity-memory-info.h create mode 100644 mono/metadata/unity-utils.c create mode 100644 mono/metadata/unity-utils.h create mode 100644 mono/metadata/w32error-unity.c create mode 100644 mono/metadata/w32event-unity.c create mode 100644 mono/metadata/w32file-unity.c create mode 100644 mono/metadata/w32mutex-unity.c create mode 100644 mono/metadata/w32process-unity.c create mode 100644 mono/metadata/w32semaphore-unity.c create mode 100644 mono/metadata/w32socket-unity.c create mode 100644 mono/mini/il2cpp-c-types.h create mode 100644 mono/mini/il2cpp-compat.h create mode 100644 mono/mini/il2cpp-stubs.cpp create mode 100644 mono/mini/mini-unity.c create mode 100644 mono/mini/pmip_my_callstack.c create mode 100644 mono/mini/pmip_my_callstack.h create mode 100644 mono/utils/mono-dl-unity.c create mode 100644 mono/utils/mono-log-unity.c create mode 100644 mono/utils/mono-threads-unity.c create mode 100644 mono/utils/networking-unity.c create mode 100644 mono/utils/os-event-unity.c create mode 100644 mono/utils/unity-rand.c create mode 100644 mono/utils/unity-time.c create mode 100644 msvc/libgcbdwgc.vcxproj create mode 100644 msvc/libgcbdwgc.vcxproj.filters create mode 100644 msvc/libmini-unity.targets create mode 100644 msvc/libmini-unity.targets.filters create mode 100644 msvc/libmonoruntime-unity.targets create mode 100644 msvc/libmonoruntime-unity.targets.filters diff --git a/.gitmodules b/.gitmodules index 4e968d7a0663..04b5228b6bef 100644 --- a/.gitmodules +++ b/.gitmodules @@ -58,3 +58,6 @@ [submodule "external/api-snapshot"] path = external/api-snapshot url = git://github.com/mono/api-snapshot.git +[submodule "external/bdwgc"] + path = external/bdwgc + url = git://github.com/Unity-Technologies/bdwgc.git diff --git a/Makefile.am b/Makefile.am index f9dd1784c836..024324e3fc7f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,9 +17,9 @@ else support_dir = endif -SUBDIRS = po $(libgc_dir) mono $(ikvm_native_dir) $(support_dir) data runtime scripts man samples $(tools_dir) msvc $(docs_dir) acceptance-tests llvm +SUBDIRS = po $(libgc_dir) $(bdwgc_dir) mono $(ikvm_native_dir) $(support_dir) data runtime scripts man samples $(tools_dir) msvc $(docs_dir) acceptance-tests llvm # Keep in sync with SUBDIRS -DIST_SUBDIRS = m4 po $(libgc_dir) mono ikvm-native $(support_dir) data runtime scripts man samples tools msvc docs acceptance-tests llvm +DIST_SUBDIRS = m4 po $(libgc_dir) $(bdwgc_dir) mono ikvm-native $(support_dir) data runtime scripts man samples tools msvc docs acceptance-tests llvm all: update_submodules diff --git a/autogen.sh b/autogen.sh index 7c58e0921502..88c2eded6c6f 100755 --- a/autogen.sh +++ b/autogen.sh @@ -148,6 +148,18 @@ automake --add-missing --gnu -Wno-portability -Wno-obsolete $am_opt || echo "Running autoconf ..." autoconf || { echo "**Error**: autoconf failed."; exit 1; } +# if test -d $srcdir/external/bdwgc/libatomic_ops; then +# echo Running external/bdwgc/libatomic_ops/autogen.sh ... +# (cd $srcdir/external/bdwgc/libatomic_ops ; ./autogen.sh) +# echo Done running external/bdwgc/libatomic_ops/autogen.sh ... +# fi + +if test -d $srcdir/external/bdwgc; then + echo Running external/bdwgc/autogen.sh ... + (cd $srcdir/external/bdwgc ; ./autogen.sh) + echo Done running external/bdwgc/autogen.sh ... +fi + if test -d $srcdir/libgc; then echo Running libgc/autogen.sh ... (cd $srcdir/libgc ; NOCONFIGURE=1 ./autogen.sh "$@") diff --git a/configure.ac b/configure.ac index 864d23df3a22..a68421e90d04 100644 --- a/configure.ac +++ b/configure.ac @@ -927,6 +927,8 @@ AC_ARG_WITH(xammac, [ --with-xammac=yes,no If you w AC_ARG_WITH(testing_aot_hybrid, [ --with-testing_aot_hybrid=yes,no If you want to build the testing_aot_hybrid assemblies (defaults to no)], [], [with_testing_aot_hybrid=default]) AC_ARG_WITH(testing_aot_full, [ --with-testing_aot_full=yes,no If you want to build the testing_aot_full assemblies (defaults to no)], [], [with_testing_aot_full=default]) AC_ARG_WITH(winaot, [ --with-winaot=yes,no If you want to build the Windows friendly AOT assemblies (defaults to no)], [], [with_winaot=default]) +AC_ARG_WITH(unityjit, [ --with-unityjit=yes,no If you want to build the Unity JIT friendly assemblies (defaults to no)], [], [with_unityjit=default]) +AC_ARG_WITH(unityaot, [ --with-unityaot=yes,no If you want to build the Unity AOT friendly assemblies (defaults to no)], [], [with_unityaot=default]) AC_ARG_WITH(orbis, [ --with-orbis=yes,no If you want to build the Orbis assemblies (defaults to no)], [], [with_orbis=default]) AC_ARG_WITH(unreal, [ --with-unreal=yes,no If you want to build the Unreal assemblies (defaults to no)], [], [with_unreal=default]) AC_ARG_WITH(wasm, [ --with-wasm=yes,no If you want to build the WebAssembly (defaults to no)], [], [with_wasm=default]) @@ -949,12 +951,15 @@ with_xammac_default=no with_testing_aot_hybrid_default=no with_testing_aot_full_default=no with_winaot_default=no +with_unityjit_default=no +with_unityaot_default=no with_orbis_default=no with_unreal_default=no with_wasm_default=no with_bitcode_default=no with_cooperative_gc_default=no +mono_feature_disable_com=yes INVARIANT_AOT_OPTIONS=nimt-trampolines=2000,ntrampolines=9000,nrgctx-fetch-trampolines=256,ngsharedvt-trampolines=4000 @@ -972,6 +977,8 @@ elif test x$with_runtime_preset = xall; then with_monotouch_tv_default=yes with_xammac_default=yes with_winaot_default=yes + with_unityjit_default=yes + with_unityaot_default=yes with_orbis_default=yes with_unreal_default=yes with_wasm_default=yes @@ -1034,6 +1041,25 @@ elif test x$with_runtime_preset = xwinaot; then AOT_BUILD_FLAGS="--runtime=mobile --aot=full,$INVARIANT_AOT_OPTIONS" AOT_RUN_FLAGS="--runtime=mobile --full-aot" AOT_MODE="llvmonly" +elif test x$with_runtime_preset = xunityjit; then + DISABLE_MCS_DOCS_default=yes + with_unityjit_default=yes + TEST_PROFILE=unityjit + + mono_feature_disable_remoting='yes' +elif test x$with_runtime_preset = xunityaot; then + DISABLE_MCS_DOCS_default=yes + with_unityaot_default=yes + TEST_PROFILE=unityaot + + #mono_feature_disable_com='yes' + mono_feature_disable_remoting='yes' + mono_feature_disable_reflection_emit_save='yes' + mono_feature_disable_reflection_emit='yes' + mono_feature_disable_appdomains='yes' + + AOT_BUILD_FLAGS="--aot=full,$INVARIANT_AOT_OPTIONS" + AOT_RUN_FLAGS="--full-aot" elif test x$with_runtime_preset = xorbis; then DISABLE_MCS_DOCS_default=yes with_orbis_default=yes @@ -1115,6 +1141,12 @@ fi if test "x$with_winaot" = "xdefault"; then with_winaot=$with_winaot_default fi +if test "x$with_unityjit = "xdefault"; then + with_unityjit=$with_unityjit_default +fi +if test "x$with_unityaot = "xdefault"; then + with_unityaot=$with_unityaot_default +fi if test "x$with_orbis" = "xdefault"; then with_orbis=$with_orbis_default fi @@ -1136,6 +1168,8 @@ AM_CONDITIONAL(INSTALL_XAMMAC, [test "x$with_xammac" != "xno"]) AM_CONDITIONAL(INSTALL_TESTING_AOT_HYBRID, [test "x$with_testing_aot_hybrid" != "xno"]) AM_CONDITIONAL(INSTALL_TESTING_AOT_FULL, [test "x$with_testing_aot_full" != "xno"]) AM_CONDITIONAL(INSTALL_WINAOT, [test "x$with_winaot" != "xno"]) +AM_CONDITIONAL(INSTALL_UNITYJIT, [test "x$with_unityjit" != "xno"]) +AM_CONDITIONAL(INSTALL_UNITYAOT, [test "x$with_unityaot" != "xno"]) AM_CONDITIONAL(INSTALL_ORBIS, [test "x$with_orbis" != "xno"]) AM_CONDITIONAL(INSTALL_UNREAL, [test "x$with_unreal" != "xno"]) AM_CONDITIONAL(INSTALL_WASM, [test "x$with_wasm" != "xno"]) @@ -1161,6 +1195,12 @@ fi if test -z "$INSTALL_WINAOT_TRUE"; then : default_profile=winaot fi +if test -z "$INSTALL_UNITYJIT_TRUE"; then : + default_profile=unityjit +fi +if test -z "$INSTALL_UNITYAOT_TRUE"; then : + default_profile=unityaot +fi if test -z "$INSTALL_ORBIS_TRUE"; then : default_profile=orbis fi @@ -1429,6 +1469,20 @@ AC_COMPILE_IFELSE([ AC_MSG_RESULT(no) ]) +dnl BDWGC GC configuration +dnl + +AC_ARG_ENABLE(bdwgc, [ --disable-bdwgc Disable the Bdwgc GC.], upport_bdwgc=$enableval,support_bdwgc=${support_bdwgc:-yes}) +AM_CONDITIONAL(SUPPORT_BDWGC, test x$support_bdwgc = xyes) +bdwgc_dir=external/bdwgc +BDWGC_DEFINES='-DHAVE_BOEHM_GC -DHAVE_BDWGC_GC' +LIBGCBDWGC_CPPFLAGS='-I$(top_srcdir)/external/bdwgc/include -I$(top_srcdir)/external/bdwgc/libatomic_ops/src' +AC_SUBST(bdwgc_dir) +AC_SUBST(BDWGC_DEFINES) +AC_SUBST(LIBGCBDWGC_CPPFLAGS) + +dnl + dnl dnl Boehm GC configuration dnl @@ -1505,7 +1559,10 @@ if test "x$support_boehm" = "xyes"; then AC_SUBST(LIBGC_STATIC_LIBS) AC_SUBST(libgc_dir) AC_SUBST(BOEHM_DEFINES) - +else + if test "x$support_bdwgc" = "xyes"; then + AC_DEFINE_UNQUOTED(DEFAULT_GC_NAME, "External BDWGC (with typed GC)", [GC description]) + fi fi AM_CONDITIONAL(SUPPORT_NULLGC, test "x$libgc" = "xnone") @@ -4250,6 +4307,11 @@ case "x$libgc" in if test "x$support_boehm" = "xyes"; then AC_CONFIG_SUBDIRS(libgc) fi + if test "x$support_bdwgc" = "xyes"; then + AC_CONFIG_SUBDIRS([external/bdwgc/libatomic_ops]) + ac_configure_args="$ac_configure_args --enable-thread-local-alloc=no --enable-parallel-mark=no --enable-verify-defines=yes --enable-gc-threads=yes --with-libatomic-ops=no --enable-no-threads-discovery=yes --enable-single-obj-compilation=yes --enable-gcj-support=yes --enable-threads=$libgc_threads --enable-munmap=yes --enable-mmap=yes --enable-ignore-dynamic-loading=yes --enable-dont-register-main-static-data=yes" + AC_CONFIG_SUBDIRS([external/bdwgc]) + fi ;; esac @@ -4925,6 +4987,8 @@ echo " Xamarin.TVOS: $with_monotouch_tv Xamarin.Mac: $with_xammac Windows AOT: $with_winaot + Unity JIT: $with_unityjit + Unity AOT: $with_unityaot Orbis: $with_orbis Unreal: $with_unreal WebAssembly: $with_wasm diff --git a/external/bdwgc b/external/bdwgc new file mode 160000 index 000000000000..8440aa8cdffd --- /dev/null +++ b/external/bdwgc @@ -0,0 +1 @@ +Subproject commit 8440aa8cdffda0b9aa324a0e63f950f05551ab27 diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/cli b/external/buildscripts/add_to_build_results/monodistribution/bin/cli new file mode 100755 index 000000000000..a8360f862951 --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/cli @@ -0,0 +1,5 @@ +#!/bin/bash +. $(dirname $0)/mono-env + +$MONO "$@" + diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/cli.bat b/external/buildscripts/add_to_build_results/monodistribution/bin/cli.bat new file mode 100644 index 000000000000..685963d34fc1 --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/cli.bat @@ -0,0 +1,7 @@ +@echo off +SETLOCAL +set MONO_PREFIX=%~dp0.. +set MONO=%MONO_PREFIX%\bin\mono +"%MONO%" %* +exit /b %ERRORLEVEL% +ENDLOCAL diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/cli_x86 b/external/buildscripts/add_to_build_results/monodistribution/bin/cli_x86 new file mode 100755 index 000000000000..de796470ff8b --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/cli_x86 @@ -0,0 +1,4 @@ +#!/bin/bash +. $(dirname $0)/mono-env + +arch -i386 $MONO "$@" diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/ilasm b/external/buildscripts/add_to_build_results/monodistribution/bin/ilasm new file mode 100755 index 000000000000..c7e0afc7f7c8 --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/ilasm @@ -0,0 +1,3 @@ +#!/bin/bash +. $(dirname $0)/mono-env +exec $MONO $MONO_OPTIONS $MONO_PREFIX/lib/mono/4.5/ilasm.exe "$@" diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/ilasm.bat b/external/buildscripts/add_to_build_results/monodistribution/bin/ilasm.bat new file mode 100644 index 000000000000..3b3e4635ee56 --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/ilasm.bat @@ -0,0 +1,2 @@ +@"%~dp0cli.bat" %MONO_OPTIONS% "%~dp0..\lib\mono\4.5\ilasm.exe" %* +exit /b %ERRORLEVEL% diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/mcs b/external/buildscripts/add_to_build_results/monodistribution/bin/mcs new file mode 100755 index 000000000000..7a48ace18cea --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/mcs @@ -0,0 +1,3 @@ +#!/bin/bash +. $(dirname $0)/mono-env +exec $MONO $MONO_OPTIONS $MONO_PREFIX/lib/mono/4.5/mcs.exe "$@" diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/mcs.bat b/external/buildscripts/add_to_build_results/monodistribution/bin/mcs.bat new file mode 100644 index 000000000000..3ef693d443d3 --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/mcs.bat @@ -0,0 +1,2 @@ +@"%~dp0cli.bat" %MONO_OPTIONS% "%~dp0..\lib\mono\4.5\mcs.exe" %* +exit /b %ERRORLEVEL% diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/mono-env b/external/buildscripts/add_to_build_results/monodistribution/bin/mono-env new file mode 100755 index 000000000000..46c41b4744ff --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/mono-env @@ -0,0 +1,7 @@ +. $(dirname $0)/monobin-env + +export MONO_PREFIX=$(dirname $0)/.. +MONO=$MONO_PREFIX/$MONOBINDIR/mono +# remove //.. pattern as it causes problem on OSX High Sierra +MONO=${MONO/\/\/\./\/\.} +export LD_LIBRARY_PATH=$MONO_PREFIX/lib diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/monobin-env b/external/buildscripts/add_to_build_results/monodistribution/bin/monobin-env new file mode 100644 index 000000000000..9b85997c3927 --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/monobin-env @@ -0,0 +1,14 @@ +MONOBINDIR=bin + +os=$(uname -a) +variant=$(uname -m) + +case "$os" in + *GNU/Linux* ) + if [ "$variant" = "x86_64" ]; then + MONOBINDIR=bin-linux64 + else + MONOBINDIR=bin-linux32 + fi + ;; +esac diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/monolinker b/external/buildscripts/add_to_build_results/monodistribution/bin/monolinker new file mode 100755 index 000000000000..4da80a1bc55b --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/monolinker @@ -0,0 +1,5 @@ +#!/bin/bash +. $(dirname $0)/mono-env + +$MONO $MONO_PATH/monolinker.exe "$@" + diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/monolinker.bat b/external/buildscripts/add_to_build_results/monodistribution/bin/monolinker.bat new file mode 100644 index 000000000000..013920349f82 --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/monolinker.bat @@ -0,0 +1,2 @@ +@"%~dp0cli.bat" %MONO_OPTIONS% "%~dp0..\lib\mono\2.0\monolinker.exe" %* +exit /b %ERRORLEVEL% diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/nunit-console b/external/buildscripts/add_to_build_results/monodistribution/bin/nunit-console new file mode 100755 index 000000000000..1a72b09096ed --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/nunit-console @@ -0,0 +1,5 @@ +#!/bin/bash +. $(dirname $0)/mono-env + +$MONO --debug $MONO_PREFIX/lib/mono/4.0/nunit-console.exe "$@" + diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/nunit-console.bat b/external/buildscripts/add_to_build_results/monodistribution/bin/nunit-console.bat new file mode 100644 index 000000000000..c21335b65c09 --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/nunit-console.bat @@ -0,0 +1,2 @@ +@"%~dp0cli.bat" %MONO_OPTIONS% --debug "%~dp0..\lib\mono\4.0\nunit-console.exe" %* +exit /b %ERRORLEVEL% diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/nunit-console2 b/external/buildscripts/add_to_build_results/monodistribution/bin/nunit-console2 new file mode 100755 index 000000000000..17db31ffd0b8 --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/nunit-console2 @@ -0,0 +1,5 @@ +#!/bin/bash +. $(dirname $0)/mono-env + +$MONO --debug $MONO_PREFIX/lib/mono/2.0/nunit-console.exe "$@" + diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/resgen2 b/external/buildscripts/add_to_build_results/monodistribution/bin/resgen2 new file mode 100755 index 000000000000..20d79ca7d3bd --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/resgen2 @@ -0,0 +1,5 @@ +#!/bin/bash +. $(dirname $0)/mono-env + +$MONO $MONO_PREFIX/lib/mono/4.5/resgen.exe "$@" + diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/resgen2.bat b/external/buildscripts/add_to_build_results/monodistribution/bin/resgen2.bat new file mode 100644 index 000000000000..c3ec2fbb896a --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/resgen2.bat @@ -0,0 +1,2 @@ +@"%~dp0cli.bat" %MONO_OPTIONS% "%~dp0..\lib\mono\4.5\resgen.exe" %* +exit /b %ERRORLEVEL% diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/xbuild b/external/buildscripts/add_to_build_results/monodistribution/bin/xbuild new file mode 100755 index 000000000000..60ba18fe8bec --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/xbuild @@ -0,0 +1,5 @@ +#!/bin/bash +. $(dirname $0)/mono-env + +$MONO $MONO_PREFIX/lib/mono/4.5/xbuild.exe "$@" + diff --git a/external/buildscripts/add_to_build_results/monodistribution/bin/xbuild.bat b/external/buildscripts/add_to_build_results/monodistribution/bin/xbuild.bat new file mode 100644 index 000000000000..50b3a8e44997 --- /dev/null +++ b/external/buildscripts/add_to_build_results/monodistribution/bin/xbuild.bat @@ -0,0 +1,2 @@ +@"%~dp0cli.bat" %MONO_OPTIONS% "%~dp0..\lib\mono\4.5\xbuild.exe" %* +exit /b %ERRORLEVEL% diff --git a/external/buildscripts/build.pl b/external/buildscripts/build.pl new file mode 100644 index 000000000000..b4f3ba85a3d9 --- /dev/null +++ b/external/buildscripts/build.pl @@ -0,0 +1,1802 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; +use lib ('external/buildscripts', "../../Tools/perl_lib","perl_lib", 'external/buildscripts/perl_lib'); +use Tools qw(InstallNameTool); + +print ">>> PATH in Build All = $ENV{PATH}\n\n"; + +my $currentdir = getcwd(); + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); + +my $buildscriptsdir = "$monoroot/external/buildscripts"; +my $addtoresultsdistdir = "$buildscriptsdir/add_to_build_results/monodistribution"; +my $buildsroot = "$monoroot/builds"; +my $includesroot = "$buildsroot/include"; +my $sourcesroot = "$buildsroot/source"; +my $distdir = "$buildsroot/monodistribution"; +my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; + +# This script should not be ran on windows, if it is, kindly call the wrapper +# to switch over to cygwin +if ($^O eq "MSWin32") +{ + print(">>> build.pl called from Windows. Switching over to cygwin\n"); + system("perl", "$buildscriptsdir/build_win_wrapper.pl", @ARGV) eq 0 or die("\n"); + exit 0; +} + +system("source","~/.profile"); + +my $build=0; +my $clean=0; +my $jobs=8; +my $test=0; +my $artifact=0; +my $debug=0; +my $disableMcs=0; +my $mcsOnly=0; +my $buildUsAndBoo=0; +my $artifactsCommon=0; +my $artifactsRuntime=1; +my $runRuntimeTests=1; +my $runClasslibTests=1; +my $checkoutOnTheFly=0; +my $forceDefaultBuildDeps=0; +my $existingMonoRootPath = ''; +my $sdk = ''; +my $arch32 = 0; +my $winPerl = ""; +my $winMonoRoot = ""; +my $msBuildVersion = "14.0"; +my $buildDeps = ""; +my $android=0; +my $androidArch = ""; +my $iphone=0; +my $iphoneArch = ""; +my $iphoneCross=0; +my $iphoneSimulator=0; +my $iphoneSimulatorArch=""; +my $tizen=0; +my $tizenEmulator=0; +my $windowsSubsystemForLinux=0; + +# Handy troubleshooting/niche options +my $skipMonoMake=0; + +# The prefix hack probably isn't needed anymore. Let's disable it by default and see how things go +my $shortPrefix=1; + +# Disabled by default for now. causes more problems than it's worth when actively making changes to the build scripts. +# Would be okay to turn on once the build scripts stabilize and you just want to rebuild code changes +my $enableCacheFile=0; + +# Linux toolchain setup needs this +my @commandPrefix = (); + +print(">>> Build All Args = @ARGV\n"); + +GetOptions( + 'build=i'=>\$build, + 'clean=i'=>\$clean, + 'test=i'=>\$test, + 'artifact=i'=>\$artifact, + 'artifactscommon=i'=>\$artifactsCommon, + 'artifactsruntime=i'=>\$artifactsRuntime, + 'debug=i'=>\$debug, + 'disablemcs=i'=>\$disableMcs, + 'mcsonly=i'=>\$mcsOnly, + 'buildusandboo=i'=>\$buildUsAndBoo, + 'runtimetests=i'=>\$runRuntimeTests, + 'classlibtests=i'=>\$runClasslibTests, + 'arch32=i'=>\$arch32, + 'jobs=i'=>\$jobs, + 'sdk=s'=>\$sdk, + 'existingmono=s'=>\$existingMonoRootPath, + 'skipmonomake=i'=>\$skipMonoMake, + 'shortprefix=i'=>\$shortPrefix, + 'winperl=s'=>\$winPerl, + 'winmonoroot=s'=>\$winMonoRoot, + 'msbuildversion=s'=>\$msBuildVersion, + 'checkoutonthefly=i'=>\$checkoutOnTheFly, + 'builddeps=s'=>\$buildDeps, + 'forcedefaultbuilddeps=i'=>\$forceDefaultBuildDeps, + 'android=i'=>\$android, + 'androidarch=s'=>\$androidArch, + 'iphone=i'=>\$iphone, + 'iphonearch=s'=>\$iphoneArch, + 'iphonecross=i'=>\$iphoneCross, + 'iphonesimulator=i'=>\$iphoneSimulator, + 'tizen=i'=>\$tizen, + 'tizenemulator=i'=>\$tizenEmulator, + 'windowssubsystemforlinux=i'=>\$windowsSubsystemForLinux, + 'enablecachefile=i'=>\$enableCacheFile, +) or die ("illegal cmdline options"); + +print ">>> Mono checkout = $monoroot\n"; + +print(">> System Info : \n"); +system("uname", "-a"); + +my $monoRevision = `git rev-parse HEAD`; +chdir("$buildscriptsdir") eq 1 or die ("failed to chdir : $buildscriptsdir\n"); +my $buildScriptsRevision = `git rev-parse HEAD`; +chdir("$monoroot") eq 1 or die ("failed to chdir : $monoroot\n"); + +print(">>> Mono Revision = $monoRevision\n"); +print(">>> Build Scripts Revision = $buildScriptsRevision\n"); + +if ($androidArch ne "") +{ + $android = 1; +} + +if ($iphoneArch ne "") +{ + $iphone = 1; +} + +if($iphoneSimulator) +{ + if ($arch32) + { + $iphoneSimulatorArch = "i386"; + } + else + { + $iphoneSimulatorArch = "x86_64"; + } +} + +my $isDesktopBuild = 1; +if ($android || $iphone || $iphoneCross || $iphoneSimulator || $tizen || $tizenEmulator) +{ + $isDesktopBuild = 0; + + # Disable building of the class libraries by default when building the android runtime + # since we don't care about a class library build in this situation (as of writing this at least) + # but only if the test flag is not set. If the test flag was set, we'd need to build the classlibs + # in order to run the tests + $disableMcs = 1 if(!($test)); +} + +# Do any settings agnostic per-platform stuff +my $externalBuildDeps = ""; +my $externalBuildDepsIl2Cpp = "$monoroot/../../il2cpp/build"; + +if ($buildDeps ne "" && not $forceDefaultBuildDeps) +{ + $externalBuildDeps = $buildDeps; +} +else +{ + $externalBuildDeps = "$monoroot/../../mono-build-deps/build"; +} + +# Only clean up the path if the directory exists, if it doesn't exist, +# abs_path ends up returning an empty string +$externalBuildDeps = abs_path($externalBuildDeps) if (-d $externalBuildDeps); + +my $existingExternalMonoRoot = "$externalBuildDeps/mono"; +my $existingExternalMono = ""; +my $monoHostArch = ""; +my $monoprefix = "$monoroot/tmp"; +my $runningOnWindows=0; +if($^O eq "linux") +{ + $monoHostArch = $arch32 ? "i686" : "x86_64"; + $existingExternalMono = "$existingExternalMonoRoot/linux"; +} +elsif($^O eq 'darwin') +{ + $monoHostArch = $arch32 ? "i386" : "x86_64"; + $existingExternalMono = "$existingExternalMonoRoot/osx"; + + # From Massi: I was getting failures in install_name_tool about space + # for the commands being too small, and adding here things like + # $ENV{LDFLAGS} = '-headerpad_max_install_names' and + # $ENV{LDFLAGS} = '-headerpad=0x40000' did not help at all (and also + # adding them to our final gcc invocation to make the bundle). + # Lucas noticed that I was lacking a Mono prefix, and having a long + # one would give us space, so here is this silly looong prefix. + if (not $shortPrefix) + { + $monoprefix = "$monoroot/tmp/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting"; + } +} +else +{ + $monoHostArch = "i686"; + $existingExternalMono = "$existingExternalMonoRoot/win"; + $runningOnWindows = 1; + + # We only care about an existing mono if we need to build. + # So only do this path clean up if we are building. + if ($build) + { + if ($existingMonoRootPath ne "" && not $existingMonoRootPath =~ /^\/cygdrive/) + { + $existingMonoRootPath = `cygpath -u $existingMonoRootPath`; + chomp($existingMonoRootPath); + } + + $existingMonoRootPath =~ tr/\\//d; + } +} + +if ($runningOnWindows) +{ + # Fixes a line ending issue that happens on windows when we try to run autogen.sh + $ENV{'SHELLOPTS'} = "igncr"; +} + +print(">>> Existing Mono = $existingMonoRootPath\n"); +print(">>> Mono Arch = $monoHostArch\n"); + +if ($build) +{ + my $platformflags = ''; + my $host = ''; + my $mcs = ''; + + my $iphoneCrossAbi = "arm-apple-darwin10"; + my $iphoneCrossMonoBinToUse = "$monoroot/builds/monodistribution/bin"; + + my @configureparams = (); + + push @configureparams, "--disable-mcs-build" if($disableMcs); + push @configureparams, "--with-glib=embedded"; + push @configureparams, "--disable-nls"; #this removes the dependency on gettext package + push @configureparams, "--disable-btls"; #this removes the dependency on cmake to build btls for now + push @configureparams, "--with-mcs-docs=no"; + push @configureparams, "--prefix=$monoprefix"; + + if(!($disableMcs)) + { + push @configureparams, "--with-unityjit=yes"; + push @configureparams, "--with-unityaot=yes"; + } + + if ($isDesktopBuild) + { + push @configureparams, "--with-monotouch=no"; + } + + if ($existingMonoRootPath eq "") + { + print(">>> No existing mono supplied. Checking for external...\n"); + + if (!(-d "$externalBuildDeps")) + { + if (not $checkoutonthefly) + { + print(">>> No external build deps found. Might as well try to check them out. If it fails, we'll continue and trust mono is in your PATH\n"); + } + + # Check out on the fly + print(">>> Checking out mono build dependencies to : $externalBuildDeps\n"); + my $repo = "https://ono.unity3d.com/unity-extra/mono-build-deps"; + print(">>> Cloning $repo at $externalBuildDeps\n"); + my $checkoutResult = system("hg", "clone", $repo, "$externalBuildDeps"); + + if ($checkoutOnTheFly && $checkoutResult ne 0) + { + die("failed to checkout mono build dependencies\n"); + } + + # Only clean up if the dir exists. Otherwise abs_path will return empty string + $externalBuildDeps = abs_path($externalBuildDeps) if (-d $externalBuildDeps); + } + + if (!(-d "$externalBuildDepsIl2Cpp")) + { + my $il2cpp_repo = "https://bitbucket.org/Unity-Technologies/il2cpp"; + print(">>> Cloning $il2cpp_repo at $externalBuildDepsIl2Cpp\n"); + $checkoutResult = system("hg", "clone", $il2cpp_repo, "$externalBuildDepsIl2Cpp"); + + if ($checkoutOnTheFly && $checkoutResult ne 0) + { + die("failed to checkout IL2CPP for the mono build dependencies\n"); + } + } + + if (-d "$existingExternalMono") + { + print(">>> External mono found at : $existingExternalMono\n"); + + if (-d "$existingExternalMono/builds") + { + print(">>> Mono already extracted at : $existingExternalMono/builds\n"); + } + + if (!(-d "$existingExternalMono/builds")) + { + # We need to extract builds.zip + print(">>> Extracting mono builds.zip...\n"); + system("unzip", "$existingExternalMono/builds.zip", "-d", "$existingExternalMono") eq 0 or die("failed to extract mono builds.zip\n"); + } + + $existingMonoRootPath = "$existingExternalMono/builds"; + } + else + { + print(">>> No external mono found. Trusting a new enough mono is in your PATH.\n"); + } + } + + if ($existingMonoRootPath ne "" && !(-d $existingMonoRootPath)) + { + die("Existing mono not found at : $existingMonoRootPath\n"); + } + + if ($externalBuildDeps ne "") + { + print "\n"; + print ">>> Building autoconf, texinfo, automake, and libtool if needed...\n"; + my $autoconfVersion = "2.69"; + my $texinfoVersion = "4.8"; + my $automakeVersion = "1.15"; + my $libtoolVersion = "2.4.6"; + my $autoconfDir = "$externalBuildDeps/autoconf-$autoconfVersion"; + my $texinfoDir = "$externalBuildDeps/texinfo-$texinfoVersion"; + my $automakeDir = "$externalBuildDeps/automake-$automakeVersion"; + my $libtoolDir = "$externalBuildDeps/libtool-$libtoolVersion"; + my $builtToolsDir = "$externalBuildDeps/built-tools"; + + $ENV{PATH} = "$builtToolsDir/bin:$ENV{PATH}"; + + if (!(-d "$autoconfDir")) + { + chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); + system("tar xzf autoconf-$autoconfVersion.tar.gz") eq 0 or die ("failed to extract autoconf\n"); + + chdir("$autoconfDir") eq 1 or die ("failed to chdir to autoconf directory\n"); + system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure autoconf\n"); + system("make") eq 0 or die ("failed to make autoconf\n"); + system("make install") eq 0 or die ("failed to make install autoconf\n"); + + chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); + } + + if (!(-d "$texinfoDir") and $windowsSubsystemForLinux) + { + chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); + system("tar xzf texinfo-$texinfoVersion.tar.gz") eq 0 or die ("failed to extract texinfo\n"); + + chdir($texinfoDir) eq 1 or die ("failed to chdir to texinfo directory\n"); + system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure texinfo\n"); + system("make") eq 0 or die ("failed to make texinfo\n"); + system("make install") eq 0 or die ("failed to make install texinfo\n"); + + chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); + } + + if (!(-d "$automakeDir")) + { + my $automakeMakeFlags = ""; + chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); + system("tar xzf automake-$automakeVersion.tar.gz") eq 0 or die ("failed to extract automake\n"); + + chdir("$automakeDir") eq 1 or die ("failed to chdir to automake directory\n"); + if($windowsSubsystemForLinux) + { + #Windows subsystem needs to run bootstrap, and make needs to be run with -i due to one doc failing to build + system("./bootstrap.sh") eq 0 or die ("failed to bootstrap automake\n"); + $automakeMakeFlags = "-i"; + } + system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure automake\n"); + system("make $automakeMakeFlags") eq 0 or die ("failed to make automake\n"); + system("make install"); + chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); + } + + if (!(-d "$libtoolDir")) + { + chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); + system("tar xzf libtool-$libtoolVersion.tar.gz") eq 0 or die ("failed to extract libtool\n"); + + chdir("$libtoolDir") eq 1 or die ("failed to chdir to libtool directory\n"); + system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure libtool\n"); + system("make") eq 0 or die ("failed to make libtool\n"); + system("make install") eq 0 or die ("failed to make install libtool\n"); + + chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); + } + + $ENV{'LIBTOOLIZE'} = "$builtToolsDir/bin/libtoolize"; + $ENV{'LIBTOOL'} = "$builtToolsDir/bin/libtool"; + } + + my $macSdkPath = ""; + my $macversion = '10.8'; + my $darwinVersion = "10"; + if ($^O eq 'darwin') + { + if ($sdk eq '') + { + $sdk='10.11'; + } + + my $macBuildEnvDir = "$externalBuildDeps/MacBuildEnvironment"; + $macSdkPath = "$macBuildEnvDir/builds/MacOSX$sdk.sdk"; + if (! -d $macSdkPath) + { + print(">>> Unzipping mac build toolchain\n"); + system("$externalBuildDeps/unzip", '-qd', "$macBuildEnvDir", "$macBuildEnvDir/builds.zip") eq 0 or die ("failed unzipping mac build toolchain\n"); + } + } + + if ($iphone || $iphoneSimulator) + { + if ($runningOnWindows) + { + die("This build is not supported on Windows\n"); + } + + my $iosBuildEnvDir = "$externalBuildDeps/iOSBuildEnvironment"; + my $iosXcodeDefaultToolchainRoot = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain"; + + if (! -d "$iosBuildEnvDir/builds") + { + print(">>> Unzipping ios build toolchain\n"); + system("$externalBuildDeps/unzip", '-qd', "$iosBuildEnvDir/builds", "$iosBuildEnvDir/builds.zip") eq 0 or die ("failed unzipping ios build toolchain\n"); + } + + $ENV{PATH} = "$iosXcodeDefaultToolchainRoot/usr/bin:$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/usr/bin:$ENV{PATH}"; + # Need to keep our libtool in front + $ENV{PATH} = "$externalBuildDeps/built-tools/bin:$ENV{PATH}"; + + push @configureparams, "--cache-file=iphone-$iphoneArch.cache" if ($enableCacheFile); + + my $iosMinimalCommon = "com,remoting,shared_perfcounters,appdomains"; + my $iosCFlagsCommon = "-DMONOTOUCH -DHOST_IOS -DDISABLE_POLICY_EVIDENCE=1 -DDISABLE_PROCESS_HANDLING=1"; + + push @configureparams, "--with-tls=pthread"; + push @configureparams, "--without-ikvm-native"; + push @configureparams, "--disable-executables"; + push @configureparams, "--disable-visibility-hidden"; + + if ($iphone) + { + my $iosSdkVersion = "9.3"; + my $iphoneOsMinVersion = "3.0"; + my $iosSdkRoot = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$iosSdkVersion.sdk"; + + print(">>> iOS Build Environment = $iosBuildEnvDir\n"); + print(">>> iOS SDK Version = $iosSdkVersion\n"); + print(">>> iOS SDK Root = $iosSdkRoot\n"); + print(">>> iPhone Arch = $iphoneArch\n"); + + $ENV{PATH} = "$iosSdkRoot/usr/bin:$ENV{PATH}"; + + $ENV{C_INCLUDE_PATH} = "$iosSdkRoot/usr/include"; + $ENV{CPLUS_INCLUDE_PATH} = "$iosSdkRoot/usr/include"; + + $ENV{CC} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch $iphoneArch"; + $ENV{CXX} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch $iphoneArch"; + $ENV{LD} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"; + + $ENV{CFLAGS} = "$iosCFlagsCommon -gdwarf-2 -DSMALL_CONFIG -DHAVE_LARGE_FILE_SUPPORT=1 -DHAVE_ARMV6=1 -DARM_FPU_VFP=1 -Wl,-application_extension -miphoneos-version-min=$iphoneOsMinVersion -mno-thumb -Os -isysroot $iosSdkRoot"; + + # Unity defines + $ENV{CFLAGS} = "-DPLATFORM_IPHONE $ENV{CFLAGS}"; + + $ENV{CXXFLAGS} = "$ENV{CFLAGS} -U__powerpc__ -U__i386__ -D__arm__"; + $ENV{CPPFLAGS} = $ENV{CXXFLAGS}; + + $ENV{LDFLAGS} = "-arch $iphoneArch -liconv -lobjc -lc++ -Wl,-syslibroot,$iosSdkRoot"; + + print "\n"; + print ">>> Environment:\n"; + print ">>> \tCC = $ENV{CC}\n"; + print ">>> \tCXX = $ENV{CXX}\n"; + print ">>> \tLD = $ENV{LD}\n"; + print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; + print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; + print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; + print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; + print ">>> \tCPLUS_INCLUDE_PATH = $ENV{CPLUS_INCLUDE_PATH}\n"; + print ">>> \tC_INCLUDE_PATH = $ENV{C_INCLUDE_PATH}\n"; + + push @configureparams, "--host=arm-apple-darwin$darwinVersion"; + + push @configureparams, "--with-sigaltstack=no"; + push @configureparams, "--disable-shared-handles"; + push @configureparams, "--with-monotouch"; + + push @configureparams, "--enable-llvm-runtime"; + push @configureparams, "--with-bitcode=yes"; + + push @configureparams, "--with-lazy-gc-thread-creation=yes"; + push @configureparams, "--enable-icall-export"; + push @configureparams, "--enable-dtrace=no"; + + push @configureparams, "--enable-minimal=$iosMinimalCommon,ssa,jit,reflection_emit_save,reflection_emit,portability,assembly_remapping,attach,verifier,full_messages,security,sgen_remset,sgen_marksweep_par,sgen_marksweep_fixed,sgen_marksweep_fixed_par,sgen_copying,logging"; + + push @configureparams, "mono_cv_uscore=yes"; + push @configureparams, "cv_mono_sizeof_sunpath=104"; + push @configureparams, "ac_cv_func_posix_getpwuid_r=yes"; + push @configureparams, "ac_cv_func_backtrace_symbols=no"; + push @configureparams, "ac_cv_func_finite=no"; + push @configureparams, "ac_cv_header_curses_h=no"; + } + elsif ($iphoneSimulator) + { + my $iosSdkVersion = "9.3"; + my $iosSimMinVersion = "4.3"; + my $iosSdkRoot = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$iosSdkVersion.sdk"; + + print(">>> iOS Sim Build Environment = $iosBuildEnvDir\n"); + print(">>> iOS Sim SDK Version = $iosSdkVersion\n"); + print(">>> iOS Sim SDK Root = $iosSdkRoot\n"); + print(">>> iOS Sim Arch = $iphoneSimulatorArch\n"); + + $ENV{PATH} = "$iosSdkRoot/usr/bin:$ENV{PATH}"; + + $ENV{MACSDKOPTIONS} = "$iosCFlagsCommon -D_XOPEN_SOURCE=1 -g -O0 -DTARGET_IPHONE_SIMULATOR -mios-simulator-version-min=$iosSimMinVersion -isysroot $iosSdkRoot"; + $ENV{CFLAGS} = "-arch $iphoneSimulatorArch $ENV{MACSDKOPTIONS}"; + $ENV{CXXFLAGS} = "$ENV{CFLAGS}"; + $ENV{CPPFLAGS} = "$ENV{CFLAGS}"; + $ENV{CC} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/usr/bin/gcc"; + $ENV{CXX} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/usr/bin/g++"; + + print "\n"; + print ">>> Environment:\n"; + print ">>> \tCC = $ENV{CC}\n"; + print ">>> \tCXX = $ENV{CXX}\n"; + print ">>> \tLD = $ENV{LD}\n"; + print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; + print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; + print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; + print ">>> \tMACSDKOPTIONS = $ENV{MACSDKOPTIONS}\n"; + + push @configureparams, "--host=$iphoneSimulatorArch-apple-darwin$darwinVersion"; + push @configureparams, "--enable-minimal=$iosMinimalCommon"; + + push @configureparams, "mono_cv_uscore=yes"; + push @configureparams, "ac_cv_func_clock_nanosleep=no"; + } + else + { + die("This should not be hit\n"); + } + } + elsif ($iphoneCross) + { + if ($runningOnWindows) + { + die("Not implemented\n"); + } + else + { + $ENV{CFLAGS} = "-DMONOTOUCH -DARM_FPU_VFP=1 -DUSE_MUNMAP -DPLATFORM_IPHONE_XCOMP -mmacosx-version-min=$macversion"; + $ENV{CXXFLAGS} = "-mmacosx-version-min=$macversion -stdlib=libc++"; + $ENV{CPPFLAGS} = "$ENV{CFLAGS} -mmacosx-version-min=$macversion"; + + $ENV{CC} = "$macSdkPath/../usr/bin/clang -arch i386"; + $ENV{CXX} = "$macSdkPath/../usr/bin/clang++ -arch i386"; + $ENV{CPP} = "$ENV{CC} -E"; + $ENV{LD} = $ENV{CC}; + $ENV{LDFLAGS} = "-stdlib=libc++"; + $ENV{MACSDKOPTIONS} = "-mmacosx-version-min=$macversion -isysroot $macSdkPath"; + + print "\n"; + print ">>> Environment:\n"; + print ">>> \tCC = $ENV{CC}\n"; + print ">>> \tCXX = $ENV{CXX}\n"; + print ">>> \tLD = $ENV{LD}\n"; + print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; + print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; + print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; + print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; + print ">>> \tMACSDKOPTIONS = $ENV{MACSDKOPTIONS}\n"; + + push @configureparams, "--cache-file=iphone-cross.cache" if ($enableCacheFile); + + push @configureparams, "--with-sigaltstack=no"; + push @configureparams, "--disable-shared-handles"; + push @configureparams, "--with-tls=pthread"; + + push @configureparams, "--target=arm-darwin"; + push @configureparams, "--with-macversion=$macversion"; + push @configureparams, "--with-cross-offsets=$iphoneCrossAbi.h"; + + push @configureparams, "--build=i386-apple-darwin10"; + push @configureparams, "--disable-libraries"; + push @configureparams, "--enable-icall-symbol-map"; + push @configureparams, "--enable-minimal=com,remoting"; + + #push @configureparams, "--enable-llvm"; + #push @configureparams, "--with-llvm=llvm/usr"; + + my @mcsArgs = (); + push @mcsArgs, "$monoroot/tools/offsets-tool/MonoAotOffsetsDumper.cs"; + push @mcsArgs, "$monoroot/mcs/class/Mono.Options/Mono.Options/Options.cs"; + push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.AST.dll"; + push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.Generator.dll"; + push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.Parser.CSharp.dll"; + push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.Parser.dll"; + push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.dll"; + push @mcsArgs, "/debug"; + push @mcsArgs, "/nowarn:0436"; + push @mcsArgs, "/out:$monoroot/tools/offsets-tool/MonoAotOffsetsDumper.exe"; + + print ">>> Compiling MonoAotOffsetDumper : $iphoneCrossMonoBinToUse/mcs @mcsArgs\n"; + system("$iphoneCrossMonoBinToUse/mcs", @mcsArgs) eq 0 or die("failed to compile MonoAotOffsetsDumper\n"); + + # clean up any pre-existing offset header just in case + if (-f "$monoroot/$iphoneCrossAbi.h") + { + system("rm", "-rf", "$iphoneCrossAbi.h"); + } + } + } + elsif ($android) + { + if (!(-d $externalBuildDeps)) + { + die("mono build deps are required and the directory was not found : $externalBuildDeps\n"); + } + + my $ndkVersion = "r13b"; + my $isArmArch = 1; + my $toolchainName = ""; + my $platformRootPostfix = ""; + my $useKraitPatch = 1; + my $kraitPatchPath = "$monoroot/../../android_krait_signal_handler/build"; + my $toolChainExtension = ""; + + $isArmArch = 0 if ($androidArch eq "x86"); + + $ENV{ANDROID_PLATFORM} = "android-9"; + $ENV{GCC_VERSION} = "4.9"; + + if ($isArmArch) + { + $ENV{GCC_PREFIX} = "arm-linux-androideabi-"; + $toolchainName = "$ENV{GCC_PREFIX}$ENV{GCC_VERSION}"; + $platformRootPostfix = "arm"; + } + else + { + $ENV{GCC_PREFIX} = "i686-linux-android-"; + $toolchainName = "x86-$ENV{GCC_VERSION}"; + $platformRootPostfix = "x86"; + $useKraitPatch = 0; + } + + if ($^O eq "linux") + { + $ENV{HOST_ENV} = "linux"; + } + elsif ($^O eq 'darwin') + { + $ENV{HOST_ENV} = "darwin"; + } + else + { + $ENV{HOST_ENV} = "windows"; + } + + print "\n"; + print(">>> Android Platform = $ENV{ANDROID_PLATFORM}\n"); + print(">>> Android NDK Version = $ndkVersion\n"); + print(">>> Android GCC Prefix = $ENV{GCC_PREFIX}\n"); + print(">>> Android GCC Version = $ENV{GCC_VERSION}\n"); + + my $ndkName = ""; + if($^O eq "linux") + { + $ndkName = "android-ndk-$ndkVersion-linux-x86_64.zip"; + } + elsif($^O eq "darwin") + { + $ndkName = "android-ndk-$ndkVersion-darwin-x86_64.zip"; + } + else + { + $ndkName = "android-ndk-$ndkVersion-windows-x86.zip"; + } + + my $depsNdkArchive = "$externalBuildDeps/$ndkName"; + my $depsNdkFinal = "$externalBuildDeps/android-ndk-$ndkVersion"; + + print(">>> Android NDK Archive = $depsNdkArchive\n"); + print(">>> Android NDK Extraction Destination = $depsNdkFinal\n"); + print("\n"); + + $ENV{ANDROID_NDK_ROOT} = "$depsNdkFinal"; + + if (-d $depsNdkFinal) + { + print(">>> Android NDK already extracted\n"); + } + else + { + print(">>> Android NDK needs to be extracted\n"); + + if ($runningOnWindows) + { + my $sevenZip = "$externalBuildDeps/7z/win64/7za.exe"; + my $winDepsNdkArchive = `cygpath -w $depsNdkArchive`; + my $winDepsNdkExtract = `cygpath -w $externalBuildDeps`; + + # clean up trailing new lines that end up in the output from cygpath. If left, they cause problems down the line + # for 7zip + $winDepsNdkArchive =~ s/\n+$//; + $winDepsNdkExtract =~ s/\n+$//; + + system($sevenZip, "x", "$winDepsNdkArchive", "-o$winDepsNdkExtract"); + } + else + { + my ($name,$path,$suffix) = fileparse($depsNdkArchive, qr/\.[^.]*/); + + print(">>> Android NDK Extension = $suffix\n"); + + # Versions after r11 use .zip extension. Currently we use r10e, but let's support the .zip extension in case + # we upgrade down the road + if (lc $suffix eq '.zip') + { + system("unzip", "-q", $depsNdkArchive, "-d", $externalBuildDeps); + } + elsif (lc $suffix eq '.bin') + { chmod(0755, $depsNdkArchive); + system($depsNdkArchive, "-o$externalBuildDeps"); + } + else + { + die "Unknown file extension '" . $suffix . "'\n"; + } + } + } + + if (!(-f "$ENV{ANDROID_NDK_ROOT}/ndk-build")) + { + die("Something went wrong with the NDK extraction\n"); + } + + my $androidNdkRoot = $ENV{ANDROID_NDK_ROOT}; + my $androidPlatformRoot = "$androidNdkRoot/platforms/$ENV{ANDROID_PLATFORM}/arch-$platformRootPostfix"; + my $androidToolchain = "$androidNdkRoot/toolchains/$toolchainName/prebuilt/$ENV{HOST_ENV}"; + + if (!(-d "$androidToolchain")) + { + if (-d "$androidToolchain-x86") + { + $androidToolchain = "$androidToolchain-x86"; + } + else + { + $androidToolchain = "$androidToolchain-x86_64"; + } + } + + if ($runningOnWindows) + { + $toolChainExtension = ".exe"; + + $androidPlatformRoot = `cygpath -w $androidPlatformRoot`; + # clean up trailing new lines that end up in the output from cygpath. + $androidPlatformRoot =~ s/\n+$//; + # Switch over to forward slashes. They propagate down the toolchain correctly + $androidPlatformRoot =~ s/\\/\//g; + + # this will get passed as a path to the linker, so we need to windows-ify the path + $kraitPatchPath = `cygpath -w $kraitPatchPath`; + $kraitPatchPath =~ s/\n+$//; + $kraitPatchPath =~ s/\\/\//g; + } + + print(">>> Android Arch = $androidArch\n"); + print(">>> Android NDK Root = $androidNdkRoot\n"); + print(">>> Android Platform Root = $androidPlatformRoot\n"); + print(">>> Android Toolchain = $androidToolchain\n"); + + if (!(-d "$androidToolchain")) + { + die("Failed to locate android toolchain\n"); + } + + if (!(-d "$androidPlatformRoot")) + { + die("Failed to locate android platform root\n"); + } + + if ("$androidArch" eq 'armv5') + { + $ENV{CFLAGS} = "-DARM_FPU_NONE=1 -march=armv5te -mtune=xscale -msoft-float"; + } + elsif ("$androidArch" eq 'armv6_vfp') + { + $ENV{CFLAGS} = "-DARM_FPU_VFP=1 -march=armv6 -mtune=xscale -msoft-float -mfloat-abi=softfp -mfpu=vfp -DHAVE_ARMV6=1"; + } + elsif ("$androidArch" eq 'armv7a') + { + $ENV{CFLAGS} = "-DARM_FPU_VFP=1 -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -DHAVE_ARMV6=1"; + $ENV{LDFLAGS} = "-Wl,--fix-cortex-a8"; + } + elsif ("$androidArch" eq 'x86') + { + $ENV{LDFLAGS} = "-lgcc" + } + else + { + die("Unsupported android arch : $androidArch\n"); + } + + if ($isArmArch) + { + $ENV{CFLAGS} = "-funwind-tables $ENV{CFLAGS}"; + $ENV{LDFLAGS} = "-Wl,-rpath-link=$androidPlatformRoot/usr/lib $ENV{LDFLAGS}"; + } + + $ENV{PATH} = "$androidToolchain/bin:$ENV{PATH}"; + $ENV{CC} = "$androidToolchain/bin/$ENV{GCC_PREFIX}gcc$toolChainExtension --sysroot=$androidPlatformRoot"; + $ENV{CXX} = "$androidToolchain/bin/$ENV{GCC_PREFIX}g++$toolChainExtension --sysroot=$androidPlatformRoot"; + $ENV{CPP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}cpp$toolChainExtension"; + $ENV{CXXCPP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}cpp$toolChainExtension"; + $ENV{CPATH} = "$androidPlatformRoot/usr/include"; + $ENV{LD} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ld$toolChainExtension"; + $ENV{AS} = "$androidToolchain/bin/$ENV{GCC_PREFIX}as$toolChainExtension"; + $ENV{AR} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ar$toolChainExtension"; + $ENV{RANLIB} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ranlib$toolChainExtension"; + $ENV{STRIP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}strip$toolChainExtension"; + + $ENV{CFLAGS} = "-DANDROID -DPLATFORM_ANDROID -DLINUX -D__linux__ -DHAVE_USR_INCLUDE_MALLOC_H -DPAGE_SIZE=0x1000 -D_POSIX_PATH_MAX=256 -DS_IWRITE=S_IWUSR -DHAVE_PTHREAD_MUTEX_TIMEDLOCK -fpic -g -ffunction-sections -fdata-sections $ENV{CFLAGS}"; + $ENV{CXXFLAGS} = $ENV{CFLAGS}; + $ENV{CPPFLAGS} = $ENV{CFLAGS}; + + if ($useKraitPatch) + { + $ENV{LDFLAGS} = "-Wl,--wrap,sigaction -L$kraitPatchPath/obj/local/armeabi -lkrait-signal-handler $ENV{LDFLAGS}"; + } + + $ENV{LDFLAGS} = "-Wl,--no-undefined -Wl,--gc-sections -ldl -lm -llog -lc $ENV{LDFLAGS}"; + + print "\n"; + print ">>> Environment:\n"; + print ">>> \tCC = $ENV{CC}\n"; + print ">>> \tCXX = $ENV{CXX}\n"; + print ">>> \tCPP = $ENV{CPP}\n"; + print ">>> \tCXXCPP = $ENV{CXXCPP}\n"; + print ">>> \tCPATH = $ENV{CPATH}\n"; + print ">>> \tLD = $ENV{LD}\n"; + print ">>> \tAS = $ENV{AS}\n"; + print ">>> \tAR = $ENV{AR}\n"; + print ">>> \tRANLIB = $ENV{RANLIB}\n"; + print ">>> \tSTRIP = $ENV{STRIP}\n"; + print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; + print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; + print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; + print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; + + if ($useKraitPatch) + { + my $kraitPatchRepo = "git://github.com/Unity-Technologies/krait-signal-handler.git"; + if (-d "$kraitPatchPath") + { + print ">>> Krait patch repository already cloned\n"; + } + else + { + system("git", "clone", "--branch", "master", "$kraitPatchRepo", "$kraitPatchPath") eq 0 or die ('failing cloning Krait patch'); + } + + chdir("$kraitPatchPath") eq 1 or die ("failed to chdir to krait patch directory\n"); + system('$ANDROID_NDK_ROOT/ndk-build clean') eq 0 or die ('failing to clean Krait patch'); + system('$ANDROID_NDK_ROOT/ndk-build') eq 0 or die ('failing to build Krait patch'); + chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); + } + + if ($isArmArch) + { + push @configureparams, "--host=armv5-linux-androideabi"; + } + elsif ("$androidArch" eq 'x86') + { + push @configureparams, "--host=i686-linux-android"; + } + else + { + die("Unsupported android arch : $androidArch\n"); + } + + push @configureparams, "--cache-file=android-$androidArch.cache" if ($enableCacheFile); + + push @configureparams, "--disable-parallel-mark"; + push @configureparams, "--disable-shared-handles"; + push @configureparams, "--with-sigaltstack=no"; + push @configureparams, "--with-tls=pthread"; + push @configureparams, "--disable-visibility-hidden"; + push @configureparams, "mono_cv_uscore=yes"; + push @configureparams, "ac_cv_header_zlib_h=no" if($runningOnWindows); + } + elsif ($tizen) + { + if (!(-d $externalBuildDeps)) + { + die("mono build deps are required and the directory was not found : $externalBuildDeps\n"); + } + + my $sdkVersion = "2.4.0r1"; + my $isArmArch = 1; + + $isArmArch = 0 if ($tizenEmulator); + + $ENV{TIZEN_PLATFORM} = "tizen-2.4"; + + if ($tizenEmulator) + { + $ENV{TIZEN_ROOTSTRAP} = "mobile-2.4-emulator.core"; + } + else + { + $ENV{TIZEN_ROOTSTRAP} = "mobile-2.4-device.core"; + } + + if ($^O eq "linux") + { + $ENV{HOST_ENV} = "linux"; + } + elsif ($^O eq 'darwin') + { + $ENV{HOST_ENV} = "darwin"; + } + else + { + $ENV{HOST_ENV} = "windows"; + } + + print "\n"; + print(">>> Tizen Platform = $ENV{TIZEN_PLATFORM}\n"); + print(">>> Tizen SDK Version = $sdkVersion\n"); + + my $sdkName = "tizen-$sdkVersion-$ENV{HOST_ENV}.tar.bz2"; + my $depsSdkArchive = "$externalBuildDeps/$sdkName"; + my $depsSdkFinal = "$externalBuildDeps/tizen-$sdkVersion-$ENV{HOST_ENV}"; + + print(">>> Tizen SDK Archive = $depsSdkArchive\n"); + print(">>> Tizen SDK Extraction Destination = $depsSdkFinal\n"); + print("\n"); + + $ENV{TIZEN_SDK_ROOT} = "$depsSdkFinal"; + + if (-d $depsSdkFinal) + { + print(">>> Tizen SDK already extracted\n"); + } + else + { + print(">>> Tizen SDK needs to be extracted\n"); + + if ($runningOnWindows) + { + my $sevenZip = "$externalBuildDeps/7z/win64/7za.exe"; + my $winDepsSdkArchive = `cygpath -w $depsSdkArchive`; + my $winDepsSdkExtract = `cygpath -w $externalBuildDeps`; + + # clean up trailing new lines that end up in the output from cygpath. If left, they cause problems down the line + # for 7zip + $winDepsSdkArchive =~ s/\n+$//; + $winDepsSdkExtract =~ s/\n+$//; + + system($sevenZip, "x", "$winDepsSdkArchive", "-o$winDepsSdkExtract"); + } + else + { + my ($name,$path,$suffix) = fileparse($depsSdkArchive, qr/\.[^.]*/); + + print(">>> Tizen SDK Extension = $suffix\n"); + + if (lc $suffix eq '.bz2') + { chmod(0755, $depsSdkArchive); + system("tar xjf $depsSdkArchive -C $externalBuildDeps") eq 0 or die ("failed to extract Tizen SDK\n"); + } + else + { + die "Unknown file extension '" . $suffix . "'\n"; + } + } + } + + if (!(-f "$ENV{TIZEN_SDK_ROOT}/tools/sdb")) + { + die("Something went wrong with the SDK extraction\n"); + } + + my $tizenSdkRoot = $ENV{TIZEN_SDK_ROOT}; + my $tizenPlatformRoot = "$tizenSdkRoot/platforms/$ENV{TIZEN_PLATFORM}/mobile/rootstraps/$ENV{TIZEN_ROOTSTRAP}"; + my $tizenToolchain = "$tizenSdkRoot/tools/llvm-3.6/bin"; + + if ($runningOnWindows) + { + $toolChainExtension = ".exe"; + + $tizenPlatformRoot = `cygpath -w $tizenPlatformRoot`; + # clean up trailing new lines that end up in the output from cygpath. + $tizenPlatformRoot =~ s/\n+$//; + # Switch over to forward slashes. They propagate down the toolchain correctly + $tizenPlatformRoot =~ s/\\/\//g; + } + + if ($tizenEmulator) + { + $tizenToolchain = "$tizenSdkRoot/tools/i386-linux-gnueabi-gcc-4.9/bin/i386"; + $ENV{CFLAGS} = "-Os -g -march=i686 -msse2 -mfpmath=sse"; + } + else + { + $tizenToolchain = "$tizenSdkRoot/tools/arm-linux-gnueabi-gcc-4.9/bin/arm"; + $ENV{CFLAGS} = "-Os -g -march=armv7-a -mfpu=vfp -mfloat-abi=softfp -DARM_FPU_VFP=1 -DHAVE_ARMV6=1"; + $ENV{LDFLAGS} = "-Wl,-rpath-link=$tizenPlatformRoot/usr/lib -L$tizenPlatformRoot/usr/lib $ENV{LDFLAGS}"; + } + + print(">>> Tizen SDK Root = $tizenSdkRoot\n"); + print(">>> Tizen Platform Root = $tizenPlatformRoot\n"); + print(">>> Tizen Toolchain Prefix = $tizenToolchain\n"); + + if (!(-d "$tizenPlatformRoot")) + { + die("Failed to locate Tizen platform root\n"); + } + + $ENV{PATH} = "$tizenToolchain/bin:$ENV{PATH}"; + $ENV{CC} = "$tizenToolchain-linux-gnueabi-gcc --sysroot=$tizenPlatformRoot"; + $ENV{CXX} = "$tizenToolchain-linux-gnueabi-g++ --sysroot=$tizenPlatformRoot"; + $ENV{CPP} = "$tizenToolchain-linux-gnueabi-cpp"; + $ENV{CXXCPP} = "$tizenToolchain-linux-gnueabi-cpp"; + $ENV{CPATH} = "$tizenPlatformRoot/usr/include"; + $ENV{LD} = "$tizenToolchain-linux-gnueabi-ld --sysroot=$tizenPlatformRoot"; + $ENV{AS} = "$tizenToolchain-linux-gnueabi-as"; + $ENV{STRIP} = "$tizenToolchain-linux-gnueabi-strip"; + + if ($tizenEmulator) + { + $ENV{AR} = "$ENV{TIZEN_SDK_ROOT}/tools/i386-linux-gnueabi-gcc-4.9/bin/i386-linux-gnueabi-ar"; + $ENV{RANLIB} = "$ENV{TIZEN_SDK_ROOT}/tools/i386-linux-gnueabi-gcc-4.9/bin/i386-linux-gnueabi-ranlib"; + } + else + { + $ENV{AR} = "$ENV{TIZEN_SDK_ROOT}/tools/arm-linux-gnueabi-gcc-4.9/bin/arm-linux-gnueabi-ar"; + $ENV{RANLIB} = "$ENV{TIZEN_SDK_ROOT}/tools/arm-linux-gnueabi-gcc-4.9/bin/arm-linux-gnueabi-ranlib"; + } + + $ENV{CFLAGS} = "-DTIZEN -DLINUX -D__linux__ -DHAVE_USR_INCLUDE_MALLOC_H -DPAGE_SIZE=0x1000 -D_POSIX_PATH_MAX=256 -DS_IWRITE=S_IWUSR -DHAVE_PTHREAD_MUTEX_TIMEDLOCK -fpic -g -ffunction-sections -fdata-sections $ENV{CFLAGS}"; + $ENV{CXXFLAGS} = $ENV{CFLAGS}; + $ENV{CPPFLAGS} = $ENV{CFLAGS}; + $ENV{LDFLAGS} = "-Wl,--no-undefined -ldlog -shared -Xlinker --as-needed $ENV{LDFLAGS}"; + + print "\n"; + print ">>> Environment:\n"; + print ">>> \tCC = $ENV{CC}\n"; + print ">>> \tCXX = $ENV{CXX}\n"; + print ">>> \tCPP = $ENV{CPP}\n"; + print ">>> \tCXXCPP = $ENV{CXXCPP}\n"; + print ">>> \tCPATH = $ENV{CPATH}\n"; + print ">>> \tLD = $ENV{LD}\n"; + print ">>> \tAS = $ENV{AS}\n"; + print ">>> \tAR = $ENV{AR}\n"; + print ">>> \tRANLIB = $ENV{RANLIB}\n"; + print ">>> \tSTRIP = $ENV{STRIP}\n"; + print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; + print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; + print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; + print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; + + if ($tizenEmulator) + { + push @configureparams, "--host=i386-tizen-linux-gnueabi"; + } + else + { + push @configureparams, "--host=arm-tizen-linux-gnueabi"; + } + + push @configureparams, "--cache-file=tizen-cross.cache" if ($enableCacheFile); + push @configureparams, "--disable-parallel-mark"; + push @configureparams, "--disable-shared-handles"; + push @configureparams, "--with-sigaltstack=no"; + push @configureparams, "--with-tls=pthread"; + push @configureparams, "--disable-visibility-hidden"; + push @configureparams, "--disable-executables"; + push @configureparams, "--with-gnu-ld=yes"; + push @configureparams, "mono_cv_uscore=yes"; + push @configureparams, "ac_cv_header_zlib_h=no" if($runningOnWindows); + } + elsif($^O eq "linux") + { + if (!(-d $externalBuildDeps)) + { + die("mono build deps are required and the directory was not found : $externalBuildDeps\n"); + } + + if($ENV{UNITY_THISISABUILDMACHINE} || $ENV{UNITY_USE_LINUX_SDK}) + { + my $sdkVersion = '20170609'; + my $schroot = "LinuxBuildEnvironment-$sdkVersion"; + my @linuxToolchain = ('schroot', '-c', $schroot, '--'); + + print "\n"; + print(">>> Linux SDK Version = $sdkVersion\n"); + + my $sdkName = "linux-sdk-$sdkVersion.tar.bz2"; + my $depsSdkArchive = "$externalBuildDeps/$sdkName"; + my $depsSdkFinal = "$externalBuildDeps/linux-sdk-$sdkVersion"; + + print(">>> Linux SDK Archive = $depsSdkArchive\n"); + print(">>> Linux SDK Extraction Destination = $depsSdkFinal\n"); + print("\n"); + + my $linuxSdkRoot = $depsSdkFinal; + + if (-d $depsSdkFinal) + { + print(">>> Linux SDK already extracted\n"); + } + else + { + print(">>> Linux SDK needs to be extracted\n"); + system('mkdir', '-p', $depsSdkFinal); + system('tar', 'xaf', $depsSdkArchive, '-C', $depsSdkFinal) eq 0 or die ("failed to extract Linux SDK\n"); + system('sudo', 'cp', '-R', "$depsSdkFinal/linux-sdk-$sdkVersion", '/etc/schroot'); + system("sed 's,^directory=.*,directory=$depsSdkFinal/$schroot,' \"$depsSdkFinal/$schroot.conf\" | sudo tee /etc/schroot/chroot.d/$schroot.conf") eq 0 or die ("failed to deploy Linux SDK\n"); + } + + @commandPrefix = @linuxToolchain; + print(">>> Linux SDK Root = $linuxSdkRoot\n"); + print(">>> Linux Toolchain Command Prefix = " . join(' ', @commandPrefix) . "\n"); + } + + push @configureparams, "--host=$monoHostArch-pc-linux-gnu"; + + push @configureparams, "--disable-parallel-mark"; #this causes crashes + + my $archflags = ''; + if ($arch32) + { + $archflags = '-m32'; + } + else + { + $archflags = '-fPIC'; + } + + if ($debug) + { + $ENV{CFLAGS} = "$archflags -g -O0"; + } + else + { + $ENV{CFLAGS} = "$archflags -Os"; #optimize for size + } + } + elsif($^O eq 'darwin') + { + # Set up mono for bootstrapping + if ($existingMonoRootPath eq "") + { + # Find the latest mono version and use that for boostrapping + my $monoInstalls = '/Library/Frameworks/Mono.framework/Versions'; + my @monoVersions = (); + + opendir( my $DIR, $monoInstalls ); + while ( my $entry = readdir $DIR ) + { + next unless -d $monoInstalls . '/' . $entry; + next if $entry eq '.' or $entry eq '..' or $entry eq 'Current'; + push @monoVersions, $entry; + } + closedir $DIR; + @monoVersions = sort @monoVersions; + my $monoVersionToUse = pop @monoVersions; + $existingMonoRootPath = "$monoInstalls/$monoVersionToUse"; + } + + $mcs = "EXTERNAL_MCS=$existingMonoRootPath/bin/mcs"; + + $ENV{'CC'} = "$macSdkPath/../usr/bin/clang"; + $ENV{'CXX'} = "$macSdkPath/../usr/bin/clang++"; + $ENV{'CFLAGS'} = $ENV{MACSDKOPTIONS} = "-D_XOPEN_SOURCE -I$macBuildEnvDir/builds/usr/include -mmacosx-version-min=$macversion -isysroot $macSdkPath"; + + $ENV{CFLAGS} = "$ENV{CFLAGS} -g -O0" if $debug; + $ENV{CFLAGS} = "$ENV{CFLAGS} -Os" if not $debug; #optimize for size + + $ENV{CC} = "$ENV{CC} -arch $monoHostArch"; + $ENV{CXX} = "$ENV{CXX} -arch $monoHostArch"; + + # Add OSX specific autogen args + push @configureparams, "--host=$monoHostArch-apple-darwin12.2.0"; + + # Need to define because Apple's SIP gets in the way of us telling mono where to find this + push @configureparams, "--with-libgdiplus=$addtoresultsdistdir/lib/libgdiplus.dylib"; + + print "\n"; + print ">>> Setting environment:\n"; + print ">>> PATH = ".$ENV{PATH}."\n"; + print ">>> C_INCLUDE_PATH = ".$ENV{C_INCLUDE_PATH}."\n"; + print ">>> CPLUS_INCLUDE_PATH = ".$ENV{CPLUS_INCLUDE_PATH}."\n"; + print ">>> CFLAGS = ".$ENV{CFLAGS}."\n"; + print ">>> CXXFLAGS = ".$ENV{CXXFLAGS}."\n"; + print ">>> CC = ".$ENV{CC}."\n"; + print ">>> CXX = ".$ENV{CXX}."\n"; + print ">>> CPP = ".$ENV{CPP}."\n"; + print ">>> CXXPP = ".$ENV{CXXPP}."\n"; + print ">>> LD = ".$ENV{LD}."\n"; + print ">>> LDFLAGS = ".$ENV{LDFLAGS}."\n"; + print "\n"; + } + else + { + push @configureparams, "--host=$monoHostArch-pc-mingw32"; + } + + if ($isDesktopBuild) + { + my $cacheArch = $arch32 ? "i386" : "x86_64"; + push @configureparams, "--cache-file=desktop-$cacheArch.cache" if ($enableCacheFile); + } + + print ">>> Existing Mono : $existingMonoRootPath\n\n"; + $ENV{'PATH'} = "$existingMonoRootPath/bin:$ENV{'PATH'}"; + + print ">>> PATH before Build = $ENV{PATH}\n\n"; + + print(">>> mcs Information : \n"); + system(@commandPrefix, ("which", "mcs")); + system(@commandPrefix, ("mcs", "--version")); + print("\n"); + + print ">>> Checking on some tools...\n"; + system(@commandPrefix, ("which", "autoconf")); + system(@commandPrefix, ("autoconf", "--version")); + + system(@commandPrefix, ("which", "texi2dvi")); + system(@commandPrefix, ("texi2dvi", "--version")); + + system(@commandPrefix, ("which", "automake")); + system(@commandPrefix, ("automake", "--version")); + + system(@commandPrefix, ("which", "libtool")); + system(@commandPrefix, ("libtool", "--version")); + + system(@commandPrefix, ("which", "libtoolize")); + system(@commandPrefix, ("libtoolize", "--version")); + print("\n"); + + print ">>> LIBTOOLIZE before Build = $ENV{LIBTOOLIZE}\n"; + print ">>> LIBTOOL before Build = $ENV{LIBTOOL}\n"; + + chdir("$monoroot") eq 1 or die ("failed to chdir 2\n"); + + if (not $skipMonoMake) + { + if ($clean) + { + if (!($mcsOnly)) + { + print(">>> Cleaning $monoprefix\n"); + rmtree($monoprefix); + } + + # Avoid "source directory already configured" ... + system(@commandPrefix, ('rm', '-f', 'config.status', 'eglib/config.status', 'libgc/config.status')); + + print("\n>>> Calling autogen in mono\n"); + print("\n"); + print("\n>>> Configure parameters are : @configureparams\n"); + print("\n"); + + system(@commandPrefix, ('./autogen.sh', @configureparams)) eq 0 or die ('failing autogenning mono'); + + if ($mcsOnly) + { + print("\n>>> Calling make clean in mcs\n"); + chdir("$monoroot/mcs"); + system(@commandPrefix, ("make","clean")) eq 0 or die ("failed to make clean\n"); + chdir("$monoroot"); + } + else + { + print("\n>>> Calling make clean in mono\n"); + system(@commandPrefix, ("make","clean")) eq 0 or die ("failed to make clean\n"); + } + } + + # this step needs to run after configure + if ($iphoneCross || $iphone || $android || $tizen) + { + # This step generates the arm_dpimacros.h file, which is needed by the offset dumper + chdir("$monoroot/mono/arch/arm"); + system("make") eq 0 or die("failed to make in $monoroot/mono/arch/arm\n"); + chdir("$monoroot"); + } + + if ($iphoneCross) + { + my @monoArgs = (); + push @monoArgs, "$monoroot/tools/offsets-tool/MonoAotOffsetsDumper.exe"; + push @monoArgs, "--abi"; + push @monoArgs, "$iphoneCrossAbi"; + push @monoArgs, "--out"; + push @monoArgs, "$monoroot"; + push @monoArgs, "--mono"; + push @monoArgs, "$monoroot"; + push @monoArgs, "--maccore"; + push @monoArgs, "$monoroot"; + + $ENV{MONO_PATH} = "$externalBuildDeps/CppSharpBinaries"; + # Need to use 32bit mono because there is a native CppSharp dylib that will be used and there's only a 32bit version of it + print ">>> Running MonoAotOffsetDumper : arch -i386 $iphoneCrossMonoBinToUse/mono @monoArgs\n"; + system("arch", "-i386", "$iphoneCrossMonoBinToUse/mono", @monoArgs) eq 0 or die("failed to run MonoAotOffsetsDumper\n"); + } + + if ($mcsOnly) + { + print("\n>>> Calling make in mcs\n"); + chdir("$monoroot/mcs"); + my @makeCommand = (@commandPrefix, ('make', "-j$jobs")); + if($mcs ne '') + { + push(@makeCommand, $mcs); + } + system(@makeCommand) eq 0 or die ("Failed to make\n"); + chdir("$monoroot"); + } + else + { + print("\n>>> Calling make\n"); + my @makeCommand = (@commandPrefix, ('make', "-j$jobs")); + if($mcs ne '') + { + push(@makeCommand, $mcs); + } + system(@makeCommand) eq 0 or die ("Failed to make\n"); + } + + if ($isDesktopBuild) + { + print("\n>>> Calling make install\n"); + system(@commandPrefix, ('make', 'install')) eq 0 or die ("Failed to make install\n"); + } + else + { + if ($disableMcs) + { + print(">>> Skipping make install. We don't need to run this step when building the runtime on non-desktop platforms.\n"); + } + else + { + # Note by Mike : make install on Windows for android runtime runs into more cygwin path issues. The one I hit was related to ranlib.exe being passed cygwin linux paths + # and as a result not being able to find stuff. The previous build scripts didn't run make install for android or iOS, so I think we are fine to skip this step. + # However, if we were to build the class libs for these cases, then we probably would need to run make install. If that day comes, we'll have to figure out what to do here. + print(">>> Attempting to build class libs for a non-desktop platform. The `make install` step is probably needed, but it has cygwin path related problems on Windows for android\n"); + die("Blocking this code path until we need it. It probably should be looked at more closely before letting it proceed\n"); + } + } + } + + if ($isDesktopBuild) + { + if ($^O eq "cygwin") + { + system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--msbuildversion=$msBuildVersion", "--clean=$clean", "--debug=$debug") eq 0 or die ('failed building mono with VS\n'); + + # Copy over the VS built stuff that we want to use instead into the prefix directory + my $archNameForBuild = $arch32 ? 'Win32' : 'x64'; + my $config = $debug ? "Debug" : "Release"; + system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono.exe $monoprefix/bin/.") eq 0 or die ("failed copying mono.exe\n"); + system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono-2.0.dll $monoprefix/bin/.") eq 0 or die ("failed copying mono-2.0.dll\n"); + system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono-2.0.pdb $monoprefix/bin/.") eq 0 or die ("failed copying mono-2.0.pdb\n"); + } + + system("cp -R $addtoresultsdistdir/bin/. $monoprefix/bin/") eq 0 or die ("Failed copying $addtoresultsdistdir/bin to $monoprefix/bin\n"); + } + + if(!($disableMcs)) + { + my @additionalProfiles = (); + push @additionalProfiles, "unityjit"; + push @additionalProfiles, "unityaot"; + + chdir("$monoroot/mcs"); + foreach my $profileName(@additionalProfiles) + { + print(">>> Making profile : $profileName\n"); + system("make", "PROFILE=$profileName") eq 0 or die ("Failed to make $profileName profile in mcs\n"); + + my $profileDestDir = "$monoprefix/lib/mono/$profileName"; + print(">>> Copying $profileName to $profileDestDir directory\n"); + + print(">>> Cleaning $profileDestDir\n"); + system("rm -rf $profileDestDir"); + + system("mkdir -p $profileDestDir") eq 0 or die("failed to make directory $profileDestDir\n"); + system("mkdir -p $profileDestDir/Facades") eq 0 or die("failed to make directory $profileDestDir/Facades\n"); + + system("cp $monoroot/mcs/class/lib/$profileName/*.dll $profileDestDir") eq 0 or die("Failed copying dlls from $monoroot/mcs/class/lib/$profileName to $profileDestDir\n"); + system("cp $monoroot/mcs/class/lib/$profileName/Facades/*.dll $profileDestDir/Facades") eq 0 or die("Failed copying dlls from $monoroot/mcs/class/lib/$profileName/Facades to $profileDestDir/Facades\n"); + } + + chdir("$monoroot"); + } +} +else +{ + print(">>> Skipping build\n"); +} + +if ($buildUsAndBoo) +{ + print(">>> Building Unity Script and Boo...\n"); + if($windowsSubsystemForLinux) + { + #boo scripts expect a bin-platform folder, but we haven't built them that way + system("ln -s $monoprefix/bin $monoprefix/bin-linux64"); + system("ln -s $monoprefix/bin $monoprefix/bin-linux32"); + } + + system(@commandPrefix, ("perl", "$buildscriptsdir/build_us_and_boo.pl", "--monoprefix=$monoprefix")) eq 0 or die ("Failed building Unity Script and Boo\n"); + + print(">>> Copying Unity Script and Boo *.Lang.dll's from 4.5 profile to unityjit profile...\n"); + system("cp $monoprefix/lib/mono/4.5/Boo*.dll $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying Boo*.dll\n"); + system("cp $monoprefix/lib/mono/4.5/UnityScript*.dll $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying UnityScript*.dll\n"); + system("cp $monoprefix/lib/mono/4.5/booc.exe $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying booc.exe\n"); + system("cp $monoprefix/lib/mono/4.5/us.exe $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying us.exe\n"); +} +else +{ + print(">>> Skipping build Unity Script and Boo\n"); +} + +if ($artifact) +{ + print(">>> Creating artifact...\n"); + + if ($artifactsCommon) + { + print(">>> Creating common artifacts...\n"); + print(">>> distribution directory = $distdir\n"); + + if (!(-d "$distdir")) + { + system("mkdir -p $distdir") eq 0 or die("failed to make directory $distdir\n"); + } + + $File::Copy::Recursive::CopyLink = 0; #make sure we copy files as files and not as symlinks, as TC unfortunately doesn't pick up symlinks. + + my $distdirlibmono = "$distdir/lib/mono"; + + print(">>> Cleaning $distdir/lib\n"); + system("rm -rf $distdir/lib"); + system("mkdir -p $distdir/lib"); + + print(">>> Creating normal profile artifacts...\n"); + system("cp -R $addtoresultsdistdir/. $distdir/") eq 0 or die ("Failed copying $addtoresultsdistdir to $distdir\n"); + + system("cp -r $monoprefix/lib/mono $distdir/lib"); + + if($^O ne 'darwin') + { + # On OSX we build a universal binary for 32-bit and 64-bit in the mono executable. The class library build + # only creates the 64-bit slice, so we don't want to end up with a single slice binary in the output. + # If we do, it will step on the universal binary produced but the OSX runtime build. + system("cp -r $monoprefix/bin $distdir/") eq 0 or die ("failed copying bin folder\n"); + } + system("cp -r $monoprefix/etc $distdir/") eq 0 or die("failed copying etc folder\n"); + + system("cp -R $externalBuildDeps/reference-assemblies/unity $distdirlibmono/unity"); + system("cp -R $externalBuildDeps/reference-assemblies/unity_web $distdirlibmono/unity_web"); + + system("cp -R $externalBuildDeps/reference-assemblies/unity/Boo*.dll $distdirlibmono/2.0-api"); + system("cp -R $externalBuildDeps/reference-assemblies/unity/UnityScript*.dll $distdirlibmono/2.0-api"); + + system("cp -R $externalBuildDeps/reference-assemblies/unity/Boo*.dll $distdirlibmono/4.0-api"); + system("cp -R $externalBuildDeps/reference-assemblies/unity/UnityScript*.dll $distdirlibmono/4.0-api"); + + system("cp -R $externalBuildDeps/reference-assemblies/unity/Boo*.dll $distdirlibmono/4.5-api"); + system("cp -R $externalBuildDeps/reference-assemblies/unity/UnityScript*.dll $distdirlibmono/4.5-api"); + + # now remove nunit from a couple places (but not all, we need some of them) + # linux tar is not happy these are removed(at least on wsl), so don't remove them for now + if(not $windowsSubsystemForLinux) + { + system("rm -rf $distdirlibmono/2.0/nunit*"); + system("rm -rf $distdirlibmono/gac/nunit*"); + } + + # Remove a self referencing sym link that causes problems + system("rm -rf $monoprefix/bin/bin"); + + if (-f "$monoroot/ZippedClasslibs.tar.gz") + { + system("rm -f $monoroot/ZippedClasslibs.tar.gz") eq 0 or die("Failed to clean existing ZippedClasslibs.tar.gz\n"); + } + + print(">>> Creating ZippedClasslibs.tar.gz\n"); + print(">>> Changing directory to : $buildsroot\n"); + chdir("$buildsroot"); + system("tar -hpczf ../ZippedClasslibs.tar.gz *") eq 0 or die("Failed to zip up classlibs\n"); + print(">>> Changing directory back to : $currentdir\n"); + chdir("$currentdir"); + } + + # Do the platform specific logic to create the builds output structure that we want + + my $embedDirRoot = "$buildsroot/embedruntimes"; + my $embedDirArchDestination = ""; + my $distDirArchBin = ""; + my $versionsOutputFile = ""; + my $crossCompilerRoot = "$buildsroot/crosscompiler"; + my $crossCompilerDestination = ""; + + if ($iphone) + { + $embedDirArchDestination = "$embedDirRoot/iphone/$iphoneArch"; + $versionsOutputFile = "$buildsroot/versions-iphone-$iphoneArch.txt"; + } + elsif ($iphoneCross) + { + $crossCompilerDestination = "$buildsroot/crosscompiler/iphone"; + $versionsOutputFile = "$buildsroot/versions-iphone-xcompiler.txt"; + } + elsif ($iphoneSimulator) + { + $embedDirArchDestination = "$embedDirRoot/iphone/$iphoneSimulatorArch"; + $versionsOutputFile = "$buildsroot/versions-iphone-$iphoneSimulatorArch.txt"; + } + elsif ($android) + { + $embedDirArchDestination = "$embedDirRoot/android/$androidArch"; + $versionsOutputFile = "$buildsroot/versions-android-$androidArch.txt"; + } + elsif ($tizenEmulator) + { + $embedDirArchDestination = "$embedDirRoot/tizenemulator/"; + $versionsOutputFile = "$buildsroot/versions-tizenemulator.txt"; + } + elsif ($tizen) + { + $embedDirArchDestination = "$embedDirRoot/tizen/"; + $versionsOutputFile = "$buildsroot/versions-tizen.txt"; + } + elsif($^O eq "linux") + { + $embedDirArchDestination = $arch32 ? "$embedDirRoot/linux32" : "$embedDirRoot/linux64"; + $distDirArchBin = $arch32 ? "$distdir/bin-linux32" : "$distdir/bin-linux64"; + $versionsOutputFile = $arch32 ? "$buildsroot/versions-linux32.txt" : "$buildsroot/versions-linux64.txt"; + } + elsif($^O eq 'darwin') + { + # Note these tmp directories will get merged into a single 'osx' directory later by a parent script + $embedDirArchDestination = "$embedDirRoot/osx-tmp-$monoHostArch"; + $distDirArchBin = "$distdir/bin-osx-tmp-$monoHostArch"; + $versionsOutputFile = $arch32 ? "$buildsroot/versions-osx32.txt" : "$buildsroot/versions-osx64.txt"; + } + else + { + $embedDirArchDestination = $arch32 ? "$embedDirRoot/win32" : "$embedDirRoot/win64"; + $distDirArchBin = $arch32 ? "$distdir/bin" : "$distdir/bin-x64"; + $versionsOutputFile = $arch32 ? "$buildsroot/versions-win32.txt" : "$buildsroot/versions-win64.txt"; + } + + # Make sure the directory for our architecture is clean before we copy stuff into it + if (-d "$embedDirArchDestination") + { + print(">>> Cleaning $embedDirArchDestination\n"); + rmtree($embedDirArchDestination); + } + + if (-d "$distDirArchBin") + { + print(">>> Cleaning $distDirArchBin\n"); + rmtree($distDirArchBin); + } + + if ($artifactsRuntime) + { + system("mkdir -p $embedDirArchDestination") if ($embedDirArchDestination ne ""); + system("mkdir -p $distDirArchBin") if ($distDirArchBin ne ""); + system("mkdir -p $crossCompilerDestination") if ($crossCompilerDestination ne ""); + + # embedruntimes directory setup + print(">>> Creating embedruntimes directory : $embedDirArchDestination\n"); + if ($iphone || $iphoneSimulator) + { + for my $file ('libmonosgen-2.0.a','libmonobdwgc-2.0.a') + { + print ">>> Copying $file\n"; + system("cp", "$monoroot/mono/mini/.libs/$file","$embedDirArchDestination/$file") eq 0 or die ("failed copying $file\n"); + } + } + elsif ($iphoneCross) + { + # Nothing to do + } + elsif ($android) + { + for my $file ('libmonosgen-2.0.so','libmonosgen-2.0.a','libmonobdwgc-2.0.so','libmonobdwgc-2.0.a') + { + print ">>> Copying $file\n"; + system("cp", "$monoroot/mono/mini/.libs/$file","$embedDirArchDestination/$file") eq 0 or die ("failed copying $file\n"); + } + } + elsif ($tizen || $tizenEmulator) + { + for my $file ('libmonosgen-2.0.so','libmonobdwgc-2.0.so') + { + print ">>> Copying $file\n"; + system("cp", "$monoroot/mono/mini/.libs/$file","$embedDirArchDestination/$file") eq 0 or die ("failed copying $file\n"); + } + } + elsif($^O eq "linux") + { + print ">>> Copying libmonosgen-2.0\n"; + system("cp", "$monoroot/mono/mini/.libs/libmonobdwgc-2.0.so","$embedDirArchDestination/libmonobdwgc-2.0.so") eq 0 or die ("failed copying libmonobdwgc-2.0.so\n"); + system("cp", "$monoroot/mono/mini/.libs/libmonosgen-2.0.so","$embedDirArchDestination/libmonosgen-2.0.so") eq 0 or die ("failed copying libmonosgen-2.0.so\n"); + + print ">>> Copying libMonoPosixHelper.so\n"; + system("cp", "$monoroot/support/.libs/libMonoPosixHelper.so","$embedDirArchDestination/libMonoPosixHelper.so") eq 0 or die ("failed copying libMonoPosixHelper.so\n"); + + if ($buildMachine) + { + system("strip $embedDirArchDestination/libmonobdwgc-2.0.so") eq 0 or die("failed to strip libmonobdwgc-2.0.so (shared)\n"); + system("strip $embedDirArchDestination/libmonosgen-2.0.so") eq 0 or die("failed to strip libmonosgen-2.0.so (shared)\n"); + system("strip $embedDirArchDestination/libMonoPosixHelper.so") eq 0 or die("failed to strip libMonoPosixHelper (shared)\n"); + } + } + elsif($^O eq 'darwin') + { + # embedruntimes directory setup + print ">>> Hardlinking libmonosgen-2.0\n"; + + system("ln","-f", "$monoroot/mono/mini/.libs/libmonobdwgc-2.0.dylib","$embedDirArchDestination/libmonobdwgc-2.0.dylib") eq 0 or die ("failed symlinking libmonobdwgc-2.0.dylib\n"); + system("ln","-f", "$monoroot/mono/mini/.libs/libmonosgen-2.0.dylib","$embedDirArchDestination/libmonosgen-2.0.dylib") eq 0 or die ("failed symlinking libmonosgen-2.0.dylib\n"); + + print "Hardlinking libMonoPosixHelper.dylib\n"; + system("ln","-f", "$monoroot/support/.libs/libMonoPosixHelper.dylib","$embedDirArchDestination/libMonoPosixHelper.dylib") eq 0 or die ("failed symlinking $libtarget/libMonoPosixHelper.dylib\n"); + + InstallNameTool("$embedDirArchDestination/libmonobdwgc-2.0.dylib", "\@executable_path/../Frameworks/MonoEmbedRuntime/osx/libmonobdwgc-2.0.dylib"); + InstallNameTool("$embedDirArchDestination/libmonosgen-2.0.dylib", "\@executable_path/../Frameworks/MonoEmbedRuntime/osx/libmonosgen-2.0.dylib"); + InstallNameTool("$embedDirArchDestination/libMonoPosixHelper.dylib", "\@executable_path/../Frameworks/MonoEmbedRuntime/osx/libMonoPosixHelper.dylib"); + + print ">>> Copying mono public headers\n"; + system("mkdir -p $includesroot/mono"); + system("cp -R $monoprefix/include/mono-2.0/mono $includesroot/mono"); + } + else + { + # embedruntimes directory setup + system("cp", "$monoprefix/bin/mono-2.0-bdwgc.dll", "$embedDirArchDestination/mono-2.0-bdwgc.dll") eq 0 or die ("failed copying mono-2.0-bdwgc.dll\n"); + system("cp", "$monoprefix/bin/mono-2.0-bdwgc.pdb", "$embedDirArchDestination/mono-2.0-bdwgc.pdb") eq 0 or die ("failed copying mono-2.0-bdwgc.pdb\n"); + + system("cp", "$monoprefix/bin/mono-2.0-sgen.dll", "$embedDirArchDestination/mono-2.0-sgen.dll") eq 0 or die ("failed copying mono-2.0-sgen.dll\n"); + system("cp", "$monoprefix/bin/mono-2.0-sgen.pdb", "$embedDirArchDestination/mono-2.0-sgen.pdb") eq 0 or die ("failed copying mono-2.0-sgen.pdb\n"); + } + + # sources directory setup + print ">>> Copying mono sources needed for il2cpp\n"; + system("mkdir -p $sourcesroot") eq 0 or die "failed making directory $sourcesroot\n"; + + # need to build some arm headers to package up for android + chdir("$monoroot/mono/arch/arm") eq 1 or die ("failed to chdir to mono/arch/arm directory\n"); + system(@commandPrefix, ("make")) eq 0 or die ("failed to make arm headers\n"); + print(">>> Changing directory back to : $currentdir\n"); + chdir("$currentdir") eq 1 or die ("failed to chdir to $currentdir\n"); + + system("perl", "$buildscriptsdir/copy_il2cpp_sources.pl", "--monoroot=$monoroot", "--sourcesroot=$sourcesroot") eq 0 or die ('failed to copy the source files needed for il2cpp'); + + # monodistribution directory setup + print(">>> Creating monodistribution directory\n"); + if ($android || $iphone || $iphoneCross || $iphoneSimulator || $tizen || $tizenEmulator) + { + # Nothing to do + } + elsif($^O eq "linux") + { + my $distDirArchEtc = $arch32 ? "$distdir/etc-linux32" : "$distdir/etc-linux64"; + + if (-d "$distDirArchEtc") + { + print(">>> Cleaning $distDirArchEtc\n"); + rmtree($distDirArchEtc); + } + + system("mkdir -p $distDirArchBin"); + system("mkdir -p $distDirArchEtc"); + system("mkdir -p $distDirArchEtc/mono"); + + system("ln", "-f", "$monoroot/mono/mini/mono-sgen","$distDirArchBin/mono") eq 0 or die("failed symlinking mono executable\n"); + system("ln", "-f", "$monoroot/tools/pedump/pedump","$distDirArchBin/pedump") eq 0 or die("failed symlinking pedump executable\n"); + system('cp', "$monoroot/data/config","$distDirArchEtc/mono/config") eq 0 or die("failed to copy config\n"); + } + elsif($^O eq 'darwin') + { + system("ln", "-f", "$monoroot/mono/mini/mono","$distDirArchBin/mono") eq 0 or die("failed hardlinking mono executable\n"); + system("ln", "-f", "$monoroot/tools/pedump/pedump","$distDirArchBin/pedump") eq 0 or die("failed hardlinking pedump executable\n"); + } + else + { + system("cp", "$monoprefix/bin/mono-2.0.dll", "$distDirArchBin/mono-2.0.dll") eq 0 or die ("failed copying mono-2.0.dll\n"); + system("cp", "$monoprefix/bin/mono-2.0.pdb", "$distDirArchBin/mono-2.0.pdb") eq 0 or die ("failed copying mono-2.0.pdb\n"); + system("cp", "$monoprefix/bin/mono.exe", "$distDirArchBin/mono.exe") eq 0 or die ("failed copying mono.exe\n"); + } + } + + # cross compiler directory setup + if ($iphoneCross) + { + print ">>> Copying mono-xcompiler\n"; + if($runningOnWindows) + { + die("Not implemented\n"); + } + else + { + system("cp", "$monoroot/mono/mini/mono","$crossCompilerDestination/mono-xcompiler") eq 0 or die ("failed copying mono-xcompiler\n"); + } + } + + # Not all build configurations output to the distro dir, so only chmod it if it exists + system("chmod", "-R", "755", $distDirArchBin) if (-d "$distDirArchBin"); + + # Output version information + print(">>> Creating version file : $versionsOutputFile\n"); + system("echo \"mono-version =\" > $versionsOutputFile"); + + # Not all build configurations output to the distro dir, only try to output version info if there is a distro dir + system("$distDirArchBin/mono --version >> $versionsOutputFile") if (-d "$distDirArchBin"); + + system("echo \"unity-mono-revision = $monoRevision\" >> $versionsOutputFile"); + system("echo \"unity-mono-build-scripts-revision = $buildScriptsRevision\" >> $versionsOutputFile"); + my $tmp = `date`; + system("echo \"build-date = $tmp\" >> $versionsOutputFile"); +} +else +{ + print(">>> Skipping artifact creation\n"); +} + +if ($test) +{ + if ($runRuntimeTests) + { + my $runtimeTestsDir = "$monoroot/mono/mini"; + chdir("$runtimeTestsDir") eq 1 or die ("failed to chdir"); + print("\n>>> Calling make check in $runtimeTestsDir\n\n"); + system("make","check") eq 0 or die ("runtime tests failed\n"); + } + else + { + print(">>> Skipping runtime unit tests\n"); + } + + if ($runClasslibTests) + { + if ($disableMcs) + { + print(">>> Skipping classlib unit tests because building the class libs was disabled\n"); + } + else + { + my $classlibTestsDir = "$monoroot/mcs/class"; + chdir("$classlibTestsDir") eq 1 or die ("failed to chdir"); + print("\n>>> Calling make run-test in $runtimeTestsDir\n\n"); + system("make","run-test") eq 0 or die ("classlib tests failed\n"); + } + } + else + { + print(">>> Skipping classlib unit tests\n"); + } +} +else +{ + print(">>> Skipping unit tests\n"); +} + +chdir ($currentdir); diff --git a/external/buildscripts/build_all_linux.pl b/external/buildscripts/build_all_linux.pl new file mode 100644 index 000000000000..d124f2b19cce --- /dev/null +++ b/external/buildscripts/build_all_linux.pl @@ -0,0 +1,27 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $currentdir = getcwd(); + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildscriptsdir = "$monoroot/external/buildscripts"; + +my @passAlongArgs = (); +foreach my $arg (@ARGV) +{ + # Filter out --clean if someone uses it. We have to clean since we are doing two builds + if (not $arg =~ /^--clean=/) + { + push @passAlongArgs, $arg; + } +} + +print(">>> Building i386\n"); +system("perl", "$buildscriptsdir/build.pl", "--arch32=1", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building i386'); + +print(">>> Building x86_64\n"); +system("perl", "$buildscriptsdir/build.pl", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building x86_64'); \ No newline at end of file diff --git a/external/buildscripts/build_all_osx.pl b/external/buildscripts/build_all_osx.pl new file mode 100644 index 000000000000..0f0eb42d6aa3 --- /dev/null +++ b/external/buildscripts/build_all_osx.pl @@ -0,0 +1,165 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $currentdir = getcwd(); + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildscriptsdir = "$monoroot/external/buildscripts"; +my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; +my $buildsroot = "$monoroot/builds"; + +my $artifact=0; +my $artifactsCommon=0; +my $buildUsAndBoo=0; + +my @thisScriptArgs = (); +my @passAlongArgs = (); +foreach my $arg (@ARGV) +{ + # Filter out --clean if someone uses it. We have to clean since we are doing two builds + if (not $arg =~ /^--clean=/) + { + # We don't need common artifacts, us, and boo, from both, so filter out temporarily and we'll + # only pass it to the second build + if ($arg =~ /^--artifactscommon=/ || $arg =~ /^--buildusandboo=/) + { + push @thisScriptArgs, $arg; + } + else + { + push @passAlongArgs, $arg; + } + } + + if ($arg =~ /^--artifact=/) + { + push @thisScriptArgs, $arg; + } +} + +print(">>> This Script Args = @thisScriptArgs\n"); +print(">>> Pass Along Args = @passAlongArgs\n"); + +@ARGV = @thisScriptArgs; +GetOptions( + 'artifact=i'=>\$artifact, + 'artifactscommon=i'=>\$artifactsCommon, + 'buildusandboo=i'=>\$buildUsAndBoo, +); + +my $monoArch32Target = "i386"; + +print(">>> Building $monoArch32Target\n"); +system("perl", "$buildscriptsdir/build.pl", "--arch32=1", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ("failing building $monoArch32Target"); + +if ($artifactsCommon) +{ + push @passAlongArgs, "--artifactscommon=1"; +} + +if ($buildUsAndBoo) +{ + push @passAlongArgs, "--buildusandboo=1"; +} + +print(">>> Building x86_64\n"); +system("perl", "$buildscriptsdir/build.pl", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building x86_64'); + +if ($artifact) +{ + print(">>> Creating universal binaries\n"); + # Merge stuff in the embedruntimes directory + my $embedDirRoot = "$buildsroot/embedruntimes"; + my $embedDirDestination = "$embedDirRoot/osx"; + my $embedDirSource32 = "$embedDirRoot/osx-tmp-$monoArch32Target"; + my $embedDirSource64 = "$embedDirRoot/osx-tmp-x86_64"; + + system("mkdir -p $embedDirDestination"); + + if (!(-d $embedDirSource32)) + { + die("Expected source directory not found : $embedDirSource32\n"); + } + + if (!(-d $embedDirSource64)) + { + die("Expected source directory not found : $embedDirSource64\n"); + } + + # Create universal binaries + for my $file ('libmonobdwgc-2.0.dylib','libmonosgen-2.0.dylib','libMonoPosixHelper.dylib') + { + print(">>> lipo $embedDirSource32/$file $embedDirSource64/$file -create -output $embedDirDestination/$file\n\n"); + system ('lipo', "$embedDirSource32/$file", "$embedDirSource64/$file", '-create', '-output', "$embedDirDestination/$file"); + } + + if (not $buildMachine) + { + print(">>> Doing non-build machine stuff...\n"); + for my $file ('libmonobdwgc-2.0.dylib','libmonosgen-2.0.dylib','libMonoPosixHelper.dylib') + { + print(">>> Removing $embedDirDestination/$file.dSYM\n"); + rmtree ("$embedDirDestination/$file.dSYM"); + print(">>> 'dsymutil $embedDirDestination/$file\n"); + system ('dsymutil', "$embedDirDestination/$file") eq 0 or warn ("Failed creating $embedDirDestination/$file.dSYM"); + } + + print(">>> Done with non-build machine stuff\n"); + } + + # Merge stuff in the monodistribution directory + my $distDirRoot = "$buildsroot/monodistribution"; + my $distDirDestinationBin = "$buildsroot/monodistribution/bin"; + my $distDirDestinationLib = "$buildsroot/monodistribution/lib"; + my $distDirSourceBin32 = "$distDirRoot/bin-osx-tmp-$monoArch32Target"; + my $distDirSourceBin64 = "$distDirRoot/bin-osx-tmp-x86_64"; + + # Should always exist because build_all would have put stuff in it, but in some situations + # depending on the options it may not. So create it if it does not exist + if (!(-d $distDirDestinationBin)) + { + system("mkdir -p $distDirDestinationBin"); + } + + if (!(-d $distDirDestinationLib)) + { + system("mkdir -p $distDirDestinationLib"); + } + + if (!(-d $distDirSourceBin32)) + { + die("Expected source directory not found : $distDirSourceBin32\n"); + } + + if (!(-d $distDirSourceBin64)) + { + die("Expected source directory not found : $distDirSourceBin64\n"); + } + + for my $file ('mono','pedump') + { + print(">>> lipo $distDirSourceBin32/$file $distDirSourceBin64/$file -create -output $distDirDestinationBin/$file\n\n"); + system ('lipo', "$distDirSourceBin32/$file", "$distDirSourceBin64/$file", '-create', '-output', "$distDirDestinationBin/$file"); + } + + #Create universal binaries for stuff is in the embed dir but will end up in the dist dir + for my $file ('libMonoPosixHelper.dylib') + { + print(">>> lipo $embedDirSource32/$file $embedDirSource64/$file -create -output $distDirDestinationLib/$file\n\n"); + system ('lipo', "$embedDirSource32/$file", "$embedDirSource64/$file", '-create', '-output', "$distDirDestinationLib/$file"); + } + + if ($buildMachine) + { + print(">>> Clean up temporary arch specific build directories\n"); + + rmtree("$distDirSourceBin32"); + rmtree("$distDirSourceBin64"); + rmtree("$embedDirSource32"); + rmtree("$embedDirSource64"); + } +} diff --git a/external/buildscripts/build_all_win.pl b/external/buildscripts/build_all_win.pl new file mode 100644 index 000000000000..3c282f5f9993 --- /dev/null +++ b/external/buildscripts/build_all_win.pl @@ -0,0 +1,27 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $currentdir = getcwd(); + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildscriptsdir = "$monoroot/external/buildscripts"; + +my @passAlongArgs = (); +foreach my $arg (@ARGV) +{ + # Filter out --clean if someone uses it. We have to clean since we are doing two builds + if (not $arg =~ /^--clean=/) + { + push @passAlongArgs, $arg; + } +} + +print(">>> Building i686\n"); +system("perl", "$buildscriptsdir/build_win_wrapper.pl", "--arch32=1", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building win32'); + +print(">>> Building x86_64\n"); +system("perl", "$buildscriptsdir/build_win_wrapper.pl", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building x64'); \ No newline at end of file diff --git a/external/buildscripts/build_classlibs_osx.pl b/external/buildscripts/build_classlibs_osx.pl new file mode 100644 index 000000000000..b1a47d9fef8d --- /dev/null +++ b/external/buildscripts/build_classlibs_osx.pl @@ -0,0 +1,40 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $build = 1; +my $clean = 1; +my $mcsOnly = 0; +my $skipMonoMake = 0; + +# Handy troubleshooting/niche options + +# The prefix hack probably isn't needed anymore. Let's disable it by default and see how things go +my $shortPrefix = 1; + +GetOptions( + "build=i"=>\$build, + "clean=i"=>\$clean, + "mcsOnly=i"=>\$mcsOnly, + 'skipmonomake=i'=>\$skipMonoMake, + 'shortprefix=i'=>\$shortPrefix, +) or die ("illegal cmdline options"); + +system( + "perl", + "$buildScriptsRoot/build.pl", + "--build=$build", + "--clean=$clean", + "--mcsonly=$mcsOnly", + "--skipmonomake=$skipMonoMake", + "--artifact=1", + "--artifactscommon=1", + "--buildusandboo=1", + "--forcedefaultbuilddeps=1", + "--shortprefix=$shortPrefix") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_classlibs_wsl.pl b/external/buildscripts/build_classlibs_wsl.pl new file mode 100644 index 000000000000..750b21d646f6 --- /dev/null +++ b/external/buildscripts/build_classlibs_wsl.pl @@ -0,0 +1,53 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $build = 1; +my $clean = 1; +my $mcsOnly = 0; +my $skipMonoMake = 0; + +# Handy troubleshooting/niche options + +# The prefix hack probably isn't needed anymore. Let's disable it by default and see how things go +my $shortPrefix = 1; + +# This script should not be ran on windows, if it is, kindly switch over to wsl +if ($^O eq "MSWin32") +{ + print(">>> Called from Windows. Switching over to wsl\n"); + my $monoRootInBash = `bash -c pwd`; + chomp $monoRootInBash; + print(">>> monoRootInBash = $monoRootInBash\n"); + my $cmdForBash = "$monoRootInBash/external/buildscripts/build_classlibs_wsl.pl @ARGV"; + system("bash", "-c", "\"perl $cmdForBash\"") eq 0 or die("\n"); + exit 0; +} + +GetOptions( + "build=i"=>\$build, + "clean=i"=>\$clean, + "mcsOnly=i"=>\$mcsOnly, + 'skipmonomake=i'=>\$skipMonoMake, + 'shortprefix=i'=>\$shortPrefix, +) or die ("illegal cmdline options"); + +system( + "perl", + "$buildScriptsRoot/build.pl", + "--build=$build", + "--clean=$clean", + "--mcsonly=$mcsOnly", + "--skipmonomake=$skipMonoMake", + "--artifact=1", + "--artifactscommon=1", + "--buildusandboo=1", + "--forcedefaultbuilddeps=1", + "--windowssubsystemforlinux=1", + "--shortprefix=$shortPrefix") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_ios_xwin.pl b/external/buildscripts/build_ios_xwin.pl new file mode 100644 index 000000000000..d20844d1ef25 --- /dev/null +++ b/external/buildscripts/build_ios_xwin.pl @@ -0,0 +1,18 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $clean = 1; + +GetOptions( + "clean=i"=>\$clean, +) or die ("illegal cmdline options"); + + +system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphonecross=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building iphone cross compiler\n"); diff --git a/external/buildscripts/build_ios_xwin.sh b/external/buildscripts/build_ios_xwin.sh new file mode 100644 index 000000000000..8095de7d7146 --- /dev/null +++ b/external/buildscripts/build_ios_xwin.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# The build configs are looking for this file rather than the perl script. +# easier to add this + +BASEDIR=$(dirname $0) + +# Note : Not Implemented yet. Script is here to make the katana build pass so that the mono build artifact is created +# Uncomment the line below when ready to implement. Remove the mkdir +if [ -d builds ]; then + echo "Skip making builds directory. Already exists" +else + mkdir builds +fi + +touch builds/dummy_ios_win.txt + + +#perl "$BASEDIR/build_ios_xwin.pl" "$@" || exit 1 diff --git a/external/buildscripts/build_runtime_android.pl b/external/buildscripts/build_runtime_android.pl new file mode 100644 index 000000000000..2bcbb6eb6d8c --- /dev/null +++ b/external/buildscripts/build_runtime_android.pl @@ -0,0 +1,30 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $androidArch = ""; +my $clean = 1; + +GetOptions( + "androidarch=s"=>\$androidArch, + "clean=i"=>\$clean, +) or die ("illegal cmdline options"); + +# By default, build runtime for all the variants we need. But allow something to specify an individual variation to build +if ($androidArch eq "") +{ + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv5", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for armv5\n"); + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv6_vfp", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for armv6_vfp\n"); + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv7a", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for armv7a\n"); + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=x86", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for x86\n"); +} +else +{ + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--androidarch=$androidArch", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for $androidArch\n"); +} diff --git a/external/buildscripts/build_runtime_android.sh b/external/buildscripts/build_runtime_android.sh new file mode 100644 index 000000000000..2916d73d5e65 --- /dev/null +++ b/external/buildscripts/build_runtime_android.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# The build configs are looking for this file rather than the perl script. +# easier to add this + +BASEDIR=$(dirname $0) + +perl "$BASEDIR/build_runtime_android.pl" "$@" diff --git a/external/buildscripts/build_runtime_iphone.pl b/external/buildscripts/build_runtime_iphone.pl new file mode 100644 index 000000000000..7c0b93e9df2e --- /dev/null +++ b/external/buildscripts/build_runtime_iphone.pl @@ -0,0 +1,67 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $clean = 1; +my $runtime = 0; +my $xcomp = 0; +my $simulator = 0; + +GetOptions( + "clean=i"=>\$clean, + "runtime=i"=>\$runtime, + "xcomp=i"=>\$xcomp, + "simulator=i"=>\$simulator, +) or die ("illegal cmdline options"); + +# Build everything by default +if ($runtime == 0 && $xcomp == 0 && $simulator == 0) +{ + print ">>> All iphone related builds will be ran\n"; + $runtime = 1; + $xcomp = 1; + $simulator = 1; +} + +if ($runtime) +{ + print ">>> Building iphone runtime\n"; + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphoneArch=armv7", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for iphone\n"); +} + +if ($xcomp) +{ + # TODO : This is a horrible waste of time, and we should fix it, but for now it gets things working. + # The mono we have in the build deps for bootstrapping doesn't have a 32bit slice, which we need in order to run the MonoAotOffsetsDumper. + # To get around this for the moment, we'll build the runtime & classlibs first, and then use that to run the MonoAotOffsetsDumper. + # Once we update the mono in the build deps, we can remove this. + if(!(-f "$monoroot/builds/monodistribution/bin/mono")) + { + print ">>> Building mono to use for bootstrapping. The version in mono build deps is missing the 32bit slice and we need a 32bit version to run the MonoAotOffsetsDumper\n"; + #system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--arch32=1", "--clean=$clean", "--classlibtests=0", "--artifact=1", "--artifactscommon=1", "--forcedefaultbuilddeps=1") eq 0 or die ("failing building mono 32bit for bootstrapping\n"); + #system("perl", "$buildScriptsRoot/build_all_osx.pl", "--build=1", "--artifact=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--artifactscommon=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); + + system("cp", "$monoroot/builds/monodistribution/bin-osx-tmp-i386/mono", "$monoroot/builds/monodistribution/bin/.") eq 0 or die ("failed to copy mono over from bin-osx-tmp-i386 to bin\n"); + system("chmod", "+x", "$monoroot/builds/monodistribution/bin/mono") eq 0 or die("Failed to chmod mono\n"); + + # Need to clean up the tmp build folder so that we don't pollute the final artifact + rmtree("$monoroot/builds/monodistribution/bin-osx-tmp-i386"); + rmtree("$monoroot/builds/embedruntimes/osx-tmp-i386"); + } + + print ">>> Building iphone cross compiler\n"; + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphonecross=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building iphone cross compiler\n"); +} + +if ($simulator) +{ + print ">>> Building iphone simulator\n"; + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphonesimulator=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building iphone simulator\n"); +} diff --git a/external/buildscripts/build_runtime_iphone.sh b/external/buildscripts/build_runtime_iphone.sh new file mode 100644 index 000000000000..21452053675b --- /dev/null +++ b/external/buildscripts/build_runtime_iphone.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# The build configs are looking for this file rather than the perl script. +# easier to add this + +BASEDIR=$(dirname $0) + +if [ -d builds ]; then + echo "Skip making builds directory. Already exists" +else + mkdir builds +fi + +if [ "x$1" == "x--runtime-only" ]; then + touch builds/dummy_iphone_runtime.txt +elif [ "x$1" == "x--xcomp-only" ]; then + touch builds/dummy_iphone_xcomp.txt +elif [ "x$1" == "x--simulator-only" ]; then + touch builds/dummy_iphone_sim.txt +fi diff --git a/external/buildscripts/build_runtime_linux.pl b/external/buildscripts/build_runtime_linux.pl new file mode 100644 index 000000000000..073b6fb5ea76 --- /dev/null +++ b/external/buildscripts/build_runtime_linux.pl @@ -0,0 +1,23 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $build64 = 0; + +GetOptions( + "build64=i"=>\$build64, +) or die ("illegal cmdline options"); + +my $arch32 = 1; +if ($build64) +{ + $arch32 = 0; +} + +system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--arch32=$arch32", "--classlibtests=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_runtime_osx.pl b/external/buildscripts/build_runtime_osx.pl new file mode 100644 index 000000000000..42009e295b51 --- /dev/null +++ b/external/buildscripts/build_runtime_osx.pl @@ -0,0 +1,11 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +system("perl", "$buildScriptsRoot/build_all_osx.pl", "--build=1", "--artifact=1", "--test=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_runtime_qnx.sh b/external/buildscripts/build_runtime_qnx.sh new file mode 100644 index 000000000000..b2eaaf63a0a8 --- /dev/null +++ b/external/buildscripts/build_runtime_qnx.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# The build configs are looking for this file rather than the perl script. +# easier to add this + +# Note : Not Implemented yet. Script is here to make the katana build pass so that the mono build artifact is created +if [ -d builds ]; then + echo "Skip making builds directory. Already exists" +else + mkdir builds +fi + +touch builds/dummy_qnx.txt diff --git a/external/buildscripts/build_runtime_stv.sh b/external/buildscripts/build_runtime_stv.sh new file mode 100644 index 000000000000..4d8fb005059c --- /dev/null +++ b/external/buildscripts/build_runtime_stv.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# The build configs are looking for this file rather than the perl script. +# easier to add this + +# Note : Not Implemented yet. Script is here to make the katana build pass so that the mono build artifact is created +if [ -d builds ]; then + echo "Skip making builds directory. Already exists" +else + mkdir builds +fi + +touch builds/dummy_stv.txt + diff --git a/external/buildscripts/build_runtime_tizen.pl b/external/buildscripts/build_runtime_tizen.pl new file mode 100644 index 000000000000..039e26c8ef9f --- /dev/null +++ b/external/buildscripts/build_runtime_tizen.pl @@ -0,0 +1,18 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $clean = 1; + +GetOptions( + "clean=i"=>\$clean, +) or die ("illegal cmdline options"); + +system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--tizen=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for tizen\n"); +system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--tizen=1", "--tizenemulator=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for tizen emulator\n"); diff --git a/external/buildscripts/build_runtime_tizen.sh b/external/buildscripts/build_runtime_tizen.sh new file mode 100644 index 000000000000..b7a4b24bc699 --- /dev/null +++ b/external/buildscripts/build_runtime_tizen.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# The build configs are looking for this file rather than the perl script. +# easier to add this + +BASEDIR=$(dirname $0) + +perl "$BASEDIR/build_runtime_tizen.pl" "$@" diff --git a/external/buildscripts/build_runtime_vs.pl b/external/buildscripts/build_runtime_vs.pl new file mode 100644 index 000000000000..ee41343ede20 --- /dev/null +++ b/external/buildscripts/build_runtime_vs.pl @@ -0,0 +1,52 @@ +sub CompileVCProj; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Spec; +use File::Basename; +use File::Copy; +use File::Path; + +print ">>> PATH in Build VS = $ENV{PATH}\n\n"; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildsroot = "$monoroot/builds"; +my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; + +my $build = 0; +my $clean = 0; +my $arch32 = 0; +my $debug = 0; +my $gc = "bdwgc"; +my $msBuildVersion = ""; + +GetOptions( + 'build=i'=>\$build, + 'clean=i'=>\$clean, + 'arch32=i'=>\$arch32, + 'debug=i'=>\$debug, + 'msbuildversion=s'=>\$msBuildVersion, + 'gc=s'=>\$gc, +) or die ("illegal cmdline options"); + +if ($build) +{ + CompileVCProj("$monoroot/msvc/mono.sln"); +} + +sub CompileVCProj +{ + my $sln = shift; + my $config; + + my $msbuild = $ENV{"ProgramFiles(x86)"}."/MSBuild/$msBuildVersion/Bin/MSBuild.exe"; + + $config = $debug ? "Debug" : "Release"; + my $arch = $arch32 ? "Win32" : "x64"; + my $target = $clean ? "/t:Clean,Build" :"/t:Build"; + my $properties = "/p:Configuration=$config;Platform=$arch;MONO_TARGET_GC=$gc"; + + print ">>> $msbuild $properties $target $sln\n\n"; + system($msbuild, $properties, $target, $sln) eq 0 + or die("MSBuild failed to build $sln\n"); +} diff --git a/external/buildscripts/build_runtime_win.pl b/external/buildscripts/build_runtime_win.pl new file mode 100644 index 000000000000..f8dda725c262 --- /dev/null +++ b/external/buildscripts/build_runtime_win.pl @@ -0,0 +1,14 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +# Note : Ideally we can switch back to this build approach once the random cygwin hangs on the build machines are sorted out +#system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--arch32=1", "--classlibtests=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); + +system("perl", "$buildScriptsRoot/build_win_no_cygwin.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_runtime_win64.pl b/external/buildscripts/build_runtime_win64.pl new file mode 100644 index 000000000000..fd36d86bfd35 --- /dev/null +++ b/external/buildscripts/build_runtime_win64.pl @@ -0,0 +1,14 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +# Note : Ideally we can switch back to this build approach once the random cygwin hangs on the build machines are sorted out +#system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--classlibtests=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); + +system("perl", "$buildScriptsRoot/build_win_no_cygwin.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_runtime_wsl.pl b/external/buildscripts/build_runtime_wsl.pl new file mode 100644 index 000000000000..fabedcff1774 --- /dev/null +++ b/external/buildscripts/build_runtime_wsl.pl @@ -0,0 +1,13 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +#Windows Subsystem for Linux currently does not support 32-bit, so the option is 64-bit only + +system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--arch32=0", "--classlibtests=0", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=1") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_unityscript_bareminimum_win.pl b/external/buildscripts/build_unityscript_bareminimum_win.pl new file mode 100644 index 000000000000..4d2d793a457c --- /dev/null +++ b/external/buildscripts/build_unityscript_bareminimum_win.pl @@ -0,0 +1,159 @@ +use lib ('.', 'perl_lib', 'external/buildscripts/perl_lib'); +use Cwd; +use File::Path; + +use File::Copy::Recursive qw(dircopy); +use Getopt::Long; +use File::Basename; + +my $root = getcwd(); + +my $monodistro = "$root/builds/monodistribution"; +my $libmono = "$monodistro/lib/mono"; + +sub AddDotNetFolderToPath() { + + my @netFrameworkLocations = ( + $ENV{"SYSTEMROOT"}."/Microsoft.NET/Framework/v4.0.30319", + $ENV{"SYSTEMROOT"}."/Microsoft.NET/Framework/v3.5" + ); + + my $netFrameworkLocation = ""; + my $checkedLocations = ""; + + find_framework: + foreach my $current (@netFrameworkLocations) + { + if (-e $current) { + $netFrameworkLocation = $current; + last find_framework; + } + + $checkedLocations = $checkedLocations . ", " . $current; + } + + if ($netFrameworkLocation eq '') { + die("Could not find dotnet framework folder. Checked: $checkedLocations"); + } + + print("Using .Net framework: $netFrameworkLocation"); + $ENV{PATH} = "$ENV{PATH};$netFrameworkLocation"; +} + +AddDotNetFolderToPath(); + +my $output = Win32::GetLongPathName("$ENV{TEMP}") . "/output/BareMinimum"; + +print("\nEnvironment Path: $ENV{PATH}\n"); + +my $booCheckout = "$root/../../boo/build"; +my $usCheckout = "$root/../../unityscript/build"; + +my $skipbuild=0; +GetOptions( + "skipbuild=i"=>\$skipbuild, +) or die ("illegal cmdline options"); + +my $monodistroLibMono = "$monodistro/lib/mono"; +my $monodistroUnity = "$monodistroLibMono/unity"; + +sub UnityBooc +{ + my $commandLine = shift; + system("$output/wsa/booc -debug- $commandLine") eq 0 or die("booc failed to execute: $commandLine"); +} + +sub BuildUnityScriptForUnity +{ + # Build system is handling this + if (!$ENV{UNITY_THISISABUILDMACHINE}) { + GitClone("git://github.com/Unity-Technologies/boo.git", $booCheckout); + } + + my $commonDefines = "NO_SERIALIZATION_INFO,NO_SYSTEM_PROCESS,NO_ICLONEABLE,MSBUILD,IGNOREKEYFILE"; + + Build("$booCheckout/src/booc/Booc.csproj", undef, "/property:TargetFrameworkVersion=4.0 /property:DefineConstants=\"" . $commonDefines . "\" /property:OutputPath=$output/wp8"); + Build("$booCheckout/src/booc/Booc.csproj", undef, "/property:TargetFrameworkVersion=4.0 /property:DefineConstants=\"" . $commonDefines . ",NO_SYSTEM_REFLECTION_EMIT\" /property:OutputPath=$output/wsa"); + + if (!$ENV{UNITY_THISISABUILDMACHINE}) { + GitClone("git://github.com/Unity-Technologies/unityscript.git", $usCheckout); + } + + UnityBooc("-out:$output/wsa/Boo.Lang.Extensions.dll -srcdir:$booCheckout/src/Boo.Lang.Extensions -r:$output/wsa/Boo.Lang.dll -r:$output/wsa/Boo.Lang.Compiler.dll"); + UnityBooc("-out:$output/wsa/Boo.Lang.Useful.dll -srcdir:$booCheckout/src/Boo.Lang.Useful -r:$output/wsa/Boo.Lang.Parser"); + UnityBooc("-out:$output/wsa/Boo.Lang.PatternMatching.dll -srcdir:$booCheckout/src/Boo.Lang.PatternMatching"); + + my $UnityScriptLangDLL = "$output/UnityScript.Lang.dll"; + UnityBooc("-out:$UnityScriptLangDLL -srcdir:$usCheckout/src/UnityScript.Lang -r:$output/wsa/Boo.Lang.Extensions.dll"); +} + +sub Build +{ + my $projectFile = shift; + + my $optionalConfiguration = shift; + my $configuration = defined($optionalConfiguration) ? $optionalConfiguration : "Release"; + + my $optionalCustomArguments = shift; + my $customArguments = defined($optionalCustomArguments) ? $optionalCustomArguments : ""; + + my $target = "Rebuild"; + my $commandLine = "MSBuild $projectFile /p:AssemblyOriginatorKeyFile= /p:SignAssembly=false /p:MonoTouch=True /t:$target /p:Configuration=$configuration $customArguments"; + + system($commandLine) eq 0 or die("Failed to xbuild '$projectFile' for unity"); +} + +sub GitClone +{ + my $repo = shift; + my $localFolder = shift; + my $branch = shift; + $branch = defined($branch)?$branch:master; + + if (-d $localFolder) { + return; + } + system("git clone --branch $branch $repo $localFolder") eq 0 or die("git clone $repo $localFolder failed!"); +} + +sub NormalizePath { + my $path = shift; + $path =~ s/\//\\/g; + + return $path; +} + +sub cp +{ + my $cmdLine = shift; + $cmdLine = NormalizePath($cmdLine); + + system("xcopy $cmdLine /s /y") eq 0 or die("failed to copy '$cmdLine'"); + print "Copied: $cmdLine\n"; +} + +rmtree("$root/builds"); +rmtree("$output"); + +BuildUnityScriptForUnity(); + +cp("$output/wsa/Boo.Lang.dll $libmono/bare-minimum/wsa/Boo.Lang.dll*"); +cp("$output/wsa/Boo.Lang.pdb $libmono/bare-minimum/wsa/Boo.Lang.pdb*"); +cp("$output/wp8/Boo.Lang.dll $libmono/bare-minimum/wp8/Boo.Lang.dll*"); +cp("$output/wp8/Boo.Lang.pdb $libmono/bare-minimum/wp8/Boo.Lang.pdb*"); +cp("$output/UnityScript.Lang.* $libmono/bare-minimum/UnityScript.Lang.*"); + +if($ENV{UNITY_THISISABUILDMACHINE}) +{ + my %checkouts = ( + 'mono-classlibs' => 'BUILD_VCS_NUMBER_Mono____Mono2_6_x_Unity3_x', + 'boo' => 'BUILD_VCS_NUMBER_Boo', + 'unityscript' => 'BUILD_VCS_NUMBER_UnityScript', + 'cecil' => 'BUILD_VCS_NUMBER_Cecil' + ); + + system("echo '' > $root/builds/versions.txt"); + for my $key (keys %checkouts) { + system("echo \"$key = $ENV{$checkouts{$key}}\" >> $root/builds/versions.txt"); + } +} diff --git a/external/buildscripts/build_us_and_boo.pl b/external/buildscripts/build_us_and_boo.pl new file mode 100644 index 000000000000..c5565e450b64 --- /dev/null +++ b/external/buildscripts/build_us_and_boo.pl @@ -0,0 +1,140 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; +use File::Copy; +use lib ('.', 'perl_lib', 'external/buildscripts/perl_lib'); +use Tools qw(GitClone); + +system("source","~/.profile"); +print ">>> My Path: $ENV{PATH}\n"; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildscriptsdir = "$monoroot/external/buildscripts"; +my $monoprefix = "$monoroot/tmp/monoprefix"; +my $buildsroot = "$monoroot/builds"; +my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; + +GetOptions( + 'monoprefix=s'=>\$monoprefix, +) or die ("illegal cmdline options"); + +my $xbuildPath = "$monoprefix/bin/xbuild"; +my $monoprefix45 = "$monoprefix/lib/mono/4.5"; + +if (!(-f "$xbuildPath")) +{ + die("Unable to locate xbuild at : $xbuildPath\n"); +} + +BuildUnityScriptFor45(); + +sub XBuild +{ + print(">>> Running : $monoprefix/bin/xbuild @_\n"); + system("$monoprefix/bin/xbuild", @_) eq 0 or die("Failed to xbuild @_\n"); +} + +sub Booc45 +{ + my $commandLine = shift; + + system("$monoprefix/bin/mono $monoprefix45/booc.exe -debug- $commandLine") eq 0 or die("booc failed to execute: $monoprefix/bin/booc -debug- $commandLine\n"); +} + +sub BuildUnityScriptFor45 +{ + my $booCheckout = "$monoroot/../../boo/build"; + print(">>> Using mono prefix $monoprefix45\n"); + + # Build host is handling this + if (!$buildMachine) + { + if (!(-d "$booCheckout")) + { + print(">>> Checking out boo\n"); + GitClone("git://github.com/Unity-Technologies/boo.git", $booCheckout, "unity-trunk"); + } + } + + my $usCheckout = "$monoroot/../../unityscript/build"; + if (!$buildMachine) + { + if (!(-d "$usCheckout")) + { + print(">>> Checking out unity script\n"); + GitClone("git://github.com/Unity-Technologies/unityscript.git", $usCheckout, "unity-trunk"); + } + } + + my $boocCsproj = "$booCheckout/src/booc/booc.csproj"; + if (!(-f "$boocCsproj")) + { + die("Unable to locate : $boocCsproj\n"); + } + + XBuild("$boocCsproj", "/t:Rebuild"); + + print(">>> Mono Prefix 4.5 = $monoprefix45\n"); + foreach my $file (glob "$booCheckout/ide-build/Boo.Lang*.dll") + { + print(">>> Copying $file to $monoprefix45\n"); + copy($file, "$monoprefix45/."); + } + + copy("$booCheckout/ide-build/booc.exe", "$monoprefix45/."); + + foreach my $file (glob "$buildscriptsdir/add_to_build_results/monodistribution/lib/mono/4.5/*") + { + print(">>> Copying $file to $monoprefix45\n"); + copy($file, "$monoprefix45/."); + my $nameOnly = basename($file); + system("chmod", "755", "$monoprefix45/$nameOnly"); + } + + Booc45("-out:$monoprefix45/Boo.Lang.Extensions.dll -noconfig -nostdlib -srcdir:$booCheckout/src/Boo.Lang.Extensions -r:System.dll -r:System.Core.dll -r:mscorlib.dll -r:Boo.Lang.dll -r:Boo.Lang.Compiler.dll"); + Booc45("-out:$monoprefix45/Boo.Lang.Useful.dll -srcdir:$booCheckout/src/Boo.Lang.Useful -r:Boo.Lang.Parser"); + Booc45("-out:$monoprefix45/Boo.Lang.PatternMatching.dll -srcdir:$booCheckout/src/Boo.Lang.PatternMatching"); + + my $UnityScriptLangDLL = "$monoprefix45/UnityScript.Lang.dll"; + Booc45("-out:$UnityScriptLangDLL -srcdir:$usCheckout/src/UnityScript.Lang"); + + my $UnityScriptDLL = "$monoprefix45/UnityScript.dll"; + Booc45("-out:$UnityScriptDLL -srcdir:$usCheckout/src/UnityScript -r:$UnityScriptLangDLL -r:Boo.Lang.Parser.dll -r:Boo.Lang.PatternMatching.dll"); + Booc45("-out:$monoprefix45/us.exe -srcdir:$usCheckout/src/us -r:$UnityScriptLangDLL -r:$UnityScriptDLL -r:Boo.Lang.Useful.dll"); + + # # unityscript test suite + # my $UnityScriptTestsCSharpDLL = "$usCheckout/src/UnityScript.Tests.CSharp/bin/Debug/UnityScript.Tests.CSharp.dll"; + # XBuild("$usCheckout/src/UnityScript.Tests.CSharp/UnityScript.Tests.CSharp.csproj", "/t:Rebuild"); + + my $usBuildDir = "$usCheckout/build"; + + if (!(-d "$usBuildDir")) + { + rmtree($usBuildDir); + } + + mkdir($usBuildDir); + + # my $UnityScriptTestsDLL = <$usBuildDir/UnityScript.Tests.dll>; + # Booc("-out:$UnityScriptTestsDLL -srcdir:$usCheckout/src/UnityScript.Tests -r:$UnityScriptLangDLL -r:$UnityScriptDLL -r:$UnityScriptTestsCSharpDLL -r:Boo.Lang.Compiler.dll -r:Boo.Lang.Useful.dll"); + + # cp("$UnityScriptTestsCSharpDLL $usBuildDir/"); + print(">>> Populating Unity Script Build Directory : $usBuildDir\n"); + foreach my $file (glob "$monoprefix45/Boo.*") + { + print(">>> Copying $file to $usBuildDir\n"); + copy($file, "$usBuildDir/."); + } + + foreach my $file (glob "$monoprefix45/UnityScript.*") + { + print(">>> Copying $file to $usBuildDir\n"); + copy($file, "$usBuildDir/."); + } + + print(">>> Copying $monoprefix45/us.exe to $usBuildDir\n"); + copy("$monoprefix45/us.exe", "$usBuildDir/."); +} \ No newline at end of file diff --git a/external/buildscripts/build_win_no_cygwin.pl b/external/buildscripts/build_win_no_cygwin.pl new file mode 100644 index 000000000000..36bf68f24a0f --- /dev/null +++ b/external/buildscripts/build_win_no_cygwin.pl @@ -0,0 +1,294 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; +use File::Copy; +use lib ('external/buildscripts', "../../Tools/perl_lib","perl_lib", 'external/buildscripts/perl_lib'); +use Tools qw(InstallNameTool); + +print ">>> PATH in Build All = $ENV{PATH}\n\n"; + +my $currentdir = getcwd(); + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); + +$monoroot =~ tr{/}{\\}; + +print ">>> monoroot = $monoroot\n"; + +my $buildscriptsdir = "$monoroot\\external\\buildscripts"; +my $addtoresultsdistdir = "$buildscriptsdir\\add_to_build_results\\monodistribution"; +my $monoprefix = "$monoroot\\tmp\\monoprefix"; +my $buildsroot = "$monoroot\\builds"; +my $distdir = "$buildsroot\\monodistribution"; +my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; + +my $build=0; +my $clean=0; +my $artifact=0; +my $debug=0; +my $checkoutOnTheFly=0; +my $forceDefaultBuildDeps=0; +my $existingMonoRootPath = ''; +my $arch32 = 0; +my $winPerl = "perl"; +my $winMonoRoot = $monoroot; +my $msBuildVersion = "14.0"; +my $buildDeps = ""; + +print(">>> Build All Args = @ARGV\n"); + +GetOptions( + 'build=i'=>\$build, + 'clean=i'=>\$clean, + 'artifact=i'=>\$artifact, + 'debug=i'=>\$debug, + 'arch32=i'=>\$arch32, + 'existingmono=s'=>\$existingMonoRootPath, + 'winperl=s'=>\$winPerl, + 'winmonoroot=s'=>\$winMonoRoot, + 'msbuildversion=s'=>\$msBuildVersion, + 'checkoutonthefly=i'=>\$checkoutOnTheFly, + 'builddeps=s'=>\$buildDeps, + 'forcedefaultbuilddeps=i'=>\$forceDefaultBuildDeps, +) or die ("illegal cmdline options"); + +my $monoRevision = `git rev-parse HEAD`; +chdir("$buildscriptsdir") eq 1 or die ("failed to chdir : $buildscriptsdir\n"); +my $buildScriptsRevision = `git rev-parse HEAD`; +chdir("$monoroot") eq 1 or die ("failed to chdir : $monoroot\n"); + +print(">>> Mono Revision = $monoRevision\n"); +print(">>> Build Scripts Revision = $buildScriptsRevision\n"); + +# Do any settings agnostic per-platform stuff +my $externalBuildDeps = ""; +my $externalBuildDepsIl2Cpp = "$monoroot/../../il2cpp/build"; + +if ($buildDeps ne "" && not $forceDefaultBuildDeps) +{ + $externalBuildDeps = $buildDeps; +} +else +{ + $externalBuildDeps = "$monoroot/../../mono-build-deps/build"; +} + +my $existingExternalMonoRoot = "$externalBuildDeps\\mono"; +my $existingExternalMono = "$existingExternalMonoRoot\\win"; + +if ($clean) +{ + print(">>> Cleaning $monoprefix\n"); + rmtree($monoprefix); +} + +# ******************* Build Stage ************************** + +if ($build) +{ + if ($existingMonoRootPath eq "") + { + print(">>> No existing mono supplied. Checking for external...\n"); + + if (!(-d "$externalBuildDeps")) + { + if (not $checkoutonthefly) + { + print(">>> No external build deps found. Might as well try to check them out. If it fails, we'll continue and trust mono is in your PATH\n"); + } + + # Check out on the fly + print(">>> Checking out mono build dependencies to : $externalBuildDeps\n"); + my $repo = "https://ono.unity3d.com/unity-extra/mono-build-deps"; + print(">>> Cloning $repo at $externalBuildDeps\n"); + my $checkoutResult = system("hg", "clone", $repo, "$externalBuildDeps"); + + if ($checkoutOnTheFly && $checkoutResult ne 0) + { + die("failed to checkout mono build dependencies\n"); + } + } + + if (!(-d "$externalBuildDepsIl2Cpp")) + { + my $il2cpp_repo = "https://bitbucket.org/Unity-Technologies/il2cpp"; + print(">>> Cloning $il2cpp_repo at $externalBuildDepsIl2Cpp\n"); + $checkoutResult = system("hg", "clone", $il2cpp_repo, "$externalBuildDepsIl2Cpp"); + + if ($checkoutOnTheFly && $checkoutResult ne 0) + { + die("failed to checkout IL2CPP for the mono build dependencies\n"); + } + } + + if (-d "$existingExternalMono") + { + print(">>> External mono found at : $existingExternalMono\n"); + + if (-d "$existingExternalMono/builds") + { + print(">>> Mono already extracted at : $existingExternalMono/builds\n"); + } + + if (!(-d "$existingExternalMono/builds")) + { + # We need to extract builds.zip + print(">>> Extracting mono builds.zip...\n"); + my $SevenZip = "$externalBuildDeps/7z/win64/7za.exe"; + print(">>> Using 7z : $SevenZip\n"); + system("$SevenZip", "x", "$existingExternalMono/builds.zip", "-o$existingExternalMono") eq 0 or die("Failed extracting mono builds.zip\n"); + } + + $existingMonoRootPath = "$existingExternalMono/builds"; + } + else + { + print(">>> No external mono found. Trusting a new enough mono is in your PATH.\n"); + } + } + + if ($existingMonoRootPath ne "" && !(-d $existingMonoRootPath)) + { + die("Existing mono not found at : $existingMonoRootPath\n"); + } + + system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--msbuildversion=$msBuildVersion", "--clean=$clean", "--debug=$debug", "--gc=bdwgc") eq 0 or die ('failed building mono bdwgc with VS\n'); + system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--msbuildversion=$msBuildVersion", "--clean=$clean", "--debug=$debug", "--gc=sgen") eq 0 or die ('failed building mono sgen with VS\n'); + + if (!(-d "$monoroot\\tmp")) + { + print(">>> Creating directory $monoroot\\tmp\n"); + system("mkdir $monoroot\\tmp") eq 0 or die ("failing creating $monoroot\\tmp\n");; + } + + if (!(-d "$monoprefix")) + { + print(">>> Creating directory $monoprefix\n"); + system("mkdir $monoprefix") eq 0 or die ("failing creating $monoprefix\n");; + } + + if (!(-d "$monoprefix\\bin")) + { + print(">>> Creating directory $monoprefix\\bin\n"); + system("mkdir $monoprefix\\bin") eq 0 or die ("failing creating $monoprefix\\bin\n");; + } + + # Copy over the VS built stuff that we want to use instead into the prefix directory + my $archNameForBuild = $arch32 ? 'Win32' : 'x64'; + my $configDirName = $debug ? "Debug" : "Release"; + + copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/mono-bdwgc.exe", "$monoprefix/bin/.") or die ("failed copying mono-bdwgc.exe\n"); + copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/mono-2.0-bdwgc.dll", "$monoprefix/bin/.") or die ("failed copying mono-2.0-bdwgc.dll\n"); + copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/mono-2.0-bdwgc.pdb", "$monoprefix/bin/.") or die ("failed copying mono-2.0-bdwgc.pdb\n"); + + copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-sgen.exe", "$monoprefix/bin/.") or die ("failed copying mono-sgen.exe\n"); + copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-2.0-sgen.dll", "$monoprefix/bin/.") or die ("failed copying mono-2.0-sgen.dll\n"); + copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-2.0-sgen.pdb", "$monoprefix/bin/.") or die ("failed copying mono-2.0-sgen.pdb\n"); + + # sgen as default exe + copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-sgen.exe", "$monoprefix/bin/mono.exe") or die ("failed copying mono-sgen.exe to mono.exe\n"); + + copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/MonoPosixHelper.dll", "$monoprefix/bin/.") or die ("failed copying MonoPosixHelper.dll\n"); + copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/MonoPosixHelper.pdb", "$monoprefix/bin/.") or die ("failed copying MonoPosixHelper.pdb\n"); + + system("xcopy /y /f $addtoresultsdistdir\\bin\\*.* $monoprefix\\bin\\") eq 0 or die ("Failed copying $addtoresultsdistdir/bin to $monoprefix/bin\n"); +} + +# ******************* Artifact Stage ************************** + +if ($artifact) +{ + print(">>> Creating artifact...\n"); + + # Do the platform specific logic to create the builds output structure that we want + + my $embedDirRoot = "$buildsroot\\embedruntimes"; + + my $embedDirArchDestination = $arch32 ? "$embedDirRoot\\win32" : "$embedDirRoot\\win64"; + my $distDirArchBin = $arch32 ? "$distdir\\bin" : "$distdir\\bin-x64"; + my $versionsOutputFile = $arch32 ? "$buildsroot\\versions-win32.txt" : "$buildsroot\\versions-win64.txt"; + + # Make sure the directory for our architecture is clean before we copy stuff into it + if (-d "$embedDirArchDestination") + { + print(">>> Cleaning $embedDirArchDestination\n"); + rmtree($embedDirArchDestination); + } + + if (-d "$distDirArchBin") + { + print(">>> Cleaning $distDirArchBin\n"); + rmtree($distDirArchBin); + } + + if (!(-d "$buildsroot")) + { + print(">>> Creating directory $buildsroot\n"); + system("mkdir $buildsroot") eq 0 or die("failed to create directory $buildsroot\n"); + } + + if (!(-d "$embedDirRoot")) + { + print(">>> Creating directory $embedDirRoot\n"); + system("mkdir $embedDirRoot") eq 0 or die("failed to create directory $embedDirRoot\n"); + } + + if (!(-d "$distdir")) + { + print(">>> Creating directory $distdir\n"); + system("mkdir $distdir") eq 0 or die("failed to create directory $distdir\n"); + } + + print(">>> Creating directory $embedDirArchDestination\n"); + system("mkdir $embedDirArchDestination") eq 0 or die("failed to create directory $embedDirArchDestination\n"); + + print(">>> Creating directory $distDirArchBin\n"); + system("mkdir $distDirArchBin") eq 0 or die("failed to create directory $distDirArchBin\n"); + + # embedruntimes directory setup + print(">>> Creating embedruntimes directory : $embedDirArchDestination\n"); + + copy("$monoprefix/bin/mono-2.0-bdwgc.dll", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-bdwgc.dll\n"); + copy("$monoprefix/bin/mono-2.0-bdwgc.pdb", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-bdwgc.pdb\n"); + + copy("$monoprefix/bin/mono-2.0-sgen.dll", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-sgen.dll\n"); + copy("$monoprefix/bin/mono-2.0-sgen.pdb", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-sgen.pdb\n"); + + copy("$monoprefix/bin/MonoPosixHelper.dll", "$embedDirArchDestination/.") or die ("failed copying MonoPosixHelper.dll\n"); + copy("$monoprefix/bin/MonoPosixHelper.pdb", "$embedDirArchDestination/.") or die ("failed copying MonoPosixHelper.pdb\n"); + + # monodistribution directory setup + print(">>> Creating monodistribution directory\n"); + copy("$monoprefix/bin/mono-2.0-bdwgc.dll", "$distDirArchBin/.") or die ("failed copying mono-2.0-bdwgc.dll\n"); + copy("$monoprefix/bin/mono-2.0-bdwgc.pdb", "$distDirArchBin/.") or die ("failed copying mono-2.0-bdwgc.pdb\n"); + + copy("$monoprefix/bin/mono-2.0-sgen.dll", "$distDirArchBin/.") or die ("failed copying mono-2.0-sgen.dll\n"); + copy("$monoprefix/bin/mono-2.0-sgen.pdb", "$distDirArchBin/.") or die ("failed copying mono-2.0-sgen.pdb\n"); + + copy("$monoprefix/bin/mono-sgen.exe", "$distDirArchBin/.") or die ("failed copying mono-sgen.exe\n"); + copy("$monoprefix/bin/mono-bdwgc.exe", "$distDirArchBin/.") or die ("failed copying mono-bdwgc.exe\n"); + copy("$monoprefix/bin/mono.exe", "$distDirArchBin/.") or die ("failed copying mono.exe\n"); + + copy("$monoprefix/bin/MonoPosixHelper.dll", "$distDirArchBin/.") or die ("failed copying MonoPosixHelper.dll\n"); + copy("$monoprefix/bin/MonoPosixHelper.pdb", "$distDirArchBin/.") or die ("failed copying MonoPosixHelper.pdb\n"); + + + # Output version information + print(">>> Creating version file : $versionsOutputFile\n"); + open(my $fh, '>', $versionsOutputFile) or die "Could not open file '$versionsOutputFile' $!"; + say $fh "mono-version ="; + my $monoVersionInfo = `$distDirArchBin\\mono --version`; + say $fh "$monoVersionInfo"; + say $fh "unity-mono-revision = $monoRevision"; + say $fh "unity-mono-build-scripts-revision = $buildScriptsRevision"; + my $tmp = `date /T`; + say $fh "$tmp"; + close $fh; +} +else +{ + print(">>> Skipping artifact creation\n"); +} diff --git a/external/buildscripts/build_win_wrapper.pl b/external/buildscripts/build_win_wrapper.pl new file mode 100644 index 000000000000..a160730672ce --- /dev/null +++ b/external/buildscripts/build_win_wrapper.pl @@ -0,0 +1,231 @@ +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; +use Config; + +print ">>> My Path: $ENV{PATH}\n\n"; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; +print ">>> Mono checkout found in $monoroot\n\n"; + +my $cygwinRootWindows = ""; +my $monoInstallLinux = ""; +my $checkoutOnTheFly=0; +my $buildDeps = ""; +my $forceDefaultBuildDeps = 0; + +my @thisScriptArgs = (); +my @passAlongArgs = (); +foreach my $arg (@ARGV) +{ + push @backupArgs, $arg; + + if ($arg =~ /^--cygwin=/) + { + push @thisScriptArgs, $arg; + } + elsif ($arg =~ /^--existingmono=/) + { + push @thisScriptArgs, $arg; + } + elsif ($arg =~ /^--checkoutonthefly=/) + { + push @thisScriptArgs, $arg; + push @passAlongArgs, $arg; + } + elsif ($arg =~ /^--builddeps=/) + { + push @thisScriptArgs, $arg; + push @passAlongArgs, $arg; + } + elsif ($arg =~ /^--forcedefaultbuilddeps=/) + { + push @thisScriptArgs, $arg; + push @passAlongArgs, $arg; + } + else + { + push @passAlongArgs, $arg; + } +} + +print(">>> This Script Args = @thisScriptArgs\n"); +print(">>> Pass Along Args = @passAlongArgs\n"); + +@ARGV = @thisScriptArgs; +GetOptions( + 'cygwin=s'=>\$cygwinRootWindows, + 'existingmono=s'=>\$monoInstallLinux, + 'checkoutonthefly=i'=>\$checkoutOnTheFly, + 'builddeps=s'=>\$buildDeps, + 'forcedefaultbuilddeps=i'=>\$forceDefaultBuildDeps, +); + +my $externalBuildDeps = ""; +my $externalBuildDepsIl2Cpp = "$monoroot/../../il2cpp/build"; + +if ($buildDeps ne "") +{ + $externalBuildDeps = $buildDeps; +} +else +{ + if (-d "$monoroot/../../mono-build-deps/build" || $forceDefaultBuildDeps) + { + $externalBuildDeps = "$monoroot/../../mono-build-deps/build"; + } + + if (!(-d "$externalBuildDeps")) + { + if (not $checkoutonthefly && $cygwinRootWindows eq "") + { + print(">>> No external build deps found and --cygwin not used. Might as well try to check them out. If the checkout fails, we'll continue, but the build will probably fail\n"); + } + + # Check out on the fly + print(">>> Checking out mono build dependencies to : $externalBuildDeps\n"); + my $repo = "https://ono.unity3d.com/unity-extra/mono-build-deps"; + print(">>> Cloning $repo at $externalBuildDeps\n"); + my $checkoutResult = system("hg", "clone", $repo, "$externalBuildDeps"); + + if ($checkoutOnTheFly && $checkoutResult ne 0) + { + die("failed to checkout mono build dependencies\n"); + } + } + + if (!(-d "$externalBuildDepsIl2Cpp")) + { + my $il2cpp_repo = "https://bitbucket.org/Unity-Technologies/il2cpp"; + print(">>> Cloning $il2cpp_repo at $externalBuildDepsIl2Cpp\n"); + $checkoutResult = system("hg", "clone", $il2cpp_repo, "$externalBuildDepsIl2Cpp"); + + if ($checkoutOnTheFly && $checkoutResult ne 0) + { + die("failed to checkout IL2CPP for the mono build dependencies\n"); + } + } +} + +print(">>> externalBuildDeps = $externalBuildDeps\n"); + +my $SevenZip = "$externalBuildDeps/7z/win64/7za.exe"; + +# Attempt to find common default cygwin install locations +if ($cygwinRootWindows eq "") +{ + print(">>> No cygwin install specified. Looking for defaults...\n"); + + my $externalCygwin = "$externalBuildDeps/cygwin64/builds"; + my $externalCygwinZip = "$externalBuildDeps/cygwin64/builds.zip"; + + if (-d "$externalCygwin") + { + $cygwinRootWindows = $externalCygwin; + print(">>> Found Cygwin at : $cygwinRootWindows\n"); + } + elsif(-f "$externalCygwinZip") + { + print(">>> Found unextracted cygwin builds.zip : $externalCygwinZip\n"); + print(">>> Using 7z : $SevenZip\n"); + print(">>> Extracting...\n"); + system("$SevenZip", "x", "$externalCygwinZip", "-o$externalBuildDeps/cygwin64") eq 0 or die("Failed extracting cygwin\n"); + $cygwinRootWindows = $externalCygwin; + } + else + { + if ($forceDefaultBuildDeps) + { + die("\nCould not fined Cygwin in default external build deps location : $externalBuildDeps\n") + } + else + { + if (-d "C:\\Cygwin64") + { + $cygwinRootWindows = "C:\\Cygwin64"; + print(">>> Found Cygwin at : $cygwinRootWindows\n"); + } + elsif (-d "C:\\Cygwin") + { + $cygwinRootWindows = "C:\\Cygwin"; + print(">>> Found Cygwin at : $cygwinRootWindows\n"); + } + else + { + die("\nCould not fined Cygwin. Define path using --cygwin=\n") + } + } + } +} +else +{ + print(">>> Cygwin Path = $cygwinRootWindows\n"); +} + +if ($monoInstallLinux eq "") +{ + print(">>> No mono install specified. Looking for defaults...\n"); + + my $externalMono = "$externalBuildDeps/mono/win/builds"; + my $externalMonoZip = "$externalBuildDeps/mono/win/builds.zip"; + + if (-d "$externalMono") + { + $monoInstallLinux = $externalMono; + $monoInstallLinux =~ s/\\/\//g; + print(">>> Found Mono at : $monoInstallLinux\n"); + } + elsif(-f "$externalMonoZip") + { + print(">>> Found unextracted mono builds.zip : $externalMonoZip\n"); + print(">>> Using 7z : $SevenZip\n"); + print(">>> Extracting...\n"); + system("$SevenZip", "x", "$externalMonoZip", "-o$externalBuildDeps/mono/win") eq 0 or die("Failed extracting mono\n"); + $monoInstallLinux = $externalMono; + $monoInstallLinux =~ s/\\/\//g; + print(">>> Found Mono at : $monoInstallLinux\n"); + } + else + { + if ($forceDefaultBuildDeps) + { + die("\nCould not fined mono in default external build deps location : $externalBuildDeps\n") + } + else + { + if (-d "C:\\Program Files (x86)\\Mono") + { + # Pass over the cygwin format since I already have it escaped correctly to survive + # crossing over the shell + $monoInstallLinux = "/cygdrive/c/Program\\ Files\\ \\(x86\\)/Mono"; + print(">>> Found Mono at : $monoInstallLinux\n"); + } + else + { + die("\n--existingmono= is required and should be in the cygwin path format\n"); + } + } + } +} +else +{ + $monoInstallLinux =~ s/\\/\//g; + print(">>> Linux Mono Path = $monoInstallLinux\n"); +} + +push @passAlongArgs, "--existingmono=$monoInstallLinux" if $monoInstallLinux ne ""; + +my $windowsPerl = $Config{perlpath}; +print ">>> Perl Exe = $windowsPerl\n"; +push @passAlongArgs, "--winperl=$windowsPerl"; +push @passAlongArgs, "--winmonoroot=$monoroot"; + +# In some cases the file gets windowsified, use SHELLOPTS to avoid issues instead of dos2unixing the file, which will cause it to show up as modified by source control +$ENV{'SHELLOPTS'} = "igncr"; + +print ">>> Calling $cygwinRootWindows\\bin\\sh.exe with @passAlongArgs"; +system("$cygwinRootWindows\\bin\\sh.exe", "$monoroot/external/buildscripts/build_win_wrapper.sh", @passAlongArgs) eq 0 or die("failed building mono\n"); diff --git a/external/buildscripts/build_win_wrapper.sh b/external/buildscripts/build_win_wrapper.sh new file mode 100644 index 000000000000..c71964f87986 --- /dev/null +++ b/external/buildscripts/build_win_wrapper.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# Need to put the cygwin stuff into our PATH +export PATH=/usr/bin:$PATH +BUILD_SCRIPT_ROOT=$(dirname $0) + +echo ">>> Build Script Root = $BUILD_SCRIPT_ROOT" +echo +echo ">>> PATH in Win Shell Script = $PATH" +echo + +perl "$BUILD_SCRIPT_ROOT/build.pl" "$@" \ No newline at end of file diff --git a/external/buildscripts/collect_allbuilds.pl b/external/buildscripts/collect_allbuilds.pl new file mode 100644 index 000000000000..71ba0b01e2de --- /dev/null +++ b/external/buildscripts/collect_allbuilds.pl @@ -0,0 +1,46 @@ +use lib ('external/buildscripts/perl_lib'); +use File::Copy::Recursive qw(dircopy rmove); +use File::Path; +use Tools qw(InstallNameTool); + +my $path = "incomingbuilds/"; + +rmtree("collectedbuilds"); +mkpath("collectedbuilds"); + +my @folders = (); +opendir(DIR, $path) or die "cant find $path: $!"; +# Sort the directories alphabetically so that classlibs comes before the +# OSX universal runtime (in the osx-i386 directory). Both builds produce the same +# files in some cases (notably libMonoPosixHelper.dylib), and we need the +# universal runtime build to be second, since it produces a universal binary +# and the classlibs build produces a 32-bit binary only. +my @files = sort readdir(DIR); +while (defined(my $file = shift @files)) { + + next if $file =~ /^\.\.?$/; + if (-d "$path$file"){ + if (-f "$path$file/versions.txt") { + system("cat $path$file/versions.txt >> collectedbuilds/versions-aggregated.txt"); + } + dircopy("$path$file","collectedbuilds/") or die ("failed copying $path$file"); + push @folders,"$path$file"; + } +} +closedir(DIR); + +system("find collectedbuilds -type f -name mono -exec chmod +x {} \\;") eq 0 or die("Failed chmodding"); +system("find collectedbuilds -type f -name mono-sgen -exec chmod +x {} \\;") eq 0 or die("Failed chmodding"); +system("find collectedbuilds -type f -name pedump -exec chmod +x {} \\;") eq 0 or die("Failed chmodding"); + +chdir("collectedbuilds"); + +rmove('versions-aggregated.txt', 'versions.txt'); + +open(MYFILE,">built_by_teamcity.txt"); +print MYFILE "These builds were created by teamcity from svn revision $ENV{BUILD_VCS_NUMBER}\n"; +print MYFILE "TC projectname was: $ENV{TEAMCITY_PROJECT_NAME}\n"; +print MYFILE "TC buildconfigname was: $ENV{TEAMCITY_BUILDCONF_NAME}\n"; +close(MYFILE); + +system("zip -r builds.zip *") eq 0 or die("failed zipping up builds"); diff --git a/external/buildscripts/copy_il2cpp_sources.pl b/external/buildscripts/copy_il2cpp_sources.pl new file mode 100644 index 000000000000..c8a28c9e5d0c --- /dev/null +++ b/external/buildscripts/copy_il2cpp_sources.pl @@ -0,0 +1,60 @@ +# +# Use this script to copy the Mono file used by IL2CPP. +# perl external\buildscripts\copy_il2cpp_sources.pl --monoroot= --sourcesroot=\External\MonoBleedingEdge\builds\source +# + +use File::Basename; +use File::Copy; +use File::Path; +use Getopt::Long; + +my $monoroot =""; +my $sourcesroot = ""; + +GetOptions( + 'monoroot=s'=>\$monoroot, + 'sourcesroot=s'=>\$sourcesroot, +) or die ("illegal cmdline options"); + +my $sourcesFile = "$monoroot/external/buildscripts/sources.txt"; +open(SOURCE_FILE, $sourcesFile) or die "failed opening $sourcesFile\n"; +my @listOfSourceFilesLines = ; +close(SOURCE_FILE); +chomp(@listOfSourceFilesLines); + +my $isPrivateFile = 0; +foreach my $sourcesLine(@listOfSourceFilesLines) +{ + if($sourcesLine =~ /#.*/) + { + next; + } + elsif($sourcesLine =~ /SOURCES:/ or $sourcesLine =~ /HEADERS:/ or $sourcesLine =~ /METADATA:/) + { + $isPrivateFile = 0; + next; + } + elsif($sourcesLine =~ /PRIVATE:/) + { + $isPrivateFile = 1; + next; + } + + $fileToCopy = "$monoroot/$sourcesLine"; + $destFile = "$sourcesroot/$sourcesLine"; + if($isPrivateFile) + { + $destFile =~ s/(.*)\/(.*\.c)/$1\/private\/$2/g; + } + + $destDir = dirname("$destFile"); + if (!-d $destDir) + { + mkpath($destDir) or die "failed making directory $destDir\n"; + } + + if (-e $fileToCopy) + { + copy($fileToCopy, $destFile) or die "failed to copy $fileToCopy to $destFile\n"; + } +} diff --git a/external/buildscripts/perl_lib/File/Copy/Recursive.pm b/external/buildscripts/perl_lib/File/Copy/Recursive.pm new file mode 100644 index 000000000000..c5fb2576f8df --- /dev/null +++ b/external/buildscripts/perl_lib/File/Copy/Recursive.pm @@ -0,0 +1,696 @@ +package File::Copy::Recursive; + +use strict; +BEGIN { + # Keep older versions of Perl from trying to use lexical warnings + $INC{'warnings.pm'} = "fake warnings entry for < 5.6 perl ($])" if $] < 5.006; +} +use warnings; + +use Carp; +use File::Copy; +use File::Spec; #not really needed because File::Copy already gets it, but for good measure :) + +use vars qw( + @ISA @EXPORT_OK $VERSION $MaxDepth $KeepMode $CPRFComp $CopyLink + $PFSCheck $RemvBase $NoFtlPth $ForcePth $CopyLoop $RMTrgFil $RMTrgDir + $CondCopy $BdTrgWrn $SkipFlop $DirPerms +); + +require Exporter; +@ISA = qw(Exporter); +@EXPORT_OK = qw(fcopy rcopy dircopy fmove rmove dirmove pathmk pathrm pathempty pathrmdir); +$VERSION = '0.38'; + +$MaxDepth = 0; +$KeepMode = 1; +$CPRFComp = 0; +$CopyLink = eval { local $SIG{'__DIE__'};symlink '',''; 1 } || 0; +$PFSCheck = 1; +$RemvBase = 0; +$NoFtlPth = 0; +$ForcePth = 0; +$CopyLoop = 0; +$RMTrgFil = 0; +$RMTrgDir = 0; +$CondCopy = {}; +$BdTrgWrn = 0; +$SkipFlop = 0; +$DirPerms = 0777; + +my $samecheck = sub { + return 1 if $^O eq 'MSWin32'; # need better way to check for this on winders... + return if @_ != 2 || !defined $_[0] || !defined $_[1]; + return if $_[0] eq $_[1]; + + my $one = ''; + if($PFSCheck) { + $one = join( '-', ( stat $_[0] )[0,1] ) || ''; + my $two = join( '-', ( stat $_[1] )[0,1] ) || ''; + if ( $one eq $two && $one ) { + carp "$_[0] and $_[1] are identical"; + return; + } + } + + if(-d $_[0] && !$CopyLoop) { + $one = join( '-', ( stat $_[0] )[0,1] ) if !$one; + my $abs = File::Spec->rel2abs($_[1]); + my @pth = File::Spec->splitdir( $abs ); + while(@pth) { + my $cur = File::Spec->catdir(@pth); + last if !$cur; # probably not necessary, but nice to have just in case :) + my $two = join( '-', ( stat $cur )[0,1] ) || ''; + if ( $one eq $two && $one ) { + # $! = 62; # Too many levels of symbolic links + carp "Caught Deep Recursion Condition: $_[0] contains $_[1]"; + return; + } + + pop @pth; + } + } + + return 1; +}; + +my $glob = sub { + my ($do, $src_glob, @args) = @_; + + local $CPRFComp = 1; + + my @rt; + for my $path ( glob($src_glob) ) { + my @call = [$do->($path, @args)] or return; + push @rt, \@call; + } + + return @rt; +}; + +my $move = sub { + my $fl = shift; + my @x; + if($fl) { + @x = fcopy(@_) or return; + } else { + @x = dircopy(@_) or return; + } + if(@x) { + if($fl) { + unlink $_[0] or return; + } else { + pathrmdir($_[0]) or return; + } + if($RemvBase) { + my ($volm, $path) = File::Spec->splitpath($_[0]); + pathrm(File::Spec->catpath($volm,$path,''), $ForcePth, $NoFtlPth) or return; + } + } + return wantarray ? @x : $x[0]; +}; + +my $ok_todo_asper_condcopy = sub { + my $org = shift; + my $copy = 1; + if(exists $CondCopy->{$org}) { + if($CondCopy->{$org}{'md5'}) { + + } + if($copy) { + + } + } + return $copy; +}; + +sub fcopy { + $samecheck->(@_) or return; + if($RMTrgFil && (-d $_[1] || -e $_[1]) ) { + my $trg = $_[1]; + if( -d $trg ) { + my @trgx = File::Spec->splitpath( $_[0] ); + $trg = File::Spec->catfile( $_[1], $trgx[ $#trgx ] ); + } + $samecheck->($_[0], $trg) or return; + if(-e $trg) { + if($RMTrgFil == 1) { + unlink $trg or carp "\$RMTrgFil failed: $!"; + } else { + unlink $trg or return; + } + } + } + my ($volm, $path) = File::Spec->splitpath($_[1]); + if($path && !-d $path) { + pathmk(File::Spec->catpath($volm,$path,''), $NoFtlPth); + } + if( -l $_[0] && $CopyLink ) { + carp "Copying a symlink ($_[0]) whose target does not exist" + if !-e readlink($_[0]) && $BdTrgWrn; + symlink readlink(shift()), shift() or return; + } else { + copy(@_) or return; + + my @base_file = File::Spec->splitpath($_[0]); + my $mode_trg = -d $_[1] ? File::Spec->catfile($_[1], $base_file[ $#base_file ]) : $_[1]; + + chmod scalar((stat($_[0]))[2]), $mode_trg if $KeepMode; + } + return wantarray ? (1,0,0) : 1; # use 0's incase they do math on them and in case rcopy() is called in list context = no uninit val warnings +} + +sub rcopy { + if (-l $_[0] && $CopyLink) { + goto &fcopy; + } + + goto &dircopy if -d $_[0] || substr( $_[0], ( 1 * -1), 1) eq '*'; + goto &fcopy; +} + +sub rcopy_glob { + $glob->(\&rcopy, @_); +} + +sub dircopy { + if($RMTrgDir && -d $_[1]) { + if($RMTrgDir == 1) { + pathrmdir($_[1]) or carp "\$RMTrgDir failed: $!"; + } else { + pathrmdir($_[1]) or return; + } + } + my $globstar = 0; + my $_zero = $_[0]; + my $_one = $_[1]; + if ( substr( $_zero, ( 1 * -1 ), 1 ) eq '*') { + $globstar = 1; + $_zero = substr( $_zero, 0, ( length( $_zero ) - 1 ) ); + } + + $samecheck->( $_zero, $_[1] ) or return; + if ( !-d $_zero || ( -e $_[1] && !-d $_[1] ) ) { + $! = 20; + return; + } + + if(!-d $_[1]) { + pathmk($_[1], $NoFtlPth) or return; + } else { + if($CPRFComp && !$globstar) { + my @parts = File::Spec->splitdir($_zero); + while($parts[ $#parts ] eq '') { pop @parts; } + $_one = File::Spec->catdir($_[1], $parts[$#parts]); + } + } + my $baseend = $_one; + my $level = 0; + my $filen = 0; + my $dirn = 0; + + my $recurs; #must be my()ed before sub {} since it calls itself + $recurs = sub { + my ($str,$end,$buf) = @_; + $filen++ if $end eq $baseend; + $dirn++ if $end eq $baseend; + + $DirPerms = oct($DirPerms) if substr($DirPerms,0,1) eq '0'; + mkdir($end,$DirPerms) or return if !-d $end; + chmod scalar((stat($str))[2]), $end if $KeepMode; + if($MaxDepth && $MaxDepth =~ m/^\d+$/ && $level >= $MaxDepth) { + return ($filen,$dirn,$level) if wantarray; + return $filen; + } + $level++; + + + my @files; + if ( $] < 5.006 ) { + opendir(STR_DH, $str) or return; + @files = grep( $_ ne '.' && $_ ne '..', readdir(STR_DH)); + closedir STR_DH; + } + else { + opendir(my $str_dh, $str) or return; + @files = grep( $_ ne '.' && $_ ne '..', readdir($str_dh)); + closedir $str_dh; + } + + for my $file (@files) { + my ($file_ut) = $file =~ m{ (.*) }xms; + my $org = File::Spec->catfile($str, $file_ut); + my $new = File::Spec->catfile($end, $file_ut); + if( -l $org && $CopyLink ) { + carp "Copying a symlink ($org) whose target does not exist" + if !-e readlink($org) && $BdTrgWrn; + symlink readlink($org), $new or return; + } + elsif(-d $org) { + $recurs->($org,$new,$buf) if defined $buf; + $recurs->($org,$new) if !defined $buf; + $filen++; + $dirn++; + } + else { + if($ok_todo_asper_condcopy->($org)) { + if($SkipFlop) { + fcopy($org,$new,$buf) or next if defined $buf; + fcopy($org,$new) or next if !defined $buf; + } + else { + fcopy($org,$new,$buf) or return if defined $buf; + fcopy($org,$new) or return if !defined $buf; + } + chmod scalar((stat($org))[2]), $new if $KeepMode; + $filen++; + } + } + } + 1; + }; + + $recurs->($_zero, $_one, $_[2]) or return; + return wantarray ? ($filen,$dirn,$level) : $filen; +} + +sub fmove { $move->(1, @_) } + +sub rmove { + if (-l $_[0] && $CopyLink) { + goto &fmove; + } + + goto &dirmove if -d $_[0] || substr( $_[0], ( 1 * -1), 1) eq '*'; + goto &fmove; +} + +sub rmove_glob { + $glob->(\&rmove, @_); +} + +sub dirmove { $move->(0, @_) } + +sub pathmk { + my @parts = File::Spec->splitdir( shift() ); + my $nofatal = shift; + my $pth = $parts[0]; + my $zer = 0; + if(!$pth) { + $pth = File::Spec->catdir($parts[0],$parts[1]); + $zer = 1; + } + for($zer..$#parts) { + $DirPerms = oct($DirPerms) if substr($DirPerms,0,1) eq '0'; + mkdir($pth,$DirPerms) or return if !-d $pth && !$nofatal; + mkdir($pth,$DirPerms) if !-d $pth && $nofatal; + $pth = File::Spec->catdir($pth, $parts[$_ + 1]) unless $_ == $#parts; + } + 1; +} + +sub pathempty { + my $pth = shift; + + return 2 if !-d $pth; + + my @names; + my $pth_dh; + if ( $] < 5.006 ) { + opendir(PTH_DH, $pth) or return; + @names = grep !/^\.+$/, readdir(PTH_DH); + } + else { + opendir($pth_dh, $pth) or return; + @names = grep !/^\.+$/, readdir($pth_dh); + } + + for my $name (@names) { + my ($name_ut) = $name =~ m{ (.*) }xms; + my $flpth = File::Spec->catdir($pth, $name_ut); + + if( -l $flpth ) { + unlink $flpth or return; + } + elsif(-d $flpth) { + pathrmdir($flpth) or return; + } + else { + unlink $flpth or return; + } + } + + if ( $] < 5.006 ) { + closedir PTH_DH; + } + else { + closedir $pth_dh; + } + + 1; +} + +sub pathrm { + my $path = shift; + return 2 if !-d $path; + my @pth = File::Spec->splitdir( $path ); + my $force = shift; + + while(@pth) { + my $cur = File::Spec->catdir(@pth); + last if !$cur; # necessary ??? + if(!shift()) { + pathempty($cur) or return if $force; + rmdir $cur or return; + } + else { + pathempty($cur) if $force; + rmdir $cur; + } + pop @pth; + } + 1; +} + +sub pathrmdir { + my $dir = shift; + if( -e $dir ) { + return if !-d $dir; + } + else { + return 2; + } + + pathempty($dir) or return; + + rmdir $dir or return; +} + +1; + +__END__ + +=head1 NAME + +File::Copy::Recursive - Perl extension for recursively copying files and directories + +=head1 SYNOPSIS + + use File::Copy::Recursive qw(fcopy rcopy dircopy fmove rmove dirmove); + + fcopy($orig,$new[,$buf]) or die $!; + rcopy($orig,$new[,$buf]) or die $!; + dircopy($orig,$new[,$buf]) or die $!; + + fmove($orig,$new[,$buf]) or die $!; + rmove($orig,$new[,$buf]) or die $!; + dirmove($orig,$new[,$buf]) or die $!; + + rcopy_glob("orig/stuff-*", $trg [, $buf]) or die $!; + rmove_glob("orig/stuff-*", $trg [,$buf]) or die $!; + +=head1 DESCRIPTION + +This module copies and moves directories recursively (or single files, well... singley) to an optional depth and attempts to preserve each file or directory's mode. + +=head1 EXPORT + +None by default. But you can export all the functions as in the example above and the path* functions if you wish. + +=head2 fcopy() + +This function uses File::Copy's copy() function to copy a file but not a directory. Any directories are recursively created if need be. +One difference to File::Copy::copy() is that fcopy attempts to preserve the mode (see Preserving Mode below) +The optional $buf in the synopsis if the same as File::Copy::copy()'s 3rd argument +returns the same as File::Copy::copy() in scalar context and 1,0,0 in list context to accomidate rcopy()'s list context on regular files. (See below for more info) + +=head2 dircopy() + +This function recursively traverses the $orig directory's structure and recursively copies it to the $new directory. +$new is created if necessary (multiple non existant directories is ok (IE foo/bar/baz). The script logically and portably creates all of them if necessary). +It attempts to preserve the mode (see Preserving Mode below) and +by default it copies all the way down into the directory, (see Managing Depth) below. +If a directory is not specified it croaks just like fcopy croaks if its not a file that is specified. + +returns true or false, for true in scalar context it returns the number of files and directories copied, +In list context it returns the number of files and directories, number of directories only, depth level traversed. + + my $num_of_files_and_dirs = dircopy($orig,$new); + my($num_of_files_and_dirs,$num_of_dirs,$depth_traversed) = dircopy($orig,$new); + +Normally it stops and return's if a copy fails, to continue on regardless set $File::Copy::Recursive::SkipFlop to true. + + local $File::Copy::Recursive::SkipFlop = 1; + +That way it will copy everythgingit can ina directory and won't stop because of permissions, etc... + +=head2 rcopy() + +This function will allow you to specify a file *or* directory. It calls fcopy() if its a file and dircopy() if its a directory. +If you call rcopy() (or fcopy() for that matter) on a file in list context, the values will be 1,0,0 since no directories and no depth are used. +This is important becasue if its a directory in list context and there is only the initial directory the return value is 1,1,1. + +=head2 rcopy_glob() + +This function lets you specify a pattern suitable for perl's glob() as the first argument. Subsequently each path returned by perl's glob() gets rcopy()ied. + +It returns and array whose items are array refs that contain the return value of each rcopy() call. + +It forces behavior as if $File::Copy::Recursive::CPRFComp is true. + +=head2 fmove() + +Copies the file then removes the original. You can manage the path the original file is in according to $RemvBase. + +=head2 dirmove() + +Uses dircopy() to copy the directory then removes the original. You can manage the path the original directory is in according to $RemvBase. + +=head2 rmove() + +Like rcopy() but calls fmove() or dirmove() instead. + +=head2 rmove_glob() + +Like rcopy_glob() but calls rmove() instead of rcopy() + +=head3 $RemvBase + +Default is false. When set to true the *move() functions will not only attempt to remove the original file or directory but will remove the given path it is in. + +So if you: + + rmove('foo/bar/baz', '/etc/'); + # "baz" is removed from foo/bar after it is successfully copied to /etc/ + + local $File::Copy::Recursive::Remvbase = 1; + rmove('foo/bar/baz','/etc/'); + # if baz is successfully copied to /etc/ : + # first "baz" is removed from foo/bar + # then "foo/bar is removed via pathrm() + +=head4 $ForcePth + +Default is false. When set to true it calls pathempty() before any directories are removed to empty the directory so it can be rmdir()'ed when $RemvBase is in effect. + +=head2 Creating and Removing Paths + +=head3 $NoFtlPth + +Default is false. If set to true rmdir(), mkdir(), and pathempty() calls in pathrm() and pathmk() do not return() on failure. + +If its set to true they just silently go about their business regardless. This isn't a good idea but its there if you want it. + +=head3 $DirPerms + +Mode to pass to any mkdir() calls. Defaults to 0777 as per umask()'s POD. Explicitly having this allows older perls to be able to use FCR and might add a bit of flexibility for you. + +Any value you set it to should be suitable for oct() + +=head3 Path functions + +These functions exist soley because they were necessary for the move and copy functions to have the features they do and not because they are of themselves the purpose of this module. That being said, here is how they work so you can understand how the copy and move funtions work and use them by themselves if you wish. + +=head4 pathrm() + +Removes a given path recursively. It removes the *entire* path so be carefull!!! + +Returns 2 if the given path is not a directory. + + File::Copy::Recursive::pathrm('foo/bar/baz') or die $!; + # foo no longer exists + +Same as: + + rmdir 'foo/bar/baz' or die $!; + rmdir 'foo/bar' or die $!; + rmdir 'foo' or die $!; + +An optional second argument makes it call pathempty() before any rmdir()'s when set to true. + + File::Copy::Recursive::pathrm('foo/bar/baz', 1) or die $!; + # foo no longer exists + +Same as:PFSCheck + + File::Copy::Recursive::pathempty('foo/bar/baz') or die $!; + rmdir 'foo/bar/baz' or die $!; + File::Copy::Recursive::pathempty('foo/bar/') or die $!; + rmdir 'foo/bar' or die $!; + File::Copy::Recursive::pathempty('foo/') or die $!; + rmdir 'foo' or die $!; + +An optional third argument acts like $File::Copy::Recursive::NoFtlPth, again probably not a good idea. + +=head4 pathempty() + +Recursively removes the given directory's contents so it is empty. returns 2 if argument is not a directory, 1 on successfully emptying the directory. + + File::Copy::Recursive::pathempty($pth) or die $!; + # $pth is now an empty directory + +=head4 pathmk() + +Creates a given path recursively. Creates foo/bar/baz even if foo does not exist. + + File::Copy::Recursive::pathmk('foo/bar/baz') or die $!; + +An optional second argument if true acts just like $File::Copy::Recursive::NoFtlPth, which means you'd never get your die() if something went wrong. Again, probably a *bad* idea. + +=head4 pathrmdir() + +Same as rmdir() but it calls pathempty() first to recursively empty it first since rmdir can not remove a directory with contents. +Just removes the top directory the path given instead of the entire path like pathrm(). Return 2 if given argument does not exist (IE its already gone). Return false if it exists but is not a directory. + +=head2 Preserving Mode + +By default a quiet attempt is made to change the new file or directory to the mode of the old one. +To turn this behavior off set + $File::Copy::Recursive::KeepMode +to false; + +=head2 Managing Depth + +You can set the maximum depth a directory structure is recursed by setting: + $File::Copy::Recursive::MaxDepth +to a whole number greater than 0. + +=head2 SymLinks + +If your system supports symlinks then symlinks will be copied as symlinks instead of as the target file. +Perl's symlink() is used instead of File::Copy's copy() +You can customize this behavior by setting $File::Copy::Recursive::CopyLink to a true or false value. +It is already set to true or false dending on your system's support of symlinks so you can check it with an if statement to see how it will behave: + + if($File::Copy::Recursive::CopyLink) { + print "Symlinks will be preserved\n"; + } else { + print "Symlinks will not be preserved because your system does not support it\n"; + } + +If symlinks are being copied you can set $File::Copy::Recursive::BdTrgWrn to true to make it carp when it copies a link whose target does not exist. Its false by default. + + local $File::Copy::Recursive::BdTrgWrn = 1; + +=head2 Removing existing target file or directory before copying. + +This can be done by setting $File::Copy::Recursive::RMTrgFil or $File::Copy::Recursive::RMTrgDir for file or directory behavior respectively. + +0 = off (This is the default) + +1 = carp() $! if removal fails + +2 = return if removal fails + + local $File::Copy::Recursive::RMTrgFil = 1; + fcopy($orig, $target) or die $!; + # if it fails it does warn() and keeps going + + local $File::Copy::Recursive::RMTrgDir = 2; + dircopy($orig, $target) or die $!; + # if it fails it does your "or die" + +This should be unnecessary most of the time but its there if you need it :) + +=head2 Turning off stat() check + +By default the files or directories are checked to see if they are the same (IE linked, or two paths (absolute/relative or different relative paths) to the same file) by comparing the file's stat() info. +It's a very efficient check that croaks if they are and shouldn't be turned off but if you must for some weird reason just set $File::Copy::Recursive::PFSCheck to a false value. ("PFS" stands for "Physical File System") + +=head2 Emulating cp -rf dir1/ dir2/ + +By default dircopy($dir1,$dir2) will put $dir1's contents right into $dir2 whether $dir2 exists or not. + +You can make dircopy() emulate cp -rf by setting $File::Copy::Recursive::CPRFComp to true. + +NOTE: This only emulates -f in the sense that it does not prompt. It does not remove the target file or directory if it exists. +If you need to do that then use the variables $RMTrgFil and $RMTrgDir described in "Removing existing target file or directory before copying" above. + +That means that if $dir2 exists it puts the contents into $dir2/$dir1 instead of $dir2 just like cp -rf. +If $dir2 does not exist then the contents go into $dir2 like normal (also like cp -rf) + +So assuming 'foo/file': + + dircopy('foo', 'bar') or die $!; + # if bar does not exist the result is bar/file + # if bar does exist the result is bar/file + + $File::Copy::Recursive::CPRFComp = 1; + dircopy('foo', 'bar') or die $!; + # if bar does not exist the result is bar/file + # if bar does exist the result is bar/foo/file + +You can also specify a star for cp -rf glob type behavior: + + dircopy('foo/*', 'bar') or die $!; + # if bar does not exist the result is bar/file + # if bar does exist the result is bar/file + + $File::Copy::Recursive::CPRFComp = 1; + dircopy('foo/*', 'bar') or die $!; + # if bar does not exist the result is bar/file + # if bar does exist the result is bar/file + +NOTE: The '*' is only like cp -rf foo/* and *DOES NOT EXPAND PARTIAL DIRECTORY NAMES LIKE YOUR SHELL DOES* (IE not like cp -rf fo* to copy foo/*) + +=head2 Allowing Copy Loops + +If you want to allow: + + cp -rf . foo/ + +type behavior set $File::Copy::Recursive::CopyLoop to true. + +This is false by default so that a check is done to see if the source directory will contain the target directory and croaks to avoid this problem. + +If you ever find a situation where $CopyLoop = 1 is desirable let me know (IE its a bad bad idea but is there if you want it) + +(Note: On Windows this was necessary since it uses stat() to detemine samedness and stat() is essencially useless for this on Windows. +The test is now simply skipped on Windows but I'd rather have an actual reliable check if anyone in Microsoft land would care to share) + +=head1 SEE ALSO + +L L + +=head1 TO DO + +I am currently working on and reviewing some other modules to use in the new interface so we can lose the horrid globals as well as some other undesirable traits and also more easily make available some long standing requests. + +Tests will be easier to do with the new interface and hence the testing focus will shift to the new interface and aim to be comprehensive. + +The old interface will work, it just won't be brought in until it is used, so it will add no overhead for users of the new interface. + +I'll add this after the latest verision has been out for a while with no new features or issues found :) + +=head1 AUTHOR + +Daniel Muey, L + +=head1 COPYRIGHT AND LICENSE + +Copyright 2004 by Daniel Muey + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut diff --git a/external/buildscripts/perl_lib/Tools.pm b/external/buildscripts/perl_lib/Tools.pm new file mode 100644 index 000000000000..8b2d7a6a7e2f --- /dev/null +++ b/external/buildscripts/perl_lib/Tools.pm @@ -0,0 +1,40 @@ +package Tools; + +use warnings; +use strict; +use File::Basename qw(dirname basename ); +use File::Spec; +use Cwd qw(realpath); +use Carp qw(croak carp); +use File::stat; + +require Exporter; +our @ISA = qw(Exporter); +our @EXPORT_OK = qw(InstallNameTool GitClone); + + +sub InstallNameTool +{ + my ($target,$pathtoburnin) = @_; + print "running otool before:\n"; + system("otool","-L",$target); + print "running install_name_tool\n"; + system("install_name_tool -id $pathtoburnin $target") eq 0 or die("Failed running install_name_tool"); + print "running otool after:\n"; + system("otool","-L",$target); +} + +sub GitClone +{ + my $repo = shift; + my $localFolder = shift; + my $branch = shift; + $branch = defined($branch)?$branch:"master"; + + if (-d $localFolder) { + return; + } + print "running git clone --branch $branch $repo $localFolder\n"; + system("git clone --branch $branch $repo $localFolder") eq 0 or die("git clone $repo $localFolder failed!"); +} + diff --git a/external/buildscripts/sources.txt b/external/buildscripts/sources.txt new file mode 100644 index 000000000000..dd393f7b0718 --- /dev/null +++ b/external/buildscripts/sources.txt @@ -0,0 +1,535 @@ +#################### +#mono eglib files +#################### +SOURCES: +eglib/src/garray.c +eglib/src/gbytearray.c +eglib/src/gerror.c +eglib/src/gfile.c +eglib/src/ghashtable.c +eglib/src/giconv.c +eglib/src/glist.c +eglib/src/gmarkup.c +eglib/src/gmem.c +eglib/src/goutput.c +eglib/src/gpattern.c +eglib/src/gptrarray.c +eglib/src/gqsort.c +eglib/src/gqueue.c +eglib/src/gshell.c +eglib/src/gslist.c +eglib/src/gspawn.c +eglib/src/gpath.c +eglib/src/gstr.c +eglib/src/gstring.c +eglib/src/gunicode.c +eglib/src/gutf8.c +eglib/src/gmisc-unity.c +eglib/src/gfile-unity.c +eglib/src/gdate-unity.c +eglib/src/gpath-unity.c +eglib/src/gdir-unity.c +eglib/src/gunicode-win32.c +HEADERS: +eglib/src/glib.h +eglib/src/gmodule.h +eglib/src/sort.frag.h +eglib/src/eglib-remap.h +eglib/src/unicode-data.h +#################### +#mono utils files +#################### +SOURCES: +mono/utils/dlmalloc.c +mono/utils/hazard-pointer.c +mono/utils/json.c +mono/utils/lock-free-alloc.c +mono/utils/lock-free-array-queue.c +mono/utils/lock-free-queue.c +mono/utils/mach-support-amd64.c +mono/utils/mach-support-x86.c +mono/utils/mach-support.c +mono/utils/mono-codeman.c +mono/utils/mono-conc-hashtable.c +mono/utils/mono-context.c +mono/utils/mono-counters.c +mono/utils/mono-dl-unity.c +mono/utils/mono-dl-windows.c +mono/utils/mono-dl-darwin.c +mono/utils/mono-dl-posix.c +mono/utils/mono-dl.c +mono/utils/mono-error.c +mono/utils/mono-filemap.c +mono/utils/mono-internal-hash.c +mono/utils/mono-io-portability.c +mono/utils/mono-linked-list-set.c +mono/utils/mono-logger.c +mono/utils/mono-log-unity.c +mono/utils/mono-log-android.c +mono/utils/mono-log-windows.c +mono/utils/mono-log-darwin.c +mono/utils/mono-log-posix.c +mono/utils/mono-log-common.c +mono/utils/mono-math.c +mono/utils/mono-md5.c +mono/utils/mono-mmap.c +mono/utils/mono-mmap-windows.c +mono/utils/mono-networkinterfaces.c +mono/utils/mono-threads-state-machine.c +mono/utils/networking.c +mono/utils/networking-posix.c +mono/utils/networking-missing.c +mono/utils/networking-windows.c +mono/utils/networking-unity.c +mono/utils/mono-path.c +mono/utils/mono-poll.c +mono/utils/mono-proclib.c +mono/utils/mono-proclib-windows.c +mono/utils/mono-property-hash.c +mono/utils/mono-publib.c +mono/utils/mono-sha1.c +mono/utils/mono-stdlib.c +mono/utils/mono-threads-android.c +mono/utils/mono-threads-mach.c +mono/utils/mono-threads-mach-helper.c +mono/utils/mono-threads-posix.c +mono/utils/mono-threads-posix-signals.c +mono/utils/mono-threads-windows.c +mono/utils/mono-threads.c +mono/utils/mono-threads-coop.c +mono/utils/mono-threads-unity.c +mono/utils/mono-tls.c +mono/utils/mono-uri.c +mono/utils/mono-value-hash.c +mono/utils/monobitset.c +mono/utils/strenc.c +mono/utils/atomic.c +mono/utils/mono-hwcap.c +mono/utils/mono-hwcap-arm.c +mono/utils/mono-hwcap-x86.c +mono/utils/bsearch.c +mono/utils/memfuncs.c +mono/utils/parse.c +mono/utils/os-event-unity.c +mono/utils/os-event-win32.c +mono/utils/os-event-unix.c +mono/utils/unity-rand.c +mono/utils/unity-time.c +mono/utils/win64.asm +HEADERS: +mono/utils/checked-build.h +mono/utils/dlmalloc.h +mono/utils/dtrace.h +mono/utils/freebsd-dwarf.h +mono/utils/freebsd-elf32.h +mono/utils/freebsd-elf64.h +mono/utils/freebsd-elf_common.h +mono/utils/gc_wrapper.h +mono/utils/hazard-pointer.h +mono/utils/json.h +mono/utils/linux_magic.h +mono/utils/lock-free-alloc.h +mono/utils/lock-free-array-queue.h +mono/utils/lock-free-queue.h +mono/utils/mach-support.h +mono/utils/memcheck.h +mono/utils/mono-codeman.h +mono/utils/mono-compiler.h +mono/utils/mono-complex.h +mono/utils/mono-conc-hashtable.h +mono/utils/mono-context.h +mono/utils/mono-coop-mutex.h +mono/utils/mono-coop-semaphore.h +mono/utils/mono-counters.h +mono/utils/mono-digest.h +mono/utils/mono-dl-fallback.h +mono/utils/mono-dl-windows-internals.h +mono/utils/mono-dl.h +mono/utils/mono-embed.h +mono/utils/mono-error-internals.h +mono/utils/mono-error.h +mono/utils/mono-internal-hash.h +mono/utils/mono-io-portability.h +mono/utils/mono-lazy-init.h +mono/utils/mono-linked-list-set.h +mono/utils/mono-logger-internals.h +mono/utils/mono-logger.h +mono/utils/mono-machine.h +mono/utils/mono-math.h +mono/utils/mono-membar.h +mono/utils/mono-memory-model.h +mono/utils/mono-mmap-internals.h +mono/utils/mono-mmap-windows-internals.h +mono/utils/mono-mmap.h +mono/utils/mono-networkinterfaces.h +mono/utils/mono-once.h +mono/utils/mono-os-mutex.h +mono/utils/mono-os-semaphore.h +mono/utils/mono-path.h +mono/utils/mono-poll.h +mono/utils/mono-proclib.h +mono/utils/mono-property-hash.h +mono/utils/mono-publib.h +mono/utils/mono-rand.h +mono/utils/mono-sigcontext.h +mono/utils/mono-signal-handler.h +mono/utils/mono-stack-unwinding.h +mono/utils/mono-stdlib.h +mono/utils/mono-string.h +mono/utils/mono-threads.h +mono/utils/mono-threads-api.h +mono/utils/mono-threads-coop.h +mono/utils/mono-threads-debug.h +mono/utils/mono-time.h +mono/utils/mono-tls.h +mono/utils/mono-uri.h +mono/utils/mono-value-hash.h +mono/utils/monobitset.h +mono/utils/networking.h +mono/utils/refcount.h +mono/utils/strenc.h +mono/utils/valgrind.h +mono/utils/atomic.h +mono/utils/mono-hwcap-vars.h +mono/utils/mono-hwcap.h +mono/utils/bsearch.h +mono/utils/memfuncs.h +mono/utils/parse.h +mono/utils/os-event.h +mono/utils/w32api.h +#################### +#mono runtime files +#################### +SOURCES: +mono/metadata/appdomain.c +mono/metadata/assembly.c +mono/metadata/attach.c +mono/metadata/boehm-gc.c +mono/metadata/class.c +mono/metadata/class-accessors.c +mono/metadata/cominterop.c +mono/metadata/console-unity.c +mono/metadata/coree.c +mono/metadata/custom-attrs.c +mono/metadata/debug-helpers.c +mono/metadata/debug-mono-ppdb.c +mono/metadata/debug-mono-symfile.c +mono/metadata/decimal-ms.c +mono/metadata/domain.c +mono/metadata/dynamic-image.c +mono/metadata/dynamic-stream.c +mono/metadata/environment.c +mono/metadata/exception.c +mono/metadata/file-mmap-unity.c +mono/metadata/filewatcher.c +mono/metadata/gc-stats.c +mono/metadata/gc.c +mono/metadata/handle.c +mono/metadata/icall.c +mono/metadata/icall-windows.c +mono/metadata/image.c +mono/metadata/jit-info.c +mono/metadata/loader.c +mono/metadata/locales.c +mono/metadata/lock-tracer.c +mono/metadata/marshal.c +mono/metadata/marshal-windows.c +mono/metadata/mempool.c +mono/metadata/metadata-verify.c +mono/metadata/metadata.c +mono/metadata/metadata-cross-helpers.c +mono/metadata/method-builder.c +mono/metadata/monitor.c +mono/metadata/mono-basic-block.c +mono/metadata/mono-config.c +mono/metadata/mono-config-dirs.c +mono/metadata/mono-debug.c +mono/metadata/mono-endian.c +mono/metadata/mono-hash.c +mono/metadata/mono-mlist.c +mono/metadata/mono-perfcounters.c +mono/metadata/mono-route.c +mono/metadata/mono-security.c +mono/metadata/mono-security-windows.c +mono/metadata/nacl-stub.c +mono/metadata/null-gc.c +mono/metadata/number-ms.c +mono/metadata/object.c +mono/metadata/opcodes.c +mono/metadata/profiler.c +mono/metadata/property-bag.c +mono/metadata/rand.c +mono/metadata/reflection.c +mono/metadata/remoting.c +mono/metadata/runtime.c +mono/metadata/security-core-clr.c +mono/metadata/security-manager.c +mono/metadata/seq-points-data.c +mono/metadata/sgen-mono.c +mono/metadata/sgen-bridge.c +mono/metadata/sgen-new-bridge.c +mono/metadata/sgen-old-bridge.c +mono/metadata/sgen-tarjan-bridge.c +mono/metadata/sgen-toggleref.c +mono/metadata/sgen-stw.c +mono/metadata/sre.c +mono/metadata/sre-encode.c +mono/metadata/sre-save.c +mono/metadata/string-icalls.c +mono/metadata/sysmath.c +mono/metadata/threads.c +mono/metadata/threadpool.c +mono/metadata/threadpool-io.c +mono/metadata/threadpool-worker-default.c +mono/metadata/verify.c +mono/metadata/unity-liveness.c +mono/metadata/unity-utils.c +mono/metadata/w32error-unity.c +mono/metadata/w32error-win32.c +mono/metadata/w32error-unix.c +mono/metadata/w32event-unity.c +mono/metadata/w32file-unity.c +mono/metadata/w32file-unix-glob.c +mono/metadata/w32file.c +mono/metadata/w32handle-namespace.c +mono/metadata/w32handle.c +mono/metadata/w32mutex-unity.c +mono/metadata/w32process-unity.c +mono/metadata/w32process-unix-osx.c +mono/metadata/w32process-unix-default.c +mono/metadata/w32process-unix.c +mono/metadata/w32process-win32.c +mono/metadata/w32process.c +mono/metadata/w32semaphore-unity.c +mono/metadata/w32socket-unity.c +mono/metadata/w32socket-unix.c +mono/metadata/w32socket-win32.c +mono/metadata/w32socket.c +HEADERS: +mono/metadata/abi-details.h +mono/metadata/attrdefs.h +mono/metadata/appdomain.h +mono/metadata/appdomain-icalls.h +mono/metadata/assembly-internals.h +mono/metadata/assembly.h +mono/metadata/attach.h +mono/metadata/blob.h +mono/metadata/cil-coff.h +mono/metadata/class-inlines.h +mono/metadata/class-internals.h +mono/metadata/class.h +mono/metadata/cominterop-win32-internals.h +mono/metadata/cominterop.h +mono/metadata/console-io.h +mono/metadata/coree-internals.h +mono/metadata/coree.h +mono/metadata/culture-info-tables.h +mono/metadata/culture-info.h +mono/metadata/custom-attrs-internals.h +mono/metadata/debug-helpers.h +mono/metadata/debug-mono-ppdb.h +mono/metadata/debug-mono-symfile.h +mono/metadata/decimal-ms.h +mono/metadata/domain-internals.h +mono/metadata/dynamic-image-internals.h +mono/metadata/dynamic-stream-internals.h +mono/metadata/environment.h +mono/metadata/exception-internals.h +mono/metadata/exception.h +mono/metadata/filewatcher.h +mono/metadata/file-mmap.h +mono/metadata/gc-internals.h +mono/metadata/handle.h +mono/metadata/number-ms.h +mono/metadata/remoting.h +mono/metadata/row-indexes.h +mono/metadata/seq-points-data.h +mono/metadata/sgen-bridge-internals.h +mono/metadata/sgen-client-mono.h +mono/metadata/sgen-dynarray.h +mono/sgen/gc-internal-agnostic.h +mono/metadata/icall-def.h +mono/metadata/icall-internals.h +mono/metadata/icall-windows-internals.h +mono/metadata/il2cpp-compat-metadata.h +mono/metadata/image-internals.h +mono/metadata/image.h +mono/metadata/loader.h +mono/metadata/locales.h +mono/metadata/lock-tracer.h +mono/metadata/marshal-internals.h +mono/metadata/marshal-windows-internals.h +mono/metadata/marshal.h +mono/metadata/mempool-internals.h +mono/metadata/mempool.h +mono/metadata/metadata-internals.h +mono/metadata/metadata.h +mono/metadata/method-builder.h +mono/metadata/monitor.h +mono/metadata/mono-basic-block.h +mono/metadata/mono-config.h +mono/metadata/mono-config-dirs.h +mono/metadata/mono-debug-debugger.h +mono/metadata/mono-debug.h +mono/metadata/mono-endian.h +mono/metadata/mono-gc.h +mono/metadata/mono-hash.h +mono/metadata/mono-mlist.h +mono/metadata/mono-perfcounters-def.h +mono/metadata/mono-perfcounters.h +mono/metadata/mono-ptr-array.h +mono/metadata/mono-route.h +mono/metadata/mono-security-windows-internals.h +mono/metadata/normalization-tables.h +mono/metadata/number-formatter.h +mono/metadata/object-internals.h +mono/metadata/object-offsets.h +mono/metadata/object.h +mono/metadata/opcodes.h +mono/metadata/profiler-private.h +mono/metadata/profiler.h +mono/metadata/property-bag.h +mono/metadata/rand.h +mono/metadata/reflection.h +mono/metadata/reflection-cache.h +mono/metadata/reflection-internals.h +mono/metadata/runtime.h +mono/metadata/security-core-clr.h +mono/metadata/security-manager.h +mono/metadata/security.h +mono/metadata/sgen-bridge.h +mono/metadata/sgen-toggleref.h +mono/metadata/sre-internals.h +mono/metadata/string-icalls.h +mono/metadata/sysmath.h +mono/metadata/tabledefs.h +mono/metadata/threadpool.h +mono/metadata/threadpool-io.h +mono/metadata/threadpool-worker.h +mono/metadata/threads.h +mono/metadata/threads-types.h +mono/metadata/tokentype.h +mono/metadata/verify-internals.h +mono/metadata/verify.h +mono/metadata/unity-utils.h +mono/metadata/wrapper-types.h +mono/metadata/w32error.h +mono/metadata/w32event.h +mono/metadata/w32file-internals.h +mono/metadata/w32file-win32-internals.h +mono/metadata/w32file-unix-glob.h +mono/metadata/w32file.h +mono/metadata/w32handle-namespace.h +mono/metadata/w32handle.h +mono/metadata/w32mutex.h +mono/metadata/w32process-internals.h +mono/metadata/w32process-unix-internals.h +mono/metadata/w32process-win32-internals.h +mono/metadata/w32process.h +mono/metadata/w32semaphore.h +mono/metadata/w32socket.h +mono/metadata/w32socket-internals.h +PRIVATE: +mono/metadata/threadpool-io-epoll.c +mono/metadata/threadpool-io-kqueue.c +mono/metadata/threadpool-io-poll.c +#################### +#mono sgen files +#################### +SOURCES: +mono/sgen/sgen-alloc.c +mono/sgen/sgen-array-list.c +mono/sgen/sgen-cardtable.c +mono/sgen/sgen-debug.c +mono/sgen/sgen-descriptor.c +mono/sgen/sgen-gc.c +mono/sgen/sgen-gchandles.c +mono/sgen/sgen-gray.c +mono/sgen/sgen-hash-table.c +mono/sgen/sgen-internal.c +mono/sgen/sgen-los.c +mono/sgen/sgen-marksweep.c +mono/sgen/sgen-memory-governor.c +mono/sgen/sgen-nursery-allocator.c +mono/sgen/sgen-pinning-stats.c +mono/sgen/sgen-pinning.c +mono/sgen/sgen-pointer-queue.c +mono/sgen/sgen-protocol.c +mono/sgen/sgen-qsort.c +mono/sgen/sgen-simple-nursery.c +mono/sgen/sgen-split-nursery.c +mono/sgen/sgen-thread-pool.c +mono/sgen/sgen-workers.c +mono/sgen/sgen-fin-weak-hash.c +mono/sgen/sgen-layout-stats.c +HEADERS: +mono/sgen/gc-internal-agnostic.h +mono/sgen/sgen-archdep.h +mono/sgen/sgen-array-list.h +mono/sgen/sgen-cardtable.h +mono/sgen/sgen-client.h +mono/sgen/sgen-conf.h +mono/sgen/sgen-copy-object.h +mono/sgen/sgen-descriptor.h +mono/sgen/sgen-gc.h +mono/sgen/sgen-gray.h +mono/sgen/sgen-hash-table.h +mono/sgen/sgen-layout-stats.h +mono/sgen/sgen-major-copy-object.h +mono/sgen/sgen-marksweep-drain-gray-stack.h +mono/sgen/sgen-memory-governor.h +mono/sgen/sgen-minor-copy-object.h +mono/sgen/sgen-minor-scan-object.h +mono/sgen/sgen-pinning.h +mono/sgen/sgen-pointer-queue.h +mono/sgen/sgen-protocol-def.h +mono/sgen/sgen-protocol.h +mono/sgen/sgen-qsort.h +mono/sgen/sgen-scan-object.h +mono/sgen/sgen-tagged-pointer.h +mono/sgen/sgen-thread-pool.h +mono/sgen/sgen-workers.h +#################### +#mono cil files +#################### +METADATA: +mono/cil/opcode.def +mono/cil/tables.def +#################### +#mono arch files +#################### +HEADERS: +mono/arch/amd64/amd64-codegen.h +mono/arch/x86/x86-codegen.h +mono/arch/arm/arm-codegen.h +mono/arch/arm/arm_dpimacros.h +mono/arch/arm/arm-vfp-codegen.h +mono/arch/arm/arm_vfpmacros.h +#################### +#mono complex files +#################### +SOURCES: +support/libm/complex.c +HEADERS: +support/libm/complex.h +support/libm/math_private.h +#################### +#mono mini files +#################### +mono/mini/cfgdump.h +mono/mini/debugger-agent.c +mono/mini/debugger-agent.h +mono/mini/il2cpp-c-types.h +mono/mini/il2cpp-compat.h +mono/mini/il2cpp-stubs.cpp +mono/mini/jit.h +mono/mini/mini-amd64.h +mono/mini/mini-arch.h +mono/mini/mini-ops.h +mono/mini/mini-unwind.h +mono/mini/mini-x86.h +mono/mini/mini.h +mono/mini/optflags-def.h +mono/mini/patch-info.h +mono/mini/regalloc.h +mono/mini/seq-points.h diff --git a/external/buildscripts/test-driver b/external/buildscripts/test-driver new file mode 100644 index 000000000000..8a05be09ec4b --- /dev/null +++ b/external/buildscripts/test-driver @@ -0,0 +1,100 @@ +#!/usr/bin/env perl + +my $interpreter = shift; +my $test = shift; +my $disabled_tests = shift; +my $output = $test; +my $stdout = $test.'.stdout'; +my $stderr = $test.'.stderr'; + +my $teamcity = $ENV{UNITY_THISISABUILDMACHINE}; +$output =~ s/\.exe$/.output/; + +$| = 0; +if ($teamcity) { + print "##teamcity[testStarted name='$test']\n"; +} +else { + print "Testing $test... "; +} + +foreach $disabled (split (/ /, $disabled_tests)) { + if ($disabled eq $test) { + print "disabled.\n"; + exit (0); + } +} + +my $res; +my $cpid = fork (); +if (!defined ($cpid)) { + $res = system("$interpreter @ARGV $test 2>$stderr 1>$stdout"); +} elsif ($cpid == 0) { + exec ("$interpreter @ARGV $test 2>$stderr 1>$stdout") || die "Cannot exec: $!"; +} else { + # in the parent, setup the alarm + # test must complete in 30 seconds or it is considered buggy + my $timeout = 30; + alarm ($timeout); + $SIG{ALRM} = sub { + print "failed after $timeout seconds timeout.\n"; + if ($teamcity) { + print "##teamcity[testFailed name='$test' message='failed after $timeout seconds timeout.' details='message and stack trace']\n"; + print "##teamcity[testFinished name='$test']\n"; + } + # process group kill + kill (-9, $cpid); + exit (3); + }; + $res = wait (); + $SIG{ALRM} = sub {}; + $res = $? >> 8; +} + +if ($teamcity && -f $stdout) { + $text = read_file ($stdout); + print "##teamcity[testStdOut name='$test' out='$text']\n"; +} + +if ($teamcity && -f $stderr) { + $text = read_file ($stderr); + print "##teamcity[testStdErr name='$test' out='$text']\n"; +} + +if ($res) { + $failedText = sprintf ("failed $? (%d) signal (%d).", $? >> 8, $? & 127); + if ($teamcity) { + print "##teamcity[testFailed name='$test' message='$failedText' details='message and stack trace']\n"; + print "##teamcity[testFinished name='$test']\n"; + } else { + print "$failedText\n"; + } + + if (($? & 127) == 2) { + exit (2); + } else { + exit (1); + } +} +if (-f $output && (read_file ($output) ne read_file ($stdout))) { + print "failed output.\n"; + exit (1); +} + +if ($teamcity) { + print "##teamcity[testFinished name='$test']\n"; +} +else { + print "pass.\n"; +} +unlink ($stderr); +exit (0); + +sub read_file { + local ($/); + my $out = shift; + open (F, "<$out") || die $!; + $out = ; + close(F); + return $out; +} diff --git a/mcs/Makefile b/mcs/Makefile index b7cb886b20ec..01b125bc81c8 100644 --- a/mcs/Makefile +++ b/mcs/Makefile @@ -23,6 +23,8 @@ xammac_net_4_5_SUBDIRS := build class xbuild_12_SUBDIRS := build class tools/xbuild xbuild_14_SUBDIRS := build class tools/xbuild winaot_SUBDIRS := build class +unityjit_SUBDIRS := build class +unityaot_SUBDIRS := build class orbis_SUBDIRS := build class unreal_SUBDIRS := build class wasm_SUBDIRS := build class @@ -80,6 +82,8 @@ $(_boot_:%=profile-do--xammac_net_4_5--%): profile-do--xammac_net_4_5--%: $(_boot_:%=profile-do--testing_aot_hybrid--%): profile-do--testing_aot_hybrid--%: profile-do--build--% $(_boot_:%=profile-do--testing_aot_full--%): profile-do--testing_aot_full--%: profile-do--build--% $(_boot_:%=profile-do--winaot--%): profile-do--winaot--%: profile-do--build--% +$(_boot_:%=profile-do--unityjit--%): profile-do--unityjit--%: profile-do--build--% +$(_boot_:%=profile-do--unityaot--%): profile-do--unityaot--%: profile-do--build--% $(_boot_:%=profile-do--orbis--%): profile-do--orbis--%: profile-do--build--% $(_boot_:%=profile-do--unreal--%): profile-do--unreal--%: profile-do--build--% $(_boot_:%=profile-do--wasm--%): profile-do--wasm--%: profile-do--build--% diff --git a/mcs/build/common/Consts.cs.in b/mcs/build/common/Consts.cs.in index 8bb64bc43a70..a6cdfdd19611 100644 --- a/mcs/build/common/Consts.cs.in +++ b/mcs/build/common/Consts.cs.in @@ -40,7 +40,7 @@ static class Consts public const string MonoCopyright = "(c) Various Mono authors"; public const int MonoCorlibVersion = @MONO_CORLIB_VERSION@; -#if MOBILE +#if MOBILE && !UNITY_AOT // Versions of .NET Framework for Silverlight 4.0 public const string FxVersion = "2.0.5.0"; public const string VsVersion = "9.0.0.0"; // unused, but needed for compilation @@ -78,7 +78,7 @@ static class Consts #error No profile symbols defined. #endif -#if MOBILE +#if MOBILE && !UNITY_AOT const string PublicKeyToken = "7cec85d7bea7798e"; #else const string PublicKeyToken = "b77a5c561934e089"; diff --git a/mcs/build/profiles/net_4_x.make b/mcs/build/profiles/net_4_x.make index a4965ddc99e0..c160d625908f 100644 --- a/mcs/build/profiles/net_4_x.make +++ b/mcs/build/profiles/net_4_x.make @@ -13,7 +13,7 @@ profile-check: @: DEFAULT_REFERENCES = -r:$(topdir)/class/lib/$(PROFILE_DIRECTORY)/mscorlib.dll -PROFILE_MCS_FLAGS = -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -d:MULTIPLEX_OS -nowarn:1699 -nostdlib $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS) +PROFILE_MCS_FLAGS = -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:UNITY_AOT -d:UNITY -d:WIN_PLATFORM -d:MULTIPLEX_OS -nowarn:1699 -nostdlib $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS) FRAMEWORK_VERSION = 4.5 XBUILD_VERSION = 4.0 diff --git a/mcs/build/profiles/unityaot.make b/mcs/build/profiles/unityaot.make new file mode 100644 index 000000000000..54128f7d25a7 --- /dev/null +++ b/mcs/build/profiles/unityaot.make @@ -0,0 +1,40 @@ +#! -*- makefile -*- + +BOOTSTRAP_PROFILE = build + +BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_CSC) +MCS = $(BOOTSTRAP_MCS) + +profile-check: + @: + +DEFAULT_REFERENCES = -r:$(topdir)/class/lib/$(PROFILE)/mscorlib.dll + +PROFILE_MCS_FLAGS = \ + -d:NET_1_1 \ + -d:NET_2_0 \ + -d:NET_2_1 \ + -d:NET_3_5 \ + -d:NET_4_0 \ + -d:NET_4_5 \ + -d:MONO \ + -d:UNITY \ + -d:UNITY_AOT \ + -d:MOBILE,MOBILE_LEGACY \ + -d:FULL_AOT_DESKTOP \ + -d:FULL_AOT_RUNTIME \ + -d:DISABLE_REMOTING \ + -d:WIN_PLATFORM \ + -nowarn:1699 \ + -nostdlib \ + $(DEFAULT_REFERENCES) \ + $(PLATFORM_DEBUG_FLAGS) + +FRAMEWORK_VERSION = 2.1 + +NO_INSTALL = yes +AOT_FRIENDLY_PROFILE = yes +#ALWAYS_AOT = yes +MOBILE_PROFILE = yes +NO_TEST = yes +#NO_SIGN_ASSEMBLY = yes diff --git a/mcs/build/profiles/unityjit.make b/mcs/build/profiles/unityjit.make new file mode 100644 index 000000000000..5bc7a4250d6e --- /dev/null +++ b/mcs/build/profiles/unityjit.make @@ -0,0 +1,17 @@ +# -*- makefile -*- + +BOOTSTRAP_PROFILE = build + +BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_CSC) +MCS = $(BOOTSTRAP_MCS) + + +profile-check: + @: + +DEFAULT_REFERENCES = -r:$(topdir)/class/lib/$(PROFILE)/mscorlib.dll +PROFILE_MCS_FLAGS = -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:UNITY_JIT -d:UNITY -d:WIN_PLATFORM -nowarn:1699 -nostdlib $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS) + +FRAMEWORK_VERSION = 4.5 +XBUILD_VERSION = 4.0 +MONO_FEATURE_APPLETLS=1 diff --git a/mcs/class/Facades/System.Drawing.Primitives/Makefile b/mcs/class/Facades/System.Drawing.Primitives/Makefile index 036ec852fa5e..174df4af8ee8 100644 --- a/mcs/class/Facades/System.Drawing.Primitives/Makefile +++ b/mcs/class/Facades/System.Drawing.Primitives/Makefile @@ -23,7 +23,7 @@ EMBEDDED_DRAWING_DEP := $(filter xammac_net_4_5 testing_aot_full testing_aot_hyb ifndef EMBEDDED_DRAWING_DEP # profiles which build a System.Drawing.dll in the repo -REPO_DRAWING_DEP := $(filter net_4_x orbis winaot unreal wasm, $(PROFILE)) +REPO_DRAWING_DEP := $(filter net_4_x orbis winaot unityaot unityjit unreal wasm, $(PROFILE)) ifdef REPO_DRAWING_DEP LIB_REFS += System.Drawing diff --git a/mcs/class/Facades/netstandard/Makefile b/mcs/class/Facades/netstandard/Makefile index b9974695d6d1..e6487dc44d16 100644 --- a/mcs/class/Facades/netstandard/Makefile +++ b/mcs/class/Facades/netstandard/Makefile @@ -23,13 +23,15 @@ LIB_MCS_FLAGS = $(SIGN_FLAGS) $(EXTRA_LIB_MCS_FLAGS) ifeq ($(PROFILE),xammac_net_4_5) LIB_REFS += System.Web.Services else ifeq (2.1, $(FRAMEWORK_VERSION)) +ifneq ($(PROFILE),unityaot) LIB_REFS += System.Web.Services +endif else LIB_REFS += System.Web endif # profiles which build a System.Drawing.dll in the repo -REPO_DRAWING_DEP := $(filter net_4_x orbis winaot unreal wasm, $(PROFILE)) +REPO_DRAWING_DEP := $(filter net_4_x orbis winaot unityaot unityjit unreal wasm, $(PROFILE)) ifdef REPO_DRAWING_DEP LIB_REFS += System.Drawing diff --git a/mcs/class/Facades/subdirs.make b/mcs/class/Facades/subdirs.make index 992516931274..141d754f38fa 100644 --- a/mcs/class/Facades/subdirs.make +++ b/mcs/class/Facades/subdirs.make @@ -80,6 +80,12 @@ monotouch_tv_PARALLEL_SUBDIRS = $(monotouch_PARALLEL_SUBDIRS) winaot_SUBDIRS = $(common_DEPS_SUBDIRS) $(netstandard_drawing_SUBDIRS) $(mobile_only_DEPS_SUBDIRS) winaot_PARALLEL_SUBDIRS = $(common_SUBDIRS) $(mobile_only_SUBDIRS) +unityjit_SUBDIRS = $(common_DEPS_SUBDIRS) $(netstandard_drawing_SUBDIRS) +unityjit_PARALLEL_SUBDIRS = $(common_SUBDIRS) + +unityaot_SUBDIRS = $(filter-out System.ServiceModel.Primitives,$(common_DEPS_SUBDIRS)) $(netstandard_drawing_SUBDIRS) $(mobile_only_DEPS_SUBDIRS) +unityaot_PARALLEL_SUBDIRS = $(filter-out System.ServiceModel.Http System.ServiceModel.Security System.ServiceModel.Duplex System.ServiceModel.NetTcp ,$(common_SUBDIRS)) $(mobile_only_SUBDIRS) + orbis_SUBDIRS = $(common_DEPS_SUBDIRS) $(netstandard_drawing_SUBDIRS) $(mobile_only_DEPS_SUBDIRS) orbis_PARALLEL_SUBDIRS = $(common_SUBDIRS) $(mobile_only_SUBDIRS) diff --git a/mcs/class/Makefile b/mcs/class/Makefile index 57fa33adaa33..d9702eca8732 100644 --- a/mcs/class/Makefile +++ b/mcs/class/Makefile @@ -339,6 +339,26 @@ net_4_x_parallel_dirs := \ legacy/Mono.Cecil \ $(pcl_facade_dirs) +unityjit_dirs := \ + $(net_4_x_dirs) \ + System.ComponentModel.Composition.4.5 \ + I18N \ + $(pcl_facade_dirs) + +unityaot_dirs := \ + $(filter-out \ + Mono.CSharp \ + System.Data.Services.Client \ + System.Net.Http.WinHttpHandler \ + System.ServiceModel.Web \ + System.ServiceModel \ + System.Web.Services \ + System.Reflection.Context \ + System.Windows \ + System.Xml.Serialization, $(mobile_common_dirs)) \ + System.Drawing \ + $(pcl_facade_dirs) + xbuild_2_0_dirs := \ Microsoft.Build.Framework \ Microsoft.Build.Utilities \ @@ -373,13 +393,15 @@ net_4_x_PARALLEL_SUBDIRS := $(net_4_x_parallel_dirs) xbuild_12_SUBDIRS := $(xbuild_4_0_dirs) xbuild_14_SUBDIRS := $(xbuild_4_0_dirs) Microsoft.NuGet.Build.Tasks winaot_SUBDIRS := $(winaot_dirs) +unityjit_SUBDIRS := $(unityjit_dirs) +unityaot_SUBDIRS := $(unityaot_dirs) orbis_SUBDIRS := $(orbis_dirs) unreal_SUBDIRS := $(unreal_dirs) wasm_SUBDIRS := $(wasm_dirs) include ../build/rules.make -SUBDIRS = $(testing_aot_full_dirs) $(testing_aot_hybrid_dirs) $(monotouch_dirs) $(monodroid_dirs) $(monodroid_tools_dirs) $(xammac_dirs) $(net_4_x_dirs) $(net_4_x_parallel_dirs) $(xammac_net_4_5_SUBDIRS) $(unreal_dirs) +SUBDIRS = $(testing_aot_full_dirs) $(testing_aot_hybrid_dirs) $(monotouch_dirs) $(monodroid_dirs) $(monodroid_tools_dirs) $(xammac_dirs) $(net_4_x_dirs) $(net_4_x_parallel_dirs) $(xammac_net_4_5_SUBDIRS) $(unityjit_dirs) $(unityaot_dirs) $(unreal_dirs) DIST_ONLY_SUBDIRS = dlr aot-compiler reference-assemblies $(xbuild_4_0_dirs) Microsoft.NuGet.Build.Tasks diff --git a/mcs/class/System.Core/unityaot_System.Core.dll.sources b/mcs/class/System.Core/unityaot_System.Core.dll.sources new file mode 100644 index 000000000000..fe9ad015d119 --- /dev/null +++ b/mcs/class/System.Core/unityaot_System.Core.dll.sources @@ -0,0 +1 @@ +#include winaot_System.Core.dll.sources diff --git a/mcs/class/System.Core/unityjit_System.Core.dll.sources b/mcs/class/System.Core/unityjit_System.Core.dll.sources new file mode 100644 index 000000000000..e5681ff8ff5b --- /dev/null +++ b/mcs/class/System.Core/unityjit_System.Core.dll.sources @@ -0,0 +1 @@ +#include net_4_x_System.Core.dll.sources diff --git a/mcs/class/System.Data/unityjit_System.Data.dll.sources b/mcs/class/System.Data/unityjit_System.Data.dll.sources new file mode 100644 index 000000000000..87d9b19fbf8c --- /dev/null +++ b/mcs/class/System.Data/unityjit_System.Data.dll.sources @@ -0,0 +1,4 @@ +#include corefx.unix.sources +#include net_4_x_System.Data.dll.sources + +../../../external/corefx/src/System.Data.Odbc/src/Common/System/Data/Common/ExternDll.Osx.cs diff --git a/mcs/class/System.Drawing/unityaot_System.Drawing.dll.sources b/mcs/class/System.Drawing/unityaot_System.Drawing.dll.sources new file mode 100644 index 000000000000..0403fdc41fcc --- /dev/null +++ b/mcs/class/System.Drawing/unityaot_System.Drawing.dll.sources @@ -0,0 +1 @@ +#include winaot_System.Drawing.dll.sources diff --git a/mcs/class/System.IdentityModel/unityaot_System.IdentityModel.dll.sources b/mcs/class/System.IdentityModel/unityaot_System.IdentityModel.dll.sources new file mode 100644 index 000000000000..429636751c2e --- /dev/null +++ b/mcs/class/System.IdentityModel/unityaot_System.IdentityModel.dll.sources @@ -0,0 +1 @@ +#include mobile_System.IdentityModel.dll.sources diff --git a/mcs/class/System.IdentityModel/unityjit_System.IdentityModel.dll.sources b/mcs/class/System.IdentityModel/unityjit_System.IdentityModel.dll.sources new file mode 100644 index 000000000000..7d312678c9ce --- /dev/null +++ b/mcs/class/System.IdentityModel/unityjit_System.IdentityModel.dll.sources @@ -0,0 +1 @@ +#include net_4_x_System.IdentityModel.dll.sources diff --git a/mcs/class/System.Runtime.Serialization/unityaot_System.Runtime.Serialization.dll.sources b/mcs/class/System.Runtime.Serialization/unityaot_System.Runtime.Serialization.dll.sources new file mode 100644 index 000000000000..6caafd411987 --- /dev/null +++ b/mcs/class/System.Runtime.Serialization/unityaot_System.Runtime.Serialization.dll.sources @@ -0,0 +1 @@ +#include mobile_System.Runtime.Serialization.dll.sources diff --git a/mcs/class/System.Runtime.Serialization/unityjit_System.Runtime.Serialization.dll.sources b/mcs/class/System.Runtime.Serialization/unityjit_System.Runtime.Serialization.dll.sources new file mode 100644 index 000000000000..5feabf388ccf --- /dev/null +++ b/mcs/class/System.Runtime.Serialization/unityjit_System.Runtime.Serialization.dll.sources @@ -0,0 +1 @@ +#include net_4_x_System.Runtime.Serialization.dll.sources diff --git a/mcs/class/System.ServiceModel.Internals/EventLogEntryType.cs b/mcs/class/System.ServiceModel.Internals/EventLogEntryType.cs index 74811394aa85..601f4574a999 100644 --- a/mcs/class/System.ServiceModel.Internals/EventLogEntryType.cs +++ b/mcs/class/System.ServiceModel.Internals/EventLogEntryType.cs @@ -41,7 +41,12 @@ build without adding this public API in System.dll. IF we brought this using System.Diagnostics; namespace System.Diagnostics { - public enum EventLogEntryType { +#if UNITY_AOT + internal +#else + public +#endif + enum EventLogEntryType { Error = 0x01, Warning = 0x02, Information = 0x04, diff --git a/mcs/class/System.ServiceModel.Web/unityaot_System.ServiceModel.Web.dll.sources b/mcs/class/System.ServiceModel.Web/unityaot_System.ServiceModel.Web.dll.sources new file mode 100644 index 000000000000..cbea0fae7b4f --- /dev/null +++ b/mcs/class/System.ServiceModel.Web/unityaot_System.ServiceModel.Web.dll.sources @@ -0,0 +1 @@ +#include mobile_System.ServiceModel.Web.dll.sources diff --git a/mcs/class/System.ServiceModel/Dummy_XM_4_5.cs b/mcs/class/System.ServiceModel/Dummy_XM_4_5.cs index 989c4dddc527..588ada68ccf6 100644 --- a/mcs/class/System.ServiceModel/Dummy_XM_4_5.cs +++ b/mcs/class/System.ServiceModel/Dummy_XM_4_5.cs @@ -126,7 +126,11 @@ internal EndpointDispatcher () namespace System.ServiceModel.Channels { +#if UNITY + static class UrlUtility { +#else public static class UrlUtility { +#endif public static string UrlEncode (string s, Encoding e) { return System.Runtime.UrlUtility.UrlEncode (s, e); diff --git a/mcs/class/System.ServiceModel/unityaot_System.ServiceModel.dll.sources b/mcs/class/System.ServiceModel/unityaot_System.ServiceModel.dll.sources new file mode 100644 index 000000000000..22ece5ce8cec --- /dev/null +++ b/mcs/class/System.ServiceModel/unityaot_System.ServiceModel.dll.sources @@ -0,0 +1 @@ +#include mobile_System.ServiceModel.dll.sources diff --git a/mcs/class/System.Web.Services/unityaot_System.Web.Services.dll.sources b/mcs/class/System.Web.Services/unityaot_System.Web.Services.dll.sources new file mode 100644 index 000000000000..9e39dcc73b13 --- /dev/null +++ b/mcs/class/System.Web.Services/unityaot_System.Web.Services.dll.sources @@ -0,0 +1 @@ +#include mobile_System.Web.Services.dll.sources diff --git a/mcs/class/System.XML/unityaot_System.Xml.dll.sources b/mcs/class/System.XML/unityaot_System.Xml.dll.sources new file mode 100644 index 000000000000..b6630930f75f --- /dev/null +++ b/mcs/class/System.XML/unityaot_System.Xml.dll.sources @@ -0,0 +1 @@ +#include mobile_System.Xml.dll.sources diff --git a/mcs/class/System/Mono.Util/MonoPInvokeCallbackAttribute.cs b/mcs/class/System/Mono.Util/MonoPInvokeCallbackAttribute.cs index 72acfed3d502..1e7130f58f8f 100644 --- a/mcs/class/System/Mono.Util/MonoPInvokeCallbackAttribute.cs +++ b/mcs/class/System/Mono.Util/MonoPInvokeCallbackAttribute.cs @@ -28,6 +28,7 @@ namespace Mono.Util { [Conditional("MONOTOUCH")] [Conditional("FULL_AOT_RUNTIME")] + [Conditional("UNITY")] [AttributeUsage (AttributeTargets.Method)] sealed class MonoPInvokeCallbackAttribute : Attribute { diff --git a/mcs/class/System/System.Net.Sockets/Socket.cs b/mcs/class/System/System.Net.Sockets/Socket.cs index fe7099144ec5..ef43e8198eec 100644 --- a/mcs/class/System/System.Net.Sockets/Socket.cs +++ b/mcs/class/System/System.Net.Sockets/Socket.cs @@ -2793,9 +2793,16 @@ internal static int FamilyHint { } } +#if UNITY + [MethodImplAttribute(MethodImplOptions.InternalCall)] + extern static bool IsProtocolSupported_internal(NetworkInterfaceComponent networkInterface); +#endif + static bool IsProtocolSupported (NetworkInterfaceComponent networkInterface) { -#if MOBILE +#if UNITY + return IsProtocolSupported_internal(networkInterface); +#elif MOBILE return true; #else var nics = NetworkInterface.GetAllNetworkInterfaces (); diff --git a/mcs/class/System/System.Net/ServicePointManager.extra.cs b/mcs/class/System/System.Net/ServicePointManager.extra.cs index d971cdd84124..1d2502e11df5 100644 --- a/mcs/class/System/System.Net/ServicePointManager.extra.cs +++ b/mcs/class/System/System.Net/ServicePointManager.extra.cs @@ -7,7 +7,7 @@ // Copyright 2013-2014 Xamarin Inc. // -#if MOBILE +#if MOBILE && !UNITY using System; using System.Collections.Generic; diff --git a/mcs/class/System/unityaot_System.dll.sources b/mcs/class/System/unityaot_System.dll.sources new file mode 100644 index 000000000000..9bd62cd0ec26 --- /dev/null +++ b/mcs/class/System/unityaot_System.dll.sources @@ -0,0 +1,4 @@ +#include mobile_System.dll.sources +../System.Web/System.Web/HttpUtility.cs +../System.Web/System.Web.Util/Helpers.cs +../System.Web/System.Web.Util/HttpEncoder.cs diff --git a/mcs/class/System/unityjit_System.dll.sources b/mcs/class/System/unityjit_System.dll.sources new file mode 100644 index 000000000000..beb6f2415cf1 --- /dev/null +++ b/mcs/class/System/unityjit_System.dll.sources @@ -0,0 +1 @@ +#include net_4_x_System.dll.sources diff --git a/mcs/class/corlib/Assembly/AssemblyInfo.cs b/mcs/class/corlib/Assembly/AssemblyInfo.cs index 54b21cdf3ba7..2d2de030429d 100644 --- a/mcs/class/corlib/Assembly/AssemblyInfo.cs +++ b/mcs/class/corlib/Assembly/AssemblyInfo.cs @@ -59,7 +59,7 @@ [assembly: CLSCompliant (true)] [assembly: AssemblyDelaySign (true)] -#if MOBILE +#if MOBILE && !UNITY_AOT [assembly: AssemblyKeyFile ("../silverlight.pub")] #else [assembly: AssemblyKeyFile ("../ecma.pub")] diff --git a/mcs/class/corlib/System.IO/MonoIO.cs b/mcs/class/corlib/System.IO/MonoIO.cs index 3567809b9da5..68418f794f37 100644 --- a/mcs/class/corlib/System.IO/MonoIO.cs +++ b/mcs/class/corlib/System.IO/MonoIO.cs @@ -733,6 +733,9 @@ public extern static char PathSeparator { [MethodImplAttribute (MethodImplOptions.InternalCall)] extern static void DumpHandles (); + + [MethodImplAttribute (MethodImplOptions.InternalCall)] + public extern static bool RemapPath (string path, out string newPath); } } diff --git a/mcs/class/corlib/System.IO/Path.cs b/mcs/class/corlib/System.IO/Path.cs index bf0093e1203e..8aaa49340d27 100644 --- a/mcs/class/corlib/System.IO/Path.cs +++ b/mcs/class/corlib/System.IO/Path.cs @@ -422,6 +422,9 @@ internal static string InsecureGetFullPath (string path) if (IsDirectorySeparator (end) && (path [path.Length - 1] != DirectorySeparatorChar)) path += DirectorySeparatorChar; + string newPath; + if (MonoIO.RemapPath(path, out newPath)) + path = newPath; return path; } diff --git a/mcs/class/referencesource/System/compmod/system/diagnostics/DiagnosticsConfiguration.cs b/mcs/class/referencesource/System/compmod/system/diagnostics/DiagnosticsConfiguration.cs index 5b5c81384b82..8bfb15ee1d38 100644 --- a/mcs/class/referencesource/System/compmod/system/diagnostics/DiagnosticsConfiguration.cs +++ b/mcs/class/referencesource/System/compmod/system/diagnostics/DiagnosticsConfiguration.cs @@ -168,8 +168,10 @@ internal static SystemDiagnosticsSection SystemDiagnosticsSection { } private static SystemDiagnosticsSection GetConfigSection() { - SystemDiagnosticsSection configSection = (SystemDiagnosticsSection) PrivilegedConfigurationManager.GetSection("system.diagnostics"); - return configSection; + object o = PrivilegedConfigurationManager.GetSection("system.diagnostics"); + if (o is SystemDiagnosticsSection) + return (SystemDiagnosticsSection)o; + return null; } internal static bool IsInitializing() { diff --git a/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs b/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs index 4fc2f7c2078c..10fb4ffe220c 100644 --- a/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs +++ b/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs @@ -230,7 +230,7 @@ public int ExitCode { get { EnsureState(State.Exited); #if MONO - if (exitCode == -1) + if (exitCode == -1 && !Environment.IsRunningOnWindows) throw new InvalidOperationException ("Cannot get the exit code from a non-child process on Unix"); #endif return exitCode; diff --git a/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/ProcessModuleCollection.cs b/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/ProcessModuleCollection.cs index 85d996b827a5..c774c51d173b 100644 --- a/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/ProcessModuleCollection.cs +++ b/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/ProcessModuleCollection.cs @@ -54,7 +54,7 @@ public void CopyTo(ProcessModule[] array, int index) { InnerList.CopyTo(array, index); } -#if MOBILE +#if MOBILE && !UNITY [Obsolete ("This API is no longer available", true)] public int Capacity { get { diff --git a/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/ProcessThreadCollection.cs b/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/ProcessThreadCollection.cs index 94fa2f43bbd1..80e77f748dd5 100644 --- a/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/ProcessThreadCollection.cs +++ b/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/ProcessThreadCollection.cs @@ -78,7 +78,7 @@ public void CopyTo(ProcessThread[] array, int index) { InnerList.CopyTo(array, index); } -#if MOBILE +#if MOBILE && !UNITY [Obsolete ("This API is no longer available", true)] public int Capacity { get { diff --git a/mcs/class/referencesource/mscorlib/system/reflection/binder.cs b/mcs/class/referencesource/mscorlib/system/reflection/binder.cs index 3d14d37f29c3..dd8d60f2f506 100644 --- a/mcs/class/referencesource/mscorlib/system/reflection/binder.cs +++ b/mcs/class/referencesource/mscorlib/system/reflection/binder.cs @@ -52,7 +52,7 @@ public abstract PropertyInfo SelectProperty(BindingFlags bindingAttr,PropertyInf public abstract void ReorderArgumentArray(ref Object[] args, Object state); -#if !FEATURE_COMINTEROP +#if !FEATURE_COMINTEROP && !UNITY // CanChangeType // This method checks whether the value can be converted into the property type. public virtual bool CanChangeType(Object value,Type type,CultureInfo culture) diff --git a/mcs/class/referencesource/mscorlib/system/threading/synchronizationcontext.cs b/mcs/class/referencesource/mscorlib/system/threading/synchronizationcontext.cs index 98e2f3fb73eb..4c5290eb74a0 100644 --- a/mcs/class/referencesource/mscorlib/system/threading/synchronizationcontext.cs +++ b/mcs/class/referencesource/mscorlib/system/threading/synchronizationcontext.cs @@ -252,7 +252,7 @@ public static void SetSynchronizationContext(SynchronizationContext syncContext) ec.SynchronizationContextNoFlow = syncContext; } -#if MOBILE_LEGACY +#if MOBILE_LEGACY && !UNITY_AOT [Obsolete("The method is not supported and will be removed")] public static void SetThreadStaticContext(SynchronizationContext syncContext) { diff --git a/mono/eglib/gdate-unity.c b/mono/eglib/gdate-unity.c new file mode 100644 index 000000000000..c25eda909206 --- /dev/null +++ b/mono/eglib/gdate-unity.c @@ -0,0 +1,8 @@ +#include +#include "Thread-c-api.h" + +void +g_usleep(gulong microseconds) +{ + UnityPalSleep(microseconds/1000); +} diff --git a/mono/eglib/gdir-unity.c b/mono/eglib/gdir-unity.c new file mode 100644 index 000000000000..a5a234137359 --- /dev/null +++ b/mono/eglib/gdir-unity.c @@ -0,0 +1,133 @@ +#include + +#include "Directory-c-api.h" +#include "Error-c-api.h" + +struct _GDir { + UnityPalFindHandle* handle; + gchar* current; + gchar* next; + const gchar* path_for_rewind; +}; + +static gboolean +setup_dir_handle(GDir*dir, const gchar* path, GError **error) +{ + gchar* path_search; + char* result_file_name = NULL; + gint unused_attributes; + UnityPalErrorCode result; + + dir->path_for_rewind = g_strdup (path); + path_search = g_malloc ((strlen(path) + 3)*sizeof(gchar)); + strcpy (path_search, path); +#ifdef G_OS_WIN32 + strcat (path_search, "\\*"); +#else + strcat (path_search, "/*"); +#endif + + dir->handle = UnityPalDirectoryFindHandleNew(path_search); + result = UnityPalDirectoryFindFirstFile(dir->handle, path_search, &result_file_name, &unused_attributes); + if (!UnityPalSuccess(result)) { + if (error) + *error = g_error_new (G_LOG_DOMAIN, g_file_error_from_errno (result), strerror (result)); + g_free (dir); + return FALSE; + } + + while ((strcmp (result_file_name, ".") == 0) || (strcmp (result_file_name, "..") == 0)) { + result = UnityPalDirectoryFindNextFile(dir->handle, &result_file_name, &unused_attributes); + if (!UnityPalSuccess(result)) { + result_file_name = NULL; + break; + } + } + + dir->current = NULL; + dir->next = result_file_name; + return TRUE; +} + +static void close_dir_handle(GDir* dir) +{ + UnityPalDirectoryCloseOSHandle(dir->handle); + UnityPalDirectoryFindHandleDelete(dir->handle); + dir->handle = 0; +} + +GDir * +g_dir_open (const gchar *path, guint flags, GError **error) +{ + GDir *dir; + + g_return_val_if_fail (path != NULL, NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + dir = g_new0 (GDir, 1); + + gboolean success = setup_dir_handle(dir, path, error); + if (!success) + return NULL; + + return dir; +} + +const gchar * +g_dir_read_name (GDir *dir) +{ + char* result_file_name; + gint unused_attributes; + UnityPalErrorCode result; + + g_return_val_if_fail (dir != NULL && dir->handle != 0, NULL); + + if (dir->current) + g_free (dir->current); + dir->current = NULL; + + dir->current = dir->next; + + if (!dir->current) + return NULL; + + dir->next = NULL; + + do { + result = UnityPalDirectoryFindNextFile(dir->handle, &result_file_name, &unused_attributes); + if (!UnityPalSuccess(result)) { + dir->next = NULL; + return dir->current; + } + } while ((strcmp (result_file_name, ".") == 0) || (strcmp (result_file_name, "..") == 0)); + + dir->next = result_file_name; + return dir->current; +} + +void +g_dir_rewind (GDir *dir) +{ + g_return_if_fail (dir != NULL && dir->handle != NULL); + + close_dir_handle(dir); + setup_dir_handle(dir, dir->path_for_rewind, NULL); +} + +void +g_dir_close (GDir *dir) +{ + g_return_if_fail (dir != NULL && dir->handle != 0); + + if (dir->current) + g_free (dir->current); + dir->current = NULL; + if (dir->next) + g_free (dir->next); + dir->next = NULL; + if (dir->path_for_rewind) + g_free(dir->path_for_rewind); + dir->path_for_rewind = NULL; + close_dir_handle(dir); + g_free (dir); +} diff --git a/mono/eglib/gfile-unity.c b/mono/eglib/gfile-unity.c new file mode 100644 index 000000000000..c7c6edf232f1 --- /dev/null +++ b/mono/eglib/gfile-unity.c @@ -0,0 +1,107 @@ +#include +#include +#include + +#include "File-c-api.h" +#include "Directory-c-api.h" + +gboolean +g_file_get_contents(const gchar *filename, gchar **contents, gsize *length, GError **error) +{ + gchar *str; + int palError; + UnityPalFileStat st; + long offset; + UnityPalFileHandle* handle = NULL; + int nread; + + handle = UnityPalOpen(filename, kFileModeOpen, 0, 0, 0, &palError); + if (handle == NULL) + { + if (error != NULL) + *error = g_error_new(G_LOG_DOMAIN, g_file_error_from_errno(palError), "Error opening file"); + return FALSE; + } + + if (UnityPalGetFileStat(filename, &st, &palError) == 0) + { + if (error != NULL) + *error = g_error_new(G_LOG_DOMAIN, g_file_error_from_errno(palError), "Error getting file attributes"); + UnityPalClose(handle, &palError); + return FALSE; + } + + str = g_malloc(st.length + 1); + offset = 0; + do + { + nread = UnityPalRead(handle, str + offset, st.length - offset, &palError); + if (nread > 0) + { + offset += nread; + } + } + while ((nread > 0 && offset < st.length) || (nread == -1 && errno == EINTR)); + + UnityPalClose(handle, &palError); + str[st.length] = '\0'; + if (length) + { + *length = st.length; + } + *contents = str; + return TRUE; +} + +gchar * +g_get_current_dir(void) +{ + int unused; + return UnityPalDirectoryGetCurrent(&unused); +} + +gboolean +g_file_test(const gchar *filename, GFileTest test) +{ + int palError = 0; + UnityPalFileAttributes attr; + + if (filename == NULL || test == 0) + return FALSE; + + attr = UnityPalGetFileAttributes(filename, &palError); + + if (palError != 0) + return FALSE; + + if ((test & G_FILE_TEST_EXISTS) != 0) + { + return TRUE; + } + + if ((test & G_FILE_TEST_IS_EXECUTABLE) != 0) + { + return UnityPalIsExecutable(filename) ? TRUE : FALSE; + } + + if ((test & G_FILE_TEST_IS_REGULAR) != 0) + { + if (attr & (kFileAttributeDevice | kFileAttributeDirectory)) + return FALSE; + return TRUE; + } + + if ((test & G_FILE_TEST_IS_DIR) != 0) + { + if (attr & kFileAttributeDirectory) + return TRUE; + } + + /* make this last in case it is OR'd with something else */ + if ((test & G_FILE_TEST_IS_SYMLINK) != 0) + { + return FALSE; + } + + return FALSE; +} diff --git a/mono/eglib/gmisc-unity.c b/mono/eglib/gmisc-unity.c new file mode 100644 index 000000000000..b1d32812e74a --- /dev/null +++ b/mono/eglib/gmisc-unity.c @@ -0,0 +1,77 @@ +#include +#include + +#include "Environment-c-api.h" +#include "Locale-c-api.h" +#include "Path-c-api.h" + +gboolean +g_hasenv(const gchar *variable) +{ + return g_getenv(variable) != NULL; +} + +gchar * +g_getenv(const gchar *variable) +{ + return UnityPalGetEnvironmentVariable(variable); +} + +gboolean +g_setenv(const gchar *variable, const gchar *value, gboolean overwrite) +{ + // This method assumes overwrite is always true. + UnityPalSetEnvironmentVariable(variable, value); + + // No code in Mono actually checks the return value. + return TRUE; +} + +void +g_unsetenv(const gchar *variable) +{ + UnityPalSetEnvironmentVariable(variable, ""); +} + +static gboolean locale_initialized = FALSE; + +gchar* +g_win32_getlocale(void) +{ + if (locale_initialized == FALSE) + { + UnityPalLocaleInitialize(); + locale_initialized = TRUE; + } + + return UnityPalGetLocale(); +} + +gboolean +g_path_is_absolute(const char *filename) +{ + return UnityPalIsAbsolutePath(filename); +} + +const gchar * +g_get_home_dir(void) +{ + return UnityPalGetHomeDirectory(); +} + +const char * +g_get_user_name(void) +{ + return UnityPalGetOsUserName(); +} + +static const char *tmp_dir; + +const gchar * +g_get_tmp_dir(void) +{ + if (tmp_dir == NULL) + tmp_dir = UnityPalGetTempPath(); + + return tmp_dir; +} diff --git a/mono/metadata/Makefile.am b/mono/metadata/Makefile.am index 3c6ed9960c5c..056188e53400 100644 --- a/mono/metadata/Makefile.am +++ b/mono/metadata/Makefile.am @@ -89,13 +89,24 @@ endif boehm_libraries = $(shared_boehm_libraries) libmonoruntime-static.la endif +if SUPPORT_BDWGC if DISABLE_EXECUTABLES -noinst_LTLIBRARIES = libmonoruntime-config.la $(shared_sgen_libraries) $(shared_boehm_libraries) +shared_bdwgc_libraries = libmonoruntimebdwgc.la else -noinst_LTLIBRARIES = libmonoruntime-config.la $(boehm_libraries) $(sgen_libraries) +if SHARED_MONO +shared_bdwgc_libraries = libmonoruntimebdwgc.la +endif +endif +bdwgc_libraries = $(shared_bdwgc_libraries) libmonoruntimebdwgc-static.la endif -AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/mono $(LIBGC_CPPFLAGS) $(GLIB_CFLAGS) $(SHARED_CFLAGS) +if DISABLE_EXECUTABLES +noinst_LTLIBRARIES = libmonoruntime-config.la $(shared_sgen_libraries) $(shared_boehm_libraries) $(shared_bdwgc_libraries) +else +noinst_LTLIBRARIES = libmonoruntime-config.la $(boehm_libraries) $(sgen_libraries) $(bdwgc_libraries) +endif + +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/mono $(GLIB_CFLAGS) $(SHARED_CFLAGS) # # Make sure any prefix changes are updated in the binaries too. @@ -125,8 +136,15 @@ null_gc_sources = \ null-gc-handles.h \ null-gc-handles.c +unity_sources = \ + unity-memory-info.c \ + unity-memory-info.h \ + unity-utils.c \ + unity-utils.h + common_sources = \ $(platform_sources) \ + $(unity_sources) \ appdomain.c \ domain.c \ appdomain-icalls.h \ @@ -295,6 +313,9 @@ gc_dependent_sources = \ gc.c \ monitor.c +unity_gc_dependent_sources = \ + unity-liveness.c + boehm_sources = \ boehm-gc.c @@ -311,19 +332,28 @@ sgen_sources = \ sgen-mono.c \ sgen-client-mono.h -libmonoruntime_la_SOURCES = $(common_sources) $(gc_dependent_sources) $(null_gc_sources) $(boehm_sources) -libmonoruntime_la_CFLAGS = $(BOEHM_DEFINES) +libmonoruntime_la_SOURCES = $(common_sources) $(gc_dependent_sources) $(unity_gc_dependent_sources) $(null_gc_sources) $(boehm_sources) +libmonoruntime_la_CFLAGS = $(BOEHM_DEFINES) $(LIBGC_CPPFLAGS) libmonoruntime_la_LIBADD = libmonoruntime-config.la -libmonoruntimesgen_la_SOURCES = $(common_sources) $(gc_dependent_sources) $(sgen_sources) +libmonoruntimebdwgc_la_SOURCES = $(common_sources) $(gc_dependent_sources) $(unity_gc_dependent_sources) $(null_gc_sources) $(boehm_sources) +libmonoruntimebdwgc_la_CFLAGS = $(BDWGC_DEFINES) $(LIBGCBDWGC_CPPFLAGS) +libmonoruntimebdwgc_la_LIBADD = libmonoruntime-config.la $(btls_libs) + +libmonoruntimesgen_la_SOURCES = $(common_sources) $(gc_dependent_sources) $(unity_gc_dependent_sources) $(sgen_sources) libmonoruntimesgen_la_CFLAGS = $(SGEN_DEFINES) libmonoruntimesgen_la_LIBADD = libmonoruntime-config.la libmonoruntime_static_la_SOURCES = $(libmonoruntime_la_SOURCES) libmonoruntime_static_la_LDFLAGS = -static -libmonoruntime_static_la_CFLAGS = $(BOEHM_DEFINES) +libmonoruntime_static_la_CFLAGS = $(BOEHM_DEFINES) $(LIBGC_CPPFLAGS) libmonoruntime_static_la_LIBADD = $(bundle_obj) libmonoruntime-config.la +libmonoruntimebdwgc_static_la_SOURCES = $(libmonoruntimebdwgc_la_SOURCES) +libmonoruntimebdwgc_static_la_LDFLAGS = -static +libmonoruntimebdwgc_static_la_CFLAGS = $(BDWGC_DEFINES) $(LIBGCBDWGC_CPPFLAGS) +libmonoruntimebdwgc_static_la_LIBADD = $(bundle_obj) libmonoruntime-config.la $(btls_static_libs) + libmonoruntimesgen_static_la_SOURCES = $(libmonoruntimesgen_la_SOURCES) libmonoruntimesgen_static_la_LDFLAGS = -static libmonoruntimesgen_static_la_CFLAGS = $(SGEN_DEFINES) diff --git a/mono/metadata/assembly.c b/mono/metadata/assembly.c index 4d4409d96561..b681385be67a 100644 --- a/mono/metadata/assembly.c +++ b/mono/metadata/assembly.c @@ -441,6 +441,56 @@ mono_set_assemblies_path (const char* path) } } +/** +* mono_set_assemblies_path_null_separated: +* @path: list of paths that contain directories where Mono will look for assemblies +* +* Use this method to override the standard assembly lookup system and +* override any assemblies coming from the GAC. This is the method +* that supports the MONO_PATH variable. +* +* Notice that MONO_PATH and this method are really a very bad idea as +* it prevents the GAC from working and it prevents the standard +* resolution mechanisms from working. Nonetheless, for some debugging +* situations and bootstrapping setups, this is useful to have. +*/ +void +mono_set_assemblies_path_null_separated(const char* path) +{ + char **dest; + + int numPaths = 0; + char* path_count_ptr = path; + while (*path_count_ptr) + { + path_count_ptr += strlen(path_count_ptr) + 1; + numPaths++; + } + dest = g_new(char**, sizeof(char*) * (numPaths + 1)); + + if (assemblies_path) + g_strfreev(assemblies_path); + assemblies_path = dest; + char* current_path = path; + while (*current_path) + { + *dest++ = mono_path_canonicalize(current_path); + current_path += strlen(current_path) + 1; + } + *dest = NULL; + + if (g_getenv("MONO_DEBUG") == NULL) + return; + + char** print_assembly_str = assemblies_path; + while (*print_assembly_str) { + if (**print_assembly_str && !g_file_test(*print_assembly_str, G_FILE_TEST_IS_DIR)) + g_warning("'%s' in MONO_PATH doesn't exist or has wrong permissions.", *print_assembly_str); + + print_assembly_str++; + } +} + static void check_path_env (void) { @@ -777,7 +827,7 @@ compute_base (char *path) return NULL; /* Not a well known Mono executable, we are embedded, cant guess the base */ - if (strcmp (p, "/mono") && strcmp (p, "/mono-boehm") && strcmp (p, "/mono-sgen") && strcmp (p, "/pedump") && strcmp (p, "/monodis")) + if (strcmp (p, "/mono") && strcmp (p, "/mono-boehm") && strcmp (p, "/mono-bdwgc") && strcmp (p, "/mono-sgen") && strcmp (p, "/pedump") && strcmp (p, "/monodis")) return NULL; *p = 0; @@ -785,7 +835,7 @@ compute_base (char *path) if (p == NULL) return NULL; - if (strcmp (p, "/bin") != 0) + if (strstr (p, "/bin") == 0) return NULL; *p = 0; return path; diff --git a/mono/metadata/assembly.h b/mono/metadata/assembly.h index 1a6f35198406..a34b5ed6c0e7 100644 --- a/mono/metadata/assembly.h +++ b/mono/metadata/assembly.h @@ -114,6 +114,7 @@ MONO_API void mono_register_machine_config (const char *config_xml); MONO_API void mono_set_rootdir (void); MONO_API void mono_set_dirs (const char *assembly_dir, const char *config_dir); MONO_API void mono_set_assemblies_path (const char* path); +MONO_API void mono_set_assemblies_path_null_separated(const char* path); MONO_END_DECLS #endif diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index 2bc3052ae690..f312607de343 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -250,7 +250,11 @@ mono_gc_base_init (void) mono_thread_info_attach (); +#ifdef HAVE_BDWGC_GC + GC_set_on_event (on_gc_notification); +#else GC_set_on_collection_event (on_gc_notification); +#endif GC_on_heap_resize = on_gc_heap_resize; gc_initialized = TRUE; @@ -393,6 +397,14 @@ mono_gc_thread_attach (MonoThreadInfo* info) return info; } +void +mono_gc_thread_detach (MonoThreadInfo *p) +{ +#if HAVE_BDWGC_GC + GC_unregister_my_thread (); +#endif +} + void mono_gc_thread_detach_with_lock (MonoThreadInfo *p) { @@ -486,7 +498,7 @@ on_gc_notification (GC_EventType event) } #endif UnlockedAdd64 (&gc_stats.major_gc_time, mono_100ns_ticks () - gc_start_time); - mono_trace_message (MONO_TRACE_GC, "gc took %" G_GINT64_FORMAT " usecs", (mono_100ns_ticks () - gc_start_time) / 10); +// mono_trace_message (MONO_TRACE_GC, "gc took %" G_GINT64_FORMAT " usecs", (mono_100ns_ticks () - gc_start_time) / 10); break; default: break; @@ -965,6 +977,10 @@ create_allocator (int atype, int tls_key, gboolean slowpath) g_assert_not_reached (); +#ifdef HAVE_BDWGC_GC + return NULL; +#else + if (atype == ATYPE_FREEPTR) { name = slowpath ? "SlowAllocPtrfree" : "AllocPtrfree"; } else if (atype == ATYPE_FREEPTR_FOR_BOX) { @@ -1176,6 +1192,7 @@ create_allocator (int atype, int tls_key, gboolean slowpath) mono_mb_free (mb); return res; +#endif } static MonoMethod* alloc_method_cache [ATYPE_NUM]; @@ -1211,6 +1228,7 @@ mono_gc_get_managed_allocator (MonoClass *klass, gboolean for_box, gboolean know */ return NULL; +#if 0 if (!SMALL_ENOUGH (klass->instance_size)) return NULL; if (mono_class_has_finalizer (klass) || mono_class_is_marshalbyref (klass)) @@ -1242,6 +1260,7 @@ mono_gc_get_managed_allocator (MonoClass *klass, gboolean for_box, gboolean know */ } return mono_gc_get_managed_allocator_by_type (atype, MANAGED_ALLOCATOR_REGULAR); +#endif } MonoMethod* @@ -1363,7 +1382,7 @@ mono_gc_invoke_with_gc_lock (MonoGCLockedCallbackFunc func, void *data) char* mono_gc_get_description (void) { - return g_strdup (DEFAULT_GC_NAME); + return g_strdup ("BDWGC"); } void @@ -1501,7 +1520,9 @@ mono_gc_pthread_create (pthread_t *new_thread, const pthread_attr_t *attr, void #ifdef HOST_WIN32 BOOL APIENTRY mono_gc_dllmain (HMODULE module_handle, DWORD reason, LPVOID reserved) { +#ifdef GC_INSIDE_DLL return GC_DllMain (module_handle, reason, reserved); +#endif } #endif @@ -1524,7 +1545,9 @@ mono_gc_get_vtable_bits (MonoClass *klass) void mono_gc_register_altstack (gpointer stack, gint32 stack_size, gpointer altstack, gint32 altstack_size) { +#if !HAVE_BDWGC_GC GC_register_altstack (stack, stack_size, altstack, altstack_size); +#endif } int @@ -1563,14 +1586,22 @@ mono_gc_make_root_descr_user (MonoGCRootMarkFunc marker) void mono_gc_toggleref_add (MonoObject *object, mono_bool strong_ref) { +#ifndef HAVE_BDWGC_GC if (GC_toggleref_add ((GC_PTR)object, (int)strong_ref) != GC_SUCCESS) g_error ("GC_toggleref_add failed\n"); +#else + g_assert_not_reached (); +#endif } void mono_gc_toggleref_register_callback (MonoToggleRefStatus (*proccess_toggleref) (MonoObject *obj)) { +#ifndef HAVE_BDWGC_GC GC_set_toggleref_func ((GC_ToggleRefStatus (*) (GC_PTR obj)) proccess_toggleref); +#else + g_assert_not_reached (); +#endif } /* Test support code */ @@ -1619,7 +1650,11 @@ mono_gc_register_finalizer_callbacks (MonoGCFinalizerCallbacks *callbacks) fin_callbacks = *callbacks; +#ifndef HAVE_BDWGC_GC GC_set_await_finalize_proc ((void (*) (GC_PTR))fin_notifier); +#else + g_assert_not_reached (); +#endif } #define BITMAP_SIZE (sizeof (*((HandleData *)NULL)->bitmap) * CHAR_BIT) diff --git a/mono/metadata/class-internals.h b/mono/metadata/class-internals.h index a789b2089651..441b67777d12 100644 --- a/mono/metadata/class-internals.h +++ b/mono/metadata/class-internals.h @@ -75,6 +75,10 @@ struct _MonoMethod { MonoMethodSignature *signature; /* name is useful mostly for debugging */ const char *name; +#ifdef IL2CPP_ON_MONO + void* method_pointer; + void* invoke_pointer; +#endif /* this is used by the inlining algorithm */ unsigned int inline_info:1; unsigned int inline_failure:1; @@ -380,6 +384,8 @@ struct _MonoClass { /* Infrequently used items. See class-accessors.c: InfrequentDataKind for what goes into here. */ MonoPropertyBag infrequent_data; + + void *unity_user_data; }; typedef struct { @@ -1259,7 +1265,7 @@ mono_class_set_type_load_failure (MonoClass *klass, const char * fmt, ...) MONO_ MonoException* mono_class_get_exception_for_failure (MonoClass *klass); -char* +UNITY_MONO_API char* mono_type_get_name_full (MonoType *type, MonoTypeNameFormat format); char* diff --git a/mono/metadata/class.c b/mono/metadata/class.c index ce2e1532faf2..3107638466fd 100644 --- a/mono/metadata/class.c +++ b/mono/metadata/class.c @@ -54,6 +54,7 @@ MonoStats mono_stats; gboolean mono_print_vtable = FALSE; gboolean mono_align_small_structs = FALSE; +extern gboolean mono_allow_gc_aware_layout; /* Statistics */ gint32 inflated_classes_size, inflated_methods_size; @@ -1840,9 +1841,14 @@ mono_class_layout_fields (MonoClass *klass, int base_instance_size, int packing_ * what the default is for other runtimes. */ /* corlib is missing [StructLayout] directives in many places */ - if (layout == TYPE_ATTRIBUTE_AUTO_LAYOUT) { + if (mono_allow_gc_aware_layout && (layout == TYPE_ATTRIBUTE_AUTO_LAYOUT)) { if (!klass->valuetype) gc_aware_layout = TRUE; + /* Unity depends on List`1 layout in native code */ + if (klass->image == mono_defaults.corlib && + strcmp (klass->name_space, "System.Collections.Generic") == 0 && + strcmp (klass->name, "List`1") == 0) + gc_aware_layout = FALSE; } /* Compute klass->blittable */ diff --git a/mono/metadata/cominterop.c b/mono/metadata/cominterop.c index 1caa6ca0f992..ed3964dbc5be 100644 --- a/mono/metadata/cominterop.c +++ b/mono/metadata/cominterop.c @@ -1692,17 +1692,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_GetCCW (MonoObject* object, Mon #endif } - -MonoBoolean -ves_icall_System_Runtime_InteropServices_Marshal_IsComObject (MonoObject* object) -{ -#ifndef DISABLE_COM - return (MonoBoolean)cominterop_object_is_rcw (object); -#else - g_assert_not_reached (); -#endif -} - gint32 ves_icall_System_Runtime_InteropServices_Marshal_ReleaseComObjectInternal (MonoObject* object) { @@ -3688,6 +3677,16 @@ ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (gpointe #endif /* DISABLE_COM */ +MonoBoolean +ves_icall_System_Runtime_InteropServices_Marshal_IsComObject (MonoObject* object) +{ +#ifndef DISABLE_COM + return (MonoBoolean)cominterop_object_is_rcw (object); +#else + return FALSE; +#endif +} + MonoString * ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringBSTR (gpointer ptr) { diff --git a/mono/metadata/console-unity.c b/mono/metadata/console-unity.c new file mode 100644 index 000000000000..97376f4c95ad --- /dev/null +++ b/mono/metadata/console-unity.c @@ -0,0 +1,47 @@ +#include +#include "Console-c-api.h" +#include "File-c-api.h" /* required for IAtty */ + +#if defined(PLATFORM_UNITY) + +void +mono_console_init (void) +{ +} + +void +mono_console_handle_async_ops (void) +{ +} + +MonoBoolean +ves_icall_System_ConsoleDriver_Isatty (gpointer handle) +{ + return UnityPalIsatty(handle); +} + +MonoBoolean +ves_icall_System_ConsoleDriver_SetEcho (MonoBoolean want_echo) +{ + return UnityPalConsoleSetEcho(want_echo); +} + +MonoBoolean +ves_icall_System_ConsoleDriver_SetBreak (MonoBoolean want_break) +{ + return UnityPalConsoleSetBreak(want_break); +} + +gint32 +ves_icall_System_ConsoleDriver_InternalKeyAvailable (gint32 timeout) +{ + return UnityPalConsoleInternalKeyAvailable(timeout); +} + +MonoBoolean +ves_icall_System_ConsoleDriver_TtySetup (MonoString *keypad, MonoString *teardown, MonoArray **control_chars, int **size) +{ + return UnityPalConsoleTtySetup(keypad, teardown, control_chars, size); +} + +#endif /* PLATFORM_UNITY */ diff --git a/mono/metadata/domain-internals.h b/mono/metadata/domain-internals.h index 6d8042c07680..a55277ff94eb 100644 --- a/mono/metadata/domain-internals.h +++ b/mono/metadata/domain-internals.h @@ -577,7 +577,7 @@ mono_runtime_get_no_exec (void); void mono_domain_parse_assembly_bindings (MonoDomain *domain, int amajor, int aminor, gchar *domain_config_file_name); -gboolean +UNITY_MONO_API gboolean mono_assembly_name_parse (const char *name, MonoAssemblyName *aname); MonoImage *mono_assembly_open_from_bundle (const char *filename, diff --git a/mono/metadata/file-mmap-unity.c b/mono/metadata/file-mmap-unity.c new file mode 100644 index 000000000000..e1956e7cade7 --- /dev/null +++ b/mono/metadata/file-mmap-unity.c @@ -0,0 +1,115 @@ + +#include +#include + +#include +#include "MemoryMappedFile-c-api.h" +#include "File-c-api.h" + +typedef struct { + void *address; + size_t length; +} MmapInstance; + +enum { + BAD_CAPACITY_FOR_FILE_BACKED = 1, + CAPACITY_SMALLER_THAN_FILE_SIZE, + FILE_NOT_FOUND, + FILE_ALREADY_EXISTS, + PATH_TOO_LONG, + COULD_NOT_OPEN, + CAPACITY_MUST_BE_POSITIVE, + INVALID_FILE_MODE, + COULD_NOT_MAP_MEMORY, + ACCESS_DENIED, + CAPACITY_LARGER_THAN_LOGICAL_ADDRESS_SPACE +}; + +#ifndef HOST_WIN32 + +typedef struct { + int kind; + int ref_count; + size_t capacity; + char *name; + int fd; +} MmapHandle; + +#endif + +void mono_mmap_close (void *mmap_handle) +{ + /* Not Supported in UnityPAL */ + g_assert_not_reached(); +} + +void mono_mmap_configure_inheritability (void *mmap_handle, gboolean inheritability) +{ + /* Not Supported in UnityPAL */ + g_assert_not_reached(); +} + +void mono_mmap_flush (void *mmap_handle) +{ + /* Not Supported in UnityPAL */ + g_assert_not_reached(); +} + +void *mono_mmap_open_file (MonoString *string, int mode, MonoString *mapName, gint64 *capacity, int access, int options, int *error) +{ + /* Not Supported in UnityPAL */ + g_assert_not_reached(); + return NULL; +} + +void *mono_mmap_open_handle (void *handle, MonoString *mapName, gint64 *capacity, int access, int options, int *error) +{ + /* Not Supported in UnityPAL */ + g_assert_not_reached(); + return NULL; +} + +int mono_mmap_map (void *handle, gint64 offset, gint64 *size, int access, void **mmap_handle, void **base_address) +{ + /* We are dropping access parameter, UnityPAL does not support */ + g_assert (handle); + + MmapInstance *h = g_malloc0 (sizeof (MmapInstance)); + h->length = *size; + + #ifdef HOST_WIN32 + h->address = UnityPalMemoryMappedFileMapWithParams((UnityPalFileHandle*) handle, (size_t) *size, (size_t) offset); + #else + MmapHandle *fh = (MmapHandle *)handle; + h->address = UnityPalMemoryMappedFileMapWithFileDescriptor(fh->fd, (size_t) *size, (size_t) offset); + #endif + + if (h->address) + { + *mmap_handle = h; + *base_address = (char*) h->address + offset; + return 0; + } + else + { + g_free (h); + return COULD_NOT_MAP_MEMORY; + } +} + +gboolean +mono_mmap_unmap (void *mmap_handle) +{ + g_assert (mmap_handle); + + MmapInstance *h = (MmapInstance *)mmap_handle; + + UnityPalMemoryMappedFileUnmapWithParams(h->address, h->length); + + g_free (h); + + /* UnityPAL does not give any indication of success or failure of an unmap, forced + to always return true */ + + return TRUE; +} diff --git a/mono/metadata/gc-internals.h b/mono/metadata/gc-internals.h index d87746dee363..cc137bdb3dcb 100644 --- a/mono/metadata/gc-internals.h +++ b/mono/metadata/gc-internals.h @@ -125,7 +125,7 @@ void* mono_gc_alloc_fixed (size_t size, MonoGCDescriptor descr, MonoG void mono_gc_free_fixed (void* addr); /* make sure the gchandle was allocated for an object in domain */ -gboolean mono_gchandle_is_in_domain (guint32 gchandle, MonoDomain *domain); +UNITY_MONO_API gboolean mono_gchandle_is_in_domain (guint32 gchandle, MonoDomain *domain); void mono_gchandle_free_domain (MonoDomain *domain); typedef void (*FinalizerThreadCallback) (gpointer user_data); @@ -354,6 +354,7 @@ gboolean mono_gc_is_critical_method (MonoMethod *method); gpointer mono_gc_thread_attach (THREAD_INFO_TYPE *info); +void mono_gc_thread_detach (THREAD_INFO_TYPE *info); void mono_gc_thread_detach_with_lock (THREAD_INFO_TYPE *info); gboolean mono_gc_thread_in_critical_region (THREAD_INFO_TYPE *info); diff --git a/mono/metadata/handle.h b/mono/metadata/handle.h index 10cc400f5101..96f1f9bf4b4b 100644 --- a/mono/metadata/handle.h +++ b/mono/metadata/handle.h @@ -286,6 +286,15 @@ mono_thread_info_push_stack_mark (MonoThreadInfo *info, void *mark) return __ret; \ } while (0); } while (0) +#define ICALL_RETURN_OBJ_TYPED(HANDLE,TYPE) \ + do { \ + CLEAR_STACK_WATERMARK \ + CLEAR_ICALL_COMMON \ + void* __ret = (HANDLE == NULL_HANDLE) ? NULL : MONO_HANDLE_RAW (HANDLE); \ + CLEAR_ICALL_FRAME \ + return (TYPE)__ret; \ + } while (0); } while (0) + /* Handle macros/functions */ @@ -507,7 +516,7 @@ uintptr_t mono_array_handle_length (MonoArrayHandle arr); static inline void mono_handle_array_getref (MonoObjectHandleOut dest, MonoArrayHandle array, uintptr_t index) { - MONO_HANDLE_SUPPRESS (mono_gc_wbarrier_generic_store (&dest->__raw, mono_array_get (MONO_HANDLE_RAW (array),gpointer, index))); + MONO_HANDLE_SUPPRESS (mono_gc_wbarrier_generic_store (&dest->__raw, mono_array_get (MONO_HANDLE_RAW (array),MonoObject*, index))); } #define mono_handle_class(o) MONO_HANDLE_SUPPRESS (mono_object_class (MONO_HANDLE_RAW (MONO_HANDLE_UNSUPPRESS (o)))) diff --git a/mono/metadata/icall-def.h b/mono/metadata/icall-def.h index 191e3aecf4c4..fe90a9b906b9 100644 --- a/mono/metadata/icall-def.h +++ b/mono/metadata/icall-def.h @@ -380,6 +380,7 @@ ICALL(MONOIO_15, "MoveFile(char*,char*,System.IO.MonoIOError&)", ves_icall_Syste #endif /* !PLATFORM_RO_FS */ ICALL(MONOIO_16, "Open(char*,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,System.IO.FileOptions,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Open) HANDLES(ICALL(MONOIO_17, "Read(intptr,byte[],int,int,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Read)) +ICALL(MONOIO_39, "RemapPath(string,string&)", ves_icall_System_IO_MonoIO_RemapPath) #ifndef PLATFORM_RO_FS ICALL(MONOIO_18, "RemoveDirectory(char*,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_RemoveDirectory) ICALL(MONOIO_18M, "ReplaceFile(char*,char*,char*,bool,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_ReplaceFile) @@ -460,6 +461,7 @@ HANDLES(ICALL(SOCK_6b, "Duplicate_internal", ves_icall_System_Net_Sockets_Socket HANDLES(ICALL(SOCK_7, "GetSocketOption_arr_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,byte[]&,int&)", ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal)) HANDLES(ICALL(SOCK_8, "GetSocketOption_obj_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,object&,int&)", ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal)) HANDLES(ICALL(SOCK_21, "IOControl_internal(intptr,int,byte[],byte[],int&)", ves_icall_System_Net_Sockets_Socket_IOControl_internal)) +ICALL(SOCK_22, "IsProtocolSupported_internal", ves_icall_System_Net_Sockets_Socket_IsProtocolSupported_internal) HANDLES(ICALL(SOCK_9, "Listen_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_Listen_internal)) HANDLES(ICALL(SOCK_10, "LocalEndPoint_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal)) HANDLES(ICALL(SOCK_11, "Poll_internal", ves_icall_System_Net_Sockets_Socket_Poll_internal)) @@ -693,8 +695,8 @@ ICALL(MARSHAL_11, "GetLastWin32Error", ves_icall_System_Runtime_InteropServices_ ICALL(MARSHAL_53, "GetNativeActivationFactory", ves_icall_System_Runtime_InteropServices_Marshal_GetNativeActivationFactory) ICALL(MARSHAL_47, "GetObjectForCCW", ves_icall_System_Runtime_InteropServices_Marshal_GetObjectForCCW) ICALL(MARSHAL_54, "GetRawIUnknownForComObjectNoAddRef", ves_icall_System_Runtime_InteropServices_Marshal_GetRawIUnknownForComObjectNoAddRef) -ICALL(MARSHAL_48, "IsComObject", ves_icall_System_Runtime_InteropServices_Marshal_IsComObject) #endif +ICALL(MARSHAL_48, "IsComObject", ves_icall_System_Runtime_InteropServices_Marshal_IsComObject) HANDLES(ICALL(MARSHAL_12, "OffsetOf", ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf)) HANDLES(ICALL(MARSHAL_13, "Prelink", ves_icall_System_Runtime_InteropServices_Marshal_Prelink)) HANDLES(ICALL(MARSHAL_14, "PrelinkAll", ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll)) @@ -754,6 +756,9 @@ ICALL_TYPE(REMSER, "System.Runtime.Remoting.RemotingServices", REMSER_0) HANDLES(ICALL(REMSER_0, "GetVirtualMethod", ves_icall_Remoting_RemotingServices_GetVirtualMethod)) ICALL(REMSER_1, "InternalExecute", ves_icall_InternalExecute) HANDLES(ICALL(REMSER_2, "IsTransparentProxy", ves_icall_IsTransparentProxy)) +#else +ICALL_TYPE(REMSER, "System.Runtime.Remoting.RemotingServices", REMSER_0) +ICALL(REMSER_0, "IsTransparentProxy", ves_icall_IsTransparentProxy) #endif ICALL_TYPE(RVH, "System.Runtime.Versioning.VersioningHelper", RVH_1) diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c index 1e5dd43e6ce5..4bdcc5c3f7df 100644 --- a/mono/metadata/icall.c +++ b/mono/metadata/icall.c @@ -85,6 +85,7 @@ #include #include #include +#include #include #include #include @@ -7050,6 +7051,12 @@ ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation (Mo g_assert_not_reached (); } +ICALL_EXPORT MonoBoolean +ves_icall_IsTransparentProxy (MonoObject *proxy) +{ + return 0; +} + #endif ICALL_EXPORT MonoObjectHandle diff --git a/mono/metadata/il2cpp-compat-metadata.h b/mono/metadata/il2cpp-compat-metadata.h new file mode 100644 index 000000000000..ef369959ef9d --- /dev/null +++ b/mono/metadata/il2cpp-compat-metadata.h @@ -0,0 +1,36 @@ +#pragma once + +#ifdef IL2CPP_MONO_DEBUGGER + +#include +#include + +#if defined(_POSIX_VERSION) +#include +#endif + +#define mono_gc_make_root_descr_all_refs il2cpp_mono_gc_make_root_descr_all_refs +#define mono_gc_alloc_fixed il2cpp_mono_gc_alloc_fixed +#define mono_gc_free_fixed il2cpp_gc_free_fixed +#define mono_gc_is_moving il2cpp_mono_gc_is_moving +#define mono_gc_invoke_with_gc_lock il2cpp_mono_gc_invoke_with_gc_lock +#define mono_gc_pthread_create il2cpp_mono_gc_pthread_create +#define mono_gc_register_root_wbarrier il2cpp_mono_gc_register_root_wbarrier +#define mono_gc_wbarrier_generic_store il2cpp_mono_gc_wbarrier_generic_store +#define mono_gc_make_vector_descr il2cpp_mono_gc_make_vector_descr +#define mono_gc_deregister_root il2cpp_mono_gc_deregister_root + +int il2cpp_mono_gc_register_root_wbarrier (char *start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, const char *msg); +SgenDescriptor il2cpp_mono_gc_make_root_descr_all_refs(int numbits); +MonoGCDescriptor il2cpp_mono_gc_make_vector_descr (void); +void* il2cpp_mono_gc_alloc_fixed (size_t size, void* descr, MonoGCRootSource source, const char *msg); +gboolean il2cpp_mono_gc_is_moving(); + +typedef void* (*MonoGCLockedCallbackFunc) (void *data); +void* il2cpp_mono_gc_invoke_with_gc_lock (MonoGCLockedCallbackFunc func, void *data); + +#ifndef HOST_WIN32 +int il2cpp_mono_gc_pthread_create (pthread_t *new_thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg); +#endif + +#endif \ No newline at end of file diff --git a/mono/metadata/image.c b/mono/metadata/image.c index 31f5d237c60e..69b2105ec270 100644 --- a/mono/metadata/image.c +++ b/mono/metadata/image.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #ifdef HAVE_UNISTD_H @@ -1360,6 +1361,8 @@ do_mono_image_open (const char *fname, MonoImageOpenStatus *status, MonoImage *image; MonoFileMap *filed; + gboolean remapped = mono_unity_file_remap_path(&fname); + if ((filed = mono_file_map_open (fname)) == NULL){ if (IS_PORTABILITY_SET) { gchar *ffname = mono_portability_find_file (fname, TRUE); @@ -1372,6 +1375,8 @@ do_mono_image_open (const char *fname, MonoImageOpenStatus *status, if (filed == NULL) { if (status) *status = MONO_IMAGE_ERROR_ERRNO; + if (remapped) + g_free((void*)fname); return NULL; } } @@ -1391,6 +1396,8 @@ do_mono_image_open (const char *fname, MonoImageOpenStatus *status, g_free (image); if (status) *status = MONO_IMAGE_IMAGE_INVALID; + if (remapped) + g_free((void*)fname); return NULL; } iinfo = g_new0 (MonoCLIImageInfo, 1); @@ -1404,6 +1411,8 @@ do_mono_image_open (const char *fname, MonoImageOpenStatus *status, image->core_clr_platform_code = mono_security_core_clr_determine_platform_image (image); mono_file_map_close (filed); + if (remapped) + g_free((void*)fname); return do_mono_image_load (image, status, care_about_cli, care_about_pecoff); } diff --git a/mono/metadata/loader.c b/mono/metadata/loader.c index ce18373fd29d..258cda1d3aa6 100644 --- a/mono/metadata/loader.c +++ b/mono/metadata/loader.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -1117,18 +1118,23 @@ cached_module_load (const char *name, int flags, char **err) if (err) *err = NULL; + gboolean remapped = mono_unity_file_remap_path(&name); global_loader_data_lock (); if (!global_module_map) global_module_map = g_hash_table_new (g_str_hash, g_str_equal); res = (MonoDl *)g_hash_table_lookup (global_module_map, name); if (res) { global_loader_data_unlock (); + if (remapped) + g_free((void*)name); return res; } res = mono_dl_open (name, flags, err); if (res) g_hash_table_insert (global_module_map, g_strdup (name), res); global_loader_data_unlock (); + if (remapped) + g_free((void*)name); return res; } diff --git a/mono/metadata/metadata.c b/mono/metadata/metadata.c index 2fe50b93c77b..93c9bbae15eb 100644 --- a/mono/metadata/metadata.c +++ b/mono/metadata/metadata.c @@ -4788,6 +4788,7 @@ mono_metadata_localscope_from_methoddef (MonoImage *meta, guint32 index) static void mono_backtrace (int limit) { +#ifndef _MSC_VER void *array[limit]; char **names; int i; @@ -4797,6 +4798,7 @@ mono_backtrace (int limit) g_print ("\t%s\n", names [i]); } g_free (names); +#endif } #endif diff --git a/mono/metadata/mono-hash.c b/mono/metadata/mono-hash.c index 3074e86d3722..a116ba5d04d8 100644 --- a/mono/metadata/mono-hash.c +++ b/mono/metadata/mono-hash.c @@ -32,6 +32,7 @@ #include #include "mono-hash.h" #include "metadata/gc-internals.h" +#include "metadata/il2cpp-compat-metadata.h" #include #include #include diff --git a/mono/metadata/null-gc.c b/mono/metadata/null-gc.c index 1f780b337f52..54f185182e6c 100644 --- a/mono/metadata/null-gc.c +++ b/mono/metadata/null-gc.c @@ -289,6 +289,11 @@ mono_gc_thread_attach (MonoThreadInfo* info) return info; } +void +mono_gc_thread_detach (MonoThreadInfo *p) +{ +} + void mono_gc_thread_detach_with_lock (MonoThreadInfo *p) { diff --git a/mono/metadata/object-internals.h b/mono/metadata/object-internals.h index f5c6ef3ccd19..524bdf5967f2 100644 --- a/mono/metadata/object-internals.h +++ b/mono/metadata/object-internals.h @@ -1689,7 +1689,7 @@ typedef enum { MonoRuntimeUnhandledExceptionPolicy mono_runtime_unhandled_exception_policy_get (void); -void +UNITY_MONO_API void mono_runtime_unhandled_exception_policy_set (MonoRuntimeUnhandledExceptionPolicy policy); void diff --git a/mono/metadata/profiler.c b/mono/metadata/profiler.c index 515366476ebc..21aececd9133 100644 --- a/mono/metadata/profiler.c +++ b/mono/metadata/profiler.c @@ -112,6 +112,7 @@ load_profiler_from_installation (const char *libname, const char *name, const ch return FALSE; } +#ifndef RUNTIME_IL2CPP void mono_profiler_load (const char *desc) { @@ -145,6 +146,7 @@ mono_profiler_load (const char *desc) g_free (mname); } +#endif MonoProfilerHandle mono_profiler_create (MonoProfiler *prof) @@ -171,6 +173,7 @@ mono_profiler_set_coverage_filter_callback (MonoProfilerHandle handle, MonoProfi mono_atomic_store_ptr (&handle->coverage_filter, (gpointer) cb); } +#ifndef RUNTIME_IL2CPP mono_bool mono_profiler_enable_coverage (void) { @@ -185,6 +188,7 @@ mono_profiler_enable_coverage (void) return mono_profiler_state.code_coverage = TRUE; } +#endif static void coverage_lock (void) @@ -198,6 +202,7 @@ coverage_unlock (void) mono_os_mutex_unlock (&mono_profiler_state.coverage_mutex); } +#ifndef RUNTIME_IL2CPP mono_bool mono_profiler_get_coverage_data (MonoProfilerHandle handle, MonoMethod *method, MonoProfilerCoverageCallback cb) { @@ -301,6 +306,7 @@ mono_profiler_get_coverage_data (MonoProfilerHandle handle, MonoMethod *method, return TRUE; } +#endif MonoProfilerCoverageInfo * mono_profiler_coverage_alloc (MonoMethod *method, guint32 entries) @@ -657,6 +663,10 @@ typedef void (*MonoLegacyProfileThreadFunc) (MonoLegacyProfiler *prof, uintptr_t typedef void (*MonoLegacyProfileGCFunc) (MonoLegacyProfiler *prof, MonoProfilerGCEvent event, int generation); typedef void (*MonoLegacyProfileGCResizeFunc) (MonoLegacyProfiler *prof, int64_t new_size); typedef void (*MonoLegacyProfileJitResult) (MonoLegacyProfiler *prof, MonoMethod *method, MonoJitInfo *jinfo, int result); +typedef void (*MonoLegacyProfileAllocFunc) (MonoLegacyProfiler *prof, MonoObject *obj, MonoClass *klass); +typedef void (*MonoLegacyProfileMethodFunc) (MonoLegacyProfiler *prof, MonoMethod *method); +typedef void (*MonoLegacyProfileExceptionFunc) (MonoLegacyProfiler *prof, MonoObject *object); +typedef void (*MonoLegacyProfileExceptionClauseFunc) (MonoLegacyProfiler *prof, MonoMethod *method, int clause_type, int clause_num); struct _MonoProfiler { MonoProfilerHandle handle; @@ -666,6 +676,12 @@ struct _MonoProfiler { MonoLegacyProfileGCFunc gc_event; MonoLegacyProfileGCResizeFunc gc_heap_resize; MonoLegacyProfileJitResult jit_end2; + MonoLegacyProfileAllocFunc allocation; + MonoLegacyProfileMethodFunc enter; + MonoLegacyProfileMethodFunc leave; + MonoLegacyProfileExceptionFunc throw_callback; + MonoLegacyProfileMethodFunc exc_method_leave; + MonoLegacyProfileExceptionClauseFunc clause_callback; }; static MonoProfiler *current; @@ -675,6 +691,9 @@ MONO_API void mono_profiler_install_thread (MonoLegacyProfileThreadFunc start, M MONO_API void mono_profiler_install_gc (MonoLegacyProfileGCFunc callback, MonoLegacyProfileGCResizeFunc heap_resize_callback); MONO_API void mono_profiler_install_jit_end (MonoLegacyProfileJitResult end); MONO_API void mono_profiler_set_events (int flags); +MONO_API void mono_profiler_install_allocation (MonoLegacyProfileAllocFunc callback); +MONO_API void mono_profiler_install_enter_leave (MonoLegacyProfileMethodFunc enter, MonoLegacyProfileMethodFunc fleave); +MONO_API void mono_profiler_install_exception (MonoLegacyProfileExceptionFunc throw_callback, MonoLegacyProfileMethodFunc exc_method_leave, MonoLegacyProfileExceptionClauseFunc clause_callback); static void shutdown_cb (MonoProfiler *prof) @@ -772,3 +791,86 @@ mono_profiler_set_events (int flags) { /* Do nothing. */ } + +static void +allocation_cb (MonoProfiler *prof, MonoObject* object) +{ + prof->allocation (prof->profiler, object, object->vtable->klass); +} + +void +mono_profiler_install_allocation (MonoLegacyProfileAllocFunc callback) +{ + current->allocation = callback; + + if (callback) + mono_profiler_set_gc_allocation_callback (current->handle, allocation_cb); +} + +static void +enter_cb (MonoProfiler *prof, MonoMethod *method, MonoProfilerCallContext *context) +{ + prof->enter (prof->profiler, method); +} + +static void +leave_cb (MonoProfiler *prof, MonoMethod *method, MonoProfilerCallContext *context) +{ + prof->leave (prof->profiler, method); +} + +static void +tail_call_cb (MonoProfiler *prof, MonoMethod *method, MonoMethod *target) +{ + prof->leave (prof->profiler, method); +} + +void +mono_profiler_install_enter_leave (MonoLegacyProfileMethodFunc enter, MonoLegacyProfileMethodFunc fleave) +{ + current->enter = enter; + current->leave = fleave; + + if (enter) + mono_profiler_set_method_enter_callback (current->handle, enter_cb); + + if (fleave) { + mono_profiler_set_method_leave_callback (current->handle, leave_cb); + mono_profiler_set_method_tail_call_callback (current->handle, tail_call_cb); + } +} + +static void +throw_callback_cb (MonoProfiler *prof, MonoObject *exception) +{ + prof->throw_callback (prof->profiler, exception); +} + +static void +exc_method_leave_cb (MonoProfiler *prof, MonoMethod *method, MonoObject *exception) +{ + prof->exc_method_leave (prof->profiler, method); +} + +static void +clause_callback_cb (MonoProfiler *prof, MonoMethod *method, uint32_t index, MonoExceptionEnum type, MonoObject *exception) +{ + prof->clause_callback (prof->profiler, method, type, index); +} + +void +mono_profiler_install_exception (MonoLegacyProfileExceptionFunc throw_callback, MonoLegacyProfileMethodFunc exc_method_leave, MonoLegacyProfileExceptionClauseFunc clause_callback) +{ + current->throw_callback = throw_callback; + current->exc_method_leave = exc_method_leave; + current->clause_callback = clause_callback; + + if (throw_callback) + mono_profiler_set_exception_throw_callback (current->handle, throw_callback_cb); + + if (exc_method_leave) + mono_profiler_set_method_exception_leave_callback (current->handle, exc_method_leave_cb); + + if (clause_callback) + mono_profiler_set_exception_clause_callback (current->handle, clause_callback_cb); +} diff --git a/mono/metadata/profiler.h b/mono/metadata/profiler.h index b6e836d3638b..c23153b33731 100644 --- a/mono/metadata/profiler.h +++ b/mono/metadata/profiler.h @@ -127,7 +127,9 @@ typedef void (*MonoProfilerCoverageCallback) (MonoProfiler *prof, const MonoProf * * This function is not async safe. */ +#ifndef RUNTIME_IL2CPP MONO_API mono_bool mono_profiler_get_coverage_data (MonoProfilerHandle handle, MonoMethod *method, MonoProfilerCoverageCallback cb); +#endif typedef enum { /* diff --git a/mono/metadata/security-manager.h b/mono/metadata/security-manager.h index d9f49ceb510c..d92e169d2164 100644 --- a/mono/metadata/security-manager.h +++ b/mono/metadata/security-manager.h @@ -57,7 +57,7 @@ MonoMethod* mono_get_context_capture_method (void); MonoSecurityManager* mono_security_manager_get_methods (void); /* Security mode */ -void mono_security_set_mode (MonoSecurityMode mode); +UNITY_MONO_API void mono_security_set_mode (MonoSecurityMode mode); MonoSecurityMode mono_security_get_mode (void); /* internal calls */ diff --git a/mono/metadata/sgen-mono.c b/mono/metadata/sgen-mono.c index e16f2c869d2f..5da2bb288b92 100644 --- a/mono/metadata/sgen-mono.c +++ b/mono/metadata/sgen-mono.c @@ -2246,6 +2246,11 @@ sgen_client_thread_attach (SgenThreadInfo* info) info->client_info.info.handle_stack = mono_handle_stack_alloc (); } +void +mono_gc_thread_detach (SgenThreadInfo *info) +{ +} + void mono_gc_thread_detach_with_lock (SgenThreadInfo *info) { diff --git a/mono/metadata/threads-types.h b/mono/metadata/threads-types.h index 2feb0ba4f848..4189f7a75094 100644 --- a/mono/metadata/threads-types.h +++ b/mono/metadata/threads-types.h @@ -209,7 +209,7 @@ gboolean mono_thread_test_and_set_state (MonoInternalThread *thread, MonoThreadS void mono_thread_init_apartment_state (void); void mono_thread_cleanup_apartment_state (void); -void mono_threads_set_shutting_down (void); +UNITY_MONO_API void mono_threads_set_shutting_down (void); gunichar2* mono_thread_get_name (MonoInternalThread *this_obj, guint32 *name_len); @@ -218,11 +218,11 @@ void mono_thread_self_abort (void); void mono_thread_set_name_internal (MonoInternalThread *this_obj, MonoString *name, gboolean permanent, gboolean reset, MonoError *error); -void mono_thread_suspend_all_other_threads (void); +UNITY_MONO_API void mono_thread_suspend_all_other_threads (void); gboolean mono_threads_abort_appdomain_threads (MonoDomain *domain, int timeout); -void mono_thread_push_appdomain_ref (MonoDomain *domain); -void mono_thread_pop_appdomain_ref (void); +UNITY_MONO_API void mono_thread_push_appdomain_ref (MonoDomain *domain); +UNITY_MONO_API void mono_thread_pop_appdomain_ref (void); gboolean mono_thread_has_appdomain_ref (MonoThread *thread, MonoDomain *domain); MonoException* mono_thread_request_interruption (mono_bool running_managed); diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index dc7f8527964a..fc8ec298885b 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -200,6 +200,7 @@ static gint32 thread_interruption_requested = 0; static MonoOSEvent background_change_event; static gboolean shutting_down = FALSE; +gboolean unity_shutting_down = FALSE; static gint32 managed_thread_id_counter = 0; @@ -3002,6 +3003,8 @@ thread_detach (MonoThreadInfo *info) g_assert (info); + mono_gc_thread_detach (info); + if (!mono_thread_info_try_get_internal_thread_gchandle (info, &gchandle)) return; @@ -3176,7 +3179,7 @@ static void build_wait_tids (gpointer key, gpointer value, gpointer user) /* Ignore background threads, we abort them later */ /* Do not lock here since it is not needed and the caller holds threads_lock */ - if (thread->state & ThreadState_Background) { + if (thread->state & ThreadState_Background || unity_shutting_down) { THREAD_DEBUG (g_message ("%s: ignoring background thread %"G_GSIZE_FORMAT, __func__, (gsize)thread->tid)); return; /* just leave, ignore */ } @@ -5333,3 +5336,24 @@ mono_thread_internal_is_current (MonoInternalThread *internal) g_assert (internal); return mono_native_thread_id_equals (mono_native_thread_id_get (), MONO_UINT_TO_NATIVE_THREAD_ID (internal->tid)); } + +MonoException* mono_unity_thread_check_exception() +{ + MonoInternalThread *thread = mono_thread_internal_current(); + MonoThread *sys_thread = mono_thread_current(); + + lock_thread(thread); + + if (sys_thread->pending_exception) { + MonoException *exc; + + exc = sys_thread->pending_exception; + sys_thread->pending_exception = NULL; + + unlock_thread(thread); + return exc; + } + + unlock_thread(thread); + return NULL; +} diff --git a/mono/metadata/unity-liveness.c b/mono/metadata/unity-liveness.c new file mode 100644 index 000000000000..d5f13ecead74 --- /dev/null +++ b/mono/metadata/unity-liveness.c @@ -0,0 +1,646 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct _LivenessState LivenessState; + +typedef struct _GPtrArray custom_growable_array; +#define array_at_index(array,index) (array)->pdata[(index)] + +#if defined(HAVE_SGEN_GC) +void sgen_stop_world (int generation); +void sgen_restart_world (int generation); +#elif defined(HAVE_BOEHM_GC) +#ifdef HAVE_BDWGC_GC +extern void GC_stop_world_external(); +extern void GC_start_world_external(); +#else +void GC_stop_world_external() +{ + g_assert_not_reached (); +} +void GC_start_world_external() +{ + g_assert_not_reached (); +} +#endif +#else +#error need to implement liveness GC API +#endif + +custom_growable_array* array_create_and_initialize (guint capacity) +{ + custom_growable_array* array = g_ptr_array_sized_new(capacity); + array->len = 0; + return array; +} + +gboolean array_is_full(custom_growable_array* array) +{ + return g_ptr_array_capacity(array) == array->len; +} + +void array_destroy (custom_growable_array* array) +{ + g_ptr_array_free(array, TRUE); +} + +void array_push_back(custom_growable_array* array, gpointer value) +{ + g_assert(!array_is_full(array)); + array->pdata[array->len] = value; + array->len++; +} + +gpointer array_pop_back(custom_growable_array* array) +{ + array->len--; + return array->pdata[array->len]; +} + +void array_clear(custom_growable_array* array) +{ + array->len = 0; +} + +void array_grow(custom_growable_array* array) +{ + int oldlen = array->len; + g_ptr_array_set_size(array, g_ptr_array_capacity(array)*2); + array->len = oldlen; +} + +typedef void (*register_object_callback)(gpointer* arr, int size, void* callback_userdata); +typedef void (*WorldStateChanged)(); +struct _LivenessState +{ + gint first_index_in_all_objects; + custom_growable_array* all_objects; + + MonoClass* filter; + + custom_growable_array* process_array; + guint initial_alloc_count; + + void* callback_userdata; + + register_object_callback filter_callback; + WorldStateChanged onWorldStartCallback; + WorldStateChanged onWorldStopCallback; +}; + +/* Liveness calculation */ +MONO_API LivenessState* mono_unity_liveness_allocate_struct (MonoClass* filter, guint max_count, register_object_callback callback, void* callback_userdata, WorldStateChanged onWorldStartCallback, WorldStateChanged onWorldStopCallback); +MONO_API void mono_unity_liveness_stop_gc_world (LivenessState* state); +MONO_API void mono_unity_liveness_finalize (LivenessState* state); +MONO_API void mono_unity_liveness_start_gc_world (LivenessState* state); +MONO_API void mono_unity_liveness_free_struct (LivenessState* state); + +MONO_API LivenessState* mono_unity_liveness_calculation_begin (MonoClass* filter, guint max_count, register_object_callback callback, void* callback_userdata, WorldStateChanged onStartWorldCallback, WorldStateChanged onStopWorldCallback); +MONO_API void mono_unity_liveness_calculation_end (LivenessState* state); + +MONO_API void mono_unity_liveness_calculation_from_root (MonoObject* root, LivenessState* state); +MONO_API void mono_unity_liveness_calculation_from_statics (LivenessState* state); + +#define MARK_OBJ(obj) \ + do { \ + (obj)->vtable = (MonoVTable*)(((gsize)(obj)->vtable) | (gsize)1); \ + } while (0) + +#define CLEAR_OBJ(obj) \ + do { \ + (obj)->vtable = (MonoVTable*)(((gsize)(obj)->vtable) & ~(gsize)1); \ + } while (0) + +#define IS_MARKED(obj) \ + (((gsize)(obj)->vtable) & (gsize)1) + +#define GET_VTABLE(obj) \ + ((MonoVTable*)(((gsize)(obj)->vtable) & ~(gsize)1)) + + +void mono_filter_objects(LivenessState* state); + +void mono_reset_state(LivenessState* state) +{ + state->first_index_in_all_objects = state->all_objects->len; + array_clear(state->process_array); +} + +void array_safe_grow(LivenessState* state, custom_growable_array* array) +{ + // if all_objects run out of space, run through list + // clear bit in vtable, start the world, reallocate, stop the world and continue + int i; + for (i = 0; i < state->all_objects->len; i++) + { + MonoObject* object = array_at_index(state->all_objects,i); + CLEAR_OBJ(object); + } + mono_unity_liveness_start_gc_world(state); + array_grow(array); + mono_unity_liveness_stop_gc_world (state); + for (i = 0; i < state->all_objects->len; i++) + { + MonoObject* object = array_at_index(state->all_objects,i); + MARK_OBJ(object); + } +} + +static gboolean should_process_value (MonoObject* val, MonoClass* filter) +{ + MonoClass* val_class = GET_VTABLE(val)->klass; + if (filter && + !mono_class_has_parent (val_class, filter)) + return FALSE; + + return TRUE; +} + +static void mono_traverse_array (MonoArray* array, LivenessState* state); +static void mono_traverse_object (MonoObject* object, LivenessState* state); +static void mono_traverse_gc_desc (MonoObject* object, LivenessState* state); +static void mono_traverse_objects (LivenessState* state); + +static void mono_traverse_generic_object( MonoObject* object, LivenessState* state ) +{ +#ifdef HAVE_SGEN_GC + gsize gc_desc = 0; +#else + gsize gc_desc = (gsize)(GET_VTABLE(object)->gc_descr); +#endif + + if (gc_desc & (gsize)1) + mono_traverse_gc_desc (object, state); + else if (GET_VTABLE(object)->klass->rank) + mono_traverse_array ((MonoArray*)object, state); + else + mono_traverse_object (object, state); +} + + +static void mono_add_process_object (MonoObject* object, LivenessState* state) +{ + if (object && !IS_MARKED(object)) + { + gboolean has_references = GET_VTABLE(object)->klass->has_references; + if(has_references || should_process_value(object,state->filter)) + { + if (array_is_full(state->all_objects)) + array_safe_grow(state, state->all_objects); + array_push_back(state->all_objects, object); + MARK_OBJ(object); + } + // Check if klass has further references - if not skip adding + if (has_references) + { + if(array_is_full(state->process_array)) + array_safe_grow(state, state->process_array); + array_push_back(state->process_array, object); + } + } +} + +static gboolean mono_field_can_contain_references(MonoClassField* field) +{ + if (MONO_TYPE_ISSTRUCT(field->type)) + return TRUE; + if (field->type->attrs & FIELD_ATTRIBUTE_LITERAL) + return FALSE; + if (field->type->type == MONO_TYPE_STRING) + return FALSE; + return MONO_TYPE_IS_REFERENCE(field->type); +} + +static void mono_traverse_object_internal (MonoObject* object, gboolean isStruct, MonoClass* klass, LivenessState* state) +{ + int i; + MonoClassField *field; + MonoClass *p; + + g_assert (object); + + // subtract the added offset for the vtable. This is added to the offset even though it is a struct + if(isStruct) + object--; + + for (p = klass; p != NULL; p = p->parent) + { + if (p->size_inited == 0) + continue; + for (i = 0; i < mono_class_get_field_count (p); i++) + { + field = &p->fields[i]; + if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) + continue; + + if(!mono_field_can_contain_references(field)) + continue; + + if (MONO_TYPE_ISSTRUCT(field->type)) + { + char* offseted = (char*)object; + offseted += field->offset; + if (field->type->type == MONO_TYPE_GENERICINST) + { + g_assert(field->type->data.generic_class->cached_class); + mono_traverse_object_internal((MonoObject*)offseted, TRUE, field->type->data.generic_class->cached_class, state); + } + else + mono_traverse_object_internal((MonoObject*)offseted, TRUE, field->type->data.klass, state); + continue; + } + + if (field->offset == -1) { + g_assert_not_reached (); + } else { + MonoObject* val = NULL; + MonoVTable *vtable = NULL; + mono_field_get_value (object, field, &val); + mono_add_process_object (val, state); + } + } + } +} + +static void mono_traverse_object (MonoObject* object, LivenessState* state) +{ + mono_traverse_object_internal (object, FALSE, GET_VTABLE(object)->klass, state); +} + +static void mono_traverse_gc_desc (MonoObject* object, LivenessState* state) +{ +#define WORDSIZE ((int)sizeof(gsize)*8) + int i = 0; + gsize mask = (gsize)(GET_VTABLE(object)->gc_descr); + + g_assert (mask & (gsize)1); + + for (i = 0; i < WORDSIZE-2; i++) + { + gsize offset = ((gsize)1 << (WORDSIZE - 1 - i)); + if (mask & offset) + { + MonoObject* val = *(MonoObject**)(((char*)object) + i * sizeof(void*)); + mono_add_process_object(val, state); + } + } +} + +static void mono_traverse_objects (LivenessState* state) +{ + int i = 0; + MonoObject* object = NULL; + + while (state->process_array->len > 0) + { + object = array_pop_back(state->process_array); + mono_traverse_generic_object(object, state); + } +} + +static void mono_traverse_array (MonoArray* array, LivenessState* state) +{ + int i = 0; + gboolean has_references; + MonoObject* object = (MonoObject*)array; + MonoClass* element_class; + size_t elementClassSize; + size_t array_length; + + g_assert (object); + + + + element_class = GET_VTABLE(object)->klass->element_class; + has_references = !mono_class_is_valuetype(element_class); + g_assert(element_class->size_inited != 0); + + for (i = 0; i < mono_class_get_field_count (element_class); i++) + { + has_references |= mono_field_can_contain_references(&element_class->fields[i]); + } + + if (!has_references) + return; + + array_length = mono_array_length (array); + if (element_class->valuetype) + { + elementClassSize = mono_class_array_element_size (element_class); + for (i = 0; i < array_length; i++) + { + MonoObject* object = (MonoObject*)mono_array_addr_with_size (array, elementClassSize, i); + mono_traverse_object_internal (object, 1, element_class, state); + + // Add 128 objects at a time and then traverse, 64 seems not be enough + if( ((i+1) & 127) == 0) + mono_traverse_objects(state); + } + } + else + { + for (i = 0; i < array_length; i++) + { + MonoObject* val = mono_array_get(array, MonoObject*, i); + mono_add_process_object(val, state); + + // Add 128 objects at a time and then traverse, 64 seems not be enough + if( ((i+1) & 127) == 0) + mono_traverse_objects(state); + } + } +} + + +void mono_filter_objects(LivenessState* state) +{ + gpointer filtered_objects[64]; + gint num_objects = 0; + + int i = state->first_index_in_all_objects; + for ( ; i < state->all_objects->len; i++) + { + MonoObject* object = state->all_objects->pdata[i]; + if (should_process_value (object, state->filter)) + filtered_objects[num_objects++] = object; + if (num_objects == 64) + { + state->filter_callback(filtered_objects, 64, state->callback_userdata); + num_objects = 0; + } + } + + if (num_objects != 0) + state->filter_callback(filtered_objects, num_objects, state->callback_userdata); +} + +/** + * mono_unity_liveness_calculation_from_statics: + * + * Returns an array of MonoObject* that are reachable from the static roots + * in the current domain and derive from @filter (if not NULL). + */ +void mono_unity_liveness_calculation_from_statics(LivenessState* liveness_state) +{ + int i, j; + MonoDomain* domain = mono_domain_get(); + + mono_reset_state(liveness_state); + + + for (i = 0; i < domain->class_vtable_array->len; ++i) + { + MonoVTable* vtable = (MonoVTable *)g_ptr_array_index (domain->class_vtable_array, i); + MonoClass* klass = vtable->klass; + MonoClassField *field; + if (!klass) + continue; + if (!klass->has_static_refs) + continue; + if (klass->image == mono_defaults.corlib) + continue; + if (klass->size_inited == 0) + continue; + for (j = 0; j < mono_class_get_field_count (klass); j++) + { + field = &klass->fields[j]; + if (!(field->type->attrs & FIELD_ATTRIBUTE_STATIC)) + continue; + if(!mono_field_can_contain_references(field)) + continue; + // shortcut check for special statics + if (field->offset == -1) + continue; + + if (MONO_TYPE_ISSTRUCT(field->type)) + { + char* offseted = (char*)mono_vtable_get_static_field_data (vtable); + offseted += field->offset; + if (field->type->type == MONO_TYPE_GENERICINST) + { + g_assert(field->type->data.generic_class->cached_class); + mono_traverse_object_internal((MonoObject*)offseted, TRUE, field->type->data.generic_class->cached_class, liveness_state); + } + else + { + mono_traverse_object_internal((MonoObject*)offseted, TRUE, field->type->data.klass, liveness_state); + } + } + else + { + MonoError error; + MonoObject* val = NULL; + + mono_field_static_get_value_checked (mono_class_vtable (domain, klass), field, &val, &error); + + if (val && mono_error_ok (&error)) + { + mono_add_process_object(val, liveness_state); + } + mono_error_cleanup (&error); + } + } + } + mono_traverse_objects (liveness_state); + //Filter objects and call callback to register found objects + mono_filter_objects(liveness_state); +} + +void mono_unity_liveness_add_object_callback(gpointer* objs, gint count, void* arr) +{ + int i; + GPtrArray* objects = (GPtrArray*)arr; + for (i = 0; i < count; i++) + { + if (g_ptr_array_capacity(objects) > objects->len) + objects->pdata[objects->len++] = objs[i]; + } +} + +/** + * mono_unity_liveness_calculation_from_statics_managed: + * + * Returns a gchandle to an array of MonoObject* that are reachable from the static roots + * in the current domain and derive from type retrieved from @filter_handle (if not NULL). + */ +gpointer mono_unity_liveness_calculation_from_statics_managed(gpointer filter_handle, WorldStateChanged onWorldStartCallback, WorldStateChanged onWorldStopCallback) +{ + int i = 0; + MonoArray *res = NULL; + MonoReflectionType* filter_type = (MonoReflectionType*)mono_gchandle_get_target (GPOINTER_TO_UINT(filter_handle)); + MonoClass* filter = NULL; + GPtrArray* objects = NULL; + LivenessState* liveness_state = NULL; + MonoError* error = NULL; + + if (filter_type) + filter = mono_class_from_mono_type (filter_type->type); + + objects = g_ptr_array_sized_new(1000); + objects->len = 0; + + liveness_state = mono_unity_liveness_calculation_begin (filter, 1000, mono_unity_liveness_add_object_callback, (void*)objects, onWorldStartCallback, onWorldStopCallback); + + mono_unity_liveness_calculation_from_statics (liveness_state); + + mono_unity_liveness_calculation_end (liveness_state); + + res = mono_array_new_checked (mono_domain_get (), filter ? filter: mono_defaults.object_class, objects->len, error); + for (i = 0; i < objects->len; ++i) { + MonoObject* o = g_ptr_array_index (objects, i); + mono_array_setref (res, i, o); + } + g_ptr_array_free (objects, TRUE); + + + return (gpointer)mono_gchandle_new ((MonoObject*)res, FALSE); + +} + +/** + * mono_unity_liveness_calculation_from_root: + * + * Returns an array of MonoObject* that are reachable from @root + * in the current domain and derive from @filter (if not NULL). + */ +void mono_unity_liveness_calculation_from_root (MonoObject* root, LivenessState* liveness_state) +{ + mono_reset_state (liveness_state); + + array_push_back (liveness_state->process_array,root); + + mono_traverse_objects (liveness_state); + + //Filter objects and call callback to register found objects + mono_filter_objects (liveness_state); +} + +/** + * mono_unity_liveness_calculation_from_root_managed: + * + * Returns a gchandle to an array of MonoObject* that are reachable from the static roots + * in the current domain and derive from type retrieved from @filter_handle (if not NULL). + */ +gpointer mono_unity_liveness_calculation_from_root_managed(gpointer root_handle, gpointer filter_handle, WorldStateChanged onWorldStartCallback, WorldStateChanged onWorldStopCallback) +{ + int i = 0; + MonoArray *res = NULL; + MonoReflectionType* filter_type = (MonoReflectionType*)mono_gchandle_get_target (GPOINTER_TO_UINT(filter_handle)); + MonoObject* root = mono_gchandle_get_target (GPOINTER_TO_UINT(root_handle)); + MonoClass* filter = NULL; + GPtrArray* objects = NULL; + LivenessState* liveness_state = NULL; + MonoError* error = NULL; + + objects = g_ptr_array_sized_new(1000); + objects->len = 0; + + if (filter_type) + filter = mono_class_from_mono_type (filter_type->type); + + liveness_state = mono_unity_liveness_calculation_begin (filter, 1000, mono_unity_liveness_add_object_callback, (void*)objects, onWorldStartCallback, onWorldStopCallback); + + mono_unity_liveness_calculation_from_root (root, liveness_state); + + mono_unity_liveness_calculation_end (liveness_state); + + res = mono_array_new_checked (mono_domain_get (), filter ? filter: mono_defaults.object_class, objects->len, error); + for (i = 0; i < objects->len; ++i) { + MonoObject* o = g_ptr_array_index (objects, i); + mono_array_setref (res, i, o); + } + + g_ptr_array_free (objects, TRUE); + + return (gpointer)mono_gchandle_new ((MonoObject*)res, FALSE); +} + +LivenessState* mono_unity_liveness_allocate_struct (MonoClass* filter, guint max_count, register_object_callback callback, void* callback_userdata, WorldStateChanged onWorldStartCallback, WorldStateChanged onWorldStopCallback) +{ + LivenessState* state = NULL; + + // construct liveness_state; + // allocate memory for the following structs + // all_objects: contains a list of all referenced objects to be able to clean the vtable bits after the traversal + // process_array. array that contains the objcets that should be processed. this should run depth first to reduce memory usage + // if all_objects run out of space, run through list, add objects that match the filter, clear bit in vtable and then clear the array. + + state = g_new(LivenessState, 1); + max_count = max_count < 1000 ? 1000 : max_count; + state->all_objects = array_create_and_initialize(max_count*4); + state->process_array = array_create_and_initialize (max_count); + + state->first_index_in_all_objects = 0; + state->filter = filter; + + state->callback_userdata = callback_userdata; + state->filter_callback = callback; + state->onWorldStartCallback = onWorldStartCallback; + state->onWorldStopCallback = onWorldStopCallback; + + return state; +} + +void mono_unity_liveness_finalize (LivenessState* state) +{ + int i; + for (i = 0; i < state->all_objects->len; i++) + { + MonoObject* object = g_ptr_array_index(state->all_objects,i); + CLEAR_OBJ(object); + } +} + +void mono_unity_liveness_free_struct (LivenessState* state) +{ + //cleanup the liveness_state + array_destroy(state->all_objects); + array_destroy(state->process_array); + g_free(state); +} + +void mono_unity_liveness_stop_gc_world (LivenessState* state) +{ + state->onWorldStopCallback(); +#if defined(HAVE_SGEN_GC) + sgen_stop_world (1); +#elif defined(HAVE_BOEHM_GC) + GC_stop_world_external (); +#else +#error need to implement liveness GC API +#endif +} + +void mono_unity_liveness_start_gc_world (LivenessState* state) +{ +#if defined(HAVE_SGEN_GC) + sgen_restart_world (1); +#elif defined(HAVE_BOEHM_GC) + GC_start_world_external (); +#else +#error need to implement liveness GC API +#endif + state->onWorldStartCallback(); +} + +LivenessState* mono_unity_liveness_calculation_begin (MonoClass* filter, guint max_count, register_object_callback callback, void* callback_userdata, WorldStateChanged onWorldStartCallback, WorldStateChanged onWorldStopCallback) +{ + LivenessState* state = mono_unity_liveness_allocate_struct (filter, max_count, callback, callback_userdata, onWorldStartCallback, onWorldStopCallback); + mono_unity_liveness_stop_gc_world (state); + // no allocations can happen beyond this point + return state; +} + +void mono_unity_liveness_calculation_end (LivenessState* state) +{ + mono_unity_liveness_finalize(state); + mono_unity_liveness_start_gc_world(state); + mono_unity_liveness_free_struct(state); +} diff --git a/mono/metadata/unity-memory-info.c b/mono/metadata/unity-memory-info.c new file mode 100644 index 000000000000..5b531ad41c61 --- /dev/null +++ b/mono/metadata/unity-memory-info.c @@ -0,0 +1,15 @@ +#include +#include +#include "unity-memory-info.h" + +MonoManagedMemorySnapshot* mono_unity_capture_memory_snapshot() +{ + MonoManagedMemorySnapshot* snapshot; + snapshot = g_new0(MonoManagedMemorySnapshot, 1); + return snapshot; +} + +void mono_unity_free_captured_memory_snapshot(MonoManagedMemorySnapshot* snapshot) +{ + g_free(snapshot); +} \ No newline at end of file diff --git a/mono/metadata/unity-memory-info.h b/mono/metadata/unity-memory-info.h new file mode 100644 index 000000000000..f8b777b06eeb --- /dev/null +++ b/mono/metadata/unity-memory-info.h @@ -0,0 +1,100 @@ +#ifndef __UNITY_MONO_MEMORY_INFO_H +#define __UNITY_MONO_MEMORY_INFO_H + +#include + +typedef struct MonoMetadataField +{ + uint32_t offset; + uint32_t typeIndex; + const char* name; + gboolean isStatic; +} MonoMetadataField; + +typedef enum MonoMetadataTypeFlags +{ + kNone = 0, + kValueType = 1 << 0, + kArray = 1 << 1, + kArrayRankMask = 0xFFFF0000 +} MonoMetadataTypeFlags; + +typedef struct MonoMetadataType +{ + MonoMetadataTypeFlags flags; // If it's an array, rank is encoded in the upper 2 bytes + MonoMetadataField* fields; + uint32_t fieldCount; + uint32_t staticsSize; + uint8_t* statics; + uint32_t baseOrElementTypeIndex; + char* name; + const char* assemblyName; + uint64_t typeInfoAddress; + uint32_t size; +} MonoMetadataType; + +typedef struct MonoMetadataSnapshot +{ + uint32_t typeCount; + MonoMetadataType* types; +} MonoMetadataSnapshot; + +typedef struct MonoManagedMemorySection +{ + uint64_t sectionStartAddress; + uint32_t sectionSize; + uint8_t* sectionBytes; +} MonoManagedMemorySection; + +typedef struct MonoManagedHeap +{ + uint32_t sectionCount; + MonoManagedMemorySection* sections; +} MonoManagedHeap; + +typedef struct MonoStacks +{ + uint32_t stackCount; + MonoManagedMemorySection* stacks; +} MonoStacks; + +typedef struct NativeObject +{ + uint32_t gcHandleIndex; + uint32_t size; + uint32_t instanceId; + uint32_t classId; + uint32_t referencedNativeObjectIndicesCount; + uint32_t* referencedNativeObjectIndices; +} NativeObject; + +typedef struct MonoGCHandles +{ + uint32_t trackedObjectCount; + uint64_t* pointersToObjects; +} MonoGCHandles; + +typedef struct MonoRuntimeInformation +{ + uint32_t pointerSize; + uint32_t objectHeaderSize; + uint32_t arrayHeaderSize; + uint32_t arrayBoundsOffsetInHeader; + uint32_t arraySizeOffsetInHeader; + uint32_t allocationGranularity; +} MonoRuntimeInformation; + +typedef struct MonoManagedMemorySnapshot +{ + MonoManagedHeap heap; + MonoStacks stacks; + MonoMetadataSnapshot metadata; + MonoGCHandles gcHandles; + MonoRuntimeInformation runtimeInformation; + void* additionalUserInformation; +} MonoManagedMemorySnapshot; + +MONO_API MonoManagedMemorySnapshot* mono_unity_capture_memory_snapshot(); +MONO_API void mono_unity_free_captured_memory_snapshot(MonoManagedMemorySnapshot* snapshot); + +#endif diff --git a/mono/metadata/unity-utils.c b/mono/metadata/unity-utils.c new file mode 100644 index 000000000000..b1f8729d4175 --- /dev/null +++ b/mono/metadata/unity-utils.c @@ -0,0 +1,1281 @@ +#include + + +#include + +/* allow Unity to use deprecated functions for now */ +#ifdef MONO_RT_EXTERNAL_ONLY +#undef MONO_RT_EXTERNAL_ONLY +#define MONO_RT_EXTERNAL_ONLY +#endif +#include +#include +#include +#ifdef WIN32 +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef WIN32 +#define UTF8_2_WIDE(src,dst) MultiByteToWideChar( CP_UTF8, 0, src, -1, dst, MAX_PATH ) +#endif + +#undef exit + +void unity_mono_exit( int code ) +{ + //fprintf( stderr, "mono: exit called, code %d\n", code ); + exit( code ); +} + + +GString* gEmbeddingHostName = 0; + + +MONO_API void mono_unity_set_embeddinghostname(const char* name) +{ + gEmbeddingHostName = g_string_new(name); +} + + + +MonoString* mono_unity_get_embeddinghostname() +{ + if (gEmbeddingHostName == 0) + mono_unity_set_embeddinghostname("mono"); + return mono_string_new_wrapper(gEmbeddingHostName->str); +} + +static gboolean socket_security_enabled = FALSE; + +gboolean +mono_unity_socket_security_enabled_get () +{ + return socket_security_enabled; +} + +void +mono_unity_socket_security_enabled_set (gboolean enabled) +{ + socket_security_enabled = enabled; +} + +void mono_unity_set_vprintf_func (vprintf_func func) +{ + //set_vprintf_func (func); +} + +MONO_API gboolean +mono_unity_class_is_interface (MonoClass* klass) +{ + return MONO_CLASS_IS_INTERFACE(klass); +} + +MONO_API gboolean +mono_unity_class_is_abstract (MonoClass* klass) +{ + return (mono_class_get_flags (klass) & TYPE_ATTRIBUTE_ABSTRACT); +} + +// classes_ref is a preallocated array of *length_ref MonoClass* +// returned classes are stored in classes_ref, number of stored classes is stored in length_ref +// return value is number of classes found (which may be greater than number of classes stored) +unsigned mono_unity_get_all_classes_with_name_case (MonoImage *image, const char *name, MonoClass **classes_ref, unsigned *length_ref) +{ + MonoClass *klass; + MonoTableInfo *tdef = &image->tables [MONO_TABLE_TYPEDEF]; + int i, count; + guint32 attrs, visibility; + unsigned length = 0; + + /* (yoinked from icall.c) we start the count from 1 because we skip the special type */ + for (i = 1; i < tdef->rows; ++i) + { + klass = mono_class_get (image, (i + 1) | MONO_TOKEN_TYPE_DEF); + if (klass && klass->name && 0 == mono_utf8_strcasecmp (klass->name, name)) + { + if (length < *length_ref) + classes_ref[length] = klass; + ++length; + } + } + + if (length < *length_ref) + *length_ref = length; + return length; +} + +gboolean +unity_mono_method_is_generic (MonoMethod* method) +{ + return method->is_generic; +} + +MONO_API MonoMethod* +unity_mono_reflection_method_get_method(MonoReflectionMethod* mrf) +{ + if(!mrf) + return NULL; + + return mrf->method; +} + +MONO_API void +mono_unity_g_free(void *ptr) +{ + g_free (ptr); +} + +MONO_API gboolean +mono_class_is_inflated (MonoClass *klass) +{ + g_assert(klass); + return (klass->class_kind == MONO_CLASS_GINST); +} + +MONO_API void +mono_thread_pool_cleanup (void) +{ + // TODO_UNITY : I am not sure we need to call this anymore + mono_threadpool_cleanup (); +} + +MONO_API void* +mono_class_get_userdata (MonoClass* klass) +{ + return klass->unity_user_data; +} + +MONO_API void +mono_class_set_userdata(MonoClass* klass, void* userdata) +{ + klass->unity_user_data = userdata; +} + +MONO_API int +mono_class_get_userdata_offset() +{ + return offsetof(struct _MonoClass, unity_user_data); +} + + +static UnityFindPluginCallback unity_find_plugin_callback; + +MONO_API void +mono_set_find_plugin_callback (UnityFindPluginCallback find) +{ + unity_find_plugin_callback = find; +} + +MONO_API UnityFindPluginCallback +mono_get_find_plugin_callback () +{ + return unity_find_plugin_callback; +} + +//object + +void mono_unity_object_init(void* obj, MonoClass* klass) +{ + if (klass->valuetype) + memset(obj, 0, klass->instance_size - sizeof(MonoObject)); + else + *(MonoObject**)obj = NULL; +} + +MonoObject* mono_unity_object_isinst_sealed(MonoObject* obj, MonoClass* targetType) +{ + return obj->vtable->klass == targetType ? obj : NULL; +} + +void mono_unity_object_unbox_nullable(MonoObject* obj, MonoClass* nullableArgumentClass, void* storage) +{ + uint32_t valueSize = nullableArgumentClass->instance_size - sizeof(MonoObject); + + if (obj == NULL) + { + *((mono_byte*)(storage)+valueSize) = 0; + } + else if (obj->vtable->klass != nullableArgumentClass) + { + mono_raise_exception_deprecated (mono_get_exception_invalid_cast()); + } + else + { + memcpy(storage, mono_object_unbox(obj), valueSize); + *((mono_byte*)(storage)+valueSize) = 1; + } +} + +MonoClass* mono_unity_object_get_class(MonoObject *obj) +{ + return obj->vtable->klass; +} + +MonoObject* mono_unity_object_compare_exchange(MonoObject **location, MonoObject *value, MonoObject *comparand) +{ + return ves_icall_System_Threading_Interlocked_CompareExchange_T(location, value, comparand); +} + +MonoObject* mono_unity_object_exchange(MonoObject **location, MonoObject *value) +{ + return ves_icall_System_Threading_Interlocked_Exchange_T(location, value); +} + +gboolean mono_unity_object_check_box_cast(MonoObject *obj, MonoClass *klass) +{ + return (obj->vtable->klass->element_class == klass->element_class); +} + +//class + +const char* mono_unity_class_get_image_name(MonoClass* klass) +{ + return klass->image->assembly_name; +} + +MonoClass* mono_unity_class_get_generic_definition(MonoClass* klass) +{ + MonoGenericClass* generic_class = mono_class_try_get_generic_class (klass); + if (generic_class) + return generic_class->container_class; + + return NULL; +} + +MonoClass* mono_unity_class_inflate_generic_class(MonoClass *gklass, MonoGenericContext *context) +{ + MonoError error; + return mono_class_inflate_generic_class_checked(gklass, context, &error); +} + +gboolean mono_unity_class_has_parent_unsafe(MonoClass *klass, MonoClass *parent) +{ + return mono_class_has_parent_fast(klass, parent); +} + +MonoAssembly* mono_unity_class_get_assembly(MonoClass *klass) +{ + return klass->image->assembly; +} + +gboolean mono_unity_class_is_array(MonoClass *klass) +{ + return klass->rank > 0; +} + +MonoClass* mono_unity_class_get_element_class(MonoClass *klass) +{ + return klass->element_class; +} + +gboolean mono_unity_class_is_delegate(MonoClass *klass) +{ + return klass->delegate; +} + +int mono_unity_class_get_instance_size(MonoClass *klass) +{ + return klass->instance_size; +} + +MonoClass* mono_unity_class_get_castclass(MonoClass *klass) +{ + return klass->cast_class; +} + +guint32 mono_unity_class_get_native_size(MonoClass* klass) +{ + MonoMarshalType* info = mono_marshal_load_type_info(klass); + return info->native_size; +} + +MonoBoolean mono_unity_class_is_string(MonoClass* klass) +{ + if (mono_class_get_type(klass)->type == MONO_TYPE_STRING) + return TRUE; + return FALSE; +} + +MonoBoolean mono_unity_class_is_class_type(MonoClass* klass) +{ + if (mono_class_get_type(klass)->type == MONO_TYPE_CLASS) + return TRUE; + return FALSE; +} + +MONO_API gboolean +mono_class_is_generic(MonoClass *klass) +{ + g_assert(klass); + return (klass->class_kind == MONO_CLASS_GTD); +} + +MONO_API gboolean +mono_class_is_blittable(MonoClass *klass) +{ + g_assert(klass); + return klass->blittable; +} + +//method + +MonoMethod* mono_unity_method_get_generic_definition(MonoMethod* method) +{ + if (method->is_inflated) + return ((MonoMethodInflated*)method)->declaring; + + return NULL; +} + +MonoReflectionMethod* mono_unity_method_get_object(MonoMethod *method) +{ + MonoError unused; + return mono_method_get_object_checked(mono_domain_get(), method, NULL, &unused); +} + +MonoMethod* mono_unity_method_alloc0(MonoClass* klass) +{ + return mono_image_alloc0(klass->image, sizeof(MonoMethod)); +} + +MonoMethod* mono_unity_method_delegate_invoke_wrapper(MonoClass* klass) +{ + MonoMethod* method = (MonoMethod*)mono_image_alloc0(klass->image, sizeof(MonoMethod)); + MonoMethod *invoke = mono_get_delegate_invoke (klass); + method->signature = mono_metadata_signature_dup_full (klass->image, mono_method_signature (invoke)); + return method; +} + +gboolean mono_unity_method_is_static(MonoMethod *method) +{ + return method->flags & METHOD_ATTRIBUTE_STATIC; +} + +MonoClass* mono_unity_method_get_class(const MonoMethod *method) +{ + return method->klass; +} + +#ifdef IL2CPP_ON_MONO + +void* mono_unity_method_get_method_pointer(MonoMethod* method) +{ + return method->method_pointer; +} + +void mono_unity_method_set_method_pointer(MonoMethod* method, void *p) +{ + method->method_pointer = p; +} + +void* mono_unity_method_get_invoke_pointer(MonoMethod* method) +{ + return method->invoke_pointer; +} + +void mono_unity_method_set_invoke_pointer(MonoMethod* method, void *p) +{ + method->invoke_pointer = p; +} + +#endif + +const char* mono_unity_method_get_name(const MonoMethod *method) +{ + return method->name; +} + + +//must match the hash in il2cpp code generation +static guint32 hash_string_djb2(guchar *str) +{ + guint32 hash = 5381; + int c; + + while (c = *str++) + hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ + + return hash; +} + +static guint32 get_array_structure_hash(MonoArrayType *atype) +{ + char buffer[100]; + char *ptr = buffer; + + *ptr++ = '['; + + char numbuffer[10]; + + for (int i = 0; i < atype->rank; ++i) + { + if (atype->numlobounds > 0 && atype->lobounds[i] != 0) + { + snprintf(numbuffer, 10, "%d", atype->lobounds[i]); + char *ptrnum = numbuffer; + while (*ptrnum) + *ptr++ = *ptrnum++; + + *ptr++ = ':'; + } + + if (atype->numsizes > 0 && atype->sizes[i] != 0) + { + snprintf(numbuffer, 10, "%d", atype->sizes[i]); + char *ptrnum = numbuffer; + while (*ptrnum) + *ptr++ = *ptrnum++; + } + + if (i < atype->rank - 1) + *ptr++ = ','; + } + + *ptr++ = ']'; + *ptr++ = 0; + + return hash_string_djb2(buffer); +} + +/* Begin: Hash computation helper functions */ + +static void get_type_hashes(MonoType *type, GList *hashes, gboolean inflate); +static void get_type_hashes_generic_inst(MonoGenericInst *inst, GList *hashes, gboolean inflate); + + +static void get_type_hashes_generic_inst(MonoGenericInst *inst, GList *hashes, gboolean inflate) +{ + for (int i = 0; i < inst->type_argc; ++i) + { + MonoType *type = inst->type_argv[i]; + get_type_hashes(type, hashes, inflate); + } +} + +static void get_type_hashes(MonoType *type, GList *hashes, gboolean inflate) +{ + if (type->type != MONO_TYPE_GENERICINST) + { + MonoClass *klass = NULL; + + switch (type->type) + { + case MONO_TYPE_ARRAY: + { + MonoArrayType *atype = type->data.array; + g_list_append(hashes, MONO_TOKEN_TYPE_SPEC); + g_list_append(hashes, get_array_structure_hash(atype)); + get_type_hashes(&(atype->eklass->this_arg), hashes, inflate); + break; + } + case MONO_TYPE_CLASS: + case MONO_TYPE_VALUETYPE: + klass = type->data.klass; + break; + case MONO_TYPE_BOOLEAN: + klass = mono_defaults.boolean_class; + break; + case MONO_TYPE_CHAR: + klass = mono_defaults.char_class; + break; + case MONO_TYPE_I: + klass = mono_defaults.int_class; + break; + case MONO_TYPE_U: + klass = mono_defaults.uint_class; + break; + case MONO_TYPE_I1: + klass = mono_defaults.sbyte_class; + break; + case MONO_TYPE_U1: + klass = mono_defaults.byte_class; + break; + case MONO_TYPE_I2: + klass = mono_defaults.int16_class; + break; + case MONO_TYPE_U2: + klass = mono_defaults.uint16_class; + break; + case MONO_TYPE_I4: + klass = mono_defaults.int32_class; + break; + case MONO_TYPE_U4: + klass = mono_defaults.uint32_class; + break; + case MONO_TYPE_I8: + klass = mono_defaults.int64_class; + break; + case MONO_TYPE_U8: + klass = mono_defaults.uint64_class; + break; + case MONO_TYPE_R4: + klass = mono_defaults.single_class; + break; + case MONO_TYPE_R8: + klass = mono_defaults.double_class; + break; + case MONO_TYPE_STRING: + klass = mono_defaults.string_class; + break; + case MONO_TYPE_OBJECT: + klass = mono_defaults.object_class; + break; + } + + if (klass) + { + g_list_append(hashes, klass->type_token); + g_list_append(hashes, hash_string_djb2(klass->image->module_name)); + } + + return; + } + else + { + g_list_append(hashes, type->data.generic_class->container_class->type_token); + g_list_append(hashes, hash_string_djb2(type->data.generic_class->container_class->image->module_name)); + + if (inflate) + get_type_hashes_generic_inst(type->data.generic_class->context.class_inst, hashes, inflate); + } + +} + +static GList* get_type_hashes_method(MonoMethod *method, gboolean inflate) +{ + GList *hashes = monoeg_g_list_alloc(); + + hashes->data = method->token; + g_list_append(hashes, hash_string_djb2(method->klass->image->module_name)); + + if (inflate && method->klass->class_kind == MONO_CLASS_GINST) + { + g_list_append(hashes, method->klass->type_token); + get_type_hashes_generic_inst(mono_class_get_generic_class (method->klass)->context.class_inst, hashes, inflate); + } + + if (inflate && method->is_inflated) + { + MonoGenericContext* methodGenericContext = mono_method_get_context(method); + if (methodGenericContext->method_inst != NULL) + get_type_hashes_generic_inst(methodGenericContext->method_inst, hashes, inflate); + } + + return hashes; +} + +//hash combination function must match the one used in IL2CPP codegen +static guint64 combine_hashes(guint64 hash1, guint64 hash2) +{ + const guint64 seed = 486187739; + return hash1 * seed + hash2; +} + +static void combine_all_hashes(gpointer data, gpointer user_data) +{ + guint64 *hash = (guint64*)user_data; + if (*hash == 0) + *hash = (guint64)data; + else + *hash = combine_hashes(*hash, (guint64)(uintptr_t)data); +} + +/* End: Hash computation helper functions */ + +guint64 mono_unity_method_get_hash(MonoMethod *method, gboolean inflate) +{ + GList *hashes = get_type_hashes_method(method, inflate); + + guint64 hash = 0; + + g_list_first(hashes); + g_list_foreach(hashes, combine_all_hashes, &hash); + g_list_free(hashes); + + return hash; +} + +guint64 mono_unity_type_get_hash(MonoType *type, gboolean inflate) +{ + GList *hashes = monoeg_g_list_alloc(); + + get_type_hashes(type, hashes, inflate); + + guint64 hash = 0; + + g_list_first(hashes); + g_list_foreach(hashes, combine_all_hashes, &hash); + g_list_free(hashes); + + return hash; +} + + +MonoMethod* mono_unity_method_get_aot_array_helper_from_wrapper(MonoMethod *method) +{ + MonoMethod *m; + const char *prefix; + MonoGenericContext ctx; + MonoType *args[16]; + char *mname, *iname, *s, *s2, *helper_name = NULL; + + prefix = "System.Collections.Generic"; + s = g_strdup_printf("%s", method->name + strlen(prefix) + 1); + s2 = strstr(s, "`1."); + g_assert(s2); + s2[0] = '\0'; + iname = s; + mname = s2 + 3; + + //printf ("X: %s %s\n", iname, mname); + + if (!strcmp(iname, "IList")) + helper_name = g_strdup_printf("InternalArray__%s", mname); + else + helper_name = g_strdup_printf("InternalArray__%s_%s", iname, mname); + m = mono_class_get_method_from_name(mono_defaults.array_class, helper_name, mono_method_signature(method)->param_count); + g_assert(m); + g_free(helper_name); + g_free(s); + + if (m->is_generic) { + MonoError error; + memset(&ctx, 0, sizeof(ctx)); + args[0] = &method->klass->element_class->byval_arg; + ctx.method_inst = mono_metadata_get_generic_inst(1, args); + m = mono_class_inflate_generic_method_checked(m, &ctx, &error); + g_assert(mono_error_ok(&error)); /* FIXME don't swallow the error */ + } + + return m; +} + +MonoObject* mono_unity_method_convert_return_type_if_needed(MonoMethod *method, void *value) +{ + if (method->signature && method->signature->ret->type == MONO_TYPE_PTR) + { + MonoError unused; + return mono_value_box_checked(mono_domain_get(), mono_defaults.int_class, &value, &unused); + } + + return (MonoObject*)value; +} + +MONO_API gboolean +unity_mono_method_is_inflated(MonoMethod* method) +{ + return method->is_inflated; +} + +guint32 mono_unity_method_get_token(MonoMethod *method) +{ + return method->token; +} + +//domain + + +void mono_unity_domain_install_finalize_runtime_invoke(MonoDomain* domain, RuntimeInvokeFunction callback) +{ + domain->finalize_runtime_invoke = callback; +} + +void mono_unity_domain_install_capture_context_runtime_invoke(MonoDomain* domain, RuntimeInvokeFunction callback) +{ + domain->capture_context_runtime_invoke = callback; +} + +void mono_unity_domain_install_capture_context_method(MonoDomain* domain, gpointer callback) +{ + domain->capture_context_method = callback; +} + +//array + +int mono_unity_array_get_element_size(MonoArray *arr) +{ + return arr->obj.vtable->klass->sizes.element_size; +} + +MonoClass* mono_unity_array_get_class(MonoArray *arr) +{ + return arr->obj.vtable->klass; +} + +mono_array_size_t mono_unity_array_get_max_length(MonoArray *arr) +{ + return arr->max_length; +} + +//type + +gboolean mono_unity_type_is_generic_instance(MonoType *type) +{ + return type->type == MONO_TYPE_GENERICINST; +} + +MonoGenericClass* mono_unity_type_get_generic_class(MonoType *type) +{ + if (type->type != MONO_TYPE_GENERICINST) + return NULL; + + return type->data.generic_class; +} + +gboolean mono_unity_type_is_enum_type(MonoType *type) +{ + if (type->type == MONO_TYPE_VALUETYPE && type->data.klass->enumtype) + return TRUE; + if (type->type == MONO_TYPE_GENERICINST && type->data.generic_class->container_class->enumtype) + return TRUE; + return FALSE; +} + +gboolean mono_unity_type_is_boolean(MonoType *type) +{ + return type->type == MONO_TYPE_BOOLEAN; +} + +MonoClass* mono_unity_type_get_element_class(MonoType *type) +{ + return type->data.klass->element_class; +} + +//generic class + +MonoGenericContext mono_unity_generic_class_get_context(MonoGenericClass *klass) +{ + return klass->context; +} + +MonoClass* mono_unity_generic_class_get_container_class(MonoGenericClass *klass) +{ + return klass->container_class; +} + +//method signature + +MonoClass* mono_unity_signature_get_class_for_param(MonoMethodSignature *sig, int index) +{ + MonoType *type = sig->params[index]; + return mono_class_from_mono_type(type); +} + +int mono_unity_signature_num_parameters(MonoMethodSignature *sig) +{ + return sig->param_count; +} + +gboolean mono_unity_signature_param_is_byref(MonoMethodSignature *sig, int index) +{ + return sig->params[index]->byref; +} + +//generic inst + +guint mono_unity_generic_inst_get_type_argc(MonoGenericInst *inst) +{ + return inst->type_argc; +} + +MonoType* mono_unity_generic_inst_get_type_argument(MonoGenericInst *inst, int index) +{ + return inst->type_argv[index]; +} + +//exception + +MonoString* mono_unity_exception_get_message(MonoException *exc) +{ + return exc->message; +} + +MonoString* mono_unity_exception_get_stack_trace(MonoException *exc) +{ + return exc->stack_trace; +} + +MonoObject* mono_unity_exception_get_inner_exception(MonoException *exc) +{ + return exc->inner_ex; +} + +MonoArray* mono_unity_exception_get_trace_ips(MonoException *exc) +{ + return exc->trace_ips; +} + +void mono_unity_exception_set_trace_ips(MonoException *exc, MonoArray *ips) +{ + g_assert(sizeof((exc)->trace_ips) == sizeof(void**)); + mono_gc_wbarrier_set_field((MonoObject*)(exc), &((exc)->trace_ips), (MonoObject*)ips); +} + +MonoException* mono_unity_exception_get_marshal_directive(const char* msg) +{ + return mono_exception_from_name_msg(mono_get_corlib(), "System.Runtime.InteropServices", "MarshalDirectiveException", msg); +} + +//defaults + +MonoClass* mono_unity_defaults_get_int_class() +{ + return mono_defaults.int_class; +} + +MonoClass* mono_unity_defaults_get_stack_frame_class() +{ + return mono_defaults.stack_frame_class; +} + +MonoClass* mono_unity_defaults_get_int32_class() +{ + return mono_defaults.int32_class; +} + +MonoClass* mono_unity_defaults_get_char_class() +{ + return mono_defaults.char_class; +} + +MonoClass* mono_unity_defaults_get_delegate_class() +{ + return mono_defaults.delegate_class; +} + +MonoClass* mono_unity_defaults_get_byte_class() +{ + return mono_defaults.byte_class; +} + +//misc + +MonoAssembly* mono_unity_assembly_get_mscorlib() +{ + return mono_defaults.corlib->assembly; +} + +MonoImage* mono_unity_image_get_mscorlib() +{ + return mono_defaults.corlib->assembly->image; +} + +MonoClass* mono_unity_generic_container_get_parameter_class(MonoGenericContainer* generic_container, gint index) +{ + MonoGenericParam *param = mono_generic_container_get_param(generic_container, index); + return mono_class_from_generic_parameter_internal(param); +} + +MonoString* mono_unity_string_append_assembly_name_if_necessary(MonoString* typeName, const char* assemblyName) +{ + if (typeName != NULL) + { + MonoTypeNameParse info; + + // The mono_reflection_parse_type function will mangle the name, so don't use this copy later. + MonoError unused; + char* nameForParsing = mono_string_to_utf8_checked(typeName, &unused); + if (mono_reflection_parse_type(nameForParsing, &info)) + { + if (!info.assembly.name) + { + GString* assemblyQualifiedName = g_string_new(0); + char* name = mono_string_to_utf8_checked(typeName, &unused); + g_string_append_printf(assemblyQualifiedName, "%s, %s", name, assemblyName); + + typeName = mono_string_new(mono_domain_get(), assemblyQualifiedName->str); + + g_string_free(assemblyQualifiedName, FALSE); + mono_free(name); + } + } + + mono_free(nameForParsing); + } + + return typeName; +} + +void mono_unity_memory_barrier() +{ + mono_memory_barrier(); +} + +MonoObject* mono_unity_delegate_get_target(MonoDelegate *delegate) +{ + return delegate->target; +} + +gchar* mono_unity_get_runtime_build_info(const char *date, const char *time) +{ + return g_strdup_printf("Unity IL2CPP(%s %s)", date, time); +} + +void* mono_unity_get_field_address(MonoObject *obj, MonoVTable *vt, MonoClassField *field) +{ + // This is a copy of mono_field_get_addr - we need to consider how to expose that on the public API. + MONO_REQ_GC_UNSAFE_MODE; + + guint8 *src; + + if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) { + if (field->offset == -1) { + /* Special static */ + gpointer addr; + + mono_domain_lock(vt->domain); + addr = g_hash_table_lookup(vt->domain->special_static_fields, field); + mono_domain_unlock(vt->domain); + src = (guint8 *)mono_get_special_static_data(GPOINTER_TO_UINT(addr)); + } + else { + src = (guint8*)mono_vtable_get_static_field_data(vt) + field->offset; + } + } + else { + src = (guint8*)obj + field->offset; + } + + return src; +} + +gboolean mono_unity_thread_state_init_from_handle(MonoThreadUnwindState *tctx, MonoThreadInfo *info, void* fixme) +{ + tctx->valid = TRUE; + tctx->unwind_data[MONO_UNWIND_DATA_DOMAIN] = mono_domain_get(); + tctx->unwind_data[MONO_UNWIND_DATA_LMF] = NULL; + tctx->unwind_data[MONO_UNWIND_DATA_JIT_TLS] = NULL; + + return TRUE; +} + +void mono_unity_stackframe_set_method(MonoStackFrame *sf, MonoMethod *method) +{ + g_assert(sizeof(sf->method) == sizeof(void**)); + MonoError unused; + mono_gc_wbarrier_set_field((MonoObject*)(sf), &(sf->method), (MonoObject*)mono_method_get_object_checked(mono_domain_get(), method, NULL, &unused)); +} + +MonoType* mono_unity_reflection_type_get_type(MonoReflectionType *type) +{ + return type->type; +} + +// layer to proxy differences between old and new Mono versions + +MONO_API void +mono_unity_runtime_set_main_args (int argc, const char* argv[]) +{ + mono_runtime_set_main_args (argc, argv); +} + +MONO_API MonoString* +mono_unity_string_empty_wrapper () +{ + return mono_string_empty (mono_domain_get ()); +} + +MONO_API MonoArray* +mono_unity_array_new_2d (MonoDomain *domain, MonoClass *eklass, size_t size0, size_t size1) +{ + MonoError error; + uintptr_t sizes[] = { (uintptr_t)size0, (uintptr_t)size1 }; + MonoClass* ac = mono_array_class_get (eklass, 2); + + MonoArray* array = mono_array_new_full_checked (domain, ac, sizes, NULL, &error); + mono_error_cleanup (&error); + + return array; +} + +MONO_API MonoArray* +mono_unity_array_new_3d (MonoDomain *domain, MonoClass *eklass, size_t size0, size_t size1, size_t size2) +{ + MonoError error; + uintptr_t sizes[] = { (uintptr_t)size0, (uintptr_t)size1, (uintptr_t)size2 }; + MonoClass* ac = mono_array_class_get (eklass, 3); + + MonoArray* array = mono_array_new_full_checked (domain, ac, sizes, NULL, &error); + mono_error_cleanup (&error); + + return array; +} + +MONO_API void +mono_unity_domain_set_config (MonoDomain *domain, const char *base_dir, const char *config_file_name) +{ + mono_domain_set_config (domain, base_dir, config_file_name); +} + +// only needed on OSX +MONO_API int +mono_unity_backtrace_from_context (void* context, void* array[], int count) +{ + return 0; +} + +MONO_API MonoException* +mono_unity_loader_get_last_error_and_error_prepare_exception () +{ + return NULL; +} + +MONO_API void +mono_unity_install_memory_callbacks (MonoAllocatorVTable* callbacks) +{ + mono_set_allocator_vtable (callbacks); +} + +static char* data_dir = NULL; +MONO_API void +mono_unity_set_data_dir(const char* dir) +{ + if (data_dir) + g_free(data_dir); + + data_dir = g_new(char*, strlen(dir) + 1); + strcpy(data_dir, dir); +} + +MONO_API char* +mono_unity_get_data_dir() +{ + return data_dir; +} + +MONO_API MonoClass* +mono_unity_class_get_generic_type_definition (MonoClass* klass) +{ + MonoGenericClass* generic_class = mono_class_try_get_generic_class (klass); + return generic_class ? generic_class->container_class : NULL; +} + +MONO_API MonoClass* +mono_unity_class_get_generic_parameter_at (MonoClass* klass, guint32 index) +{ + MonoGenericContainer* generic_container = mono_class_try_get_generic_container (klass); + if (!generic_container || index >= generic_container->type_argc) + return NULL; + + return mono_class_from_generic_parameter_internal (mono_generic_container_get_param (generic_container, index)); +} + +MONO_API guint32 +mono_unity_class_get_generic_parameter_count (MonoClass* klass) +{ + MonoGenericContainer* generic_container = mono_class_try_get_generic_container (klass); + + if (!generic_container) + return 0; + + return generic_container->type_argc; +} + +MONO_API MonoClass* +mono_unity_class_get(MonoImage* image, guint32 type_token) +{ + // Unity expects to try to get classes that don't exist, and + // have a value of NULL returned. So eat the error message. + MonoError unused; + MonoClass* klass= mono_class_get_checked(image, type_token, &unused); + mono_error_cleanup(&unused); + return klass; +} + +MONO_API gpointer +mono_unity_alloc(gsize size) +{ + return g_malloc(size); +} + + +MONO_API void +mono_unity_thread_fast_attach (MonoDomain *domain) +{ + g_assert_not_reached (); +#if 1 + MonoInternalThread *thread; + + g_assert (domain); + g_assert (domain != mono_get_root_domain ()); + + thread = mono_thread_internal_current (); + g_assert (thread); + + mono_thread_push_appdomain_ref (domain); + g_assert (mono_domain_set (domain, FALSE)); + + //mono_profiler_thread_fast_attach (thread->tid); +#endif +} + +MONO_API void +mono_unity_thread_fast_detach () +{ + g_assert_not_reached (); +#if 1 + MonoInternalThread *thread; + MonoDomain *current_domain; + + thread = mono_thread_internal_current (); + g_assert (thread); + + current_domain = mono_domain_get (); + + g_assert (current_domain); + g_assert (current_domain != mono_get_root_domain ()); + + //mono_profiler_thread_fast_detach (thread->tid); + + // Migrating to the root domain and popping the domain reference allows + // the thread to stay alive and keep running while the domain can be unloaded + g_assert (mono_domain_set (mono_get_root_domain (), FALSE)); + mono_thread_pop_appdomain_ref (); +#endif +} + +// hack, FIXME jon + +/* +size_t RemapPathFunction (const char* path, char* buffer, size_t buffer_len) + path = original path + buffer = provided buffer to fill out + buffer_len = byte size of buffer (above) + return value = buffer size needed, incl. terminating 0 + * may be called with buffer = null / buffer_len = 0, or a shorter-than-necessary-buffer. + * return value is always the size _needed_; not the size written. + * terminating zero should always be written. + * if buffer_len is less than needed, buffer content is undefined + * if return value is 0 no remapping is needed / available +*/ +static RemapPathFunction g_RemapPathFunc = NULL; + +/* calls remapper function if registered; allocates memory if remapping is available */ +static inline size_t +call_remapper(const char* path, char** buf) +{ + size_t len; + + if (!g_RemapPathFunc) + return FALSE; + + *buf = NULL; + len = g_RemapPathFunc(path, *buf, 0); + + if (len == 0) + return 0; + + *buf = g_new (char, len); + g_RemapPathFunc(path, *buf, len); + + return len; +} + +/* updates 'path' if remapping is available; returns TRUE if updated (path must be free()'d) */ +gboolean +mono_unity_file_remap_path(const char** path) +{ + size_t len; + char * buf; + + len = call_remapper(*path, &buf); + if (len == 0) + return FALSE; + + *path = buf; + return TRUE; +} + + + +/* sets 'new_path', and returns TRUE, if remapping is available */ +static gboolean +remap_path (MonoString *path, MonoString** new_path) +{ + MonoError error; + MonoString * str; + char * utf8_path; + char * buf; + char * path_end; + size_t len; + + *new_path = NULL; + + if (!g_RemapPathFunc) + return FALSE; + + utf8_path = mono_string_to_utf8_ignore(path); + len = call_remapper(utf8_path, &buf); + if (len == 0) + { + g_free(utf8_path); + return FALSE; + } + + path_end = memchr(buf, '\0', len); + len = path_end ? (size_t) (path_end - buf) : len; + str = mono_string_new_len_checked (mono_domain_get (), buf, (guint)len, &error); + + g_free(utf8_path); + g_free (buf); + + mono_gc_wbarrier_generic_store(new_path, (MonoObject*)str); + mono_error_set_pending_exception (&error); + + return *new_path ? TRUE : FALSE; +} + +/* returns remapped path, if remapping is available. otherwise returns original path */ +const gunichar2 * +mono_unity_get_remapped_path (const gunichar2 *path) +{ + // JON TODO: + return path; + //MonoString * new_path; + //return remap_path(path, &new_path) ? new_path : path; +} + +MonoBoolean +ves_icall_System_IO_MonoIO_RemapPath (MonoString *path, MonoString **new_path) +{ + return remap_path(path, new_path); +} + +void +mono_unity_register_path_remapper(RemapPathFunction func) +{ + g_RemapPathFunc = func; +} + +MonoMethod* +mono_method_get_method_definition (MonoMethod *method) +{ + while (method->is_inflated) + method = ((MonoMethodInflated*)method)->declaring; + return method; +} + +gboolean mono_allow_gc_aware_layout = TRUE; + +void +mono_class_set_allow_gc_aware_layout(mono_bool allow) +{ + mono_allow_gc_aware_layout = allow; +} diff --git a/mono/metadata/unity-utils.h b/mono/metadata/unity-utils.h new file mode 100644 index 000000000000..f87533855d53 --- /dev/null +++ b/mono/metadata/unity-utils.h @@ -0,0 +1,182 @@ +#ifndef __UNITY_MONO_UTILS_H +#define __UNITY_MONO_UTILS_H + +#include +#include +#include +#include + +typedef void(*vprintf_func)(const char* msg, va_list args); +typedef struct { + void* (*malloc_func)(size_t size); + void(*free_func)(void *ptr); + void* (*calloc_func)(size_t nmemb, size_t size); + void* (*realloc_func)(void *ptr, size_t size); +} MonoMemoryCallbacks; + +/** + * Custom exit function, called instead of system exit() + */ +void unity_mono_exit( int code ); + +/** + * Closes redirected output files. + */ +void unity_mono_close_output(void); + +extern MonoString* mono_unity_get_embeddinghostname(void); + +#ifdef WIN32 +FILE* unity_fopen( const char *name, const char *mode ); +#endif + +extern gboolean mono_unity_socket_security_enabled_get (void); +MONO_API extern void mono_unity_socket_security_enabled_set (gboolean enabled); +MONO_API void mono_unity_set_vprintf_func(vprintf_func func); + + +void unity_mono_install_memory_callbacks(MonoMemoryCallbacks* callbacks); + +MONO_API gboolean +unity_mono_method_is_generic (MonoMethod* method); + +typedef const char*(*UnityFindPluginCallback)(const char*); + +MONO_API void +mono_set_find_plugin_callback(UnityFindPluginCallback find); + +MONO_API UnityFindPluginCallback +mono_get_find_plugin_callback(); + +//object +void mono_unity_object_init(void* obj, MonoClass* klass); +MonoObject* mono_unity_object_isinst_sealed(MonoObject* obj, MonoClass* targetType); +void mono_unity_object_unbox_nullable(MonoObject* obj, MonoClass* nullableArgumentClass, void* storage); +MonoClass* mono_unity_object_get_class(MonoObject *obj); +MonoObject* mono_unity_object_compare_exchange(MonoObject **location, MonoObject *value, MonoObject *comparand); +MonoObject* mono_unity_object_exchange(MonoObject **location, MonoObject *value); +gboolean mono_unity_object_check_box_cast(MonoObject *obj, MonoClass *klass); + +//class +const char* mono_unity_class_get_image_name(MonoClass* klass); +MonoClass* mono_unity_class_get_generic_definition(MonoClass* klass); +MonoClass* mono_unity_class_inflate_generic_class(MonoClass *gklass, MonoGenericContext *context); +gboolean mono_unity_class_has_parent_unsafe(MonoClass *klass, MonoClass *parent); +MonoAssembly* mono_unity_class_get_assembly(MonoClass *klass); +gboolean mono_unity_class_is_array(MonoClass *klass); +MonoClass* mono_unity_class_get_element_class(MonoClass *klass); +gboolean mono_unity_class_is_delegate(MonoClass *klass); +int mono_unity_class_get_instance_size(MonoClass *klass); +MonoClass* mono_unity_class_get_castclass(MonoClass *klass); +guint32 mono_unity_class_get_native_size(MonoClass* klass); +MonoBoolean mono_unity_class_is_string(MonoClass* klass); +MonoBoolean mono_unity_class_is_class_type(MonoClass* klass); +MONO_API gboolean mono_class_is_generic(MonoClass *klass); +MONO_API gboolean mono_class_is_blittable(MonoClass *klass); +MONO_API gboolean mono_class_is_inflated(MonoClass *klass); + +//method +MonoMethod* mono_unity_method_get_generic_definition(MonoMethod* method); +MonoReflectionMethod* mono_unity_method_get_object(MonoMethod *method); +MonoMethod* mono_unity_method_alloc0(MonoClass* klass); +MonoMethod* mono_unity_method_delegate_invoke_wrapper(MonoClass* klass); +gboolean mono_unity_method_is_static(MonoMethod *method); +MonoClass* mono_unity_method_get_class(const MonoMethod *method); + +#ifdef IL2CPP_ON_MONO +void* mono_unity_method_get_method_pointer(MonoMethod* method); +void mono_unity_method_set_method_pointer(MonoMethod* method, void *p); +void* mono_unity_method_get_invoke_pointer(MonoMethod* method); +void mono_unity_method_set_invoke_pointer(MonoMethod* method, void *p); +#endif + +const char* mono_unity_method_get_name(const MonoMethod *method); +guint64 mono_unity_method_get_hash(MonoMethod *method, gboolean inflate); +MonoMethod* mono_unity_method_get_aot_array_helper_from_wrapper(MonoMethod *method); +MonoObject* mono_unity_method_convert_return_type_if_needed(MonoMethod *method, void *value); +MONO_API gboolean unity_mono_method_is_inflated(MonoMethod* method); +guint32 mono_unity_method_get_token(MonoMethod *method); + +//domain +void mono_unity_domain_install_finalize_runtime_invoke(MonoDomain* domain, RuntimeInvokeFunction callback); +void mono_unity_domain_install_capture_context_runtime_invoke(MonoDomain* domain, RuntimeInvokeFunction callback); +void mono_unity_domain_install_capture_context_method(MonoDomain* domain, void* callback); + +//array +int mono_unity_array_get_element_size(MonoArray *arr); +MonoClass* mono_unity_array_get_class(MonoArray *arr); +mono_array_size_t mono_unity_array_get_max_length(MonoArray *arr); + +//type +gboolean mono_unity_type_is_generic_instance(MonoType *type); +MonoGenericClass* mono_unity_type_get_generic_class(MonoType *type); +gboolean mono_unity_type_is_enum_type(MonoType *type); +gboolean mono_unity_type_is_boolean(MonoType *type); +MonoClass* mono_unity_type_get_element_class(MonoType *type); //only safe to call when the type has a defined klass data element +guint64 mono_unity_type_get_hash(MonoType *type, gboolean inflate); + +//generic class +MonoGenericContext mono_unity_generic_class_get_context(MonoGenericClass *klass); +MonoClass* mono_unity_generic_class_get_container_class(MonoGenericClass *klass); + +//method signature +MonoClass* mono_unity_signature_get_class_for_param(MonoMethodSignature *sig, int index); +int mono_unity_signature_num_parameters(MonoMethodSignature *sig); +gboolean mono_unity_signature_param_is_byref(MonoMethodSignature *sig, int index); + +//generic inst +guint mono_unity_generic_inst_get_type_argc(MonoGenericInst *inst); +MonoType* mono_unity_generic_inst_get_type_argument(MonoGenericInst *inst, int index); + +//exception +MonoString* mono_unity_exception_get_message(MonoException *exc); +MonoString* mono_unity_exception_get_stack_trace(MonoException *exc); +MonoObject* mono_unity_exception_get_inner_exception(MonoException *exc); +MonoArray* mono_unity_exception_get_trace_ips(MonoException *exc); +void mono_unity_exception_set_trace_ips(MonoException *exc, MonoArray *ips); +MonoException* mono_unity_exception_get_marshal_directive(const char* msg); + +//defaults +MonoClass* mono_unity_defaults_get_int_class(); +MonoClass* mono_unity_defaults_get_stack_frame_class(); +MonoClass* mono_unity_defaults_get_int32_class(); +MonoClass* mono_unity_defaults_get_char_class(); +MonoClass* mono_unity_defaults_get_delegate_class(); +MonoClass* mono_unity_defaults_get_byte_class(); + +//misc +MonoAssembly* mono_unity_assembly_get_mscorlib(); +MonoImage* mono_unity_image_get_mscorlib(); +MonoClass* mono_unity_generic_container_get_parameter_class(MonoGenericContainer* generic_container, gint index); +MonoString* mono_unity_string_append_assembly_name_if_necessary(MonoString* typeName, const char* assemblyName); +void mono_unity_memory_barrier(); +MonoException* mono_unity_thread_check_exception(); +MonoObject* mono_unity_delegate_get_target(MonoDelegate *delegate); +gchar* mono_unity_get_runtime_build_info(const char *date, const char *time); +void* mono_unity_get_field_address(MonoObject *obj, MonoVTable *vt, MonoClassField *field); +gboolean mono_unity_thread_state_init_from_handle(MonoThreadUnwindState *tctx, MonoThreadInfo *info, void* fixme); +void mono_unity_stackframe_set_method(MonoStackFrame *sf, MonoMethod *method); +MonoType* mono_unity_reflection_type_get_type(MonoReflectionType *type); +MONO_API void mono_unity_set_data_dir(const char* dir); +MONO_API char* mono_unity_get_data_dir(); +MONO_API MonoClass* mono_unity_class_get(MonoImage* image, guint32 type_token); +MONO_API gpointer mono_unity_alloc(gsize size); +MONO_API void mono_unity_g_free (void *ptr); + +// hack, FIXME jon +typedef size_t (*RemapPathFunction)(const char* path, char* buffer, size_t buffer_len); +MONO_API void mono_unity_register_path_remapper (RemapPathFunction func); +gboolean +mono_unity_file_remap_path(const char** path); +MonoBoolean +ves_icall_System_IO_MonoIO_RemapPath (MonoString *path, MonoString **new_path); +const gunichar2 * +mono_unity_get_remapped_path (const gunichar2 *path); + +MonoMethod* +mono_method_get_method_definition(MonoMethod *method); + +void +mono_class_set_allow_gc_aware_layout(mono_bool allow); + +#endif diff --git a/mono/metadata/verify-internals.h b/mono/metadata/verify-internals.h index 821de196bdd6..51a996c76741 100644 --- a/mono/metadata/verify-internals.h +++ b/mono/metadata/verify-internals.h @@ -19,7 +19,7 @@ typedef enum { MONO_VERIFIER_MODE_STRICT } MiniVerifierMode; -void mono_verifier_set_mode (MiniVerifierMode mode); +UNITY_MONO_API void mono_verifier_set_mode (MiniVerifierMode mode); void mono_verifier_enable_verify_all (void); gboolean mono_verifier_is_enabled_for_image (MonoImage *image); diff --git a/mono/metadata/w32error-unity.c b/mono/metadata/w32error-unity.c new file mode 100644 index 000000000000..5617f52f549f --- /dev/null +++ b/mono/metadata/w32error-unity.c @@ -0,0 +1,27 @@ +#include +#include "w32error.h" + +#if defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS) + +guint32 +mono_w32error_get_last (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +void +mono_w32error_set_last (guint32 error) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +guint32 +mono_w32error_unix_to_win32 (guint32 error) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + + +#endif /* PLATFORM_UNITY && UNITY_USE_PLATFORM_STUBS */ diff --git a/mono/metadata/w32event-unity.c b/mono/metadata/w32event-unity.c new file mode 100644 index 000000000000..e1a570ba0f8a --- /dev/null +++ b/mono/metadata/w32event-unity.c @@ -0,0 +1,84 @@ +#include "w32event.h" +#include "Handle-c-api.h" +#include "Event-c-api.h" +#include "Error-c-api.h" + +void +mono_w32event_init (void) +{ +} + +gpointer +mono_w32event_create (gboolean manual, gboolean initial) +{ + UnityPalEvent* event = UnityPalEventNew(manual, initial); + return UnityPalEventHandleNew(event); +} + +gboolean +mono_w32event_close (gpointer handle) +{ + UnityPalHandleDestroy(handle); + return TRUE; +} + +void +mono_w32event_set (gpointer handle) +{ + UnityPalEventSet(UnityPalEventHandleGet(handle)); +} + +void +mono_w32event_reset (gpointer handle) +{ + UnityPalEventReset(UnityPalEventHandleGet(handle)); +} + +gpointer +ves_icall_System_Threading_Events_CreateEvent_internal (MonoBoolean manual, MonoBoolean initial, MonoStringHandle name, gint32 *err, MonoError *error) +{ + error_init (error); + if (!MONO_HANDLE_IS_NULL (name)) + { + g_assertion_message("Named events are not supported by the Unity platform."); + return NULL; + } + + UnityPalEvent* event = UnityPalEventNew(manual, initial); + *err = UnityPalGetLastError(); + return UnityPalEventHandleNew(event); +} + +gboolean +ves_icall_System_Threading_Events_SetEvent_internal (gpointer handle) +{ + UnityPalErrorCode result = UnityPalEventSet(UnityPalEventHandleGet(handle)); + return UnityPalSuccess(result); +} + +gboolean +ves_icall_System_Threading_Events_ResetEvent_internal (gpointer handle) +{ + UnityPalErrorCode result = UnityPalEventReset(UnityPalEventHandleGet(handle)); + return UnityPalSuccess(result); +} + +void +ves_icall_System_Threading_Events_CloseEvent_internal (gpointer handle) +{ + UnityPalHandleDestroy(handle); +} + +gpointer +ves_icall_System_Threading_Events_OpenEvent_internal (MonoStringHandle name, gint32 rights, gint32 *err, MonoError *error) +{ + g_assertion_message("Named events are not supported by the Unity platform."); + return NULL; +} + +MonoW32HandleNamespace* +mono_w32event_get_namespace (MonoW32HandleNamedEvent *event) +{ + g_assertion_message("Named events are not supported by the Unity platform."); + return NULL; +} diff --git a/mono/metadata/w32file-unity.c b/mono/metadata/w32file-unity.c new file mode 100644 index 000000000000..786c41111bd4 --- /dev/null +++ b/mono/metadata/w32file-unity.c @@ -0,0 +1,554 @@ +#include +#include + + + +#include "Directory-c-api.h" +#include "File-c-api.h" +#include "w32error.h" +#include "w32file.h" +#include "utils/strenc.h" +#include + + +#ifdef HOST_WIN32 + +gunichar2 +ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar () +{ + return (gunichar2) ':'; /* colon */ +} + +gunichar2 +ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar () +{ + return (gunichar2) '\\'; /* backslash */ +} + +gunichar2 +ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar () +{ + return (gunichar2) '/'; /* forward slash */ +} + +gunichar2 +ves_icall_System_IO_MonoIO_get_PathSeparator () +{ + return (gunichar2) ';'; /* semicolon */ +} + +void ves_icall_System_IO_MonoIO_DumpHandles (void) +{ + return; +} +#endif /* HOST_WIN32 */ + +gpointer +mono_w32file_create(const gunichar2 *name, guint32 fileaccess, guint32 sharemode, guint32 createmode, guint32 attrs) +{ + int error = 0; + gpointer handle; + gchar* palPath = mono_unicode_to_external(name); + handle = UnityPalOpen(palPath, (int) createmode, (int) fileaccess, (int) sharemode, attrs, &error); + mono_w32error_set_last(error); + g_free(palPath); + + if (handle == NULL) + return INVALID_HANDLE_VALUE; + + return handle; +} + +gboolean +mono_w32file_close (gpointer handle) +{ + if (handle == NULL) + return FALSE; + + int error = 0; + gboolean result = UnityPalClose(handle, &error); + mono_w32error_set_last(error); + + return result; +} + +gboolean +mono_w32file_read(gpointer handle, gpointer buffer, guint32 numbytes, guint32 *bytesread) +{ + int error = 0; + + *bytesread = UnityPalRead(handle, buffer, numbytes, &error); + mono_w32error_set_last(error); + + return TRUE; +} + +gboolean +mono_w32file_write (gpointer handle, gconstpointer buffer, guint32 numbytes, guint32 *byteswritten) +{ + int error = 0; + + *byteswritten = UnityPalWrite(handle, buffer, numbytes, &error); + mono_w32error_set_last(error); + + return (*byteswritten > 0); +} + +gboolean +mono_w32file_flush (gpointer handle) +{ + int error = 0; + + gboolean result = UnityPalFlush(handle, &error); + mono_w32error_set_last(error); + + return result; +} + +gboolean +mono_w32file_truncate (gpointer handle) +{ + int error = 0; + + gboolean result = UnityPalTruncate(handle, &error); + mono_w32error_set_last(error); + + return result; +} + +guint32 +mono_w32file_seek (gpointer handle, gint32 movedistance, gint32 *highmovedistance, guint32 method) +{ + int error = 0; + + int32_t result = UnityPalSeek(handle, movedistance, 0, &error); + mono_w32error_set_last(error); + + return result; +} + +gint +mono_w32file_get_type (gpointer handle) +{ + if (handle == NULL) + return 0; + + return UnityPalGetFileType(handle); +} + +gboolean +mono_w32file_get_times (gpointer handle, FILETIME *create_time, FILETIME *access_time, FILETIME *write_time) +{ + /* Not Supported in UnityPAL */ + g_assert_not_reached(); +} + +gboolean +mono_w32file_set_times (gpointer handle, const FILETIME *create_time, const FILETIME *access_time, const FILETIME *write_time) +{ + int error = 0; + + gboolean result = UnityPalSetFileTime(handle, create_time, access_time, write_time, &error); + mono_w32error_set_last(error); + + return result; +} + +gpointer +mono_w32file_find_first (const gunichar2 *pattern, WIN32_FIND_DATA *find_data) +{ + gchar* palPath = mono_unicode_to_external(pattern); + UnityPalFindHandle* findHandle = UnityPalDirectoryFindHandleNew(palPath); + int32_t resultAttributes = 0; + + int32_t result = 0; + const char* filename; + + result = UnityPalDirectoryFindFirstFile(findHandle, palPath, &filename, &resultAttributes); + + if (result != 0) + { + mono_w32error_set_last(result); + return INVALID_HANDLE_VALUE; + } + + find_data->dwFileAttributes = resultAttributes; + + gunichar2 *utf16_basename; + glong bytes; + utf16_basename = g_utf8_to_utf16 (filename, -1, NULL, &bytes, NULL); + + /* this next section of memset and memcpy is code from mono, the cFileName field is + gunichar2 cFileName [MAX_PATH]. + Notes from mono: + Truncating a utf16 string like this might leave the last + gchar incomplete + utf16 is 2 * utf8 + */ + bytes *= 2; + memset (find_data->cFileName, '\0', (MAX_PATH * 2)); + memcpy (find_data->cFileName, utf16_basename, bytes < (MAX_PATH * 2) - 2 ? bytes : (MAX_PATH * 2) - 2); + + g_free(filename); + g_free(palPath); + g_free(utf16_basename); + + find_data->dwReserved0 = 0; + find_data->dwReserved1 = 0; + + find_data->cAlternateFileName [0] = 0; + + return findHandle; +} + +gboolean +mono_w32file_find_next (gpointer handle, WIN32_FIND_DATA *find_data) +{ + + int32_t resultAttributes = 0; + int32_t result; + const char* filename; + + result = UnityPalDirectoryFindNextFile(handle, &filename, &resultAttributes); + + find_data->dwFileAttributes = resultAttributes; + gunichar2 *utf16_basename; + glong bytes; + utf16_basename = g_utf8_to_utf16 (filename, -1, NULL, &bytes, NULL); + bytes *= 2; + + memset (find_data->cFileName, '\0', (MAX_PATH * 2)); + memcpy (find_data->cFileName, utf16_basename, bytes < (MAX_PATH * 2) - 2 ? bytes : (MAX_PATH * 2) - 2); + + g_free(filename); + g_free(utf16_basename); + + find_data->dwReserved0 = 0; + find_data->dwReserved1 = 0; + + find_data->cAlternateFileName [0] = 0; + + return (result == 0); +} + +gboolean +mono_w32file_find_close (gpointer handle) +{ + gboolean result = UnityPalDirectoryCloseOSHandle(handle); + UnityPalDirectoryFindHandleDelete(handle); + + return result; +} + +gboolean +mono_w32file_create_directory (const gunichar2 *name) +{ + int error = 0; + + gchar* palPath = mono_unicode_to_external(name); + gboolean result = UnityPalDirectoryCreate(palPath, &error); + mono_w32error_set_last(error); + g_free(palPath); + + return result; +} + +guint32 +mono_w32file_get_attributes (const gunichar2 *name) +{ + int error = 0; + + gchar* palPath = mono_unicode_to_external(name); + guint32 result = UnityPalGetFileAttributes(palPath, &error); + mono_w32error_set_last(error); + g_free(palPath); + + return result; +} + +gboolean +mono_w32file_get_attributes_ex (const gunichar2 *name, MonoIOStat *stat) +{ + gboolean result; + UnityPalFileStat palStat; + int error = 0; + + gchar* palPath = mono_unicode_to_external(name); + result = UnityPalGetFileStat(palPath, &palStat, &error); + mono_w32error_set_last(error); + + if (result) { + stat->attributes = palStat.attributes; + stat->creation_time = palStat.creation_time; + stat->last_access_time = palStat.last_access_time; + stat->last_write_time = palStat.last_write_time; + stat->length = palStat.length; + } + g_free(palPath); + + return result; +} + +gboolean +mono_w32file_set_attributes (const gunichar2 *name, guint32 attrs) +{ + int error = 0; + + gchar* palPath = mono_unicode_to_external(name); + gboolean result = UnityPalSetFileAttributes(palPath, attrs, &error); + mono_w32error_set_last(error); + g_free(palPath); + + return result; +} + +gboolean +mono_w32file_create_pipe (gpointer *readpipe, gpointer *writepipe, guint32 size) +{ + return UnityPalCreatePipe(*readpipe, *writepipe); +} + +gboolean +mono_w32file_get_disk_free_space (const gunichar2 *path_name, guint64 *free_bytes_avail, guint64 *total_number_of_bytes, guint64 *total_number_of_free_bytes) +{ + g_assert_not_reached(); + return FALSE; +} + +gboolean +mono_w32file_get_volume_information (const gunichar2 *path, gunichar2 *volumename, gint volumesize, gint *outserial, gint *maxcomp, gint *fsflags, gunichar2 *fsbuffer, gint fsbuffersize) +{ + g_assert_not_reached(); + return FALSE; +} + +gboolean +mono_w32file_move (const gunichar2 *path, const gunichar2 *dest, gint32 *error) +{ + gboolean result; + *error = 0; + MONO_ENTER_GC_SAFE; + + gchar* palPath = mono_unicode_to_external(path); + gchar* palDest = mono_unicode_to_external(dest); + result = UnityPalMoveFile(palPath, palDest, error); + mono_w32error_set_last(*error); + g_free(palPath); + g_free(palDest); + + MONO_EXIT_GC_SAFE; + + return result; +} + +gboolean +mono_w32file_replace (const gunichar2 *destination_file_name, const gunichar2 *source_file_name, const gunichar2 *destination_backup_file_name, guint32 flags, gint32 *error) +{ + gboolean result; + gchar* destPath = NULL; + gchar* sourcePath = NULL; + gchar* destBackupPath = NULL; + + if (destination_file_name != NULL) + { + destPath = mono_unicode_to_external(destination_file_name); + } + + if (source_file_name != NULL) + { + sourcePath = mono_unicode_to_external(source_file_name); + } + + if (destination_backup_file_name != NULL) + { + destBackupPath = mono_unicode_to_external(destination_backup_file_name); + } + + MONO_ENTER_GC_SAFE; + + result = UnityPalReplaceFile(sourcePath, destPath, destBackupPath, 0, error); + mono_w32error_set_last(*error); + + MONO_EXIT_GC_SAFE; + + g_free(destPath); + g_free(sourcePath); + g_free(destBackupPath); + + return result; +} + +gboolean +mono_w32file_copy (const gunichar2 *path, const gunichar2 *dest, gboolean overwrite, gint32 *error) +{ + gboolean result; + *error = 0; + + MONO_ENTER_GC_SAFE; + + gchar* palPath = mono_unicode_to_external(path); + gchar* palDest = mono_unicode_to_external(dest); + result = UnityPalCopyFile(palPath, palDest, overwrite, error); + mono_w32error_set_last(*error); + g_free(palPath); + g_free(palDest); + + MONO_EXIT_GC_SAFE; + + return result; +} + +gboolean +mono_w32file_lock (gpointer handle, gint64 position, gint64 length, gint32 *error) +{ + MONO_ENTER_GC_SAFE; + + UnityPalLock(handle, position, length, error); + mono_w32error_set_last(*error); + + MONO_EXIT_GC_SAFE; + + return (*error == 0); +} + +gboolean +mono_w32file_unlock (gpointer handle, gint64 position, gint64 length, gint32 *error) +{ + MONO_ENTER_GC_SAFE; + + UnityPalUnlock(handle, position, length, error); + mono_w32error_set_last(*error); + + MONO_EXIT_GC_SAFE; + + return (*error == 0); +} + +gpointer +mono_w32file_get_console_input (void) +{ + return UnityPalGetStdInput(); +} + +gpointer +mono_w32file_get_console_output (void) +{ + return UnityPalGetStdOutput(); +} + +gpointer +mono_w32file_get_console_error (void) +{ + return UnityPalGetStdError(); +} + +gint64 +mono_w32file_get_file_size (gpointer handle, gint32 *error) +{ + gint64 length; + + MONO_ENTER_GC_SAFE; + + length = UnityPalGetLength(handle, error); + mono_w32error_set_last(*error); + + MONO_EXIT_GC_SAFE; + + return length; +} + +guint32 +mono_w32file_get_drive_type (const gunichar2 *root_path_name) +{ + return 0; +} + +gint32 +mono_w32file_get_logical_drive (guint32 len, gunichar2 *buf) +{ + return -1; +} + +gboolean +mono_w32file_remove_directory (const gunichar2 *name) +{ + int error = 0; + + gchar* palPath = mono_unicode_to_external (name); + gboolean result = UnityPalDirectoryRemove(palPath, &error); + mono_w32error_set_last(error); + g_free(palPath); + + return result; +} + +gboolean mono_w32file_delete(const gunichar2 *name) +{ + int error = 0; + + gchar* palPath = mono_unicode_to_external (name); + gboolean result = UnityPalDeleteFile(palPath, &error); + mono_w32error_set_last (error); + g_free(palPath); + + return result; +} + +guint32 +mono_w32file_get_cwd (guint32 length, gunichar2 *buffer) +{ + /* length is the number of characters in buffer, including the null terminator */ + /* count is the number of characters in the current directory, including the null terminator */ + gunichar2 *utf16_path; + glong count; + uintptr_t bytes; + int error = 0; + + const char* palPath = UnityPalDirectoryGetCurrent(&error); + mono_w32error_set_last (error); + utf16_path = mono_unicode_from_external(palPath, &bytes); + count = (bytes / 2) + 1; + + if (count <= length) { + /* Add the terminator */ + memset (buffer, '\0', bytes+2); + memcpy (buffer, utf16_path, bytes); + } + + g_free(utf16_path); + g_free(palPath); + + return count; +} + +gboolean +mono_w32file_set_cwd (const gunichar2 *path) +{ + int error = 0; + + gchar* palPath = mono_unicode_to_external(path); + gboolean result = UnityPalDirectorySetCurrent(palPath, &error); + mono_w32error_set_last (error); + g_free(palPath); + + return result; +} + +gboolean +mono_w32file_set_length (gpointer handle, gint64 length, gint32 *error) +{ + gboolean result = UnityPalSetLength(handle, length, error); + mono_w32error_set_last(*error); + + return result; +} + +void +mono_w32file_cleanup (void) +{ +} + +void +mono_w32file_init (void) +{ +} diff --git a/mono/metadata/w32file.c b/mono/metadata/w32file.c index e2432c7dc2b9..9a9956323bcb 100644 --- a/mono/metadata/w32file.c +++ b/mono/metadata/w32file.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -190,6 +191,7 @@ MonoBoolean ves_icall_System_IO_MonoIO_CreateDirectory (const gunichar2 *path, gint32 *error) { gboolean ret; + path = mono_unity_get_remapped_path(path); *error=ERROR_SUCCESS; @@ -205,6 +207,7 @@ MonoBoolean ves_icall_System_IO_MonoIO_RemoveDirectory (const gunichar2 *path, gint32 *error) { gboolean ret; + path = mono_unity_get_remapped_path(path); *error=ERROR_SUCCESS; @@ -221,6 +224,7 @@ ves_icall_System_IO_MonoIO_FindFirstFile (const gunichar2 *path_with_pattern, Mo { HANDLE hnd; WIN32_FIND_DATA data; + path_with_pattern = mono_unity_get_remapped_path(path_with_pattern); hnd = mono_w32file_find_first (path_with_pattern, &data); @@ -315,6 +319,7 @@ ves_icall_System_IO_MonoIO_SetCurrentDirectory (const gunichar2 *path, gint32 *error) { gboolean ret; + path = mono_unity_get_remapped_path(path); *error=ERROR_SUCCESS; @@ -329,6 +334,12 @@ ves_icall_System_IO_MonoIO_SetCurrentDirectory (const gunichar2 *path, MonoBoolean ves_icall_System_IO_MonoIO_MoveFile (const gunichar2 *path, const gunichar2 *dest, gint32 *error) { + // TODO_UNITY + gboolean ret; + + path = mono_unity_get_remapped_path(path); + dest = mono_unity_get_remapped_path(dest); + *error=ERROR_SUCCESS; return mono_w32file_move (path, dest, error); } @@ -339,6 +350,9 @@ ves_icall_System_IO_MonoIO_ReplaceFile (const gunichar2 *source_file_name, const gint32 *error) { guint32 replace_flags = REPLACEFILE_WRITE_THROUGH; + source_file_name = mono_unity_get_remapped_path(source_file_name); + destination_file_name = mono_unity_get_remapped_path(destination_file_name); + destination_backup_file_name = mono_unity_get_remapped_path(destination_backup_file_name); *error = ERROR_SUCCESS; if (ignore_metadata_errors) @@ -353,6 +367,8 @@ MonoBoolean ves_icall_System_IO_MonoIO_CopyFile (const gunichar2 *path, const gunichar2 *dest, MonoBoolean overwrite, gint32 *error) { + path = mono_unity_get_remapped_path(path); + dest = mono_unity_get_remapped_path(dest); *error=ERROR_SUCCESS; return mono_w32file_copy (path, dest, overwrite, error); } @@ -361,6 +377,7 @@ MonoBoolean ves_icall_System_IO_MonoIO_DeleteFile (const gunichar2 *path, gint32 *error) { gboolean ret; + path = mono_unity_get_remapped_path(path); *error=ERROR_SUCCESS; @@ -376,6 +393,7 @@ gint32 ves_icall_System_IO_MonoIO_GetFileAttributes (const gunichar2 *path, gint32 *error) { gint32 ret; + path = mono_unity_get_remapped_path(path); *error=ERROR_SUCCESS; ret = mono_w32file_get_attributes (path); @@ -430,6 +448,7 @@ MonoBoolean ves_icall_System_IO_MonoIO_GetFileStat (const gunichar2 *path, MonoIOStat *stat, gint32 *error) { gboolean result; + path = mono_unity_get_remapped_path(path); *error=ERROR_SUCCESS; @@ -450,6 +469,7 @@ ves_icall_System_IO_MonoIO_Open (const gunichar2 *filename, gint32 mode, { HANDLE ret; int attributes, attrs; + filename = mono_unity_get_remapped_path(filename); *error=ERROR_SUCCESS; diff --git a/mono/metadata/w32mutex-unity.c b/mono/metadata/w32mutex-unity.c new file mode 100644 index 000000000000..f58205fca35c --- /dev/null +++ b/mono/metadata/w32mutex-unity.c @@ -0,0 +1,49 @@ +#include "w32mutex.h" +#include "Mutex-c-api.h" + +void +mono_w32mutex_init (void) +{ +} + +gpointer +ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoStringHandle name, MonoBoolean *created, MonoError *error) +{ + UnityPalMutex* mutex = NULL; + + *created = TRUE; + + if (!name) { + mutex = UnityPalMutexNew (owned); + } else { + g_assertion_message ("Named mutexes are not supported by the Unity platform."); + } + + return UnityPalMutexHandleNew(mutex); +} + +MonoBoolean +ves_icall_System_Threading_Mutex_ReleaseMutex_internal (gpointer handle) +{ + UnityPalMutexUnlock(UnityPalMutexHandleGet(handle)); + return TRUE; +} + +gpointer +ves_icall_System_Threading_Mutex_OpenMutex_internal (MonoStringHandle name, gint32 rights, gint32 *err, MonoError *error) +{ + g_assertion_message ("Named mutexes are not supported by the Unity platform."); + return NULL; +} + +MonoW32HandleNamespace* +mono_w32mutex_get_namespace (MonoW32HandleNamedMutex *mutex) +{ + g_assertion_message ("Named mutexes are not supported by the Unity platform."); + return NULL; +} + +void +mono_w32mutex_abandon (void) +{ +} diff --git a/mono/metadata/w32process-unity.c b/mono/metadata/w32process-unity.c new file mode 100644 index 000000000000..fdc276faa29e --- /dev/null +++ b/mono/metadata/w32process-unity.c @@ -0,0 +1,174 @@ +#include +#include + +#if defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS) + +void +mono_w32process_init (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +void +mono_w32process_cleanup (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +gpointer +ves_icall_System_Diagnostics_Process_GetProcess_internal (guint32 pid) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return NULL; +} + +MonoBoolean +ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoW32ProcessStartInfo *proc_start_info, MonoW32ProcessInfo *process_info) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +MonoBoolean +ves_icall_System_Diagnostics_Process_CreateProcess_internal (MonoW32ProcessStartInfo *proc_start_info, gpointer stdin_handle, + gpointer stdout_handle, gpointer stderr_handle, MonoW32ProcessInfo *process_info) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +MonoArray * +ves_icall_System_Diagnostics_Process_GetProcesses_internal (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return NULL; +} + +MonoBoolean +ves_icall_Microsoft_Win32_NativeMethods_CloseProcess (gpointer handle) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +MonoBoolean +ves_icall_Microsoft_Win32_NativeMethods_TerminateProcess (gpointer handle, gint32 exitcode) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +MonoBoolean +ves_icall_Microsoft_Win32_NativeMethods_GetExitCodeProcess (gpointer handle, gint32 *exitcode) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +MonoBoolean +ves_icall_Microsoft_Win32_NativeMethods_GetProcessWorkingSetSize (gpointer handle, gsize *min, gsize *max) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +MonoBoolean +ves_icall_Microsoft_Win32_NativeMethods_SetProcessWorkingSetSize (gpointer handle, gsize min, gsize max) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +gint32 +ves_icall_Microsoft_Win32_NativeMethods_GetPriorityClass (gpointer handle) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +MonoBoolean +ves_icall_Microsoft_Win32_NativeMethods_SetPriorityClass (gpointer handle, gint32 priorityClass) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +MonoBoolean +ves_icall_Microsoft_Win32_NativeMethods_GetProcessTimes (gpointer handle, gint64 *creationtime, gint64 *exittime, gint64 *kerneltime, gint64 *usertime) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +gpointer +ves_icall_Microsoft_Win32_NativeMethods_GetCurrentProcess (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +gboolean +mono_w32process_get_fileversion_info (gunichar2 *filename, guint32 handle, guint32 len, gpointer data) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +guint32 +mono_w32process_get_fileversion_info_size (gunichar2 *filename, guint32 *handle) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +guint32 +mono_w32process_get_pid (gpointer handle) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +guint32 +mono_w32process_module_get_filename (gpointer process, gpointer module, gunichar2 *basename, guint32 size) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +gboolean +mono_w32process_module_get_information (gpointer process, gpointer module, MODULEINFO *modinfo, guint32 size) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +guint32 +mono_w32process_module_get_name (gpointer process, gpointer module, gunichar2 *basename, guint32 size) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + + +gboolean +mono_w32process_try_get_modules (gpointer process, gpointer *modules, guint32 size, guint32 *needed) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +guint32 +mono_w32process_ver_language_name (guint32 lang, gunichar2 *lang_out, guint32 lang_len) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +gboolean +mono_w32process_ver_query_value (gconstpointer datablock, const gunichar2 *subblock, gpointer *buffer, guint32 *len) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +#endif /* PLATFORM_UNITY && UNITY_USE_PLATFORM_STUBS */ diff --git a/mono/metadata/w32semaphore-unity.c b/mono/metadata/w32semaphore-unity.c new file mode 100644 index 000000000000..778cb1693ccc --- /dev/null +++ b/mono/metadata/w32semaphore-unity.c @@ -0,0 +1,42 @@ +#include "w32semaphore.h" +#include "Semaphore-c-api.h" +#include "Error-c-api.h" + +void +mono_w32semaphore_init (void) +{ +} + +gpointer +ves_icall_System_Threading_Semaphore_CreateSemaphore_internal (gint32 initialCount, gint32 maximumCount, MonoString *name, gint32 *error) +{ + if (name != NULL) + { + g_assertion_message("Named semaphores are not supported by the Unity platform."); + return NULL; + } + + UnityPalSemaphore* semaphore = UnityPalSemaphoreNew(initialCount, maximumCount); + *error = UnityPalGetLastError(); + return UnityPalSemaphoreHandleNew(semaphore); +} + +MonoBoolean +ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal (gpointer handle, gint32 releaseCount, gint32 *prevcount) +{ + return UnityPalSemaphorePost(UnityPalSemaphoreHandleGet(handle), releaseCount, prevcount); +} + +gpointer +ves_icall_System_Threading_Semaphore_OpenSemaphore_internal (MonoString *name, gint32 rights, gint32 *error) +{ + g_assertion_message("Named semaphores are not supported by the Unity platform."); + return NULL; +} + +MonoW32HandleNamespace* +mono_w32semaphore_get_namespace (MonoW32HandleNamedSemaphore *semaphore) +{ + g_assertion_message("Named semaphores are not supported by the Unity platform."); + return NULL; +} diff --git a/mono/metadata/w32socket-internals.h b/mono/metadata/w32socket-internals.h index 62e2eb154c9c..7557818a630d 100644 --- a/mono/metadata/w32socket-internals.h +++ b/mono/metadata/w32socket-internals.h @@ -63,6 +63,9 @@ mono_w32socket_cleanup (void); SOCKET mono_w32socket_accept (SOCKET s, struct sockaddr *addr, socklen_t *addrlen, gboolean blocking); +SOCKET +mono_w32socket_accept_internal (SOCKET s, struct sockaddr *addr, socklen_t *addrlen, gboolean blocking); + int mono_w32socket_connect (SOCKET s, const struct sockaddr *name, int namelen, gboolean blocking); diff --git a/mono/metadata/w32socket-unity.c b/mono/metadata/w32socket-unity.c new file mode 100644 index 000000000000..636710383552 --- /dev/null +++ b/mono/metadata/w32socket-unity.c @@ -0,0 +1,190 @@ +#include "w32socket.h" +#include "w32socket-internals.h" + +#if defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS) + +gboolean +ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +MonoBoolean +ves_icall_System_Net_Dns_GetHostByName_internal (MonoString *host, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list, gint32 hint) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +void +mono_w32socket_initialize (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +void +mono_w32socket_cleanup (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +SOCKET mono_w32socket_accept (SOCKET s, struct sockaddr *addr, socklen_t *addrlen, gboolean blocking) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return INVALID_SOCKET; +} + +int mono_w32socket_connect (SOCKET s, const struct sockaddr *name, int namelen, gboolean blocking) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +int mono_w32socket_recv (SOCKET s, char *buf, int len, int flags, gboolean blocking) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +int mono_w32socket_recvfrom (SOCKET s, char *buf, int len, int flags, struct sockaddr *from, socklen_t *fromlen, gboolean blocking) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +int mono_w32socket_recvbuffers (SOCKET s, WSABUF *lpBuffers, guint32 dwBufferCount, guint32 *lpNumberOfBytesRecvd, guint32 *lpFlags, gpointer lpOverlapped, gpointer lpCompletionRoutine, gboolean blocking) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +int mono_w32socket_send (SOCKET s, char *buf, int len, int flags, gboolean blocking) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +int mono_w32socket_sendto (SOCKET s, const char *buf, int len, int flags, const struct sockaddr *to, int tolen, gboolean blocking) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +int mono_w32socket_sendbuffers (SOCKET s, WSABUF *lpBuffers, guint32 dwBufferCount, guint32 *lpNumberOfBytesRecvd, guint32 lpFlags, gpointer lpOverlapped, gpointer lpCompletionRoutine, gboolean blocking) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +BOOL mono_w32socket_transmit_file (SOCKET hSocket, gpointer hFile, TRANSMIT_FILE_BUFFERS *lpTransmitBuffers, guint32 dwReserved, gboolean blocking) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +gint +mono_w32socket_disconnect (SOCKET sock, gboolean reuse) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +gint +mono_w32socket_set_blocking (SOCKET sock, gboolean blocking) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +gint +mono_w32socket_get_available (SOCKET sock, guint64 *amount) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +void +mono_w32socket_set_last_error (gint32 error) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +gint32 +mono_w32socket_get_last_error (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +gint32 +mono_w32socket_convert_error (gint error) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +gint +mono_w32socket_bind (SOCKET sock, struct sockaddr *addr, socklen_t addrlen) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +gint +mono_w32socket_getpeername (SOCKET sock, struct sockaddr *name, socklen_t *namelen) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +gint +mono_w32socket_getsockname (SOCKET sock, struct sockaddr *name, socklen_t *namelen) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +gint +mono_w32socket_getsockopt (SOCKET sock, gint level, gint optname, gpointer optval, socklen_t *optlen) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +gint +mono_w32socket_setsockopt (SOCKET sock, gint level, gint optname, const gpointer optval, socklen_t optlen) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +gint +mono_w32socket_listen (SOCKET sock, gint backlog) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +gint +mono_w32socket_shutdown (SOCKET sock, gint how) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +SOCKET +mono_w32socket_socket (int domain, int type, int protocol) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return INVALID_SOCKET; +} + +gboolean +mono_w32socket_close (SOCKET sock) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +#endif /* PLATFORM_UNITY && UNITY_USE_PLATFORM_STUBS */ diff --git a/mono/metadata/w32socket-win32.c b/mono/metadata/w32socket-win32.c index 076500687bae..400497ac3597 100644 --- a/mono/metadata/w32socket-win32.c +++ b/mono/metadata/w32socket-win32.c @@ -136,7 +136,6 @@ static gboolean alertable_socket_wait (SOCKET sock, int event_bit) SOCKET mono_w32socket_accept (SOCKET s, struct sockaddr *addr, socklen_t *addrlen, gboolean blocking) { - MonoInternalThread *curthread = mono_thread_internal_current (); SOCKET newsock = INVALID_SOCKET; MONO_ENTER_GC_SAFE; ALERTABLE_SOCKET_CALL (FD_ACCEPT_BIT, blocking, TRUE, newsock, accept, s, addr, addrlen); diff --git a/mono/metadata/w32socket.c b/mono/metadata/w32socket.c index 8fab506185d0..4e9121f0edf9 100644 --- a/mono/metadata/w32socket.c +++ b/mono/metadata/w32socket.c @@ -2466,6 +2466,12 @@ ves_icall_System_Net_Sockets_Socket_IOControl_internal (gsize sock, gint32 code, return (gint)output_bytes; } +MonoBoolean +ves_icall_System_Net_Sockets_Socket_IsProtocolSupported_internal (gint32 networkInterface) +{ + return TRUE; +} + static gboolean addrinfo_add_string (MonoDomain *domain, const char *s, MonoArrayHandle arr, int index, MonoError *error) { diff --git a/mono/metadata/w32socket.h b/mono/metadata/w32socket.h index b03ac936738b..4208591c41fc 100644 --- a/mono/metadata/w32socket.h +++ b/mono/metadata/w32socket.h @@ -265,6 +265,9 @@ ves_icall_System_Net_Dns_GetHostByName_internal (MonoStringHandle host, MonoStri MonoArrayHandleOut h_aliases, MonoArrayHandleOut h_addr_list, gint32 hint, MonoError *error); +MonoBoolean +ves_icall_System_Net_Sockets_Socket_IsProtocolSupported_internal (gint32 networkInterface); + MonoBoolean ves_icall_System_Net_Dns_GetHostByAddr_internal (MonoStringHandle addr, MonoStringHandleOut h_name, MonoArrayHandleOut h_aliases, MonoArrayHandleOut h_addr_list, diff --git a/mono/mini/.gitignore b/mono/mini/.gitignore index af434f4218a0..0fb8914a9923 100644 --- a/mono/mini/.gitignore +++ b/mono/mini/.gitignore @@ -31,6 +31,7 @@ /TAGS /mono-sgen /mono-boehm +/mono-bdwgc /buildver-sgen.h /buildver-boehm.h /regressiontests.out diff --git a/mono/mini/Makefile.am.in b/mono/mini/Makefile.am.in index 400646c70b44..c3bca5a13773 100755 --- a/mono/mini/Makefile.am.in +++ b/mono/mini/Makefile.am.in @@ -18,12 +18,21 @@ libgc_libs=$(monodir)/libgc/libmonogc.la libgc_static_libs=$(monodir)/libgc/libmonogc-static.la endif +libbdwgc_libs=$(monodir)/external/bdwgc/libgc.la +libbdwgc_static_libs=$(monodir)/external/bdwgc/libgc-static.la + boehm_libs= \ $(monodir)/mono/metadata/libmonoruntime.la \ $(monodir)/mono/utils/libmonoutils.la \ $(GLIB_LIBS) $(LIBICONV) \ $(libgc_libs) +bdwgc_libs= \ + $(monodir)/mono/metadata/libmonoruntimebdwgc.la \ + $(monodir)/mono/utils/libmonoutils.la \ + $(GLIB_LIBS) $(LIBICONV) \ + $(libbdwgc_libs) + sgen_libs = \ $(monodir)/mono/metadata/libmonoruntimesgen.la \ $(monodir)/mono/sgen/libmonosgen.la \ @@ -36,6 +45,12 @@ boehm_static_libs= \ $(GLIB_LIBS) $(LIBICONV) \ $(libgc_static_libs) +bdwgc_static_libs= \ + $(monodir)/mono/metadata/libmonoruntimebdwgc-static.la \ + $(monodir)/mono/utils/libmonoutils.la \ + $(GLIB_LIBS) $(LIBICONV) \ + $(libbdwgc_static_libs) + sgen_static_libs = \ $(monodir)/mono/metadata/libmonoruntimesgen-static.la \ $(monodir)/mono/sgen/libmonosgen-static.la \ @@ -105,15 +120,28 @@ boehm_libraries = libmonoboehm-2.0.la boehm_static_libraries = libmini-static.la $(boehm_static_libs) boehm_binaries = mono-boehm endif + +if SUPPORT_BDWGC +bdwgc_libraries = libmonobdwgc-2.0.la +bdwgc_static_libraries = libmini-static.la $(bdwgc_static_libs) +bdwgc_binaries = mono-bdwgc +endif if SUPPORT_SGEN mono_bin_suffix = sgen libmono_suffix = sgen -else +endif + +if SUPPORT_BOEHM mono_bin_suffix = boehm libmono_suffix = boehm endif +if SUPPORT_BDWGC +mono_bin_suffix = bdwgc +libmono_suffix = bdwgc +endif + if DISABLE_EXECUTABLES else mono: mono-$(mono_bin_suffix) @@ -130,9 +158,9 @@ endif if DISABLE_EXECUTABLES else if HOST_WIN32 -bin_PROGRAMS = $(boehm_binaries) $(sgen_binaries) monow +bin_PROGRAMS = $(boehm_binaries) $(bdwgc_binaries) $(sgen_binaries) monow else -bin_PROGRAMS = $(boehm_binaries) $(sgen_binaries) +bin_PROGRAMS = $(boehm_binaries) $(bdwgc_binaries) $(sgen_binaries) endif endif @@ -143,10 +171,10 @@ noinst_PROGRAMS = genmdesc mono endif if DISABLE_EXECUTABLES -shared_libraries = $(boehm_libraries) $(sgen_libraries) +shared_libraries = $(boehm_libraries) $(bdwgc_libraries) $(sgen_libraries) else if SHARED_MONO -shared_libraries = $(boehm_libraries) $(sgen_libraries) +shared_libraries = $(boehm_libraries) $(bdwgc_libraries) $(sgen_libraries) endif endif @@ -182,6 +210,11 @@ mono_CFLAGS = $(AM_CFLAGS) mono_boehm_CFLAGS = $(AM_CFLAGS) +mono_bdwgc_SOURCES = \ + main.c + +mono_bdwgc_CFLAGS = $(AM_CFLAGS) + AM_CPPFLAGS = $(LIBGC_CPPFLAGS) mono_sgen_SOURCES = \ @@ -204,6 +237,16 @@ endif mono_boehm-main.$(OBJEXT): buildver-boehm.h endif +if SUPPORT_BDWGC +if DISABLE_EXECUTABLES +buildver-boehm.h: libmini-static.la $(monodir)/mono/metadata/libmonoruntimebdwgc.la +else +buildver-boehm.h: libmini-static.la $(monodir)/mono/metadata/libmonoruntimebdwgc-static.la +endif + @echo "const char *build_date = \"`date`\";" > buildver-boehm.h +mono_bdwgc-main.$(OBJEXT): buildver-boehm.h +endif + if DISABLE_EXECUTABLES buildver-sgen.h: libmini-static.la $(monodir)/mono/metadata/libmonoruntimesgen.la $(monodir)/mono/sgen/libmonosgen.la else @@ -230,9 +273,11 @@ if STATIC_MONO # This leads to higher performance, especially with TLS MONO_LIB=$(boehm_static_libraries) MONO_SGEN_LIB=$(sgen_static_libraries) +MONO_BDWGC_LIB=$(bdwgc_static_libraries) else MONO_LIB=libmonoboehm-2.0.la MONO_SGEN_LIB=libmonosgen-2.0.la +MONO_BDWGC_LIB=libmonobdwgc-2.0.la endif if LOADED_LLVM @@ -252,6 +297,17 @@ mono_boehm_LDADD = \ mono_boehm_LDFLAGS = \ $(static_flags) -export-dynamic $(monobinldflags) $(monobin_platform_ldflags) +mono_bdwgc_LDADD = \ + $(MONO_BDWGC_LIB) \ + $(GLIB_LIBS) \ + $(LLVMMONOF) \ + $(LIBICONV) \ + -lm \ + $(MONO_DTRACE_OBJECT) + +mono_bdwgc_LDFLAGS = \ + $(static_flags) -export-dynamic $(monobinldflags) $(monobin_platform_ldflags) + mono_sgen_LDADD = \ $(MONO_SGEN_LIB) \ $(GLIB_LIBS) \ @@ -292,7 +348,13 @@ if SUPPORT_BOEHM monow_LDADD = $(mono_boehm_LDADD) monow_LDFLAGS = $(mono_boehm_LDFLAGS) -mwindows monow_SOURCES = $(mono_boehm_SOURCES) -else +endif +if SUPPORT_BDWGC +monow_LDADD = $(mono_bdwgc_LDADD) +monow_LDFLAGS = $(mono_bdwgc_LDFLAGS) -mwindows +monow_SOURCES = $(mono_bdwgc_SOURCES) +endif +if SUPPORT_SGEN monow_LDADD = $(mono_sgen_LDADD) monow_LDFLAGS = $(mono_sgen_LDFLAGS) -mwindows monow_SOURCES = $(mono_sgen_SOURCES) @@ -312,6 +374,9 @@ genmdesc_LDADD = \ $(GLIB_LIBS) \ $(LIBICONV) +unity_sources = \ + mini-unity.c + wasm_sources = \ mini-wasm.c \ mini-wasm.h \ @@ -496,8 +561,10 @@ common_sources = \ type-checking.c \ lldb.h \ lldb.c \ + pmip_my_callstack.h \ + pmip_my_callstack.c \ memory-access.c \ - mini-profiler.c + mini-profiler.c test_sources = \ basic-calls.cs \ @@ -638,7 +705,7 @@ os_sources = $(darwin_sources) $(posix_sources) monobin_platform_ldflags=-framework CoreFoundation -framework Foundation endif -libmini_la_SOURCES = $(common_sources) $(llvm_sources) $(llvm_runtime_sources) $(interp_sources) $(arch_sources) $(os_sources) +libmini_la_SOURCES = $(common_sources) $(llvm_sources) $(llvm_runtime_sources) $(interp_sources) $(arch_sources) $(os_sources) $(unity_sources) libmini_la_CFLAGS = $(mono_CFLAGS) libmonoboehm_2_0_la_SOURCES = @@ -646,6 +713,11 @@ libmonoboehm_2_0_la_CFLAGS = $(mono_boehm_CFLAGS) libmonoboehm_2_0_la_LIBADD = libmini.la $(boehm_libs) $(LIBMONO_DTRACE_OBJECT) $(LLVMMONOF) libmonoboehm_2_0_la_LDFLAGS = $(libmonoldflags) $(monobin_platform_ldflags) +libmonobdwgc_2_0_la_SOURCES = +libmonobdwgc_2_0_la_CFLAGS = $(mono_bdwgc_CFLAGS) +libmonobdwgc_2_0_la_LIBADD = libmini.la $(bdwgc_libs) $(LIBMONO_DTRACE_OBJECT) $(LLVMMONOF) +libmonobdwgc_2_0_la_LDFLAGS = $(libmonoldflags) $(monobin_platform_ldflags) + libmonosgen_2_0_la_SOURCES = libmonosgen_2_0_la_CFLAGS = $(mono_sgen_CFLAGS) libmonosgen_2_0_la_LIBADD = libmini.la $(sgen_libs) $(LIBMONO_DTRACE_OBJECT) $(LLVMMONOF) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index a5fbec9de5cd..94c64bedf332 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -64,6 +64,7 @@ #include #include #include +#include #include #include #include @@ -73,7 +74,6 @@ #include #include #include -#include "debugger-agent.h" #include "mini.h" #include "seq-points.h" #include "interp/interp.h" @@ -99,7 +99,9 @@ #include -#define THREAD_TO_INTERNAL(thread) (thread)->internal_thread +#define THREAD_TO_INTERNAL(thread) VM_THREAD_GET_INTERNAL(thread) + +#include "debugger-agent.h" typedef struct { gboolean enabled; @@ -173,6 +175,10 @@ struct _InvokeData typedef struct { MonoThreadUnwindState context; +#ifdef IL2CPP_MONO_DEBUGGER + Il2CppThreadUnwindState il2cpp_context; +#endif + /* This is computed on demand when it is requested using the wire protocol */ /* It is freed up when the thread is resumed */ int frame_count; @@ -205,6 +211,8 @@ typedef struct { MonoContext handler_ctx; /* Whenever thread_stop () was called for this thread */ gboolean terminated; + /* If thread should be suspended and processed. FALSE if fast detach has been called */ + gboolean attached; /* Whenever to disable breakpoints (used during invokes) */ gboolean disable_breakpoints; @@ -590,7 +598,7 @@ typedef struct { char *category, *message; /* For EVENT_KIND_TYPE_LOAD */ MonoClass *klass; -} EventInfo; +} DebuggerEventInfo; typedef struct { guint8 *buf, *p, *end; @@ -795,6 +803,10 @@ static void suspend_init (void); static void ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint *sp, MonoSeqPointInfo *info, MonoContext *ctx, DebuggerTlsData *tls, gboolean step_to_catch, StackFrame **frames, int nframes); +#ifdef IL2CPP_MONO_DEBUGGER +static void ss_start_il2cpp(SingleStepReq *ss_req, DebuggerTlsData *tls); +static void GetSequencePointsAndSourceFilesUniqueSequencePoints(MonoMethod* method, GPtrArray** sequencePoints, GPtrArray** uniqueFileSequencePoints, GArray** uniqueFileSequencePointIndices); +#endif static ErrorCode ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilter filter, EventRequest *req); static void ss_destroy (SingleStepReq *req); @@ -812,6 +824,25 @@ static void register_socket_transport (void); #endif +#ifndef IL2CPP_MONO_DEBUGGER +static MonoAssembly* mono_domain_get_assemblies_iter(MonoDomain *domain, void* *iter) +{ + if (!iter) + return NULL; + + if (*iter) + *iter = ((GList*)(*iter))->next; + else + *iter = domain->domain_assemblies; + + + if (*iter) + return ((GList*)(*iter))->data; + else + return NULL; +} +#endif + static inline gboolean is_debugger_thread (void) { @@ -821,7 +852,11 @@ is_debugger_thread (void) if (!internal) return FALSE; +#ifndef IL2CPP_MONO_DEBUGGER return internal->debugger_thread; +#else + return debugger_thread_id == mono_native_thread_id_get (); +#endif } static int @@ -1036,6 +1071,7 @@ mono_debugger_agent_init (void) breakpoints_init (); suspend_init (); +#ifndef IL2CPP_MONO_DEBUGGER mini_get_debug_options ()->gen_sdb_seq_points = TRUE; /* * This is needed because currently we don't handle liveness info. @@ -1054,6 +1090,7 @@ mono_debugger_agent_init (void) * workaround. */ mini_get_debug_options ()->load_aot_jit_info_eagerly = TRUE; +#endif // !IL2CPP_MONO_DEBUGGER #ifdef HAVE_SETPGID if (agent_config.setpgid) @@ -1064,6 +1101,26 @@ mono_debugger_agent_init (void) finish_agent_init (TRUE); } +#ifdef IL2CPP_MONO_DEBUGGER +void +mono_debugger_run_debugger_thread_func(void* arg) +{ + debugger_thread(arg); +} + +typedef struct { + void(*il2cpp_debugger_save_thread_context)(Il2CppThreadUnwindState* context); +} MonoDebuggerRuntimeCallbacks; + +static MonoDebuggerRuntimeCallbacks callbacks; + +void mono_debugger_install_runtime_callbacks(MonoDebuggerRuntimeCallbacks* cbs) +{ + callbacks = *cbs; +} + +#endif // IL2CPP_MONO_DEBUGGER + /* * finish_agent_init: * @@ -1191,7 +1248,13 @@ static int socket_transport_accept (int socket_fd) { MONO_ENTER_GC_SAFE; +#if defined(HOST_WIN32) && !defined(IL2CPP_MONO_DEBUGGER) + conn_fd = mono_w32socket_accept (socket_fd, NULL, NULL, TRUE); + if (conn_fd != -1) + mono_w32socket_set_blocking (conn_fd, TRUE); +#else conn_fd = accept (socket_fd, NULL, NULL); +#endif MONO_EXIT_GC_SAFE; if (conn_fd == -1) { @@ -1395,6 +1458,9 @@ socket_transport_close1 (void) /* Close the read part only so it can still send back replies */ /* Also shut down the connection listener so that we can exit normally */ #ifdef HOST_WIN32 + MonoThreadInfo* info = mono_thread_info_lookup (debugger_thread_id); + if (info) + mono_threads_suspend_abort_syscall (info); /* SD_RECEIVE doesn't break the recv in the debugger thread */ shutdown (conn_fd, SD_BOTH); shutdown (listen_fd, SD_BOTH); @@ -1646,12 +1712,15 @@ start_debugger_thread (void) { MonoError error; MonoInternalThread *thread; - +#ifdef IL2CPP_MONO_DEBUGGER + il2cpp_start_debugger_thread (); +#else thread = mono_thread_create_internal (mono_get_root_domain (), debugger_thread, NULL, MONO_THREAD_CREATE_FLAGS_DEBUGGER, &error); mono_error_assert_ok (&error); debugger_thread_handle = mono_threads_open_thread_handle (thread->handle); g_assert (debugger_thread_handle); +#endif // IL2CPP_MONO_DEBUGGER; } /* @@ -2168,6 +2237,36 @@ typedef struct { /* Protected by the dbg lock */ static GPtrArray *ids [ID_NUM]; +#ifdef IL2CPP_MONO_DEBUGGER + +static GHashTable* s_jit_info_hashtable; + +void mono_debugger_il2cpp_init () +{ + s_jit_info_hashtable = g_hash_table_new_full(mono_aligned_addr_hash, NULL, NULL, NULL); +} + +static gpointer +unity_mono_jit_find_compiled_method_with_jit_info(MonoDomain *domain, MonoMethod *method, MonoJitInfo **ji) +{ + MonoJitInfo* ji2; + + g_assert(mono_get_root_domain() == domain); + + ji2 = g_hash_table_lookup(s_jit_info_hashtable, method); + + if (!ji2) + { + *ji = NULL; + return NULL; + } + + *ji = ji2; + return ji2->code_start; +} + +#endif // IL2CPP_MONO_DEBUGGER + static void ids_init (void) { @@ -2195,7 +2294,7 @@ ids_cleanup (void) void mono_debugger_agent_free_domain_info (MonoDomain *domain) { - AgentDomainInfo *info = (AgentDomainInfo *)domain_jit_info (domain)->agent_info; + AgentDomainInfo *info = (AgentDomainInfo *)VM_DOMAIN_GET_AGENT_INFO(domain); int i, j; GHashTableIter iter; GPtrArray *file_names; @@ -2230,7 +2329,7 @@ mono_debugger_agent_free_domain_info (MonoDomain *domain) g_free (info); } - domain_jit_info (domain)->agent_info = NULL; + VM_DOMAIN_SET_AGENT_INFO(domain, NULL); /* Clear ids referencing structures in the domain */ dbg_lock (); @@ -2257,10 +2356,10 @@ get_agent_domain_info (MonoDomain *domain) mono_domain_lock (domain); - info = (AgentDomainInfo *)domain_jit_info (domain)->agent_info; + info = (AgentDomainInfo *)VM_DOMAIN_GET_AGENT_INFO(domain); if (!info) { info = g_new0 (AgentDomainInfo, 1); - domain_jit_info (domain)->agent_info = info; + VM_DOMAIN_SET_AGENT_INFO(domain, info); info->loaded_classes = g_hash_table_new (mono_aligned_addr_hash, NULL); info->source_files = g_hash_table_new (mono_aligned_addr_hash, NULL); info->source_file_to_class = g_hash_table_new (g_str_hash, g_str_equal); @@ -2359,7 +2458,7 @@ decode_typeid (guint8 *buf, guint8 **endbuf, guint8 *limit, MonoDomain **domain, if (G_UNLIKELY (log_level >= 2) && klass) { char *s; - s = mono_type_full_name (&klass->byval_arg); + s = mono_type_full_name (mono_class_get_type(klass)); DEBUG_PRINTF (2, "[dbg] recv class [%s]\n", s); g_free (s); } @@ -2419,7 +2518,7 @@ buffer_add_typeid (Buffer *buf, MonoDomain *domain, MonoClass *klass) if (G_UNLIKELY (log_level >= 2) && klass) { char *s; - s = mono_type_full_name (&klass->byval_arg); + s = mono_type_full_name (mono_class_get_type(klass)); if (is_debugger_thread ()) DEBUG_PRINTF (2, "[dbg] send class [%s]\n", s); else @@ -2447,8 +2546,11 @@ buffer_add_assemblyid (Buffer *buf, MonoDomain *domain, MonoAssembly *assembly) int id; id = buffer_add_ptr_id (buf, domain, ID_ASSEMBLY, assembly); - if (G_UNLIKELY (log_level >= 2) && assembly) - DEBUG_PRINTF (2, "[dbg] send assembly [%s][%s][%d]\n", assembly->aname.name, domain->friendly_name, id); + if (G_UNLIKELY (log_level >= 2) && assembly) { + char* name = VM_ASSEMBLY_GET_NAME(assembly); + DEBUG_PRINTF (2, "[dbg] send assembly [%s][%s][%d]\n", name, VM_DOMAIN_GET_NAME(domain), id); + VM_ASSEMBLY_FREE_NAME(name); + } } static inline void @@ -2480,7 +2582,7 @@ static void invoke_method (void); /* * SUSPEND/RESUME */ - +#ifndef IL2CPP_MONO_DEBUGGER static MonoJitInfo* get_top_method_ji (gpointer ip, MonoDomain **domain, gpointer *out_ip) { @@ -2509,6 +2611,7 @@ get_top_method_ji (gpointer ip, MonoDomain **domain, gpointer *out_ip) } return ji; } +#endif /* * save_thread_context: @@ -2524,10 +2627,14 @@ save_thread_context (MonoContext *ctx) tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id); g_assert (tls); +#ifndef IL2CPP_MONO_DEBUGGER if (ctx) mono_thread_state_init_from_monoctx (&tls->context, ctx); else mono_thread_state_init_from_current (&tls->context); +#else + callbacks.il2cpp_debugger_save_thread_context(&tls->il2cpp_context); +#endif // !IL2CPP_MONO_DEBUGGER } /* Number of threads suspended */ @@ -2594,7 +2701,7 @@ copy_unwind_state_from_frame_data (MonoThreadUnwindState *to, GetLastFrameUserDa to->unwind_data [MONO_UNWIND_DATA_JIT_TLS] = jit_tls; to->valid = TRUE; } - +#ifndef IL2CPP_MONO_DEBUGGER /* * thread_interrupt: * @@ -2679,6 +2786,7 @@ thread_interrupt (DebuggerTlsData *tls, MonoThreadInfo *info, MonoJitInfo *ji) } } } +#endif /* * reset_native_thread_suspend_state: @@ -2714,6 +2822,12 @@ debugger_interrupt_critical (MonoThreadInfo *info, gpointer user_data) MonoJitInfo *ji; data->valid_info = TRUE; +#ifdef IL2CPP_MONO_DEBUGGER + if (!data->tls->suspended && !data->tls->suspending) { + data->tls->suspended = TRUE; + mono_coop_sem_post(&suspend_sem); + } +#else ji = mono_jit_info_table_find_internal ( (MonoDomain *)mono_thread_info_get_suspend_state (info)->unwind_data [MONO_UNWIND_DATA_DOMAIN], (char *)MONO_CONTEXT_GET_IP (&mono_thread_info_get_suspend_state (info)->ctx), @@ -2722,6 +2836,7 @@ debugger_interrupt_critical (MonoThreadInfo *info, gpointer user_data) /* This is signal safe */ thread_interrupt (data->tls, info, ji); +#endif // IL2CPP_MONO_DEBUGGER return MonoResumeThread; } @@ -2756,6 +2871,7 @@ notify_thread (gpointer key, gpointer value, gpointer user_data) } } +#ifndef IL2CPP_MONO_DEBUGGER static void process_suspend (DebuggerTlsData *tls, MonoContext *ctx) { @@ -2795,13 +2911,14 @@ process_suspend (DebuggerTlsData *tls, MonoContext *ctx) g_assert (ji); /* Can't suspend in these methods */ method = jinfo_get_method (ji); - if (method->klass == mono_defaults.string_class && (!strcmp (method->name, "memset") || strstr (method->name, "memcpy"))) + if (method->klass == mono_defaults.string_class && (!strcmp (mono_method_get_name(method), "memset") || strstr (mono_method_get_name(method), "memcpy"))) return; save_thread_context (ctx); suspend_current (); } +#endif /* * suspend_vm: @@ -3219,7 +3336,7 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) if (tls->frames && tls->frames_up_to_date) return; - DEBUG_PRINTF (1, "Frames for %p(tid=%lx):\n", thread, (glong)thread->tid); + DEBUG_PRINTF (1, "Frames for %p(tid=%lx):\n", thread, VM_INTERNAL_THREAD_GET_ID(thread)); user_data.tls = tls; user_data.frames = NULL; @@ -3227,10 +3344,17 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) tls->frame_count = 0; return; } if (!tls->really_suspended && tls->async_state.valid) { +#ifdef IL2CPP_MONO_DEBUGGER + NOT_IMPLEMENTED; +#else /* Have to use the state saved by the signal handler */ process_frame (&tls->async_last_frame, NULL, &user_data); mono_walk_stack_with_state (process_frame, &tls->async_state, opts, &user_data); +#endif // IL2CPP_MONO_DEBUGGER } else if (tls->filter_state.valid) { +#ifdef IL2CPP_MONO_DEBUGGER + NOT_IMPLEMENTED; +#else /* * We are inside an exception filter. * @@ -3244,8 +3368,32 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) * After that, we resume unwinding from the location where the exception has been thrown. */ mono_walk_stack_with_state (process_frame, &tls->filter_state, opts, &user_data); +#endif // IL2CPP_MONO_DEBUGGER } else if (tls->context.valid) { +#ifdef IL2CPP_MONO_DEBUGGER + NOT_IMPLEMENTED; +#else mono_walk_stack_with_state (process_frame, &tls->context, opts, &user_data); +#endif // IL2CPP_MONO_DEBUGGER +#ifdef IL2CPP_MONO_DEBUGGER + } else if (tls->il2cpp_context.frameCount > 0) { + for (int frame_index = tls->il2cpp_context.frameCount - 1; frame_index >= 0; --frame_index) + { + Il2CppSequencePointC* seq_point = tls->il2cpp_context.sequencePoints[frame_index]; + StackFrame* frame = g_new0(StackFrame, 1); + frame->method = seq_point->method; + frame->actual_method = seq_point->method; + frame->api_method = seq_point->method; + frame->il_offset = seq_point->ilOffset; + frame->native_offset = 0; + frame->flags = 0; + frame->ji = 0; + frame->domain = mono_domain_get(); + frame->has_ctx = 1; + + user_data.frames = g_slist_append(user_data.frames, frame); + } +#endif // IL2CPP_MONO_DEBUGGER } else { // FIXME: tls->frame_count = 0; @@ -3258,6 +3406,7 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) for (tmp = user_data.frames; tmp; tmp = tmp->next) { f = (StackFrame *)tmp->data; +#ifndef IL2CPP_DEBUGGER /* * Reuse the id for already existing stack frames, so invokes don't invalidate * the still valid stack frames. @@ -3268,6 +3417,7 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) break; } } +#endif // !IL2CPP_MONO_DEBUGGER if (i >= tls->frame_count) f->id = mono_atomic_inc_i32 (&frame_id); @@ -3425,6 +3575,26 @@ init_jit_info_dbg_attrs (MonoJitInfo *ji) ji->dbg_attrs_inited = TRUE; } +static gboolean find_source_file_in_hash_table(const char* needle, GHashTable* haystack) +{ + gboolean found = FALSE; + char *s = strdup_tolower(needle); + if (g_hash_table_lookup(haystack, s)) { + found = TRUE; + } else { + char *s2 = dbg_path_get_basename(needle); + char *s3 = strdup_tolower(s2); + + if (g_hash_table_lookup(haystack, s3)) + found = TRUE; + g_free(s2); + g_free(s3); + } + g_free(s); + + return found; +} + /* * EVENT HANDLING */ @@ -3440,7 +3610,7 @@ init_jit_info_dbg_attrs (MonoJitInfo *ji) * LOCKING: Assumes the loader lock is held. */ static GSList* -create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, EventInfo *ei, int *suspend_policy) +create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEventInfo *ei, int *suspend_policy) { int i, j; GSList *events = NULL; @@ -3475,9 +3645,9 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, EventInfo if (mod->data.thread != mono_thread_internal_current ()) filtered = TRUE; } else if (mod->kind == MOD_KIND_EXCEPTION_ONLY && ei) { - if (mod->data.exc_class && mod->subclasses && !mono_class_is_assignable_from (mod->data.exc_class, ei->exc->vtable->klass)) + if (mod->data.exc_class && mod->subclasses && !mono_class_is_assignable_from (mod->data.exc_class, VM_OBJECT_GET_CLASS(ei->exc))) filtered = TRUE; - if (mod->data.exc_class && !mod->subclasses && mod->data.exc_class != ei->exc->vtable->klass) + if (mod->data.exc_class && !mod->subclasses && mod->data.exc_class != VM_OBJECT_GET_CLASS(ei->exc)) filtered = TRUE; if (ei->caught && !mod->caught) filtered = TRUE; @@ -3504,6 +3674,21 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, EventInfo int i; GPtrArray *source_file_list; +#ifdef IL2CPP_MONO_DEBUGGER + int fileCount; + const char **files; + + files = il2cpp_get_source_files_for_type(ei->klass, &fileCount); + for (int i = 0; i < fileCount; ++i) + { + char *s = strdup_tolower(files[i]); + + found = find_source_file_in_hash_table(s, mod->data.source_files); + g_free(s); + if (found) + break; + } +#else while ((method = mono_class_get_methods (ei->klass, &iter))) { MonoDebugMethodInfo *minfo = mono_debug_lookup_method (method); @@ -3511,33 +3696,20 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, EventInfo mono_debug_get_seq_points (minfo, &source_file, &source_file_list, NULL, NULL, NULL); for (i = 0; i < source_file_list->len; ++i) { sinfo = (MonoDebugSourceInfo *)g_ptr_array_index (source_file_list, i); - /* - * Do a case-insesitive match by converting the file name to - * lowercase. - */ - s = strdup_tolower (sinfo->source_file); - if (g_hash_table_lookup (mod->data.source_files, s)) - found = TRUE; - else { - char *s2 = dbg_path_get_basename (sinfo->source_file); - char *s3 = strdup_tolower (s2); - - if (g_hash_table_lookup (mod->data.source_files, s3)) - found = TRUE; - g_free (s2); - g_free (s3); - } - g_free (s); + found = find_source_file_in_hash_table(sinfo->source_file, mod->data.source_files); + if (found) + break; } g_ptr_array_free (source_file_list, TRUE); } } +#endif if (!found) filtered = TRUE; } else if (mod->kind == MOD_KIND_TYPE_NAME_ONLY && ei && ei->klass) { char *s; - s = mono_type_full_name (&ei->klass->byval_arg); + s = mono_type_full_name (VM_CLASS_GET_TYPE(ei->klass)); if (!g_hash_table_lookup (mod->data.type_names, s)) filtered = TRUE; g_free (s); @@ -3617,7 +3789,11 @@ event_to_string (EventKind event) * The EVENTS list is freed by this function. */ static void +#ifndef IL2CPP_MONO_DEBUGGER process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx, GSList *events, int suspend_policy) +#else +process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx, GSList *events, int suspend_policy, uint64_t il2cpp_seqpoint_id) +#endif { Buffer buf; GSList *l; @@ -3706,6 +3882,9 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx case EVENT_KIND_METHOD_ENTRY: case EVENT_KIND_METHOD_EXIT: buffer_add_methodid (&buf, domain, (MonoMethod *)arg); +#if defined(IL2CPP_MONO_DEBUGGER) && defined(IL2CPP_DEBUGGER_TESTS) + buffer_add_long (&buf, il2cpp_seqpoint_id); +#endif break; case EVENT_KIND_ASSEMBLY_LOAD: buffer_add_assemblyid (&buf, domain, (MonoAssembly *)arg); @@ -3728,6 +3907,9 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx case EVENT_KIND_STEP: buffer_add_methodid (&buf, domain, (MonoMethod *)arg); buffer_add_long (&buf, il_offset); +#if defined(IL2CPP_MONO_DEBUGGER) && defined(IL2CPP_DEBUGGER_TESTS) + buffer_add_long (&buf, il2cpp_seqpoint_id); +#endif break; case EVENT_KIND_VM_START: buffer_add_domainid (&buf, mono_get_root_domain ()); @@ -3737,8 +3919,11 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx buffer_add_int (&buf, mono_environment_exitcode_get ()); break; case EVENT_KIND_EXCEPTION: { - EventInfo *ei = (EventInfo *)arg; + DebuggerEventInfo *ei = (DebuggerEventInfo *)arg; buffer_add_objid (&buf, ei->exc); +#if defined(IL2CPP_MONO_DEBUGGER) && defined(IL2CPP_DEBUGGER_TESTS) + buffer_add_long(&buf, il2cpp_seqpoint_id); +#endif /* * We are not yet suspending, so get_objref () will not keep this object alive. So we need to do it * later after the suspension. (#12494). @@ -3749,7 +3934,7 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx case EVENT_KIND_USER_BREAK: break; case EVENT_KIND_USER_LOG: { - EventInfo *ei = (EventInfo *)arg; + DebuggerEventInfo *ei = (DebuggerEventInfo *)arg; buffer_add_int (&buf, ei->level); buffer_add_string (&buf, ei->category ? ei->category : ""); buffer_add_string (&buf, ei->message ? ei->message : ""); @@ -3828,7 +4013,7 @@ process_profiler_event (EventKind event, gpointer arg) { int suspend_policy; GSList *events; - EventInfo ei, *ei_arg = NULL; + DebuggerEventInfo ei, *ei_arg = NULL; if (event == EVENT_KIND_TYPE_LOAD) { ei.klass = (MonoClass *)arg; @@ -3839,7 +4024,11 @@ process_profiler_event (EventKind event, gpointer arg) events = create_event_list (event, NULL, NULL, ei_arg, &suspend_policy); mono_loader_unlock (); +#ifndef IL2CPP_MONO_DEBUGGER process_event (event, arg, 0, NULL, events, suspend_policy); +#else + process_event (event, arg, 0, NULL, events, suspend_policy, 0); +#endif } static void @@ -3868,7 +4057,7 @@ thread_startup (MonoProfiler *prof, uintptr_t tid) if (is_debugger_thread ()) return; - g_assert (mono_native_thread_id_equals (MONO_UINT_TO_NATIVE_THREAD_ID (tid), MONO_UINT_TO_NATIVE_THREAD_ID (thread->tid))); + g_assert (mono_native_thread_id_equals (MONO_UINT_TO_NATIVE_THREAD_ID (tid), MONO_UINT_TO_NATIVE_THREAD_ID (VM_INTERNAL_THREAD_GET_ID(thread)))); mono_loader_lock (); old_thread = (MonoInternalThread *)mono_g_hash_table_lookup (tid_to_thread, GUINT_TO_POINTER (tid)); @@ -3896,10 +4085,21 @@ thread_startup (MonoProfiler *prof, uintptr_t tid) } tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id); - g_assert (!tls); - // FIXME: Free this somewhere + if (tls) { + if (!tls->terminated) + MONO_GC_UNREGISTER_ROOT(tls->thread); +#ifdef IL2CPP_MONO_DEBUGGER + il2cpp_gc_free_fixed (tls); +#else + g_free (tls); +#endif + } +#ifdef IL2CPP_MONO_DEBUGGER + tls = il2cpp_gc_alloc_fixed(sizeof(DebuggerTlsData)); +#else tls = g_new0 (DebuggerTlsData, 1); MONO_GC_REGISTER_ROOT_SINGLE (tls->thread, MONO_ROOT_SOURCE_DEBUGGER, "debugger thread reference"); +#endif tls->thread = thread; mono_native_tls_set_value (debugger_tls_id, tls); @@ -3930,11 +4130,13 @@ thread_end (MonoProfiler *prof, uintptr_t tid) if (thread) { mono_g_hash_table_remove (tid_to_thread_obj, GUINT_TO_POINTER (tid)); tls = (DebuggerTlsData *)mono_g_hash_table_lookup (thread_to_tls, thread); - if (tls) { + if (tls && !tls->terminated) { /* FIXME: Maybe we need to free this instead, but some code can't handle that */ tls->terminated = TRUE; /* Can't remove from tid_to_thread, as that would defeat the check in thread_start () */ +#ifndef IL2CPP_MONO_DEBUGGER MONO_GC_UNREGISTER_ROOT (tls->thread); +#endif tls->thread = NULL; } } @@ -4098,10 +4300,12 @@ send_assemblies_for_domain (MonoDomain *domain, void *user_data) mono_domain_set (domain, TRUE); mono_domain_assemblies_lock (domain); - for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) { - MonoAssembly* ass = (MonoAssembly *)tmp->data; - emit_assembly_load (ass, NULL); - } + + void *iter = NULL; + MonoAssembly *ass; + while (ass = VM_DOMAIN_GET_ASSEMBLIES(domain, &iter)) + emit_assembly_load(ass, NULL); + mono_domain_assemblies_unlock (domain); mono_domain_set (old_domain, TRUE); @@ -4122,6 +4326,13 @@ jit_failed (MonoProfiler *prof, MonoMethod *method) static void jit_end (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *jinfo) { +#ifdef IL2CPP_MONO_DEBUGGER + //if (!result) + { + g_hash_table_insert(s_jit_info_hashtable, method, jinfo); + } +#endif // IL2CPP_MONO_DEBUGGER + /* * We emit type load events when the first method of the type is JITted, * since the class load profiler callbacks might be called with the @@ -4164,6 +4375,9 @@ typedef struct { guint8 *ip; MonoJitInfo *ji; MonoDomain *domain; +#ifdef IL2CPP_MONO_DEBUGGER + Il2CppSequencePointC* seq_point; +#endif } BreakpointInstance; /* @@ -4295,6 +4509,8 @@ insert_breakpoint (MonoSeqPointInfo *seq_points, MonoDomain *domain, MonoJitInfo DEBUG_PRINTF (1, "[dbg] Inserted breakpoint at %s:[il=0x%x,native=0x%x] [%p](%d).\n", mono_method_full_name (jinfo_get_method (ji), TRUE), (int)it.seq_point.il_offset, (int)it.seq_point.native_offset, inst->ip, count); } +#ifndef IL2CPP_MONO_DEBUGGER + static void remove_breakpoint (BreakpointInstance *inst) { @@ -4320,7 +4536,9 @@ remove_breakpoint (BreakpointInstance *inst) #else NOT_IMPLEMENTED; #endif -} +} + +#endif // !IL2CPP_MONO_DEBUGGER /* * This doesn't take any locks. @@ -4332,6 +4550,9 @@ bp_matches_method (MonoBreakpoint *bp, MonoMethod *method) if (!bp->method) return TRUE; +#ifdef IL2CPP_MONO_DEBUGGER + return il2cpp_mono_methods_match(bp->method, method); +#else if (method == bp->method) return TRUE; if (method->is_inflated && ((MonoMethodInflated*)method)->declaring == bp->method) @@ -4355,6 +4576,7 @@ bp_matches_method (MonoBreakpoint *bp, MonoMethod *method) } return FALSE; +#endif // IL2CPP_MONO_DEBUGGER } /* @@ -4365,6 +4587,7 @@ bp_matches_method (MonoBreakpoint *bp, MonoMethod *method) static void add_pending_breakpoints (MonoMethod *method, MonoJitInfo *ji) { +#ifndef IL2CPP_MONO_DEBUGGER int i, j; MonoSeqPointInfo *seq_points; MonoDomain *domain; @@ -4413,6 +4636,7 @@ add_pending_breakpoints (MonoMethod *method, MonoJitInfo *ji) } mono_loader_unlock (); +#endif } static void @@ -4492,6 +4716,27 @@ set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req, MonoError method_seq_points = g_ptr_array_new (); mono_loader_lock (); +#ifdef IL2CPP_MONO_DEBUGGER + void *seqPointIter = NULL; + Il2CppSequencePointC *seqPoint; + while(seqPoint = il2cpp_get_method_sequence_points(method, &seqPointIter)) + { + if (bp_matches_method(bp, seqPoint->method) && seqPoint->ilOffset == bp->il_offset) + { + BreakpointInstance* inst = g_new0(BreakpointInstance, 1); + inst->il_offset = bp->il_offset;// it.seq_point.il_offset; + inst->native_offset = 0;// it.seq_point.native_offset; + inst->domain = mono_domain_get(); + inst->seq_point = seqPoint; + + seqPoint->isActive = TRUE; + + mono_loader_lock(); + g_ptr_array_add(bp->children, inst); + mono_loader_unlock(); + } + } +#else g_hash_table_iter_init (&iter, domains); while (g_hash_table_iter_next (&iter, (void**)&domain, NULL)) { mono_domain_lock (domain); @@ -4513,6 +4758,7 @@ set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req, MonoError seq_points = (MonoSeqPointInfo *)g_ptr_array_index (method_seq_points, i); set_bp_in_method (domain, m, seq_points, bp, error); } +#endif // IL2CPP_MONO_DEBUGGER g_ptr_array_add (breakpoints, bp); mono_loader_unlock (); @@ -4529,6 +4775,73 @@ set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req, MonoError return bp; } +#ifdef IL2CPP_MONO_DEBUGGER + +static MonoBreakpoint* set_breakpoint_fast(Il2CppSequencePointC *sp, EventRequest *req, MonoError *error) +{ + MonoBreakpoint *bp; + GHashTableIter iter, iter2; + MonoDomain *domain; + MonoMethod *m; + MonoSeqPointInfo *seq_points; + GPtrArray *methods; + GPtrArray *method_domains; + GPtrArray *method_seq_points; + int i; + + if (error) + error_init(error); + + // FIXME: + // - suspend/resume the vm to prevent code patching problems + // - multiple breakpoints on the same location + // - dynamic methods + // - races + + bp = g_new0(MonoBreakpoint, 1); + bp->method = sp->method; + bp->il_offset = sp->ilOffset; + bp->req = req; + bp->children = g_ptr_array_new(); + + DEBUG_PRINTF(1, "[dbg] Setting %sbreakpoint at %s:0x%x.\n", (req->event_kind == EVENT_KIND_STEP) ? "single step " : "", bp->method ? mono_method_full_name(bp->method, TRUE) : "", (int)bp->il_offset); + + methods = g_ptr_array_new(); + method_domains = g_ptr_array_new(); + method_seq_points = g_ptr_array_new(); + + mono_loader_lock(); + + BreakpointInstance* inst = g_new0(BreakpointInstance, 1); + inst->il_offset = bp->il_offset;// it.seq_point.il_offset; + inst->native_offset = 0;// it.seq_point.native_offset; + inst->domain = mono_domain_get(); + inst->seq_point = sp; + + sp->isActive = TRUE; + + mono_loader_lock(); + g_ptr_array_add(bp->children, inst); + mono_loader_unlock(); + + g_ptr_array_add(breakpoints, bp); + mono_loader_unlock(); + + g_ptr_array_free(methods, TRUE); + g_ptr_array_free(method_domains, TRUE); + g_ptr_array_free(method_seq_points, TRUE); + + if (error && !mono_error_ok(error)) + { + clear_breakpoint(bp); + return NULL; + } + + return bp; +} + +#endif // IL2CPP_MONO_DEBUGGER + static void clear_breakpoint (MonoBreakpoint *bp) { @@ -4538,7 +4851,11 @@ clear_breakpoint (MonoBreakpoint *bp) for (i = 0; i < bp->children->len; ++i) { BreakpointInstance *inst = (BreakpointInstance *)g_ptr_array_index (bp->children, i); - remove_breakpoint (inst); +#ifndef IL2CPP_MONO_DEBUGGER + remove_breakpoint(inst); +#else + inst->seq_point->isActive = FALSE; +#endif g_free (inst); } @@ -4605,7 +4922,9 @@ clear_breakpoints_for_domain (MonoDomain *domain) BreakpointInstance *inst = (BreakpointInstance *)g_ptr_array_index (bp->children, j); if (inst->domain == domain) { +#ifndef IL2CPP_MONO_DEBUGGER remove_breakpoint (inst); +#endif g_free (inst); @@ -4658,12 +4977,14 @@ ensure_jit (StackFrame* frame) static gboolean ss_update (SingleStepReq *req, MonoJitInfo *ji, SeqPoint *sp, DebuggerTlsData *tls, MonoContext *ctx, MonoMethod* method) { +#ifndef IL2CPP_MONO_DEBUGGER MonoDebugMethodInfo *minfo; MonoDebugSourceLocation *loc = NULL; +#endif gboolean hit = TRUE; if (req->async_stepout_method == method) { - DEBUG_PRINTF (1, "[%p] Breakpoint hit during async step-out at %s hit, continuing stepping out.\n", (gpointer)(gsize)mono_native_thread_id_get (), method->name); + DEBUG_PRINTF (1, "[%p] Breakpoint hit during async step-out at %s hit, continuing stepping out.\n", (gpointer)(gsize)mono_native_thread_id_get (), mono_method_get_name(method)); return FALSE; } @@ -4713,6 +5034,8 @@ ss_update (SingleStepReq *req, MonoJitInfo *ji, SeqPoint *sp, DebuggerTlsData *t return TRUE; /* Have to check whenever a different source line was reached */ + +#ifndef IL2CPP_MONO_DEBUGGER minfo = mono_debug_lookup_method (method); if (minfo) @@ -4735,9 +5058,83 @@ ss_update (SingleStepReq *req, MonoJitInfo *ji, SeqPoint *sp, DebuggerTlsData *t ss_req->last_line = loc->row; mono_debug_free_source_location (loc); } +#else + NOT_IMPLEMENTED; +#endif + + return hit; +} + +#ifdef IL2CPP_MONO_DEBUGGER +/* +* ss_update_il2cpp: +* +* Return FALSE if single stepping needs to continue. +*/ +static gboolean +ss_update_il2cpp(SingleStepReq *req, DebuggerTlsData *tls, MonoContext *ctx, Il2CppSequencePointC *sequencePoint) +{ + gboolean hit = TRUE; + + if (il2cpp_mono_methods_match(req->async_stepout_method, sequencePoint->method)) + { + DEBUG_PRINTF(1, "[%p] Breakpoint hit during async step-out at %s hit, continuing stepping out.\n", (gpointer)(gsize)mono_native_thread_id_get(), mono_method_get_name(sequencePoint->method)); + return FALSE; + } + + if ((req->depth == STEP_DEPTH_OVER || req->depth == STEP_DEPTH_OUT) && hit && !req->async_stepout_method) + { + gboolean is_step_out = req->depth == STEP_DEPTH_OUT; + + // Because functions can call themselves recursively, we need to make sure we're stopping at the right stack depth. + // In case of step out, the target is the frame *enclosing* the one where the request was made. + int target_frames = req->nframes + (is_step_out ? -1 : 0); + if (req->nframes > 0 && tls->il2cpp_context.frameCount > 0 && tls->il2cpp_context.frameCount > target_frames) + { + /* Hit the breakpoint in a recursive call, don't halt */ + DEBUG_PRINTF(1, "[%p] Breakpoint at lower frame while stepping %s, continuing single stepping.\n", (gpointer)(gsize)mono_native_thread_id_get(), is_step_out ? "out" : "over"); + return FALSE; + } + } + + if (req->depth == STEP_DEPTH_INTO && req->size == STEP_SIZE_MIN && ss_req->start_method) + { + if (ss_req->start_method == sequencePoint->method && req->nframes && tls->il2cpp_context.frameCount == req->nframes) + {//Check also frame count(could be recursion) + DEBUG_PRINTF(1, "[%p] Seq point at nonempty stack %x while stepping in, continuing single stepping.\n", (gpointer)(gsize)mono_native_thread_id_get(), sequencePoint->ilOffset); + return FALSE; + } + } + + if (req->size != STEP_SIZE_LINE) + return TRUE; + + /* Have to check whenever a different source line was reached */ + + if (sequencePoint->lineEnd < 0) + { + DEBUG_PRINTF(1, "[%p] No line number info for il offset %x, continuing single stepping.\n", (gpointer)(gsize)mono_native_thread_id_get(), sequencePoint->ilOffset); + ss_req->last_method = sequencePoint->method; + hit = FALSE; + } + else if (sequencePoint->lineEnd >= 0 && sequencePoint->method == ss_req->last_method && sequencePoint->lineEnd == ss_req->last_line) + { + if (tls->il2cpp_context.frameCount == req->nframes) + { // If the frame has changed we're clearly not on the same source line. + DEBUG_PRINTF(1, "[%p] Same source line (%d), continuing single stepping.\n", (gpointer)(gsize)mono_native_thread_id_get(), sequencePoint->lineEnd); + hit = FALSE; + } + } + + if (sequencePoint->lineEnd >= 0) + { + ss_req->last_method = sequencePoint->method; + ss_req->last_line = sequencePoint->lineEnd; + } return hit; } +#endif static gboolean breakpoint_matches_assembly (MonoBreakpoint *bp, MonoAssembly *assembly) @@ -4748,6 +5145,7 @@ breakpoint_matches_assembly (MonoBreakpoint *bp, MonoAssembly *assembly) static gpointer get_this_addr (StackFrame *frame) { +#ifndef IL2CPP_MONO_DEBUGGER if (frame->ji->is_interp) return mono_interp_frame_get_this (frame->interp_frame); @@ -4758,6 +5156,10 @@ get_this_addr (StackFrame *frame) guint8 *addr = (guint8 *)mono_arch_context_get_int_reg (&frame->ctx, var->index & ~MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS); addr += (gint32)var->offset; return addr; +#else + g_assert_not_reached (); + return NULL; +#endif } static MonoMethod* @@ -4908,6 +5310,7 @@ process_breakpoint (DebuggerTlsData *tls, gboolean from_signal) ip = (guint8 *)MONO_CONTEXT_GET_IP (ctx); ji = mini_jit_info_table_find (mono_domain_get (), (char*)ip, NULL); +#ifndef IL2CPP_MONO_DEBUGGER if (!ji) { /* Interpreter */ // FIXME: Pass a flag instead to detect this @@ -4922,6 +5325,7 @@ process_breakpoint (DebuggerTlsData *tls, gboolean from_signal) ji = mono_interp_frame_get_jit_info (frame); ip = mono_interp_frame_get_ip (frame); } +#endif g_assert (ji && !ji->is_trampoline); method = jinfo_get_method (ji); @@ -4955,7 +5359,7 @@ process_breakpoint (DebuggerTlsData *tls, gboolean from_signal) g_assert (found_sp); - DEBUG_PRINTF (1, "[%p] Breakpoint hit, method=%s, ip=%p, [il=0x%x,native=0x%x].\n", (gpointer) (gsize) mono_native_thread_id_get (), method->name, ip, sp.il_offset, native_offset); + DEBUG_PRINTF (1, "[%p] Breakpoint hit, method=%s, ip=%p, [il=0x%x,native=0x%x].\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_get_name(method), ip, sp.il_offset, native_offset); bp = NULL; for (i = 0; i < breakpoints->len; ++i) { @@ -5052,11 +5456,23 @@ process_breakpoint (DebuggerTlsData *tls, gboolean from_signal) * resume. */ if (ss_events) +#ifndef IL2CPP_MONO_DEBUGGER process_event (EVENT_KIND_STEP, method, 0, ctx, ss_events, suspend_policy); +#else + process_event (EVENT_KIND_STEP, method, 0, ctx, ss_events, suspend_policy, 0); +#endif if (bp_events) +#ifndef IL2CPP_MONO_DEBUGGER process_event (kind, method, 0, ctx, bp_events, suspend_policy); +#else + process_event (kind, method, 0, ctx, bp_events, suspend_policy, 0); +#endif if (enter_leave_events) +#ifndef IL2CPP_MONO_DEBUGGER process_event (kind, method, 0, ctx, enter_leave_events, suspend_policy); +#else + process_event (kind, method, 0, ctx, enter_leave_events, suspend_policy, 0); +#endif } /* Process a breakpoint/single step event after resuming from a signal handler */ @@ -5167,16 +5583,22 @@ mono_debugger_agent_user_break (void) memset (&data, 0, sizeof (UserBreakCbData)); data.ctx = &ctx; +#ifndef IL2CPP_MONO_DEBUGGER /* Obtain a context */ MONO_CONTEXT_SET_IP (&ctx, NULL); mono_walk_stack_with_ctx (user_break_cb, NULL, (MonoUnwindOptions)0, &data); g_assert (data.found); +#endif mono_loader_lock (); events = create_event_list (EVENT_KIND_USER_BREAK, NULL, NULL, NULL, &suspend_policy); mono_loader_unlock (); +#ifndef IL2CPP_MONO_DEBUGGER process_event (EVENT_KIND_USER_BREAK, NULL, 0, &ctx, events, suspend_policy); +#else + process_event (EVENT_KIND_USER_BREAK, NULL, 0, &ctx, events, suspend_policy, 0); +#endif } else if (debug_options.native_debugger_break) { G_BREAKPOINT (); } @@ -5199,7 +5621,11 @@ ss_depth_to_string (StepDepth depth) } static void +#ifndef IL2CPP_MONO_DEBUGGER process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal) +#else +process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, uint64_t sequencePointId) +#endif { MonoJitInfo *ji; guint8 *ip; @@ -5212,9 +5638,14 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal) SeqPoint sp; MonoSeqPointInfo *info; +#ifndef IL2CPP_MONO_DEBUGGER /* Skip the instruction causing the single step */ +#ifndef IL2CPP_MONO_DEBUGGER if (from_signal) mono_arch_skip_single_step (ctx); +#else + NOT_IMPLEMENTED; +#endif if (suspend_count > 0) { /* Fastpath during invokes, see in process_suspend () */ @@ -5236,9 +5667,11 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal) ji = get_top_method_ji (ip, &domain, (gpointer*)&ip); g_assert (ji && !ji->is_trampoline); +#ifndef IL2CPP_MONO_DEBUGGER if (log_level > 0) { DEBUG_PRINTF (1, "[%p] Single step event (depth=%s) at %s (%p)[0x%x], sp %p, last sp %p\n", (gpointer) (gsize) mono_native_thread_id_get (), ss_depth_to_string (ss_req->depth), mono_method_full_name (jinfo_get_method (ji), TRUE), MONO_CONTEXT_GET_IP (ctx), (int)((guint8*)MONO_CONTEXT_GET_IP (ctx) - (guint8*)ji->code_start), MONO_CONTEXT_GET_SP (ctx), ss_req->last_sp); } +#endif method = jinfo_get_method (ji); g_assert (method); @@ -5251,7 +5684,7 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal) * Stopping in memset makes half-initialized vtypes visible. * Stopping in memcpy makes half-copied vtypes visible. */ - if (method->klass == mono_defaults.string_class && (!strcmp (method->name, "memset") || strstr (method->name, "memcpy"))) + if (method->klass == mono_defaults.string_class && (!strcmp (mono_method_get_name(method), "memset") || strstr (mono_method_get_name(method), "memcpy"))) return; /* @@ -5289,10 +5722,11 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal) if ((ss_req->filter & STEP_FILTER_STATIC_CTOR) && (method->flags & METHOD_ATTRIBUTE_SPECIAL_NAME) && - !strcmp (method->name, ".cctor")) + !strcmp (mono_method_get_name(method), ".cctor")) return; // FIXME: Has to lock earlier +#endif reqs = g_ptr_array_new (); @@ -5300,13 +5734,43 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal) g_ptr_array_add (reqs, ss_req->req); +#ifndef IL2CPP_MONO_DEBUGGER events = create_event_list (EVENT_KIND_STEP, reqs, ji, NULL, &suspend_policy); +#else + events = create_event_list(EVENT_KIND_STEP, reqs, NULL, NULL, &suspend_policy); +#endif g_ptr_array_free (reqs, TRUE); mono_loader_unlock (); +#ifndef IL2CPP_MONO_DEBUGGER process_event (EVENT_KIND_STEP, jinfo_get_method (ji), il_offset, ctx, events, suspend_policy); +#else + Il2CppSequencePointC* sequence_pt = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]; + + /* + * This could be in ss_update method, but mono_find_next_seq_point_for_native_offset is pretty expensive method, + * hence we prefer this check here. + */ + if (ss_req->user_assemblies) + { + gboolean found = FALSE; + for (int k = 0; ss_req->user_assemblies[k]; k++) + { + if (ss_req->user_assemblies[k] == VM_IMAGE_GET_ASSEMBLY(VM_CLASS_GET_IMAGE(VM_METHOD_GET_DECLARING_TYPE(sequence_pt->method)))) + { + found = TRUE; + break; + } + } + + if (!found) + return; + } + + process_event(EVENT_KIND_STEP, sequence_pt->method, sequence_pt->ilOffset, NULL, events, suspend_policy, sequencePointId); +#endif } static void @@ -5347,7 +5811,11 @@ mono_debugger_agent_single_step_event (void *sigctx) } void +#ifndef IL2CPP_MONO_DEBUGGER debugger_agent_single_step_from_context (MonoContext *ctx) +#else +debugger_agent_single_step_from_context (MonoContext *ctx, uint64_t sequencePointId) +#endif { DebuggerTlsData *tls; MonoThreadUnwindState orig_restore_state; @@ -5362,6 +5830,7 @@ debugger_agent_single_step_from_context (MonoContext *ctx) g_assert (tls); +#ifndef IL2CPP_MONO_DEBUGGER /* Have to save/restore the restore_ctx as we can be called recursively during invokes etc. */ memcpy (&orig_restore_state, &tls->restore_state, sizeof (MonoThreadUnwindState)); mono_thread_state_init_from_monoctx (&tls->restore_state, ctx); @@ -5371,6 +5840,11 @@ debugger_agent_single_step_from_context (MonoContext *ctx) memcpy (ctx, &tls->restore_state.ctx, sizeof (MonoContext)); memcpy (&tls->restore_state, &orig_restore_state, sizeof (MonoThreadUnwindState)); +#else + save_thread_context(NULL); + + process_single_step_inner(tls, FALSE, sequencePointId); +#endif } void @@ -5409,6 +5883,7 @@ debugger_agent_breakpoint_from_context (MonoContext *ctx) static void start_single_stepping (void) { +#ifndef IL2CPP_MONO_DEBUGGER #ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED int val = mono_atomic_inc_i32 (&ss_count); @@ -5419,11 +5894,13 @@ start_single_stepping (void) #else g_assert_not_reached (); #endif +#endif } static void stop_single_stepping (void) { +#ifndef IL2CPP_MONO_DEBUGGER #ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED int val = mono_atomic_dec_i32 (&ss_count); @@ -5434,6 +5911,7 @@ stop_single_stepping (void) #else g_assert_not_reached (); #endif +#endif } /* @@ -5541,20 +6019,49 @@ ss_bp_add_one (SingleStepReq *ss_req, int *ss_req_bp_count, GHashTable **ss_req_ } } -static gboolean -is_last_non_empty (SeqPoint* sp, MonoSeqPointInfo *info) +#ifdef IL2CPP_MONO_DEBUGGER + +static void ss_bp_add_one_il2cpp(SingleStepReq *ss_req, int *ss_req_bp_count, GHashTable **ss_req_bp_cache, Il2CppSequencePointC *sp) { - if (!sp->next_len) - return TRUE; - SeqPoint* next = g_new (SeqPoint, sp->next_len); - mono_seq_point_init_next (info, *sp, next); - for (int i = 0; i < sp->next_len; i++) { - if (next [i].flags & MONO_SEQ_POINT_FLAG_NONEMPTY_STACK) { - if (!is_last_non_empty (&next [i], info)) { - g_free (next); - return FALSE; - } - } else { + // This list is getting too long, switch to using the hash table + if (!*ss_req_bp_cache && *ss_req_bp_count > MAX_LINEAR_SCAN_BPS) + { + *ss_req_bp_cache = g_hash_table_new(ss_bp_hash, ss_bp_eq); + for (GSList *l = ss_req->bps; l; l = l->next) + g_hash_table_insert(*ss_req_bp_cache, l->data, l->data); + } + + if (ss_bp_is_unique(ss_req->bps, *ss_req_bp_cache, sp->method, sp->ilOffset)) + { + // Create and add breakpoint + MonoBreakpoint *bp = set_breakpoint_fast(sp, ss_req->req, NULL); + ss_req->bps = g_slist_append(ss_req->bps, bp); + if (*ss_req_bp_cache) + g_hash_table_insert(*ss_req_bp_cache, bp, bp); + (*ss_req_bp_count)++; + } + else + { + DEBUG_PRINTF(1, "[dbg] Candidate breakpoint at %s:[il=0x%x] is a duplicate for this step request, will not add.\n", mono_method_full_name(sp->method, TRUE), (int)sp->ilOffset); + } +} + +#endif // IL2CPP_MONO_DEBUGGER + +static gboolean +is_last_non_empty (SeqPoint* sp, MonoSeqPointInfo *info) +{ + if (!sp->next_len) + return TRUE; + SeqPoint* next = g_new (SeqPoint, sp->next_len); + mono_seq_point_init_next (info, *sp, next); + for (int i = 0; i < sp->next_len; i++) { + if (next [i].flags & MONO_SEQ_POINT_FLAG_NONEMPTY_STACK) { + if (!is_last_non_empty (&next [i], info)) { + g_free (next); + return FALSE; + } + } else { g_free (next); return FALSE; } @@ -5601,8 +6108,12 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI if (ctx && !frames) { /* Need parent frames */ +#ifndef IL2CPP_MONO_DEBUGGER if (!tls->context.valid) mono_thread_state_init_from_monoctx (&tls->context, ctx); +#else + NOT_IMPLEMENTED; +#endif compute_frame_info (tls->thread, tls); frames = tls->frames; nframes = tls->frame_count; @@ -5674,7 +6185,11 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI StackFrame *frame = frames [frame_index]; method = frame->method; +#ifndef IL2CPP_MONO_DEBUGGER found_sp = mono_find_prev_seq_point_for_native_offset (frame->domain, frame->method, frame->native_offset, &info, &local_sp); +#else + found_sp = FALSE; +#endif sp = (found_sp)? &local_sp : NULL; frame_index ++; if (sp && sp->next_len != 0) @@ -5689,7 +6204,11 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI StackFrame *frame = frames [frame_index]; method = frame->method; +#ifndef IL2CPP_MONO_DEBUGGER found_sp = mono_find_prev_seq_point_for_native_offset (frame->domain, frame->method, frame->native_offset, &info, &local_sp); +#else + found_sp = FALSE; +#endif sp = (found_sp)? &local_sp : NULL; if (sp && sp->next_len != 0) break; @@ -5702,7 +6221,11 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI StackFrame *frame = frames [frame_index]; parent_sp_method = frame->method; +#ifndef IL2CPP_MONO_DEBUGGER found_sp = mono_find_prev_seq_point_for_native_offset (frame->domain, frame->method, frame->native_offset, &parent_info, &local_parent_sp); +#else + found_sp = FALSE; +#endif parent_sp = found_sp ? &local_parent_sp : NULL; if (found_sp && parent_sp->next_len != 0) break; @@ -5713,6 +6236,7 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI } if (sp && sp->next_len > 0) { +#ifndef IL2CPP_MONO_DEBUGGER SeqPoint* next = g_new(SeqPoint, sp->next_len); mono_seq_point_init_next (info, *sp, next); @@ -5722,9 +6246,13 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI ss_bp_add_one (ss_req, &ss_req_bp_count, &ss_req_bp_cache, method, next_sp->il_offset); } g_free (next); +#else + NOT_IMPLEMENTED; +#endif } if (parent_sp) { +#ifndef IL2CPP_MONO_DEBUGGER SeqPoint* next = g_new(SeqPoint, parent_sp->next_len); mono_seq_point_init_next (parent_info, *parent_sp, next); @@ -5734,6 +6262,9 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI ss_bp_add_one (ss_req, &ss_req_bp_count, &ss_req_bp_cache, parent_sp_method, next_sp->il_offset); } g_free (next); +#else + NOT_IMPLEMENTED; +#endif } if (ss_req->nframes == 0) @@ -5750,6 +6281,30 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI ss_req->depth = STEP_DEPTH_INTO; } + if (ss_req->depth == STEP_DEPTH_OVER) { +#ifndef IL2CPP_MONO_DEBUGGER + /* Need to stop in catch clauses as well */ + for (i = 0; i < nframes; ++i) { + StackFrame *frame = frames[i]; + + if (frame->ji) { + MonoJitInfo *jinfo = frame->ji; + for (j = 0; j < jinfo->num_clauses; ++j) { + MonoJitExceptionInfo *ei = &jinfo->clauses[j]; + + found_sp = mono_find_next_seq_point_for_native_offset(frame->domain, frame->method, (char*)ei->handler_start - (char*)jinfo->code_start, NULL, &local_sp); + sp = (found_sp) ? &local_sp : NULL; + + if (found_sp) + ss_bp_add_one(ss_req, &ss_req_bp_count, &ss_req_bp_cache, frame->method, sp->il_offset); + } + } + } +#else + NOT_IMPLEMENTED; +#endif + } + if (ss_req->depth == STEP_DEPTH_INTO) { /* Enable global stepping so we stop at method entry too */ enable_global = TRUE; @@ -5779,6 +6334,75 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI g_hash_table_destroy (ss_req_bp_cache); } +#ifdef IL2CPP_MONO_DEBUGGER + +static void +ss_start_il2cpp(SingleStepReq *ss_req, DebuggerTlsData *tls) +{ + // When 8 or more entries are in bps, we build a hash table to serve as a set of breakpoints. + // Recreating this on each pass is a little wasteful but at least keeps behavior linear. + int ss_req_bp_count = g_slist_length(ss_req->bps); + GHashTable *ss_req_bp_cache = NULL; + gboolean enable_global = FALSE; + + /* Stop the previous operation */ + ss_stop(ss_req); + + DEBUG_PRINTF(0, "Step depth: %d\n", ss_req->depth); + + if (ss_req->depth == STEP_DEPTH_OVER) + { + MonoMethod* currentMethod = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]->method; + + void *seqPointIter = NULL; + Il2CppSequencePointC *seqPoint; + while(seqPoint = il2cpp_get_method_sequence_points(currentMethod, &seqPointIter)) + { + if (seqPoint->kind != kSequencePointKindC_Normal) + continue; + + if (il2cpp_mono_methods_match(seqPoint->method, currentMethod)) + ss_bp_add_one_il2cpp(ss_req, &ss_req_bp_count, &ss_req_bp_cache, seqPoint); + } + } + + if (tls->il2cpp_context.frameCount > 1) + { + Il2CppSequencePointC* sequencePointForStepOut = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 2]; + g_assert(sequencePointForStepOut->kind == kSequencePointKindC_StepOut); + ss_bp_add_one_il2cpp(ss_req, &ss_req_bp_count, &ss_req_bp_cache, sequencePointForStepOut); + } + + if (ss_req_bp_cache) + g_hash_table_destroy(ss_req_bp_cache); + + + if (ss_req->depth == STEP_DEPTH_INTO) + { + /* Enable global stepping so we stop at method entry too */ + enable_global = TRUE; + } + + if (enable_global) + { + DEBUG_PRINTF(1, "[dbg] Turning on global single stepping.\n"); + ss_req->global = TRUE; + start_single_stepping(); + } + else if (!ss_req->bps) + { + DEBUG_PRINTF(1, "[dbg] Turning on global single stepping.\n"); + ss_req->global = TRUE; + start_single_stepping(); + } + else + { + ss_req->global = FALSE; + } +} + +#endif // IL2CPP_MONO_DEBUGGER + /* * Start single stepping of thread THREAD */ @@ -5791,7 +6415,9 @@ ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilte SeqPoint local_sp; gboolean found_sp; MonoMethod *method = NULL; +#ifndef IL2CPP_DEBUGGER MonoDebugMethodInfo *minfo; +#endif gboolean step_to_catch = FALSE; gboolean set_ip = FALSE; StackFrame **frames = NULL; @@ -5829,6 +6455,20 @@ ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilte tls = (DebuggerTlsData *)mono_g_hash_table_lookup (thread_to_tls, thread); mono_loader_unlock (); g_assert (tls); + +#ifdef IL2CPP_MONO_DEBUGGER + ss_req->nframes = tls->il2cpp_context.frameCount; + + if (tls->il2cpp_context.frameCount > 0) + { + Il2CppSequencePointC* seq_point = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]; + ss_req->start_method = seq_point->method; + ss_req->last_method = seq_point->method; + ss_req->last_line = seq_point->lineEnd; + } + + ss_start_il2cpp(ss_req, tls); +#else if (!tls->context.valid) { DEBUG_PRINTF (1, "Received a single step request on a thread with no managed frames."); return ERR_INVALID_ARGUMENT; @@ -5919,6 +6559,7 @@ ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilte if (frames) free_frames (frames, nframes); +#endif return ERR_NONE; } @@ -5963,7 +6604,7 @@ mono_debugger_agent_debug_log (int level, MonoString *category, MonoString *mess MonoError error; int suspend_policy; GSList *events; - EventInfo ei; + DebuggerEventInfo ei; if (!agent_config.enabled) return; @@ -5983,8 +6624,11 @@ mono_debugger_agent_debug_log (int level, MonoString *category, MonoString *mess ei.message = mono_string_to_utf8_checked (message, &error); mono_error_cleanup (&error); } - +#ifndef IL2CPP_MONO_DEBUGGER process_event (EVENT_KIND_USER_LOG, &ei, 0, NULL, events, suspend_policy); +#else + process_event (EVENT_KIND_USER_LOG, &ei, 0, NULL, events, suspend_policy, 0); +#endif g_free (ei.category); g_free (ei.message); @@ -6003,19 +6647,89 @@ mono_debugger_agent_unhandled_exception (MonoException *exc) { int suspend_policy; GSList *events; - EventInfo ei; + DebuggerEventInfo ei; if (!inited) return; - memset (&ei, 0, sizeof (EventInfo)); + memset (&ei, 0, sizeof (DebuggerEventInfo)); ei.exc = (MonoObject*)exc; mono_loader_lock (); events = create_event_list (EVENT_KIND_EXCEPTION, NULL, NULL, &ei, &suspend_policy); mono_loader_unlock (); +#ifndef IL2CPP_MONO_DEBUGGER process_event (EVENT_KIND_EXCEPTION, &ei, 0, NULL, events, suspend_policy); +#else + process_event (EVENT_KIND_EXCEPTION, &ei, 0, NULL, events, suspend_policy, 0); +#endif +} +#endif + +#ifdef IL2CPP_MONO_DEBUGGER +void +unity_debugger_agent_handle_exception(MonoException *exc, Il2CppSequencePointC *sequencePoint) +{ + int i, j, suspend_policy; + GSList *events; + DebuggerEventInfo ei; + DebuggerTlsData *tls = NULL; + + if (thread_to_tls != NULL) + { + MonoInternalThread *thread = mono_thread_internal_current(); + + mono_loader_lock(); + tls = (DebuggerTlsData *)mono_g_hash_table_lookup(thread_to_tls, thread); + mono_loader_unlock(); + + if (tls && tls->abort_requested) + return; + if (tls && tls->disable_breakpoints) + return; + } + + memset(&ei, 0, sizeof(DebuggerEventInfo)); + + ei.exc = (MonoObject*)exc; + ei.caught = TRUE; + + mono_loader_lock(); + + /* Treat exceptions which are caught in non-user code as unhandled */ + for (i = 0; i < event_requests->len; ++i) + { + EventRequest *req = (EventRequest *)g_ptr_array_index(event_requests, i); + if (req->event_kind != EVENT_KIND_EXCEPTION) + continue; + + for (j = 0; j < req->nmodifiers; ++j) + { + Modifier *mod = &req->modifiers[j]; + + if (mod->kind == MOD_KIND_ASSEMBLY_ONLY && sequencePoint) + { + int k; + gboolean found = FALSE; + MonoAssembly **assemblies = mod->data.assemblies; + + if (assemblies) + { + for (k = 0; assemblies[k]; ++k) + if (assemblies[k] == VM_IMAGE_GET_ASSEMBLY(VM_CLASS_GET_IMAGE(VM_METHOD_GET_DECLARING_TYPE(sequencePoint->method)))) + found = TRUE; + } + if (!found) + ei.caught = FALSE; + } + } + } + + events = create_event_list(EVENT_KIND_EXCEPTION, NULL, NULL, &ei, &suspend_policy); + mono_loader_unlock(); + + process_event(EVENT_KIND_EXCEPTION, &ei, 0, NULL, events, suspend_policy, sequencePoint ? sequencePoint->id : 0); } #endif @@ -6026,7 +6740,7 @@ mono_debugger_agent_handle_exception (MonoException *exc, MonoContext *throw_ctx int i, j, suspend_policy; GSList *events; MonoJitInfo *ji, *catch_ji; - EventInfo ei; + DebuggerEventInfo ei; DebuggerTlsData *tls = NULL; if (thread_to_tls != NULL) { @@ -6042,7 +6756,7 @@ mono_debugger_agent_handle_exception (MonoException *exc, MonoContext *throw_ctx return; } - memset (&ei, 0, sizeof (EventInfo)); + memset (&ei, 0, sizeof (DebuggerEventInfo)); /* Just-In-Time debugging */ if (!catch_ctx) { @@ -6054,7 +6768,11 @@ mono_debugger_agent_handle_exception (MonoException *exc, MonoContext *throw_ctx */ events = g_slist_append (NULL, GUINT_TO_POINTER (0xffffff)); ei.exc = (MonoObject*)exc; +#ifndef IL2CPP_MONO_DEBUGGER process_event (EVENT_KIND_EXCEPTION, &ei, 0, throw_ctx, events, SUSPEND_POLICY_ALL); +#else + process_event (EVENT_KIND_EXCEPTION, &ei, 0, throw_ctx, events, SUSPEND_POLICY_ALL, 0); +#endif return; } } else if (agent_config.onthrow && !inited) { @@ -6079,7 +6797,11 @@ mono_debugger_agent_handle_exception (MonoException *exc, MonoContext *throw_ctx */ events = g_slist_append (NULL, GUINT_TO_POINTER (0xffffff)); ei.exc = (MonoObject*)exc; +#ifndef IL2CPP_MONO_DEBUGGER process_event (EVENT_KIND_EXCEPTION, &ei, 0, throw_ctx, events, SUSPEND_POLICY_ALL); +#else + process_event (EVENT_KIND_EXCEPTION, &ei, 0, throw_ctx, events, SUSPEND_POLICY_ALL, 0); +#endif return; } } @@ -6135,7 +6857,11 @@ mono_debugger_agent_handle_exception (MonoException *exc, MonoContext *throw_ctx } } +#ifndef IL2CPP_MONO_DEBUGGER process_event (EVENT_KIND_EXCEPTION, &ei, 0, throw_ctx, events, suspend_policy); +#else + process_event (EVENT_KIND_EXCEPTION, &ei, 0, throw_ctx, events, suspend_policy, 0); +#endif if (tls) tls->has_catch_frame = FALSE; @@ -6202,8 +6928,8 @@ mono_debugger_agent_end_exception_filter (MonoException *exc, MonoContext *ctx, * AS_VTYPE determines whenever to treat primitive types as primitive types or * vtypes. */ -static void -buffer_add_value_full (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain, +#ifndef IL2CPP_MONO_DEBUGGER +static void buffer_add_value_full (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain, gboolean as_vtype, GHashTable *parent_vtypes) { MonoObject *obj; @@ -6340,7 +7066,7 @@ buffer_add_value_full (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain, } buffer_add_byte (buf, MONO_TYPE_VALUETYPE); - buffer_add_byte (buf, klass->enumtype); + buffer_add_byte (buf, VM_CLASS_GET_ENUMTYPE(klass)); buffer_add_typeid (buf, domain, klass); nfields = 0; @@ -6383,6 +7109,218 @@ buffer_add_value_full (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain, NOT_IMPLEMENTED; } } +#else +static void buffer_add_value_full(Buffer *buf, MonoType *t, void *addr, MonoDomain *domain, + gboolean as_vtype, GHashTable *parent_vtypes) +{ + MonoObject *obj; + gboolean boxed_vtype = FALSE; + + if (il2cpp_type_is_byref(t)) + { + if (!(*(void**)addr)) + { + /* This can happen with compiler generated locals */ + //printf ("%s\n", mono_type_full_name (t)); + buffer_add_byte(buf, VALUE_TYPE_ID_NULL); + return; + } + g_assert(*(void**)addr); + addr = *(void**)addr; + } + + if (as_vtype) + { + switch (il2cpp_type_get_type(t)) + { + case MONO_TYPE_BOOLEAN: + case MONO_TYPE_I1: + case MONO_TYPE_U1: + case MONO_TYPE_CHAR: + case MONO_TYPE_I2: + case MONO_TYPE_U2: + case MONO_TYPE_I4: + case MONO_TYPE_U4: + case MONO_TYPE_R4: + case MONO_TYPE_I8: + case MONO_TYPE_U8: + case MONO_TYPE_R8: + case MONO_TYPE_I: + case MONO_TYPE_U: + case MONO_TYPE_PTR: + goto handle_vtype; + break; + default: + break; + } + } + + switch (il2cpp_type_get_type(t)) + { + case MONO_TYPE_VOID: + buffer_add_byte(buf, il2cpp_type_get_type(t)); + break; + case MONO_TYPE_BOOLEAN: + case MONO_TYPE_I1: + case MONO_TYPE_U1: + buffer_add_byte(buf, il2cpp_type_get_type(t)); + buffer_add_int(buf, *(gint8*)addr); + break; + case MONO_TYPE_CHAR: + case MONO_TYPE_I2: + case MONO_TYPE_U2: + buffer_add_byte(buf, il2cpp_type_get_type(t)); + buffer_add_int(buf, *(gint16*)addr); + break; + case MONO_TYPE_I4: + case MONO_TYPE_U4: + case MONO_TYPE_R4: + buffer_add_byte(buf, il2cpp_type_get_type(t)); + buffer_add_int(buf, *(gint32*)addr); + break; + case MONO_TYPE_I8: + case MONO_TYPE_U8: + case MONO_TYPE_R8: + buffer_add_byte(buf, il2cpp_type_get_type(t)); + buffer_add_long(buf, *(gint64*)addr); + break; + case MONO_TYPE_I: + case MONO_TYPE_U: + /* Treat it as a vtype */ + goto handle_vtype; + case MONO_TYPE_PTR: { + gssize val = *(gssize*)addr; + + buffer_add_byte(buf, il2cpp_type_get_type(t)); + buffer_add_long(buf, val); + break; + } + handle_ref: + case MONO_TYPE_STRING: + case MONO_TYPE_SZARRAY: + case MONO_TYPE_OBJECT: + case MONO_TYPE_CLASS: + case MONO_TYPE_ARRAY: + obj = *(MonoObject**)addr; + + if (!obj) + { + buffer_add_byte(buf, VALUE_TYPE_ID_NULL); + } + else + { + Il2CppMonoClass *klass = il2cpp_object_get_class(obj); + if (il2cpp_class_is_valuetype(klass)) + { + t = il2cpp_class_get_type(il2cpp_object_get_class(obj)); + addr = mono_object_unbox(obj); + boxed_vtype = TRUE; + goto handle_vtype; + } + else if (il2cpp_class_get_rank(klass)) + { + buffer_add_byte(buf, il2cpp_type_get_type(il2cpp_class_get_type(klass))); + } + else if (il2cpp_type_get_type(il2cpp_class_get_type(klass)) == MONO_TYPE_GENERICINST) + { + buffer_add_byte(buf, MONO_TYPE_CLASS); + } + else + { + buffer_add_byte(buf, il2cpp_type_get_type(il2cpp_class_get_type(klass))); + } + buffer_add_objid(buf, obj); + } + break; + handle_vtype: + case MONO_TYPE_VALUETYPE: + case MONO_TYPE_TYPEDBYREF: { + int nfields; + gpointer iter; + MonoClassField *f; + MonoClass *klass = mono_class_from_mono_type(t); + int vtype_index; + + if (boxed_vtype) + { + /* + * Handle boxed vtypes recursively referencing themselves using fields. + */ + if (!parent_vtypes) + parent_vtypes = g_hash_table_new(NULL, NULL); + vtype_index = GPOINTER_TO_INT(g_hash_table_lookup(parent_vtypes, addr)); + if (vtype_index) + { + if (CHECK_PROTOCOL_VERSION(2, 33)) + { + buffer_add_byte(buf, VALUE_TYPE_ID_PARENT_VTYPE); + buffer_add_int(buf, vtype_index - 1); + } + else + { + /* The client can't handle PARENT_VTYPE */ + buffer_add_byte(buf, VALUE_TYPE_ID_NULL); + } + break; + } + else + { + g_hash_table_insert(parent_vtypes, addr, GINT_TO_POINTER(g_hash_table_size(parent_vtypes) + 1)); + } + } + + buffer_add_byte(buf, MONO_TYPE_VALUETYPE); + buffer_add_byte(buf, VM_CLASS_GET_ENUMTYPE(klass)); + buffer_add_typeid(buf, domain, klass); + + nfields = 0; + iter = NULL; + while ((f = mono_class_get_fields(klass, &iter))) + { + if (VM_TYPE_GET_ATTRS(VM_FIELD_GET_TYPE(f)) & FIELD_ATTRIBUTE_STATIC) + continue; + if (VM_FIELD_IS_DELETED(f)) + continue; + nfields++; + } + buffer_add_int(buf, nfields); + + iter = NULL; + while ((f = mono_class_get_fields(klass, &iter))) + { + if (VM_TYPE_GET_ATTRS(VM_FIELD_GET_TYPE(f)) & FIELD_ATTRIBUTE_STATIC) + continue; + if (VM_FIELD_IS_DELETED(f)) + continue; + buffer_add_value_full(buf, VM_FIELD_GET_TYPE(f), (guint8*)addr + VM_FIELD_GET_OFFSET(f) - sizeof(MonoObject), domain, FALSE, parent_vtypes); + } + + if (boxed_vtype) + { + g_hash_table_remove(parent_vtypes, addr); + if (g_hash_table_size(parent_vtypes) == 0) + { + g_hash_table_destroy(parent_vtypes); + parent_vtypes = NULL; + } + } + break; + } + case MONO_TYPE_GENERICINST: + if (mono_type_generic_inst_is_valuetype(t)) + { + goto handle_vtype; + } + else + { + goto handle_ref; + } + break; + default: + NOT_IMPLEMENTED; + } +} +#endif static void buffer_add_value (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain) @@ -6393,7 +7331,7 @@ buffer_add_value (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain) static gboolean obj_is_of_type (MonoObject *obj, MonoType *t) { - MonoClass *klass = obj->vtable->klass; + MonoClass *klass = VM_OBJECT_GET_CLASS(obj); if (!mono_class_is_assignable_from (mono_class_from_mono_type (t), klass)) { if (mono_class_is_transparent_proxy (klass)) { klass = ((MonoTransparentProxy *)obj)->remote_class->proxy_class; @@ -6430,7 +7368,7 @@ decode_vtype (MonoType *t, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8 if (t && klass != mono_class_from_mono_type (t)) { char *name = mono_type_full_name (t); - char *name2 = mono_type_full_name (&klass->byval_arg); + char *name2 = mono_type_full_name (mono_class_get_type(klass)); DEBUG_PRINTF (1, "[%p] Expected value of type %s, got %s.\n", (gpointer) (gsize) mono_native_thread_id_get (), name, name2); g_free (name); g_free (name2); @@ -6439,11 +7377,11 @@ decode_vtype (MonoType *t, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8 nfields = decode_int (buf, &buf, limit); while ((f = mono_class_get_fields (klass, &iter))) { - if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) + if (VM_TYPE_GET_ATTRS(VM_FIELD_GET_TYPE(f)) & FIELD_ATTRIBUTE_STATIC) continue; - if (mono_field_is_deleted (f)) + if (VM_FIELD_IS_DELETED(f)) continue; - err = decode_value (f->type, domain, (guint8*)addr + f->offset - sizeof (MonoObject), buf, &buf, limit); + err = decode_value (VM_FIELD_GET_TYPE(f), domain, (guint8*)addr + VM_FIELD_GET_OFFSET(f) - sizeof (MonoObject), buf, &buf, limit); if (err != ERR_NONE) return err; nfields --; @@ -6460,19 +7398,19 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr, { ErrorCode err; - if (type != t->type && !MONO_TYPE_IS_REFERENCE (t) && - !(t->type == MONO_TYPE_I && type == MONO_TYPE_VALUETYPE) && - !(t->type == MONO_TYPE_U && type == MONO_TYPE_VALUETYPE) && - !(t->type == MONO_TYPE_PTR && type == MONO_TYPE_I8) && - !(t->type == MONO_TYPE_GENERICINST && type == MONO_TYPE_VALUETYPE) && - !(t->type == MONO_TYPE_VALUETYPE && type == MONO_TYPE_OBJECT)) { + if (type != VM_TYPE_GET_TYPE(t) && !MONO_TYPE_IS_REFERENCE (t) && + !(VM_TYPE_GET_TYPE(t) == MONO_TYPE_I && type == MONO_TYPE_VALUETYPE) && + !(VM_TYPE_GET_TYPE(t) == MONO_TYPE_U && type == MONO_TYPE_VALUETYPE) && + !(VM_TYPE_GET_TYPE(t) == MONO_TYPE_PTR && type == MONO_TYPE_I8) && + !(VM_TYPE_GET_TYPE(t) == MONO_TYPE_GENERICINST && type == MONO_TYPE_VALUETYPE) && + !(VM_TYPE_GET_TYPE(t) == MONO_TYPE_VALUETYPE && type == MONO_TYPE_OBJECT)) { char *name = mono_type_full_name (t); DEBUG_PRINTF (1, "[%p] Expected value of type %s, got 0x%0x.\n", (gpointer) (gsize) mono_native_thread_id_get (), name, type); g_free (name); return ERR_INVALID_ARGUMENT; } - switch (t->type) { + switch (VM_TYPE_GET_TYPE(t)) { case MONO_TYPE_BOOLEAN: *(guint8*)addr = decode_int (buf, &buf, limit); break; @@ -6540,11 +7478,11 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr, return err; if (!obj) return ERR_INVALID_ARGUMENT; - if (obj->vtable->klass != mono_class_from_mono_type (t)) { - DEBUG_PRINTF (1, "Expected type '%s', got object '%s'\n", mono_type_full_name (t), obj->vtable->klass->name); + if (VM_OBJECT_GET_CLASS(obj) != mono_class_from_mono_type (t)) { + DEBUG_PRINTF (1, "Expected type '%s', got object '%s'\n", mono_type_full_name (t), VM_CLASS_GET_NAME(VM_OBJECT_GET_CLASS(obj))); return ERR_INVALID_ARGUMENT; } - memcpy (addr, mono_object_unbox (obj), mono_class_value_size (obj->vtable->klass, NULL)); + memcpy (addr, mono_object_unbox (obj), mono_class_value_size (VM_OBJECT_GET_CLASS(obj), NULL)); } else { err = decode_vtype (t, domain, addr, buf, &buf, limit); if (err != ERR_NONE) @@ -6569,7 +7507,7 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr, return ERR_INVALID_ARGUMENT; } } - if (obj && obj->vtable->domain != domain) + if (obj && VM_OBJECT_GET_DOMAIN(obj) != domain) return ERR_INVALID_ARGUMENT; mono_gc_wbarrier_generic_store (addr, obj); @@ -6635,8 +7573,8 @@ decode_value (MonoType *t, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8 ErrorCode err; int type = decode_byte (buf, &buf, limit); - if (t->type == MONO_TYPE_GENERICINST && mono_class_is_nullable (mono_class_from_mono_type (t))) { - MonoType *targ = t->data.generic_class->context.class_inst->type_argv [0]; + if (VM_TYPE_GET_TYPE(t) == MONO_TYPE_GENERICINST && mono_class_is_nullable (mono_class_from_mono_type (t))) { + MonoType *targ = VM_GENERIC_INST_TYPE_ARG(VM_GENERIC_CLASS_GET_INST(VM_TYPE_GET_GENERIC_CLASS(t)), 0); guint8 *nullable_buf; /* @@ -7053,7 +7991,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 * Invoke this method directly, currently only Environment.Exit () is supported. */ this_arg = NULL; - DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (invoke->method, TRUE), this_arg ? this_arg->vtable->klass->name : ""); + DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (invoke->method, TRUE), this_arg ? VM_CLASS_GET_NAME(VM_OBJECT_GET_CLASS(this_arg)) : ""); mono_runtime_try_invoke (invoke->method, NULL, invoke->args, &exc, &error); mono_error_assert_ok (&error); @@ -7066,77 +8004,79 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 return err; sig = mono_method_signature (m); - if (m->klass->valuetype) - this_buf = (guint8 *)g_alloca (mono_class_instance_size (m->klass)); + if (VM_CLASS_IS_VALUETYPE(VM_METHOD_GET_DECLARING_TYPE(m))) + this_buf = (guint8 *)g_alloca (mono_class_instance_size (VM_METHOD_GET_DECLARING_TYPE(m))); else this_buf = (guint8 *)g_alloca (sizeof (MonoObject*)); - if (m->klass->valuetype && (m->flags & METHOD_ATTRIBUTE_STATIC)) { + if (VM_CLASS_IS_VALUETYPE(VM_METHOD_GET_DECLARING_TYPE(m)) && (VM_METHOD_GET_FLAGS(m) & METHOD_ATTRIBUTE_STATIC)) { /* Should be null */ int type = decode_byte (p, &p, end); if (type != VALUE_TYPE_ID_NULL) { DEBUG_PRINTF (1, "[%p] Error: Static vtype method invoked with this argument.\n", (gpointer) (gsize) mono_native_thread_id_get ()); return ERR_INVALID_ARGUMENT; } - memset (this_buf, 0, mono_class_instance_size (m->klass)); - } else if (m->klass->valuetype && !strcmp (m->name, ".ctor")) { + memset (this_buf, 0, mono_class_instance_size (VM_METHOD_GET_DECLARING_TYPE(m))); + } else if (VM_CLASS_IS_VALUETYPE(VM_METHOD_GET_DECLARING_TYPE(m)) && !strcmp (VM_METHOD_GET_NAME(m), ".ctor")) { /* Could be null */ guint8 *tmp_p; int type = decode_byte (p, &tmp_p, end); if (type == VALUE_TYPE_ID_NULL) { - memset (this_buf, 0, mono_class_instance_size (m->klass)); + memset (this_buf, 0, mono_class_instance_size (VM_METHOD_GET_DECLARING_TYPE(m))); p = tmp_p; } else { - err = decode_value (&m->klass->byval_arg, domain, this_buf, p, &p, end); + err = decode_value(VM_CLASS_GET_TYPE(VM_METHOD_GET_DECLARING_TYPE(m)), domain, this_buf, p, &p, end); + if (err != ERR_NONE) return err; } } else { - err = decode_value (&m->klass->byval_arg, domain, this_buf, p, &p, end); + err = decode_value (VM_CLASS_GET_TYPE(VM_METHOD_GET_DECLARING_TYPE(m)), domain, this_buf, p, &p, end); + if (err != ERR_NONE) return err; } - if (!m->klass->valuetype) + if (!VM_CLASS_IS_VALUETYPE(VM_METHOD_GET_DECLARING_TYPE(m))) this_arg = *(MonoObject**)this_buf; else this_arg = NULL; - if (MONO_CLASS_IS_INTERFACE (m->klass)) { + if (VM_CLASS_IS_INTERFACE (VM_METHOD_GET_DECLARING_TYPE(m))) { if (!this_arg) { DEBUG_PRINTF (1, "[%p] Error: Interface method invoked without this argument.\n", (gpointer) (gsize) mono_native_thread_id_get ()); return ERR_INVALID_ARGUMENT; } m = mono_object_get_virtual_method (this_arg, m); /* Transform this to the format the rest of the code expects it to be */ - if (m->klass->valuetype) { - this_buf = (guint8 *)g_alloca (mono_class_instance_size (m->klass)); - memcpy (this_buf, mono_object_unbox (this_arg), mono_class_instance_size (m->klass)); + if (VM_CLASS_IS_VALUETYPE(VM_METHOD_GET_DECLARING_TYPE(m))) { + this_buf = (guint8 *)g_alloca (mono_class_instance_size (VM_METHOD_GET_DECLARING_TYPE(m))); + memcpy (this_buf, mono_object_unbox (this_arg), mono_class_instance_size (VM_METHOD_GET_DECLARING_TYPE(m))); } - } else if ((m->flags & METHOD_ATTRIBUTE_VIRTUAL) && !m->klass->valuetype && invoke->flags & INVOKE_FLAG_VIRTUAL) { + } else if ((VM_METHOD_GET_FLAGS(m) & METHOD_ATTRIBUTE_VIRTUAL) && !VM_CLASS_IS_VALUETYPE(VM_METHOD_GET_DECLARING_TYPE(m)) && invoke->flags & INVOKE_FLAG_VIRTUAL) { if (!this_arg) { DEBUG_PRINTF (1, "[%p] Error: invoke with INVOKE_FLAG_VIRTUAL flag set without this argument.\n", (gpointer) (gsize) mono_native_thread_id_get ()); return ERR_INVALID_ARGUMENT; } m = mono_object_get_virtual_method (this_arg, m); - if (m->klass->valuetype) { - this_buf = (guint8 *)g_alloca (mono_class_instance_size (m->klass)); - memcpy (this_buf, mono_object_unbox (this_arg), mono_class_instance_size (m->klass)); + if (VM_CLASS_IS_VALUETYPE(VM_METHOD_GET_DECLARING_TYPE(m))) { + this_buf = (guint8 *)g_alloca (mono_class_instance_size (VM_METHOD_GET_DECLARING_TYPE(m))); + memcpy (this_buf, mono_object_unbox (this_arg), mono_class_instance_size (VM_METHOD_GET_DECLARING_TYPE(m))); } } - DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (m, TRUE), this_arg ? this_arg->vtable->klass->name : ""); + DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (m, TRUE), this_arg ? VM_CLASS_GET_NAME(VM_OBJECT_GET_CLASS(this_arg)) : ""); - if (this_arg && this_arg->vtable->domain != domain) + if (this_arg && VM_OBJECT_GET_DOMAIN(this_arg) != domain) NOT_IMPLEMENTED; - if (!m->klass->valuetype && !(m->flags & METHOD_ATTRIBUTE_STATIC) && !this_arg) { - if (!strcmp (m->name, ".ctor")) { - if (mono_class_is_abstract (m->klass)) + if (!VM_CLASS_IS_VALUETYPE(VM_METHOD_GET_DECLARING_TYPE(m)) && !(VM_METHOD_GET_FLAGS(m) & METHOD_ATTRIBUTE_STATIC) && !this_arg) { + if (!strcmp (VM_METHOD_GET_NAME(m), ".ctor")) { + if (mono_class_is_abstract (VM_METHOD_GET_DECLARING_TYPE(m))) return ERR_INVALID_ARGUMENT; else { MonoError error; - this_arg = mono_object_new_checked (domain, m->klass, &error); + this_arg = mono_object_new_checked (domain, VM_METHOD_GET_DECLARING_TYPE(m), &error); mono_error_assert_ok (&error); } } else { @@ -7144,7 +8084,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 } } - if (this_arg && !obj_is_of_type (this_arg, &m->klass->byval_arg)) + if (this_arg && !obj_is_of_type (this_arg, VM_CLASS_GET_TYPE(VM_METHOD_GET_DECLARING_TYPE(m)))) return ERR_INVALID_ARGUMENT; nargs = decode_int (p, &p, end); @@ -7159,10 +8099,10 @@ 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 != ERR_NONE) break; - if (args [i] && ((MonoObject*)args [i])->vtable->domain != domain) + if (args [i] && VM_OBJECT_GET_DOMAIN(((MonoObject*)args [i])) != domain) NOT_IMPLEMENTED; - if (sig->params [i]->byref) { + if (VM_TYPE_IS_BYREF(sig->params [i])) { arg_buf [i] = (guint8 *)g_alloca (sizeof (mgreg_t)); *(gpointer*)arg_buf [i] = args [i]; args [i] = arg_buf [i]; @@ -7174,8 +8114,12 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 if (err != ERR_NONE) break; if (mono_class_is_nullable (arg_class)) { +#ifndef IL2CPP_MONO_DEBUGGER args [i] = mono_nullable_box (arg_buf [i], arg_class, &error); mono_error_assert_ok (&error); +#else + g_assert_not_reached (); +#endif } else { args [i] = arg_buf [i]; } @@ -7193,7 +8137,8 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 /* * Add an LMF frame to link the stack frames on the invoke method with our caller. */ -#ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED +#ifndef IL2CPP_MONO_DEBUGGER +#ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED if (invoke->has_ctx) { /* Setup our lmf */ memset (&ext, 0, sizeof (ext)); @@ -7202,20 +8147,21 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 mono_push_lmf (&ext); } +#endif #endif mono_stopwatch_start (&watch); - res = mono_runtime_try_invoke (m, m->klass->valuetype ? (gpointer) this_buf : (gpointer) this_arg, args, &exc, &error); + res = mono_runtime_try_invoke (m, VM_CLASS_IS_VALUETYPE (VM_METHOD_GET_DECLARING_TYPE (m)) ? (gpointer)this_buf : (gpointer)this_arg, args, &exc, &error); if (!mono_error_ok (&error) && exc == NULL) { exc = (MonoObject*) mono_error_convert_to_exception (&error); } else { mono_error_cleanup (&error); /* FIXME report error */ } mono_stopwatch_stop (&watch); - DEBUG_PRINTF (1, "[%p] Invoke result: %p, exc: %s, time: %ld ms.\n", (gpointer) (gsize) mono_native_thread_id_get (), res, exc ? exc->vtable->klass->name : NULL, (long)mono_stopwatch_elapsed_ms (&watch)); + DEBUG_PRINTF (1, "[%p] Invoke result: %p, exc: %s, time: %ld ms.\n", (gpointer) (gsize) mono_native_thread_id_get (), res, exc ? VM_CLASS_GET_NAME (VM_OBJECT_GET_CLASS (exc)) : NULL, (long)mono_stopwatch_elapsed_ms (&watch)); if (exc) { buffer_add_byte (buf, 0); - buffer_add_value (buf, &mono_defaults.object_class->byval_arg, &exc, domain); + buffer_add_value (buf, VM_CLASS_GET_TYPE (VM_DEFAULTS_OBJECT_CLASS), &exc, domain); } else { gboolean out_this = FALSE; gboolean out_args = FALSE; @@ -7225,20 +8171,20 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 if ((invoke->flags & INVOKE_FLAG_RETURN_OUT_ARGS) && CHECK_PROTOCOL_VERSION (2, 35)) out_args = TRUE; buffer_add_byte (buf, 1 + (out_this ? 2 : 0) + (out_args ? 4 : 0)); - if (m->string_ctor) { + if (VM_METHOD_IS_STRING_CTOR(m)) { buffer_add_value (buf, &mono_get_string_class ()->byval_arg, &res, domain); - } else if (sig->ret->type == MONO_TYPE_VOID && !m->string_ctor) { - if (!strcmp (m->name, ".ctor")) { - if (!m->klass->valuetype) - buffer_add_value (buf, &mono_defaults.object_class->byval_arg, &this_arg, domain); + } else if (VM_TYPE_GET_TYPE (sig->ret) == MONO_TYPE_VOID && !VM_METHOD_IS_STRING_CTOR(m)) { + if (!strcmp (VM_METHOD_GET_NAME (m), ".ctor")) { + if (!VM_CLASS_IS_VALUETYPE (VM_METHOD_GET_DECLARING_TYPE (m))) + buffer_add_value (buf, VM_CLASS_GET_TYPE (VM_DEFAULTS_OBJECT_CLASS), &this_arg, domain); else - buffer_add_value (buf, &m->klass->byval_arg, this_buf, domain); + buffer_add_value (buf, VM_CLASS_GET_TYPE (VM_METHOD_GET_DECLARING_TYPE (m)), this_buf, domain); } else { - buffer_add_value (buf, &mono_defaults.void_class->byval_arg, NULL, domain); + buffer_add_value (buf, VM_CLASS_GET_TYPE (VM_DEFAULTS_VOID_CLASS), NULL, domain); } } else if (MONO_TYPE_IS_REFERENCE (sig->ret)) { buffer_add_value (buf, sig->ret, &res, domain); - } else if (mono_class_from_mono_type (sig->ret)->valuetype || sig->ret->type == MONO_TYPE_PTR || sig->ret->type == MONO_TYPE_FNPTR) { + } else if (VM_CLASS_IS_VALUETYPE (mono_class_from_mono_type (sig->ret)) || VM_TYPE_GET_TYPE (sig->ret) == MONO_TYPE_PTR || VM_TYPE_GET_TYPE (sig->ret) == MONO_TYPE_FNPTR) { if (mono_class_is_nullable (mono_class_from_mono_type (sig->ret))) { MonoClass *k = mono_class_from_mono_type (sig->ret); guint8 *nullable_buf = (guint8 *)g_alloca (mono_class_value_size (k, NULL)); @@ -7255,13 +8201,13 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 } if (out_this) /* Return the new value of the receiver after the call */ - buffer_add_value (buf, &m->klass->byval_arg, this_buf, domain); + buffer_add_value (buf, VM_CLASS_GET_TYPE(VM_METHOD_GET_DECLARING_TYPE(m)), this_buf, domain); if (out_args) { buffer_add_int (buf, nargs); for (i = 0; i < nargs; ++i) { if (MONO_TYPE_IS_REFERENCE (sig->params [i])) buffer_add_value (buf, sig->params [i], &args [i], domain); - else if (sig->params [i]->byref) + else if (VM_TYPE_IS_BYREF(sig->params [i])) /* add_value () does an indirection */ buffer_add_value (buf, sig->params [i], &arg_buf [i], domain); else @@ -7272,9 +8218,11 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 tls->disable_breakpoints = FALSE; +#ifndef IL2CPP_MONO_DEBUGGER #ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED if (invoke->has_ctx) mono_pop_lmf ((MonoLMF*)&ext); +#endif #endif *endp = p; @@ -7415,7 +8363,12 @@ get_source_files_for_type (MonoClass *klass) files = g_ptr_array_new (); - while ((method = mono_class_get_methods (klass, &iter))) { +#ifdef IL2CPP_MONO_DEBUGGER + const char **fileNames = il2cpp_get_source_files_for_type(klass, &i); + for (j = 0; j < i; ++j) + g_ptr_array_add(files, g_strdup(fileNames[j])); +#else + while ((method = mono_class_get_methods(klass, &iter))) { MonoDebugMethodInfo *minfo = mono_debug_lookup_method (method); GPtrArray *source_file_list; @@ -7432,6 +8385,7 @@ get_source_files_for_type (MonoClass *klass) g_ptr_array_free (source_file_list, TRUE); } } +#endif return files; } @@ -7479,6 +8433,8 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf) clear_suspended_objs (); break; case CMD_VM_DISPOSE: + suspend_vm (); + wait_for_suspend (); /* Clear all event requests */ mono_loader_lock (); while (event_requests->len > 0) { @@ -7530,7 +8486,7 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf) wait_for_suspend (); #ifdef TRY_MANAGED_SYSTEM_ENVIRONMENT_EXIT - env_class = mono_class_try_load_from_name (mono_defaults.corlib, "System", "Environment"); + env_class = mono_class_try_load_from_name (VM_DEFAULTS_CORLIB_IMAGE, "System", "Environment"); if (env_class) exit_method = mono_class_get_method_from_name (env_class, "Exit", 1); #endif @@ -7717,7 +8673,7 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf) mono_loader_lock (); g_hash_table_iter_init (&iter, domains); while (g_hash_table_iter_next (&iter, NULL, (void**)&domain)) { - AgentDomainInfo *info = (AgentDomainInfo *)domain_jit_info (domain)->agent_info; + AgentDomainInfo *info = (AgentDomainInfo *)VM_DOMAIN_GET_AGENT_INFO(domain); /* Update 'source_file_to_class' cache */ g_hash_table_iter_init (&kiter, info->loaded_classes); @@ -7818,13 +8774,14 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf) GSList *tmp; mono_domain_assemblies_lock (domain); - for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) { - ass = (MonoAssembly *)tmp->data; - - if (ass->image) { + void *iter = NULL; + while (ass = VM_DOMAIN_GET_ASSEMBLIES (domain, &iter)) + { + if (VM_ASSEMBLY_GET_IMAGE (ass)) + { MonoError probe_type_error; /* FIXME really okay to call while holding locks? */ - t = mono_reflection_get_type_checked (ass->image, ass->image, &info, ignore_case, &type_resolve, &probe_type_error); + t = mono_reflection_get_type_checked (VM_ASSEMBLY_GET_IMAGE (ass), VM_ASSEMBLY_GET_IMAGE (ass), &info, ignore_case, &type_resolve, &probe_type_error); mono_error_cleanup (&probe_type_error); if (t) { g_ptr_array_add (res_classes, mono_type_get_class (t)); @@ -7933,7 +8890,7 @@ event_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (exc_class) { req->modifiers [i].data.exc_class = exc_class; - if (!mono_class_is_assignable_from (mono_defaults.exception_class, exc_class)) { + if (!mono_class_is_assignable_from (VM_DEFAULTS_EXCEPTION_CLASS, exc_class)) { g_free (req); return ERR_INVALID_ARGUMENT; } @@ -8142,7 +9099,7 @@ domain_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (err != ERR_NONE) return err; - buffer_add_assemblyid (buf, domain, domain->domain->mbr.obj.vtable->klass->image->assembly); + buffer_add_assemblyid (buf, domain, VM_DOMAIN_GET_CORLIB(domain)); break; } case CMD_APPDOMAIN_CREATE_STRING: { @@ -8183,7 +9140,7 @@ domain_commands (int command, guint8 *p, guint8 *end, Buffer *buf) o = mono_object_new_checked (domain, klass, &error); mono_error_assert_ok (&error); - err = decode_value (&klass->byval_arg, domain, (guint8 *)mono_object_unbox (o), p, &p, end); + err = decode_value (mono_class_get_type(klass), domain, (guint8 *)mono_object_unbox (o), p, &p, end); if (err != ERR_NONE) return err; @@ -8200,6 +9157,14 @@ domain_commands (int command, guint8 *p, guint8 *end, Buffer *buf) static ErrorCode get_assembly_object_command (MonoDomain *domain, MonoAssembly *ass, Buffer *buf, MonoError *error) { +#ifdef IL2CPP_MONO_DEBUGGER + MonoReflectionAssemblyHandle o = il2cpp_mono_assembly_get_object_handle(domain, ass, error); + if (o == NULL) { + return ERR_INVALID_OBJECT; + } + buffer_add_objid(buf, (MonoObject*)o); + return ERR_NONE; +#else HANDLE_FUNCTION_ENTER(); ErrorCode err = ERR_NONE; error_init (error); @@ -8211,6 +9176,7 @@ get_assembly_object_command (MonoDomain *domain, MonoAssembly *ass, Buffer *buf, buffer_add_objid (buf, MONO_HANDLE_RAW (MONO_HANDLE_CAST (MonoObject, o))); leave: HANDLE_FUNCTION_RETURN_VAL (err); +#endif } @@ -8227,31 +9193,39 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) switch (command) { case CMD_ASSEMBLY_GET_LOCATION: { - buffer_add_string (buf, mono_image_get_filename (ass->image)); - break; + buffer_add_string (buf, mono_image_get_filename (VM_ASSEMBLY_GET_IMAGE(ass))); + break; } case CMD_ASSEMBLY_GET_ENTRY_POINT: { guint32 token; MonoMethod *m; - if (ass->image->dynamic) { + if (VM_ASSEMBLY_IS_DYNAMIC(ass)) { buffer_add_id (buf, 0); } else { - token = mono_image_get_entry_point (ass->image); +#ifdef IL2CPP_MONO_DEBUGGER + m = il2cpp_mono_image_get_entry_point(VM_ASSEMBLY_GET_IMAGE(ass)); + if (m == NULL) + buffer_add_id (buf, 0); + else + buffer_add_methodid (buf, domain, m); +#else + token = mono_image_get_entry_point (VM_ASSEMBLY_GET_IMAGE(ass)); if (token == 0) { buffer_add_id (buf, 0); } else { MonoError error; - m = mono_get_method_checked (ass->image, token, NULL, NULL, &error); + m = mono_get_method_checked (VM_ASSEMBLY_GET_IMAGE(ass), token, NULL, NULL, &error); if (!m) mono_error_cleanup (&error); /* FIXME don't swallow the error */ buffer_add_methodid (buf, domain, m); } +#endif // IL2CPP_MONO_DEBUGGER } break; } case CMD_ASSEMBLY_GET_MANIFEST_MODULE: { - buffer_add_moduleid (buf, domain, ass->image); + buffer_add_moduleid (buf, domain, VM_ASSEMBLY_GET_IMAGE(ass)); break; } case CMD_ASSEMBLY_GET_OBJECT: { @@ -8283,7 +9257,7 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) } else { if (info.assembly.name) NOT_IMPLEMENTED; - t = mono_reflection_get_type_checked (ass->image, ass->image, &info, ignorecase, &type_resolve, &error); + t = mono_reflection_get_type_checked (VM_ASSEMBLY_GET_IMAGE(ass), VM_ASSEMBLY_GET_IMAGE(ass), &info, ignorecase, &type_resolve, &error); if (!is_ok (&error)) { mono_error_cleanup (&error); /* FIXME don't swallow the error */ mono_reflection_free_type_info (&info); @@ -8302,14 +9276,17 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) case CMD_ASSEMBLY_GET_NAME: { gchar *name; MonoAssembly *mass = ass; - +#ifdef IL2CPP_MONO_DEBUGGER + name = VM_ASSEMBLY_GET_NAME(mass); +#else name = g_strdup_printf ( "%s, Version=%d.%d.%d.%d, Culture=%s, PublicKeyToken=%s%s", mass->aname.name, mass->aname.major, mass->aname.minor, mass->aname.build, mass->aname.revision, - mass->aname.culture && *mass->aname.culture? mass->aname.culture: "neutral", - mass->aname.public_key_token [0] ? (char *)mass->aname.public_key_token : "null", + mass->aname.culture && *mass->aname.culture ? mass->aname.culture : "neutral", + mass->aname.public_key_token[0] ? (char *)mass->aname.public_key_token : "null", (mass->aname.flags & ASSEMBLYREF_RETARGETABLE_FLAG) ? ", Retargetable=Yes" : ""); +#endif buffer_add_string (buf, name); g_free (name); @@ -8333,14 +9310,14 @@ module_commands (int command, guint8 *p, guint8 *end, Buffer *buf) MonoImage *image = decode_moduleid (p, &p, end, &domain, &err); char *basename; - basename = g_path_get_basename (image->name); + basename = g_path_get_basename (VM_IMAGE_GET_NAME(image)); buffer_add_string (buf, basename); // name - buffer_add_string (buf, image->module_name); // scopename - buffer_add_string (buf, image->name); // fqname + buffer_add_string (buf, VM_IMAGE_GET_MODULE_NAME(image)); // scopename + buffer_add_string (buf, VM_IMAGE_GET_NAME(image)); // fqname buffer_add_string (buf, mono_image_get_guid (image)); // guid - buffer_add_assemblyid (buf, domain, image->assembly); // assembly + buffer_add_assemblyid (buf, domain, VM_IMAGE_GET_ASSEMBLY(image)); // assembly g_free (basename); - break; + break; } default: return ERR_NOT_IMPLEMENTED; @@ -8474,8 +9451,8 @@ collect_interfaces (MonoClass *klass, GHashTable *ifaces, MonoError *error) if (!mono_error_ok (error)) return; - for (i = 0; i < klass->interface_count; i++) { - ic = klass->interfaces [i]; + gpointer iter = NULL; + while (ic = VM_CLASS_GET_INTERFACES(klass, &iter)) { g_hash_table_insert (ifaces, ic, ic); collect_interfaces (ic, ifaces, error); @@ -8490,6 +9467,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint MonoError error; MonoClass *nested; MonoType *type; + int type_tag; gpointer iter; guint8 b; int nnested; @@ -8498,34 +9476,36 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint switch (command) { case CMD_TYPE_GET_INFO: { - buffer_add_string (buf, klass->name_space); - buffer_add_string (buf, klass->name); + buffer_add_string (buf, mono_class_get_namespace(klass)); + buffer_add_string (buf, mono_class_get_name(klass)); // FIXME: byref - name = mono_type_get_name_full (&klass->byval_arg, MONO_TYPE_NAME_FORMAT_FULL_NAME); + type = mono_class_get_type(klass); + name = mono_type_get_name_full (type, MONO_TYPE_NAME_FORMAT_FULL_NAME); buffer_add_string (buf, name); g_free (name); - buffer_add_assemblyid (buf, domain, klass->image->assembly); - buffer_add_moduleid (buf, domain, klass->image); - buffer_add_typeid (buf, domain, klass->parent); - if (klass->rank || klass->byval_arg.type == MONO_TYPE_PTR) - buffer_add_typeid (buf, domain, klass->element_class); + buffer_add_assemblyid (buf, domain, mono_image_get_assembly(mono_class_get_image(klass))); + buffer_add_moduleid (buf, domain, mono_class_get_image(klass)); + buffer_add_typeid (buf, domain, mono_class_get_parent(klass)); + + type_tag = mono_type_get_type(type); + if (mono_class_get_rank(klass) || type_tag == MONO_TYPE_PTR) + buffer_add_typeid (buf, domain, mono_class_get_element_class(klass)); else buffer_add_id (buf, 0); - buffer_add_int (buf, klass->type_token); - buffer_add_byte (buf, klass->rank); + buffer_add_int (buf, mono_class_get_type_token(klass)); + buffer_add_byte (buf, mono_class_get_rank(klass)); buffer_add_int (buf, mono_class_get_flags (klass)); b = 0; - type = &klass->byval_arg; // FIXME: Can't decide whenever a class represents a byref type if (FALSE) b |= (1 << 0); - if (type->type == MONO_TYPE_PTR) + if (type_tag == MONO_TYPE_PTR) b |= (1 << 1); - if (!type->byref && (((type->type >= MONO_TYPE_BOOLEAN) && (type->type <= MONO_TYPE_R8)) || (type->type == MONO_TYPE_I) || (type->type == MONO_TYPE_U))) + if (!mono_type_is_byref(type) && (((type_tag >= MONO_TYPE_BOOLEAN) && (type_tag <= MONO_TYPE_R8)) || (type_tag == MONO_TYPE_I) || (type_tag == MONO_TYPE_U))) b |= (1 << 2); - if (type->type == MONO_TYPE_VALUETYPE) + if (type_tag == MONO_TYPE_VALUETYPE) b |= (1 << 3); - if (klass->enumtype) + if (mono_class_is_enum(klass)) b |= (1 << 4); if (mono_class_is_gtd (klass)) b |= (1 << 5); @@ -8544,7 +9524,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint if (mono_class_is_gtd (klass)) buffer_add_typeid (buf, domain, klass); else if (mono_class_is_ginst (klass)) - buffer_add_typeid (buf, domain, mono_class_get_generic_class (klass)->container_class); + buffer_add_typeid (buf, domain, VM_GENERIC_CLASS_GET_CONTAINER_CLASS(mono_class_get_generic_class (klass))); else buffer_add_id (buf, 0); } @@ -8552,17 +9532,17 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint int count, i; if (mono_class_is_ginst (klass)) { - MonoGenericInst *inst = mono_class_get_generic_class (klass)->context.class_inst; + MonoGenericInst *inst = VM_GENERIC_CLASS_GET_INST(mono_class_get_generic_class(klass)); - count = inst->type_argc; + count = VM_GENERIC_INST_TYPE_ARGC(inst); buffer_add_int (buf, count); for (i = 0; i < count; i++) - buffer_add_typeid (buf, domain, mono_class_from_mono_type (inst->type_argv [i])); + buffer_add_typeid (buf, domain, mono_class_from_mono_type (VM_GENERIC_INST_TYPE_ARG(inst, i))); } else if (mono_class_is_gtd (klass)) { MonoGenericContainer *container = mono_class_get_generic_container (klass); MonoClass *pklass; - count = container->type_argc; + count = VM_GENERIC_CONTAINER_GET_TYPE_ARGC(container); buffer_add_int (buf, count); for (i = 0; i < count; i++) { pklass = mono_class_from_generic_parameter_internal (mono_generic_container_get_param (container, i)); @@ -8605,9 +9585,9 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint while ((f = mono_class_get_fields (klass, &iter))) { buffer_add_fieldid (buf, domain, f); - buffer_add_string (buf, f->name); - buffer_add_typeid (buf, domain, mono_class_from_mono_type (f->type)); - buffer_add_int (buf, f->type->attrs); + buffer_add_string (buf, VM_FIELD_GET_NAME(f)); + buffer_add_typeid (buf, domain, mono_class_from_mono_type (mono_field_get_type(f))); + buffer_add_int (buf, VM_TYPE_GET_ATTRS(mono_field_get_type(f))); i ++; } g_assert (i == nfields); @@ -8625,10 +9605,10 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint while ((p = mono_class_get_properties (klass, &iter))) { buffer_add_propertyid (buf, domain, p); - buffer_add_string (buf, p->name); - buffer_add_methodid (buf, domain, p->get); - buffer_add_methodid (buf, domain, p->set); - buffer_add_int (buf, p->attrs); + buffer_add_string (buf, VM_PROPERTY_GET_NAME(p)); + buffer_add_methodid (buf, domain, VM_PROPERTY_GET_GET_METHOD(p)); + buffer_add_methodid (buf, domain, VM_PROPERTY_GET_SET_METHOD(p)); + buffer_add_int (buf, VM_PROPERTY_GET_ATTRS(p)); i ++; } g_assert (i == nprops); @@ -8649,7 +9629,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint return ERR_LOADER_ERROR; } - err = buffer_add_cattrs (buf, domain, klass->image, attr_klass, cinfo); + err = buffer_add_cattrs (buf, domain, mono_class_get_image(klass), attr_klass, cinfo); if (err != ERR_NONE) return err; break; @@ -8672,7 +9652,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint return ERR_LOADER_ERROR; } - err = buffer_add_cattrs (buf, domain, klass->image, attr_klass, cinfo); + err = buffer_add_cattrs (buf, domain, mono_class_get_image(klass), attr_klass, cinfo); if (err != ERR_NONE) return err; break; @@ -8695,7 +9675,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint return ERR_LOADER_ERROR; } - err = buffer_add_cattrs (buf, domain, klass->image, attr_klass, cinfo); + err = buffer_add_cattrs (buf, domain, mono_class_get_image(klass), attr_klass, cinfo); if (err != ERR_NONE) return err; break; @@ -8729,18 +9709,23 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint if (err != ERR_NONE) return err; - if (!(f->type->attrs & FIELD_ATTRIBUTE_STATIC)) + if (!(VM_TYPE_GET_ATTRS(VM_FIELD_GET_TYPE(f)) & FIELD_ATTRIBUTE_STATIC)) + return ERR_INVALID_FIELDID; + +#ifdef IL2CPP_MONO_DEBUGGER + if (!thread && VM_FIELD_GET_OFFSET(f) == THREAD_STATIC_FIELD_OFFSET) return ERR_INVALID_FIELDID; +#else special_static_type = mono_class_field_get_special_static_type (f); if (special_static_type != SPECIAL_STATIC_NONE) { if (!(thread && special_static_type == SPECIAL_STATIC_THREAD)) return ERR_INVALID_FIELDID; } - +#endif /* Check that the field belongs to the object */ found = FALSE; - for (k = klass; k; k = k->parent) { - if (k == f->parent) { + for (k = klass; k; k = VM_CLASS_GET_PARENT(k)) { + if (k == VM_FIELD_GET_PARENT(f)) { found = TRUE; break; } @@ -8748,12 +9733,12 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint if (!found) return ERR_INVALID_FIELDID; - vtable = mono_class_vtable (domain, f->parent); - val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type))); + vtable = mono_class_vtable (domain, VM_FIELD_GET_PARENT(f)); + val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (VM_FIELD_GET_TYPE(f)))); mono_field_static_get_value_for_thread (thread ? thread : mono_thread_internal_current (), vtable, f, val, &error); if (!is_ok (&error)) return ERR_INVALID_FIELDID; - buffer_add_value (buf, f->type, val, domain); + buffer_add_value (buf, VM_FIELD_GET_TYPE(f), val, domain); g_free (val); } break; @@ -8772,15 +9757,15 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint if (err != ERR_NONE) return err; - if (!(f->type->attrs & FIELD_ATTRIBUTE_STATIC)) + if (!(VM_TYPE_GET_ATTRS(mono_field_get_type(f)) & FIELD_ATTRIBUTE_STATIC)) return ERR_INVALID_FIELDID; if (mono_class_field_is_special_static (f)) return ERR_INVALID_FIELDID; /* Check that the field belongs to the object */ found = FALSE; - for (k = klass; k; k = k->parent) { - if (k == f->parent) { + for (k = klass; k; k = mono_class_get_parent(k)) { + if (k == mono_field_get_parent(f)) { found = TRUE; break; } @@ -8790,14 +9775,14 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint // FIXME: Check for literal/const - vtable = mono_class_vtable (domain, f->parent); - val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type))); - err = decode_value (f->type, domain, val, p, &p, end); + vtable = mono_class_vtable (domain, mono_field_get_parent(f)); + val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (mono_field_get_type(f)))); + err = decode_value (mono_field_get_type(f), domain, val, p, &p, end); if (err != ERR_NONE) { g_free (val); return err; } - if (MONO_TYPE_IS_REFERENCE (f->type)) + if (MONO_TYPE_IS_REFERENCE (mono_field_get_type(f))) mono_field_static_set_value (vtable, f, *(gpointer*)val); else mono_field_static_set_value (vtable, f, val); @@ -8806,7 +9791,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint break; } case CMD_TYPE_GET_OBJECT: { - MonoObject *o = (MonoObject*)mono_type_get_object_checked (domain, &klass->byval_arg, &error); + MonoObject *o = (MonoObject*)mono_type_get_object_checked (domain, mono_class_get_type(klass), &error); if (!mono_error_ok (&error)) { mono_error_cleanup (&error); return ERR_INVALID_OBJECT; @@ -8878,7 +9863,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint tclass = klass; - for (parent = tclass; parent; parent = parent->parent) { + for (parent = tclass; parent; parent = VM_CLASS_GET_PARENT(parent)) { mono_class_setup_interfaces (parent, &error); if (!mono_error_ok (&error)) return ERR_LOADER_ERROR; @@ -8910,11 +9895,11 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint iclass = decode_typeid (p, &p, end, NULL, &err); if (err != ERR_NONE) return err; - +#ifndef IL2CPP_MONO_DEBUGGER ioffset = mono_class_interface_offset_with_variance (klass, iclass, &variance_used); if (ioffset == -1) return ERR_INVALID_ARGUMENT; - +#endif nmethods = mono_class_num_methods (iclass); buffer_add_int (buf, nmethods); @@ -8922,8 +9907,13 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint while ((method = mono_class_get_methods (iclass, &iter))) { buffer_add_methodid (buf, domain, method); } + for (i = 0; i < nmethods; ++i) - buffer_add_methodid (buf, domain, klass->vtable [i + ioffset]); +#ifdef IL2CPP_MONO_DEBUGGER + buffer_add_methodid(buf, domain, il2cpp_get_interface_method(klass, iclass, i)); +#else + buffer_add_methodid(buf, domain, klass->vtable[i + ioffset]); +#endif } break; } @@ -8975,6 +9965,75 @@ type_commands (int command, guint8 *p, guint8 *end, Buffer *buf) return err; } +#ifdef IL2CPP_MONO_DEBUGGER + +gint CompareSeqPointsByIlOffset(gconstpointer a, gconstpointer b) +{ + Il2CppSequencePointC *seqPointA = *(Il2CppSequencePointC**)a; + Il2CppSequencePointC *seqPointB = *(Il2CppSequencePointC**)b; + + if (seqPointA->ilOffset < seqPointB->ilOffset) + return -1; + else if (seqPointA->ilOffset > seqPointB->ilOffset) + return 1; + else + return 0; +} + +static void GetSequencePointsAndSourceFilesUniqueSequencePoints(MonoMethod* method, GPtrArray** sequencePoints, GPtrArray** uniqueFileSequencePoints, GArray** uniqueFileSequencePointIndices) +{ + int i; + *sequencePoints = g_ptr_array_new(); + *uniqueFileSequencePoints = g_ptr_array_new(); + *uniqueFileSequencePointIndices = g_array_new(FALSE, FALSE, sizeof(int)); + + void *seqPointIter = NULL; + Il2CppSequencePointC *seqPoint; + while (seqPoint = il2cpp_get_method_sequence_points(method, &seqPointIter)) + { + if (il2cpp_mono_methods_match(seqPoint->method, method)) + g_ptr_array_add(*sequencePoints, seqPoint); + } + + g_ptr_array_sort(*sequencePoints, CompareSeqPointsByIlOffset); + + for(i=0;i < (*sequencePoints)->len;++i) + { + int j; + seqPoint = (Il2CppSequencePointC*)(*sequencePoints)->pdata[i]; + + for (j = 0; j < (*uniqueFileSequencePoints)->len; j++) + { + Il2CppSequencePointC* uniqueSequencePoint = g_ptr_array_index(*uniqueFileSequencePoints, j); + if (strcmp(uniqueSequencePoint->sourceFile, seqPoint->sourceFile) == 0) + break; + } + + if (j == (*uniqueFileSequencePoints)->len) + g_ptr_array_add(*uniqueFileSequencePoints, seqPoint); + + int index = (*uniqueFileSequencePoints)->len - 1; + g_array_append_val(*uniqueFileSequencePointIndices, index); + } +} + +static const Il2CppMethodExecutionContextInfoC* GetExecutionContextInfo(MonoMethod* method, uint32_t* count) +{ + void *seqPointIter = NULL; + Il2CppSequencePointC *seqPoint; + while (seqPoint = il2cpp_get_method_sequence_points(method, &seqPointIter)) + { + if (il2cpp_mono_methods_match(seqPoint->method, method)) + { + *count = seqPoint->executionContextInfoCount; + return seqPoint->executionContextInfos; + } + } + + g_assert(FALSE); // shouldn't be ever reached +} +#endif // IL2CPP_MONO_DEBUGGER + static ErrorCode method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, guint8 *p, guint8 *end, Buffer *buf) { @@ -8983,18 +10042,20 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g switch (command) { case CMD_METHOD_GET_NAME: { - buffer_add_string (buf, method->name); - break; + buffer_add_string (buf, mono_method_get_name(method)); + break; } case CMD_METHOD_GET_DECLARING_TYPE: { - buffer_add_typeid (buf, domain, method->klass); + buffer_add_typeid (buf, domain, mono_method_get_class(method)); break; } case CMD_METHOD_GET_DEBUG_INFO: { MonoError error; + int i, j; +#ifndef IL2CPP_MONO_DEBUGGER MonoDebugMethodInfo *minfo; char *source_file; - int i, j, n_il_offsets; + int n_il_offsets; int *source_files; GPtrArray *source_file_list; MonoSymSeqPoint *sym_seq_points; @@ -9059,6 +10120,52 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g g_free (sym_seq_points); g_ptr_array_free (source_file_list, TRUE); mono_metadata_free_mh (header); +#else + GPtrArray* sequencePoints; + GPtrArray* uniqueFileSequencePoints; + GArray* uniqueFileSequencePointIndices; + GetSequencePointsAndSourceFilesUniqueSequencePoints(method, &sequencePoints, &uniqueFileSequencePoints, &uniqueFileSequencePointIndices); + + buffer_add_int(buf, 0); + if (CHECK_PROTOCOL_VERSION(2, 13)) { + buffer_add_int(buf, uniqueFileSequencePoints->len); + for (i = 0; i < uniqueFileSequencePoints->len; ++i) { + Il2CppSequencePointC* sequencePoint = g_ptr_array_index(uniqueFileSequencePoints, i); + buffer_add_string(buf, sequencePoint->sourceFile); + if (CHECK_PROTOCOL_VERSION(2, 14)) { + buffer_add_data(buf, sequencePoint->sourceFileHash, 16); + } + } + } + else { + if (uniqueFileSequencePoints->len > 0) { + buffer_add_string(buf, ((Il2CppSequencePointC*)g_ptr_array_index(uniqueFileSequencePoints, 0))->sourceFile); + } else { + buffer_add_string(buf, ""); + } + } + buffer_add_int(buf, sequencePoints->len); + DEBUG_PRINTF(10, "Line number table for method %s:\n", mono_method_full_name(method, TRUE)); + for (i = 0; i < sequencePoints->len; ++i) { + Il2CppSequencePointC* sequencePoint = g_ptr_array_index(sequencePoints, i); + DEBUG_PRINTF(10, "IL%x -> %s:%d %d %d %d\n", sequencePoint->ilOffset, sequencePoint->sourceFile, + sequencePoint->lineStart, sequencePoint->columnStart, sequencePoint->lineEnd, sequencePoint->columnEnd); + buffer_add_int(buf, sequencePoint->ilOffset); + buffer_add_int(buf, sequencePoint->lineStart); + if (CHECK_PROTOCOL_VERSION(2, 13)) + buffer_add_int(buf, g_array_index(uniqueFileSequencePointIndices, int, i)); + if (CHECK_PROTOCOL_VERSION(2, 19)) + buffer_add_int(buf, sequencePoint->columnStart); + if (CHECK_PROTOCOL_VERSION(2, 32)) { + buffer_add_int(buf, sequencePoint->lineEnd); + buffer_add_int(buf, sequencePoint->columnEnd); + } + } + + g_ptr_array_free(sequencePoints, TRUE); + g_ptr_array_free(uniqueFileSequencePoints, TRUE); + g_array_free(uniqueFileSequencePointIndices, TRUE); +#endif break; } case CMD_METHOD_GET_PARAM_INFO: { @@ -9089,6 +10196,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g } case CMD_METHOD_GET_LOCALS_INFO: { MonoError error; +#ifndef IL2CPP_MONO_DEBUGGER int i, num_locals; MonoDebugLocalsInfo *locals; int *locals_map = NULL; @@ -9162,31 +10270,69 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g if (locals) mono_debug_free_locals (locals); g_free (locals_map); +#else + uint32_t executionInfoCount, localVariableCount = 0, i; + const Il2CppMethodExecutionContextInfoC* executionContextInfo = GetExecutionContextInfo(method, &executionInfoCount); + if (CHECK_PROTOCOL_VERSION(2, 43)) { + buffer_add_int(buf, 0); + } + + for (i = 0; i < executionInfoCount; i++) + { + if (executionContextInfo[i].variableKind == kMethodVariableKindC_LocalVariable) + localVariableCount++; + } + + buffer_add_int(buf, localVariableCount); + + for (i = 0; i < executionInfoCount; i++) + { + if (executionContextInfo[i].variableKind == kMethodVariableKindC_LocalVariable) + buffer_add_typeid(buf, domain, mono_class_from_mono_type(*executionContextInfo[i].type)); + } + + for (i = 0; i < executionInfoCount; i++) + { + if (executionContextInfo[i].variableKind == kMethodVariableKindC_LocalVariable) + buffer_add_string(buf, executionContextInfo[i].name); + } + + for (i = 0; i < localVariableCount; i++) + { + buffer_add_int(buf, 0); + buffer_add_int(buf, 0); + } +#endif // !IL2CPP_MONO_DEBUGGER break; } - case CMD_METHOD_GET_INFO: - buffer_add_int (buf, method->flags); - buffer_add_int (buf, method->iflags); - buffer_add_int (buf, method->token); + case CMD_METHOD_GET_INFO: { + int iflags; + buffer_add_int (buf, mono_method_get_flags(method, &iflags)); + buffer_add_int (buf, iflags); + buffer_add_int (buf, mono_method_get_token(method)); + gboolean is_generic = FALSE; + gboolean is_inflated = FALSE; if (CHECK_PROTOCOL_VERSION (2, 12)) { guint8 attrs = 0; - if (method->is_generic) + is_generic = VM_METHOD_IS_GENERIC(method); + is_inflated = VM_METHOD_IS_INFLATED(method); + if (is_generic) attrs |= (1 << 0); if (mono_method_signature (method)->generic_param_count) attrs |= (1 << 1); buffer_add_byte (buf, attrs); - if (method->is_generic || method->is_inflated) { + if (is_generic || is_inflated) { MonoMethod *result; - if (method->is_generic) { + if (is_generic) { result = method; } else { MonoMethodInflated *imethod = (MonoMethodInflated *)method; - - result = imethod->declaring; - if (imethod->context.class_inst) { - MonoClass *klass = ((MonoMethod *) imethod)->klass; + + result = VM_INFLATED_METHOD_GET_DECLARING(imethod); + if (VM_INFLATED_METHOD_GET_CLASS_INST(imethod)) { + MonoClass *klass = VM_METHOD_GET_DECLARING_TYPE((MonoMethod *) imethod); /*Generic methods gets the context of the GTD.*/ if (mono_class_get_context (klass)) { MonoError error; @@ -9204,18 +10350,18 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g if (mono_method_signature (method)->generic_param_count) { int count, i; - if (method->is_inflated) { + if (is_inflated) { MonoGenericInst *inst = mono_method_get_context (method)->method_inst; if (inst) { - count = inst->type_argc; + count = VM_GENERIC_INST_TYPE_ARGC(inst); buffer_add_int (buf, count); for (i = 0; i < count; i++) - buffer_add_typeid (buf, domain, mono_class_from_mono_type (inst->type_argv [i])); + buffer_add_typeid (buf, domain, mono_class_from_mono_type (VM_GENERIC_INST_TYPE_ARG(inst, i))); } else { buffer_add_int (buf, 0); } - } else if (method->is_generic) { + } else if (is_generic) { MonoGenericContainer *container = mono_method_get_generic_container (method); count = mono_method_signature (method)->generic_param_count; @@ -9234,6 +10380,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g } } break; + } case CMD_METHOD_GET_BODY: { MonoError error; int i; @@ -9384,11 +10531,11 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g g_free (type_argv); return ERR_INVALID_ARGUMENT; } - type_argv [i] = &klass->byval_arg; + type_argv [i] = mono_class_get_type(klass); } ginst = mono_metadata_get_generic_inst (type_argc, type_argv); g_free (type_argv); - tmp_context.class_inst = mono_class_is_ginst (method->klass) ? mono_class_get_generic_class (method->klass)->context.class_inst : NULL; + tmp_context.class_inst = mono_class_is_ginst (VM_METHOD_GET_DECLARING_TYPE(method)) ? VM_GENERIC_CLASS_GET_INST(mono_class_get_generic_class (VM_METHOD_GET_DECLARING_TYPE(method))) : NULL; tmp_context.method_inst = ginst; inflated = mono_class_inflate_generic_method_checked (method, &tmp_context, &error); @@ -9508,18 +10655,19 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf) break; } case CMD_THREAD_GET_STATE: - buffer_add_int (buf, thread->state); + buffer_add_int (buf, VM_INTERNAL_THREAD_GET_STATE(thread)); break; case CMD_THREAD_GET_INFO: - buffer_add_byte (buf, thread->threadpool_thread); + buffer_add_byte (buf, VM_INTERNAL_THREAD_GET_THREADPOOL_THREAD(thread)); break; case CMD_THREAD_GET_ID: buffer_add_long (buf, (guint64)(gsize)thread); break; case CMD_THREAD_GET_TID: - buffer_add_long (buf, (guint64)thread->tid); + buffer_add_long (buf, (guint64)VM_INTERNAL_THREAD_GET_ID(thread)); break; case CMD_THREAD_SET_IP: { +#ifndef IL2CPP_MONO_DEBUGGER DebuggerTlsData *tls; MonoMethod *method; MonoDomain *domain; @@ -9564,6 +10712,9 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf) } else { MONO_CONTEXT_SET_IP (&tls->restore_state.ctx, (guint8*)tls->frames [0]->ji->code_start + sp.native_offset); } +#else + return ERR_NOT_IMPLEMENTED; +#endif break; } default: @@ -9573,6 +10724,51 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf) return ERR_NONE; } +#ifdef IL2CPP_MONO_DEBUGGER + +static uint32_t GetExecutionContextIndex(const Il2CppSequencePointC* sequencePoint, MethodVariableKindC variableKind, uint32_t variablePosition) +{ + uint32_t executionContextPosition, variablesIterated = 0; + + for (executionContextPosition = 0;; executionContextPosition++) + { + g_assert(executionContextPosition < sequencePoint->executionContextInfoCount); + + if (sequencePoint->executionContextInfos[executionContextPosition].variableKind == variableKind) + { + if (variablesIterated == variablePosition) + return executionContextPosition; + + variablesIterated++; + } + } +} + +static void GetVariable(DebuggerTlsData* tls, StackFrame* frame, MethodVariableKindC variableKind, uint32_t variablePosition, Il2CppMonoType** type, void** var) +{ + for (int frame_index = 0; frame_index < tls->il2cpp_context.frameCount; ++frame_index) + { + if (tls->il2cpp_context.sequencePoints[frame_index]->method == frame->actual_method) + { + Il2CppSequencePointC* sequencePoint = tls->il2cpp_context.sequencePoints[frame_index]; + Il2CppSequencePointExecutionContextC* executionContext = tls->il2cpp_context.executionContexts[frame_index]; + uint32_t executionContextPosition = GetExecutionContextIndex(sequencePoint, variableKind, variablePosition); + *type = *sequencePoint->executionContextInfos[executionContextPosition].type; + *var = executionContext->values[executionContextPosition]; + } + } +} + +static void SendVariableData(DebuggerTlsData* tls, StackFrame* frame, Buffer* buf, MethodVariableKindC variableKind, uint32_t variablePosition) +{ + MonoType* localVariableType; + void* localVariableValue; + GetVariable(tls, frame, variableKind, variablePosition, &localVariableType, &localVariableValue); + buffer_add_value_full(buf, localVariableType, localVariableValue, frame->domain, FALSE, NULL); +} + +#endif + static ErrorCode frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) { @@ -9583,10 +10779,12 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) int pos, i, len, frame_idx; DebuggerTlsData *tls; StackFrame *frame; - MonoDebugMethodJitInfo *jit; MonoMethodSignature *sig; gssize id; +#ifndef IL2CPP_MONO_DEBUGGER + MonoDebugMethodJitInfo *jit; MonoMethodHeader *header; +#endif objid = decode_objid (p, &p, end); err = get_object (objid, (MonoObject**)&thread_obj); @@ -9622,25 +10820,31 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (!frame->has_ctx) return ERR_ABSENT_INFORMATION; +#ifndef IL2CPP_MONO_DEBUGGER if (!ensure_jit (frame)) return ERR_ABSENT_INFORMATION; jit = frame->jit; +#endif sig = mono_method_signature (frame->actual_method); +#ifndef IL2CPP_MONO_DEBUGGER if (!(jit->has_var_info || frame->ji->is_interp) || !mono_get_seq_points (frame->domain, frame->actual_method)) /* * The method is probably from an aot image compiled without soft-debug, variables might be dead, etc. */ return ERR_ABSENT_INFORMATION; +#endif switch (command) { case CMD_STACK_FRAME_GET_VALUES: { MonoError error; len = decode_int (p, &p, end); +#ifndef IL2CPP_MONO_DEBUGGER header = mono_method_get_header_checked (frame->actual_method, &error); mono_error_assert_ok (&error); /* FIXME report error */ +#endif for (i = 0; i < len; ++i) { pos = decode_int (p, &p, end); @@ -9650,6 +10854,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) DEBUG_PRINTF (4, "[dbg] send arg %d.\n", pos); +#ifndef IL2CPP_MONO_DEBUGGER if (frame->ji->is_interp) { guint8 *addr; @@ -9661,7 +10866,11 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) add_var (buf, jit, sig->params [pos], &jit->params [pos], &frame->ctx, frame->domain, FALSE); } +#else + SendVariableData (tls, frame, buf, kMethodVariableKindC_Parameter, pos); +#endif } else { +#ifndef IL2CPP_MONO_DEBUGGER MonoDebugLocalsInfo *locals; locals = mono_debug_lookup_locals (frame->method); @@ -9684,19 +10893,25 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) add_var (buf, jit, header->locals [pos], &jit->locals [pos], &frame->ctx, frame->domain, FALSE); } +#else + SendVariableData (tls, frame, buf, kMethodVariableKindC_LocalVariable, pos); +#endif } } +#ifndef IL2CPP_MONO_DEBUGGER mono_metadata_free_mh (header); +#endif break; } case CMD_STACK_FRAME_GET_THIS: { if (frame->method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE) return ERR_ABSENT_INFORMATION; - if (frame->api_method->klass->valuetype) { + if (VM_CLASS_IS_VALUETYPE (VM_METHOD_GET_DECLARING_TYPE (frame->api_method))) { if (!sig->hasthis) { MonoObject *p = NULL; - buffer_add_value (buf, &mono_defaults.object_class->byval_arg, &p, frame->domain); + buffer_add_value (buf, VM_CLASS_GET_TYPE (VM_DEFAULTS_OBJECT_CLASS), &p, frame->domain); } else { +#ifndef IL2CPP_MONO_DEBUGGER if (frame->ji->is_interp) { guint8 *addr; @@ -9706,12 +10921,23 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) } else { add_var (buf, jit, &frame->actual_method->klass->this_arg, jit->this_var, &frame->ctx, frame->domain, TRUE); } +#else + for (int frame_index = 0; frame_index < tls->il2cpp_context.frameCount; ++frame_index) + { + if (tls->il2cpp_context.sequencePoints[frame_index]->method == frame->actual_method) + { + buffer_add_value_full (buf, VM_CLASS_GET_THIS_ARG (VM_METHOD_GET_DECLARING_TYPE (frame->actual_method)), tls->il2cpp_context.executionContexts[frame_index]->values[0], frame->domain, TRUE, NULL); + break; + } + } +#endif } } else { if (!sig->hasthis) { MonoObject *p = NULL; - buffer_add_value (buf, &frame->actual_method->klass->byval_arg, &p, frame->domain); + buffer_add_value (buf, VM_CLASS_GET_TYPE (VM_METHOD_GET_DECLARING_TYPE (frame->actual_method)), &p, frame->domain); } else { +#ifndef IL2CPP_MONO_DEBUGGER if (frame->ji->is_interp) { guint8 *addr; @@ -9721,6 +10947,9 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) } else { add_var (buf, jit, &frame->api_method->klass->byval_arg, jit->this_var, &frame->ctx, frame->domain, TRUE); } +#else + SendVariableData (tls, frame, buf, kMethodVariableKindC_This, 0); +#endif } } break; @@ -9729,12 +10958,18 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) MonoError error; guint8 *val_buf; MonoType *t; +#ifndef IL2CPP_MONO_DEBUGGER MonoDebugVarInfo *var = NULL; +#else + void *var; +#endif gboolean is_arg = FALSE; len = decode_int (p, &p, end); +#ifndef IL2CPP_MONO_DEBUGGER header = mono_method_get_header_checked (frame->actual_method, &error); mono_error_assert_ok (&error); /* FIXME report error */ +#endif for (i = 0; i < len; ++i) { pos = decode_int (p, &p, end); @@ -9742,12 +10977,17 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (pos < 0) { pos = - pos - 1; +#ifndef IL2CPP_MONO_DEBUGGER g_assert (pos >= 0 && pos < jit->num_params); t = sig->params [pos]; var = &jit->params [pos]; +#else + GetVariable (tls, frame, kMethodVariableKindC_Parameter, pos, &t, &var); +#endif is_arg = TRUE; } else { +#ifndef IL2CPP_MONO_DEBUGGER MonoDebugLocalsInfo *locals; locals = mono_debug_lookup_locals (frame->method); @@ -9760,6 +11000,9 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) t = header->locals [pos]; var = &jit->locals [pos]; +#else + GetVariable(tls, frame, kMethodVariableKindC_LocalVariable, pos, &t, &var); +#endif } if (MONO_TYPE_IS_REFERENCE (t)) @@ -9770,6 +11013,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (err != ERR_NONE) return err; +#ifndef IL2CPP_MONO_DEBUGGER if (frame->ji->is_interp) { guint8 *addr; @@ -9781,8 +11025,13 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) } else { set_var (t, var, &frame->ctx, frame->domain, val_buf, frame->reg_locations, &tls->restore_state.ctx); } +#else + il2cpp_set_var (val_buf, var, t); +#endif } +#ifndef IL2CPP_MONO_DEBUGGER mono_metadata_free_mh (header); +#endif break; } case CMD_STACK_FRAME_GET_DOMAIN: { @@ -9793,7 +11042,11 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) case CMD_STACK_FRAME_SET_THIS: { guint8 *val_buf; MonoType *t; +#ifndef IL2CPP_MONO_DEBUGGER MonoDebugVarInfo *var; +#else + void *var; +#endif t = &frame->actual_method->klass->byval_arg; /* Checked by the sender */ @@ -9804,6 +11057,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (err != ERR_NONE) return err; +#ifndef IL2CPP_MONO_DEBUGGER if (frame->ji->is_interp) { guint8 *addr; @@ -9815,6 +11069,10 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) set_var (&frame->actual_method->klass->this_arg, var, &frame->ctx, frame->domain, val_buf, frame->reg_locations, &tls->restore_state.ctx); } +#else + GetVariable (tls, frame, kMethodVariableKindC_This, 0, &t, &var); + il2cpp_set_var (val_buf, var, t); +#endif break; } default: @@ -9824,7 +11082,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) return ERR_NONE; } -static ErrorCode +static int array_commands (int command, guint8 *p, guint8 *end, Buffer *buf) { MonoArray *arr; @@ -9839,14 +11097,14 @@ array_commands (int command, guint8 *p, guint8 *end, Buffer *buf) switch (command) { case CMD_ARRAY_REF_GET_LENGTH: - buffer_add_int (buf, arr->obj.vtable->klass->rank); + buffer_add_int (buf, VM_ARRAY_GET_RANK(arr)); if (!arr->bounds) { buffer_add_int (buf, arr->max_length); buffer_add_int (buf, 0); } else { - for (i = 0; i < arr->obj.vtable->klass->rank; ++i) { - buffer_add_int (buf, arr->bounds [i].length); - buffer_add_int (buf, arr->bounds [i].lower_bound); + for (i = 0; i < VM_ARRAY_GET_RANK(arr); ++i) { + buffer_add_int (buf, VM_ARRAY_BOUND_LENGTH(arr, i)); + buffer_add_int (buf, VM_ARRAY_BOUND_LOWER_BOUND(arr, i)); } } break; @@ -9858,10 +11116,10 @@ array_commands (int command, guint8 *p, guint8 *end, Buffer *buf) // Reordered to avoid integer overflow g_assert (!(index > arr->max_length - len)); - esize = mono_array_element_size (arr->obj.vtable->klass); + esize = mono_array_element_size (VM_OBJECT_GET_CLASS(arr)); for (i = index; i < index + len; ++i) { elem = (gpointer*)((char*)arr->vector + (i * esize)); - buffer_add_value (buf, &arr->obj.vtable->klass->element_class->byval_arg, elem, arr->obj.vtable->domain); + buffer_add_value (buf, VM_CLASS_GET_TYPE(VM_CLASS_GET_ELEMENT_CLASS(VM_OBJECT_GET_CLASS(arr))), elem, VM_OBJECT_GET_DOMAIN(arr)); } break; case CMD_ARRAY_REF_SET_VALUES: @@ -9872,11 +11130,10 @@ array_commands (int command, guint8 *p, guint8 *end, Buffer *buf) // Reordered to avoid integer overflow g_assert (!(index > arr->max_length - len)); - esize = mono_array_element_size (arr->obj.vtable->klass); + esize = mono_array_element_size (VM_OBJECT_GET_CLASS(arr)); for (i = index; i < index + len; ++i) { elem = (gpointer*)((char*)arr->vector + (i * esize)); - - decode_value (&arr->obj.vtable->klass->element_class->byval_arg, arr->obj.vtable->domain, (guint8 *)elem, p, &p, end); + decode_value (VM_CLASS_GET_TYPE(VM_CLASS_GET_ELEMENT_CLASS(VM_OBJECT_GET_CLASS(arr))), VM_OBJECT_GET_DOMAIN(arr), (guint8 *)elem, p, &p, end); } break; default: @@ -9970,7 +11227,7 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) MonoClass *obj_type; gboolean remote_obj = FALSE; - obj_type = obj->vtable->klass; + obj_type = VM_OBJECT_GET_CLASS(obj); if (mono_class_is_transparent_proxy (obj_type)) { obj_type = ((MonoTransparentProxy *)obj)->remote_class->proxy_class; remote_obj = TRUE; @@ -9981,7 +11238,7 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) switch (command) { case CMD_OBJECT_REF_GET_TYPE: /* This handles transparent proxies too */ - buffer_add_typeid (buf, obj->vtable->domain, mono_class_from_mono_type (((MonoReflectionType*)obj->vtable->type)->type)); + buffer_add_typeid (buf, VM_OBJECT_GET_DOMAIN(obj), mono_class_from_mono_type (((MonoReflectionType*)obj->vtable->type)->type)); break; case CMD_OBJECT_REF_GET_VALUES: len = decode_int (p, &p, end); @@ -9993,8 +11250,8 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) /* Check that the field belongs to the object */ found = FALSE; - for (k = obj_type; k; k = k->parent) { - if (k == f->parent) { + for (k = obj_type; k; k = VM_CLASS_GET_PARENT(k)) { + if (k == VM_FIELD_GET_PARENT(f)) { found = TRUE; break; } @@ -10002,22 +11259,22 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (!found) return ERR_INVALID_FIELDID; - if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) { + if (VM_TYPE_GET_ATTRS(VM_FIELD_GET_TYPE(f)) & FIELD_ATTRIBUTE_STATIC) { guint8 *val; MonoVTable *vtable; if (mono_class_field_is_special_static (f)) return ERR_INVALID_FIELDID; - g_assert (f->type->attrs & FIELD_ATTRIBUTE_STATIC); - vtable = mono_class_vtable (obj->vtable->domain, f->parent); - val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type))); + g_assert (VM_TYPE_GET_ATTRS(VM_FIELD_GET_TYPE(f)) & FIELD_ATTRIBUTE_STATIC); + vtable = mono_class_vtable (VM_OBJECT_GET_DOMAIN(obj), VM_FIELD_GET_PARENT(f)); + val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (VM_FIELD_GET_TYPE(f)))); mono_field_static_get_value_checked (vtable, f, val, &error); if (!is_ok (&error)) { mono_error_cleanup (&error); /* FIXME report the error */ return ERR_INVALID_OBJECT; } - buffer_add_value (buf, f->type, val, obj->vtable->domain); + buffer_add_value (buf, VM_FIELD_GET_TYPE(f), val, VM_OBJECT_GET_DOMAIN(obj)); g_free (val); } else { guint8 *field_value = NULL; @@ -10033,10 +11290,11 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) #else g_assert_not_reached (); #endif - } else - field_value = (guint8*)obj + f->offset; + } + else + field_value = VM_FIELD_GET_ADDRESS(obj, f); - buffer_add_value (buf, f->type, field_value, obj->vtable->domain); + buffer_add_value (buf, VM_FIELD_GET_TYPE(f), field_value, VM_OBJECT_GET_DOMAIN(obj)); } } break; @@ -10050,8 +11308,8 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) /* Check that the field belongs to the object */ found = FALSE; - for (k = obj_type; k; k = k->parent) { - if (k == f->parent) { + for (k = obj_type; k; k = VM_CLASS_GET_PARENT(k)) { + if (k == VM_FIELD_GET_PARENT(f)) { found = TRUE; break; } @@ -10059,18 +11317,18 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (!found) return ERR_INVALID_FIELDID; - if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) { + if (VM_TYPE_GET_ATTRS(VM_FIELD_GET_TYPE(f)) & FIELD_ATTRIBUTE_STATIC) { guint8 *val; MonoVTable *vtable; if (mono_class_field_is_special_static (f)) return ERR_INVALID_FIELDID; - g_assert (f->type->attrs & FIELD_ATTRIBUTE_STATIC); - vtable = mono_class_vtable (obj->vtable->domain, f->parent); + g_assert (VM_TYPE_GET_ATTRS(VM_FIELD_GET_TYPE(f)) & FIELD_ATTRIBUTE_STATIC); + vtable = mono_class_vtable (VM_OBJECT_GET_DOMAIN(obj), VM_FIELD_GET_PARENT(f)); - val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type))); - err = decode_value (f->type, obj->vtable->domain, val, p, &p, end); + val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (VM_FIELD_GET_TYPE(f)))); + err = decode_value (VM_FIELD_GET_TYPE(f), VM_OBJECT_GET_DOMAIN(obj), val, p, &p, end); if (err != ERR_NONE) { g_free (val); return err; @@ -10078,7 +11336,7 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) mono_field_static_set_value (vtable, f, val); g_free (val); } else { - err = decode_value (f->type, obj->vtable->domain, (guint8*)obj + f->offset, p, &p, end); + err = decode_value (VM_FIELD_GET_TYPE(f), VM_OBJECT_GET_DOMAIN(obj), (guint8*)obj + VM_FIELD_GET_OFFSET(f), p, &p, end); if (err != ERR_NONE) return err; } @@ -10088,11 +11346,11 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) buffer_add_long (buf, (gssize)obj); break; case CMD_OBJECT_REF_GET_DOMAIN: - buffer_add_domainid (buf, obj->vtable->domain); + buffer_add_domainid (buf, VM_OBJECT_GET_DOMAIN(obj)); break; case CMD_OBJECT_REF_GET_INFO: - buffer_add_typeid (buf, obj->vtable->domain, mono_class_from_mono_type (((MonoReflectionType*)obj->vtable->type)->type)); - buffer_add_domainid (buf, obj->vtable->domain); + buffer_add_typeid (buf, VM_OBJECT_GET_DOMAIN(obj), mono_class_from_mono_type(VM_OBJECT_GET_TYPE(obj))); + buffer_add_domainid (buf, VM_OBJECT_GET_DOMAIN(obj)); break; default: return ERR_NOT_IMPLEMENTED; @@ -10385,17 +11643,22 @@ debugger_thread (void *arg) gboolean attach_failed = FALSE; DEBUG_PRINTF (1, "[dbg] Agent thread started, pid=%p\n", (gpointer) (gsize) mono_native_thread_id_get ()); - - debugger_thread_id = mono_native_thread_id_get (); + debugger_thread_id = mono_native_thread_id_get (); +#ifdef IL2CPP_MONO_DEBUGGER + mono_thread_attach (il2cpp_mono_get_root_domain ()); +#endif MonoInternalThread *internal = mono_thread_internal_current (); +#ifdef IL2CPP_MONO_DEBUGGER + internal->debugger_thread = 1; +#endif MonoString *str = mono_string_new_checked (mono_domain_get (), "Debugger agent", &error); mono_error_assert_ok (&error); mono_thread_set_name_internal (internal, str, TRUE, FALSE, &error); mono_error_assert_ok (&error); - internal->state |= ThreadState_Background; - internal->flags |= MONO_THREAD_FLAG_DONT_MANAGE; + VM_INTERNAL_THREAD_SET_STATE_BACKGROUND (internal); + VM_INTERNAL_THREAD_SET_FLAG_DONT_MANAGE (internal); if (agent_config.defer) { if (!wait_for_attach ()) { @@ -10405,6 +11668,17 @@ debugger_thread (void *arg) mono_set_is_debugger_attached (TRUE); /* Send start event to client */ process_profiler_event (EVENT_KIND_VM_START, mono_thread_get_main ()); +#ifdef IL2CPP_MONO_DEBUGGER + { + Il2CppMonoDomain* domain = il2cpp_mono_get_root_domain(); + appdomain_load(NULL, domain); + AgentDomainInfo *info = VM_DOMAIN_GET_AGENT_INFO(domain); + void *iter = NULL; + Il2CppMonoClass *klass; + while(klass = il2cpp_iterate_loaded_classes(&iter)) + g_hash_table_insert(info->loaded_classes, klass, klass); + } +#endif } } else { mono_set_is_debugger_attached (TRUE); @@ -10536,6 +11810,10 @@ debugger_thread (void *arg) mono_set_is_debugger_attached (FALSE); +#ifdef IL2CPP_MONO_DEBUGGER + il2cpp_mono_free_method_signatures(); +#endif + mono_coop_mutex_lock (&debugger_thread_exited_mutex); debugger_thread_exited = TRUE; mono_coop_cond_signal (&debugger_thread_exited_cond); @@ -10550,6 +11828,168 @@ debugger_thread (void *arg) return 0; } +#ifdef IL2CPP_MONO_DEBUGGER + +static void +unity_process_breakpoint_inner(DebuggerTlsData *tls, gboolean from_signal, Il2CppSequencePointC* sequencePoint) +{ + MonoJitInfo *ji = NULL; + guint8 *ip; + int i, j, suspend_policy; + MonoBreakpoint *bp; + BreakpointInstance *inst; + GPtrArray *bp_reqs, *ss_reqs_orig, *ss_reqs; + GSList *bp_events = NULL, *ss_events = NULL, *enter_leave_events = NULL; + EventKind kind = EVENT_KIND_BREAKPOINT; + MonoContext *ctx = &tls->restore_state.ctx; + //MonoSeqPointInfo *info; + SeqPoint sp; + gboolean found_sp; + MonoMethod* method = sequencePoint->method; + + /* + * Skip the instruction causing the breakpoint signal. + */ + unity_mono_jit_find_compiled_method_with_jit_info(mono_domain_get(), method, &ji); + + if (from_signal) + g_assert_not_reached(); + + if (VM_METHOD_GET_WRAPPER_TYPE(method) || tls->disable_breakpoints) + return; + + bp_reqs = g_ptr_array_new(); + ss_reqs = g_ptr_array_new(); + ss_reqs_orig = g_ptr_array_new(); + + mono_loader_lock(); + + bp = NULL; + for (i = 0; i < breakpoints->len; ++i) { + bp = (MonoBreakpoint *)g_ptr_array_index(breakpoints, i); + + if (!bp->method || !il2cpp_mono_methods_match(bp->method, sequencePoint->method)) + continue; + + if (bp->req->event_kind == EVENT_KIND_STEP) + { + SingleStepReq *ss_req = (SingleStepReq *)bp->req->info; + gboolean validFrame = FALSE; + validFrame |= ss_req->depth == STEP_DEPTH_INTO; + validFrame |= ss_req->depth == STEP_DEPTH_OVER && tls->il2cpp_context.frameCount <= ss_req->nframes; + validFrame |= ss_req->depth == STEP_DEPTH_OUT && tls->il2cpp_context.frameCount < ss_req->nframes; + if (!validFrame) + continue; + } + + for (j = 0; j < bp->children->len; ++j) { + inst = (BreakpointInstance *)g_ptr_array_index(bp->children, j); + if (inst->il_offset == bp->il_offset) { + if (bp->req->event_kind == EVENT_KIND_STEP) { + for (int j = 0; j < bp->children->len; ++j) + { + BreakpointInstance *inst = (BreakpointInstance *)g_ptr_array_index(bp->children, j); + if (inst->seq_point == sequencePoint) + { + g_ptr_array_add(ss_reqs_orig, bp->req); + break; + } + } + } + else { + g_ptr_array_add(bp_reqs, bp->req); + } + } + } + } + + if (bp_reqs->len == 0 && ss_reqs_orig->len == 0) + { + for (i = 0; i < breakpoints->len; ++i) + { + bp = (MonoBreakpoint *)g_ptr_array_index(breakpoints, i); + + if (bp) + { + /* Maybe a method entry/exit event */ + if ((bp->il_offset == METHOD_ENTRY_IL_OFFSET) && (bp->il_offset == sequencePoint->ilOffset)) + { + kind = EVENT_KIND_METHOD_ENTRY; + break; + } + else if ((bp->il_offset == METHOD_EXIT_IL_OFFSET) && (bp->il_offset == sequencePoint->ilOffset)) + { + kind = EVENT_KIND_METHOD_EXIT; + break; + } + } + } + } + + g_assert(ss_reqs_orig->len <= 1); + if (ss_reqs_orig->len == 1) + { + EventRequest *req = (EventRequest *)g_ptr_array_index(ss_reqs_orig, 0); + SingleStepReq *ss_req = (SingleStepReq *)req->info; + gboolean hit = ss_update_il2cpp(ss_req, tls, ctx, sequencePoint); + if (hit) + { + g_ptr_array_add(ss_reqs, req); + ss_start_il2cpp(ss_req, tls); + } + } + + if (ss_reqs->len > 0) + ss_events = create_event_list(EVENT_KIND_STEP, ss_reqs, ji, NULL, &suspend_policy); + if (bp_reqs->len > 0) + bp_events = create_event_list(EVENT_KIND_BREAKPOINT, bp_reqs, ji, NULL, &suspend_policy); + if (kind != EVENT_KIND_BREAKPOINT) + enter_leave_events = create_event_list(kind, NULL, ji, NULL, &suspend_policy); + + mono_loader_unlock(); + + g_ptr_array_free(bp_reqs, TRUE); + g_ptr_array_free(ss_reqs, TRUE); + + /* + * FIXME: The first event will suspend, so the second will only be sent after the + * resume. + */ + if (ss_events) + process_event(EVENT_KIND_STEP, method, 0, ctx, ss_events, suspend_policy, sequencePoint->id); + if (bp_events) + process_event(kind, method, 0, ctx, bp_events, suspend_policy, sequencePoint->id); + if (enter_leave_events) + process_event(kind, method, 0, ctx, enter_leave_events, suspend_policy, sequencePoint->id); +} + +void +unity_debugger_agent_breakpoint(Il2CppSequencePointC* sequencePoint) +{ + DebuggerTlsData *tls; + MonoThreadUnwindState orig_restore_state; + guint8 *orig_ip; + + if (is_debugger_thread()) + return; + + tls = (DebuggerTlsData *)mono_native_tls_get_value(debugger_tls_id); + g_assert(tls); + + save_thread_context(NULL); + + unity_process_breakpoint_inner(tls, FALSE, sequencePoint); +} + +gboolean unity_debugger_agent_is_global_breakpoint_active() +{ + if (!ss_req) + return FALSE; + else + return ss_req->global; +} + +#endif // IL2CPP_MONO_DEBUGGER #else /* DISABLE_DEBUGGER_AGENT */ diff --git a/mono/mini/debugger-agent.h b/mono/mini/debugger-agent.h index 1ff9de11db46..dcfab1cf25f7 100644 --- a/mono/mini/debugger-agent.h +++ b/mono/mini/debugger-agent.h @@ -6,11 +6,17 @@ #define __MONO_DEBUGGER_AGENT_H__ #include "mini.h" +#include "il2cpp-compat.h" #include MONO_API void mono_debugger_agent_parse_options (char *options); +#ifdef IL2CPP_MONO_DEBUGGER +void +mono_debugger_run_debugger_thread_func(void* arg); +#endif // IL2CPP_MONO_DEBUGGER + void mono_debugger_agent_init (void); @@ -21,7 +27,11 @@ void mono_debugger_agent_single_step_event (void *sigctx); void +#ifndef IL2CPP_MONO_DEBUGGER debugger_agent_single_step_from_context (MonoContext *ctx); +#else +debugger_agent_single_step_from_context (MonoContext *ctx, uint64_t sequencePointId); +#endif void debugger_agent_breakpoint_from_context (MonoContext *ctx); diff --git a/mono/mini/exceptions-amd64.c b/mono/mini/exceptions-amd64.c index f147c8946f45..be3330b61b5c 100644 --- a/mono/mini/exceptions-amd64.c +++ b/mono/mini/exceptions-amd64.c @@ -128,7 +128,7 @@ get_win32_restore_stack (void) * Unhandled Exception Filter * Top-level per-process exception handler. */ -static LONG CALLBACK seh_vectored_exception_handler(EXCEPTION_POINTERS* ep) +LONG CALLBACK seh_vectored_exception_handler(EXCEPTION_POINTERS* ep) { EXCEPTION_RECORD* er; CONTEXT* ctx; diff --git a/mono/mini/il2cpp-c-types.h b/mono/mini/il2cpp-c-types.h new file mode 100644 index 000000000000..76661334d728 --- /dev/null +++ b/mono/mini/il2cpp-c-types.h @@ -0,0 +1,447 @@ +#ifndef __IL2CPP_MONO_DEBUGGER_OPAQUE_TYPES_H__ +#define __IL2CPP_MONO_DEBUGGER_OPAQUE_TYPES_H__ + +#define IL2CPP_MONO_PUBLIC_KEY_TOKEN_LENGTH 17 + +typedef struct _Il2CppMonoType Il2CppMonoType; +typedef struct _Il2CppMonoClass Il2CppMonoClass; +typedef struct _Il2CppMonoAssemblyName Il2CppMonoAssemblyNameReplacement; +typedef struct _Il2CppMonoAssembly Il2CppMonoAssembly; +typedef struct _Il2CppMonoDomain Il2CppMonoDomain; +typedef struct _Il2CppMonoImage Il2CppMonoImage; +typedef struct _Il2CppMonoMethodSignature Il2CppMonoMethodSignature; +typedef struct _Il2CppMonoMethod Il2CppMonoMethod; +typedef struct _Il2CppMonoClassField Il2CppMonoClassField; +typedef struct _Il2CppMonoArrayType Il2CppMonoArrayType; +typedef struct _Il2CppMonoGenericParam Il2CppMonoGenericParam; +typedef struct _Il2CppMonoGenericInst Il2CppMonoGenericInst; +typedef struct _Il2CppMonoGenericContext Il2CppMonoGenericContext; +typedef struct _Il2CppMonoGenericClass Il2CppMonoGenericClass; +typedef struct _Il2CppMonoMethodHeader Il2CppMonoMethodHeader; +typedef struct _Il2CppMonoVTable Il2CppMonoVTable; +typedef struct _Il2CppMonoProperty Il2CppMonoProperty; +typedef struct _Il2CppMonoString Il2CppMonoString; +typedef struct _Il2CppMonoAppDomain Il2CppMonoAppDomain; +typedef struct _Il2CppMonoMarshalByRefObject Il2CppMonoMarshalByRefObject; +typedef struct _Il2CppMonoObject Il2CppMonoObject; +typedef struct _Il2CppMonoArray Il2CppMonoArray; +typedef struct _Il2CppMonoCustomAttrInfo Il2CppMonoCustomAttrInfo; +typedef struct _Il2CppMonoThread Il2CppMonoThread; +typedef struct _Il2CppMonoGHashTable Il2CppMonoGHashTable; +typedef struct _Il2CppMonoGenericContainer Il2CppMonoGenericContainer; +typedef struct _Il2CppMonoReflectionAssembly Il2CppMonoReflectionAssembly; +typedef struct _Il2CppMonoReflectionType Il2CppMonoReflectionType; +typedef struct _Il2CppMonoProfiler Il2CppMonoProfiler; +typedef struct _Il2CppMonoJitTlsData Il2CppMonoJitTlsData; +typedef struct _Il2CppMonoRuntimeExceptionHandlingCallbacks Il2CppMonoRuntimeExceptionHandlingCallbacks; +typedef struct _Il2CppMonoInternalThread Il2CppMonoInternalThread; +typedef struct _Il2CppMonoCustomAttrEntry Il2CppMonoCustomAttrEntry; +typedef struct _Il2CppMonoStackFrameInfo Il2CppMonoStackFrameInfo; +typedef struct _Il2CppMonoDefaults Il2CppMonoDefaults; +typedef struct _Il2CppMonoMethodInflated Il2CppMonoMethodInflated; +typedef struct _Il2CppMonoException Il2CppMonoException; +typedef struct _Il2CppCattrNamedArg Il2CppCattrNamedArg; +typedef struct _Il2CppMonoExceptionClause Il2CppMonoExceptionClause; +typedef struct _Il2CppMonoTypeNameParse Il2CppMonoTypeNameParse; + +struct _Il2CppMonoString { void *dummy; }; +struct _Il2CppMonoArrayType { void *dummy; }; +struct _Il2CppMonoGenericParam { void *dummy; }; +struct _Il2CppMonoGHashTable { void *dummy; }; +struct _Il2CppMonoProfiler { void *dummy; }; +struct _Il2CppMonoJitTlsData { void *dummy; }; +struct _Il2CppMonoReflectionAssembly { void *dummy; }; + +struct _Il2CppMonoExceptionClause +{ + uint32_t flags; + uint32_t try_offset; + uint32_t try_len; + uint32_t handler_offset; + uint32_t handler_len; + union { + uint32_t filter_offset; + Il2CppMonoClass *catch_class; + } data; +}; + +struct _Il2CppMonoGenericContainer +{ + int type_argc : 29; +}; + +struct _Il2CppCattrNamedArg +{ + Il2CppMonoType *type; + Il2CppMonoClassField *field; + Il2CppMonoProperty *prop; +}; + +struct _Il2CppMonoObject +{ + Il2CppMonoVTable *vtable; + void *synchronization; +}; + +struct _Il2CppMonoException +{ + Il2CppMonoObject object; +}; + +struct _Il2CppMonoGenericContext { + Il2CppMonoGenericInst *class_inst; + Il2CppMonoGenericInst *method_inst; +}; + +struct _Il2CppMonoMethodInflated +{ + Il2CppMonoMethod *declaring; + Il2CppMonoGenericContext context; +}; + +struct _Il2CppMonoDefaults +{ + Il2CppMonoImage *corlib; + Il2CppMonoClass *object_class; + Il2CppMonoClass *string_class; + Il2CppMonoClass *void_class; + Il2CppMonoClass *exception_class; + Il2CppMonoClass *runtimetype_class; + Il2CppMonoClass *typehandle_class; + Il2CppMonoClass *fieldhandle_class; + Il2CppMonoClass *methodhandle_class; +}; + +struct _Il2CppMonoStackFrameInfo +{ + MonoStackFrameType type; + MonoJitInfo *ji; + Il2CppMonoMethod *method; + Il2CppMonoMethod *actual_method; + Il2CppMonoDomain *domain; + gboolean managed; + gboolean async_context; + int native_offset; + int il_offset; + gpointer interp_exit_data; + gpointer interp_frame; + gpointer lmf; + guint32 unwind_info_len; + guint8 *unwind_info; + mgreg_t **reg_locations; +}; + +struct _Il2CppMonoCustomAttrEntry +{ + Il2CppMonoMethod *ctor; + uint32_t data_size; + const mono_byte* data; +}; + +struct _Il2CppMonoCustomAttrInfo +{ + int num_attrs; + Il2CppMonoCustomAttrEntry attrs [MONO_ZERO_LEN_ARRAY]; +}; + +struct _Il2CppMonoReflectionType +{ + Il2CppMonoType *type; +}; + +struct _Il2CppMonoInternalThread +{ + Il2CppMonoObject obj; + int lock_thread_id; + void* handle; + void* native_handle; + Il2CppMonoArray* cached_culture_info; + uint16_t* name; + int name_len; + uint32_t state; + Il2CppMonoObject* abort_exc; + int abort_state_handle; + uint64_t tid; + intptr_t debugger_thread; + void** static_data; + void* runtime_thread_info; + Il2CppMonoObject* current_appcontext; + Il2CppMonoObject* root_domain_thread; + Il2CppMonoArray* _serialized_principal; + int _serialized_principal_version; + void* appdomain_refs; + int32_t interruption_requested; + void* synch_cs; + uint8_t threadpool_thread; + uint8_t thread_interrupt_requested; + int stack_size; + uint8_t apartment_state; + int critical_region_level; + int managed_id; + uint32_t small_id; + void* manage_callback; + void* interrupt_on_stop; + void* flags; + void* thread_pinning_ref; + void* abort_protected_block_count; + int32_t priority; + void* owned_mutexes; + void * suspended; + int32_t self_suspended; + size_t thread_state; + size_t unused2; + void* last; +}; + +struct _Il2CppMonoThread +{ + Il2CppMonoInternalThread *internal_thread; +}; + +typedef gboolean (*Il2CppMonoInternalStackWalk) (Il2CppMonoStackFrameInfo *frame, MonoContext *ctx, gpointer data); + +struct _Il2CppMonoRuntimeExceptionHandlingCallbacks +{ + void (*il2cpp_mono_walk_stack_with_state) (Il2CppMonoInternalStackWalk func, MonoThreadUnwindState *state, MonoUnwindOptions options, void *user_data); +}; + + +struct _Il2CppMonoArray +{ + Il2CppMonoObject obj; + MonoArrayBounds *bounds; + mono_array_size_t max_length; + double vector [MONO_ZERO_LEN_ARRAY]; +}; + +struct _Il2CppMonoMarshalByRefObject +{ + Il2CppMonoObject obj; +}; + +struct _Il2CppMonoMethodHeader +{ + const unsigned char *code; + guint32 code_size; + guint16 num_locals; + Il2CppMonoExceptionClause *clauses; + unsigned int num_clauses : 15; + Il2CppMonoType *locals [MONO_ZERO_LEN_ARRAY]; +}; + +struct _Il2CppMonoVTable +{ + Il2CppMonoClass *klass; + Il2CppMonoDomain *domain; + guint8 initialized; + gpointer type; + guint init_failed : 1; +}; + +struct _Il2CppMonoProperty +{ + const char *name; + Il2CppMonoMethod *get; + Il2CppMonoMethod *set; + guint32 attrs; +}; + +struct _Il2CppMonoAppDomain +{ + Il2CppMonoMarshalByRefObject mbr; +}; + +struct _Il2CppMonoAssemblyName +{ + const char *name; + const char *culture; + mono_byte public_key_token [IL2CPP_MONO_PUBLIC_KEY_TOKEN_LENGTH]; + uint32_t flags; + uint16_t major, minor, build, revision; +}; + +struct _Il2CppMonoAssembly +{ + Il2CppMonoAssemblyNameReplacement aname; + Il2CppMonoImage *image; +}; + +struct _Il2CppMonoDomain +{ + gpointer runtime_info; + guint32 state; + char *friendly_name; + mono_mutex_t assemblies_lock; + GSList *domain_assemblies; + Il2CppMonoAssembly *entry_assembly; + Il2CppMonoAppDomain *domain; +}; + +struct _Il2CppMonoImage +{ + Il2CppMonoAssembly *assembly; + char *name; + const char *module_name; + guint8 dynamic : 1; +}; + +struct _Il2CppMonoMethodSignature +{ + Il2CppMonoType *ret; + guint16 param_count; + unsigned int generic_param_count : 16; + unsigned int call_convention : 6; + unsigned int hasthis : 1; + Il2CppMonoType **params; +}; + +struct _Il2CppMonoMethod +{ + Il2CppMonoClass *klass; + const char *name; + guint16 flags; + guint16 iflags; + guint32 token; + unsigned int wrapper_type:5; + unsigned int is_inflated:1; + unsigned int is_generic:1; +}; + +struct _Il2CppMonoClassField +{ + Il2CppMonoType *type; + int offset; + const char *name; + Il2CppMonoClass *parent; +}; + +struct _Il2CppMonoGenericInst +{ + guint type_argc : 22; + guint is_open : 1; + Il2CppMonoType *type_argv [MONO_ZERO_LEN_ARRAY]; +}; + + +struct _Il2CppMonoGenericClass +{ + Il2CppMonoGenericContext context; + Il2CppMonoClass *container_class; +}; + +struct _Il2CppMonoType +{ + union { + Il2CppMonoClass *klass; + Il2CppMonoType *type; + Il2CppMonoArrayType *array; + Il2CppMonoMethodSignature *method; + Il2CppMonoGenericParam *generic_param; + Il2CppMonoGenericClass *generic_class; + } data; + unsigned int attrs : 16; + MonoTypeEnum type : 8; + unsigned int byref : 1; +}; + +struct _Il2CppMonoClass +{ + const char *name; + Il2CppMonoType byval_arg; + Il2CppMonoImage *image; + guint valuetype : 1; + guint enumtype : 1; + guint16 interface_count; + Il2CppMonoClass **interfaces; + const char *name_space; + Il2CppMonoClass *parent; + guint8 rank; + guint32 type_token; + Il2CppMonoClass *element_class; + Il2CppMonoMethod **vtable; + Il2CppMonoType this_arg; +}; + +struct _Il2CppMonoTypeNameParse +{ + Il2CppMonoAssemblyNameReplacement assembly; + void *il2cppTypeNameParseInfo; +}; + +typedef enum +{ + kMethodVariableKindC_This, + kMethodVariableKindC_Parameter, + kMethodVariableKindC_LocalVariable +} MethodVariableKindC; + +typedef enum +{ + kSequencePointKindC_Normal, + kSequencePointKindC_StepOut +} SequencePointKindC; + +typedef struct +{ + const Il2CppMonoType* const* const type; + const char* const name; + const MethodVariableKindC variableKind; +} Il2CppMethodExecutionContextInfoC; + +typedef struct +{ + const Il2CppMethodExecutionContextInfoC* const executionContextInfos; + const uint32_t executionContextInfoCount; + const Il2CppMonoMethod* method; + const char* const sourceFile; + const uint8_t sourceFileHash[16]; + const int32_t lineStart, lineEnd; + const int32_t columnStart, columnEnd; + const int32_t ilOffset; + const SequencePointKindC kind; + uint8_t isActive; + uint64_t id; +} Il2CppSequencePointC; + +typedef struct +{ + void** values; +} Il2CppSequencePointExecutionContextC; + +typedef struct Il2CppThreadUnwindState +{ + Il2CppSequencePointC** sequencePoints; + Il2CppSequencePointExecutionContextC** executionContexts; + uint32_t frameCount; +} Il2CppThreadUnwindState; + +TYPED_HANDLE_DECL (Il2CppMonoObject); +TYPED_HANDLE_DECL (Il2CppMonoReflectionAssembly); +Il2CppMonoDefaults il2cpp_mono_defaults; +MonoDebugOptions il2cpp_mono_debug_options; + +typedef void (*Il2CppMonoProfileFunc) (Il2CppMonoProfiler *prof); +typedef void (*Il2CppMonoProfileAppDomainFunc) (Il2CppMonoProfiler *prof, Il2CppMonoDomain *domain); +typedef void (*Il2CppMonoProfileAppDomainResult) (Il2CppMonoProfiler *prof, Il2CppMonoDomain *domain, int result); +typedef void (*Il2CppMonoProfileAssemblyFunc) (Il2CppMonoProfiler *prof, Il2CppMonoAssembly *assembly); +typedef void (*Il2CppMonoProfileJitResult) (Il2CppMonoProfiler *prof, Il2CppMonoMethod *method, MonoJitInfo* jinfo, int result); +typedef void (*Il2CppMonoProfileAssemblyResult) (Il2CppMonoProfiler *prof, Il2CppMonoAssembly *assembly, int result); +typedef void (*Il2CppMonoProfileThreadFunc) (Il2CppMonoProfiler *prof, uintptr_t tid); +typedef gboolean (*Il2CppMonoJitStackWalk) (Il2CppMonoStackFrameInfo *frame, MonoContext *ctx, gpointer data); +typedef void (*Il2CppMonoDomainFunc) (Il2CppMonoDomain *domain, void* user_data); + +typedef void (*emit_assembly_load_callback)(void*, void*); +typedef void(*emit_type_load_callback)(void*, void*, void*); + +void il2cpp_set_thread_state_background(Il2CppMonoThread* thread); +void* il2cpp_domain_get_agent_info(Il2CppMonoAppDomain* domain); +void il2cpp_domain_set_agent_info(Il2CppMonoAppDomain* domain, void* agentInfo); +void il2cpp_start_debugger_thread(); +uintptr_t il2cpp_internal_thread_get_thread_id(Il2CppMonoInternalThread* thread); +void* il2cpp_gc_alloc_fixed(size_t size); +void il2cpp_gc_free_fixed(void* address); +char* il2cpp_assembly_get_name(Il2CppMonoAssembly* assembly); +const char* il2cpp_domain_get_name(Il2CppMonoDomain* domain); +int il2cpp_mono_type_get_attrs(Il2CppMonoType* type); + +#endif \ No newline at end of file diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h new file mode 100644 index 000000000000..730dd634ef26 --- /dev/null +++ b/mono/mini/il2cpp-compat.h @@ -0,0 +1,662 @@ +#pragma once + +#include +#if defined(RUNTIME_IL2CPP) +#include "il2cpp-c-types.h" +#include "il2cpp-api.h" +#endif // RUNTIME_IL2CPP +#include +#include +#include + +#ifdef IL2CPP_MONO_DEBUGGER + +#define THREAD_STATIC_FIELD_OFFSET -1 + +#define VM_THREAD_GET_INTERNAL(thread) il2cpp_mono_thread_get_internal(thread) +#define VM_INTERNAL_THREAD_SET_STATE_BACKGROUND(internal_thread) il2cpp_internal_thread_set_state_background(internal_thread) +#define VM_INTERNAL_THREAD_SET_FLAG_DONT_MANAGE(thread) +#define VM_INTERNAL_THREAD_GET_ID(internal_thread) il2cpp_internal_thread_get_thread_id(internal_thread) +#define VM_INTERNAL_THREAD_GET_STATE(internal_thread) il2cpp_internal_thread_get_state(internal_thread) +#define VM_INTERNAL_THREAD_GET_THREADPOOL_THREAD(internal_thread) il2cpp_internal_thread_get_threadpool_thread(internal_thread) +#define VM_DOMAIN_GET_AGENT_INFO(domain) il2cpp_domain_get_agent_info(domain) +#define VM_DOMAIN_SET_AGENT_INFO(domain, value) il2cpp_domain_set_agent_info(domain, value) +#define VM_DOMAIN_GET_NAME(domain) il2cpp_domain_get_name(domain) +#define VM_DOMAIN_GET_CORLIB(domain) il2cpp_image_get_assembly(il2cpp_get_corlib()) +#define VM_DOMAIN_GET_ASSEMBLIES(domain, iter) il2cpp_domain_get_assemblies_iter(domain, iter) +#define VM_ASSEMBLY_GET_NAME(assembly) il2cpp_assembly_get_name(assembly) +#define VM_ASSEMBLY_FREE_NAME(name) g_free(name) +#define VM_ASSEMBLY_IS_DYNAMIC(assembly) FALSE +#define VM_ASSEMBLY_GET_IMAGE(assembly) il2cpp_mono_assembly_get_image(assembly) +#define VM_ASSEMBLY_NAME_GET_NAME(assembly) il2cpp_assembly_name_name(assembly) +#define VM_ASSEMBLY_NAME_GET_MAJOR(assembly) il2cpp_assembly_name_major(assembly) +#define VM_ASSEMBLY_NAME_GET_MINOR(assembly) il2cpp_assembly_name_minor(assembly) +#define VM_ASSEMBLY_NAME_GET_BUILD(assembly) il2cpp_assembly_name_build(assembly) +#define VM_ASSEMBLY_NAME_GET_REVISION(assembly) il2cpp_assembly_name_revision(assembly) +#define VM_ASSEMBLY_NAME_GET_CULTURE(assembly) il2cpp_assembly_name_culture(assembly) +#define VM_ASSEMBLY_NAME_GET_PUBLIC_KEY_TOKEN(assembly, i) il2cpp_assembly_name_public_key_token(assembly, i) +#define VM_ASSEMBLY_NAME_GET_PUBLIC_KEY_TOKEN_STRING(assembly) il2cpp_assembly_name_public_key_token_string(assembly) +#define VM_ASSEMBLY_NAME_GET_FLAGS(assembly) il2cpp_assembly_name_flags(assembly) +#define VM_CLASS_GET_TYPE(klass) il2cpp_class_get_type(klass) +#define VM_CLASS_GET_THIS_ARG(klass) il2cpp_class_this_arg(klass) +#define VM_CLASS_GET_ELEMENT_CLASS(klass) il2cpp_class_get_element_class(klass) +#define VM_CLASS_GET_PARENT(klass) il2cpp_class_get_parent(klass) +#define VM_CLASS_GET_IMAGE(klass) il2cpp_class_get_image(klass) +#define VM_CLASS_IS_VALUETYPE(klass) il2cpp_class_is_valuetype(klass) +#define VM_CLASS_IS_INTERFACE(klass) il2cpp_class_is_interface(klass) +#define VM_CLASS_GET_NAME(klass) il2cpp_class_get_name(klass) +#define VM_CLASS_GET_INTERFACES(klass, iter) il2cpp_class_get_interfaces(klass, iter) +#define VM_CLASS_GET_ENUMTYPE(klass) il2cpp_class_get_enumtype(klass) +#define VM_METHOD_GET_WRAPPER_TYPE(method) FALSE +#define VM_METHOD_GET_DECLARING_TYPE(method) il2cpp_method_get_declaring_type(method) +#define VM_METHOD_GET_FLAGS(method) il2cpp_method_get_flags_no_iflags(method) +#define VM_METHOD_GET_NAME(method) il2cpp_method_get_name(method) +#define VM_METHOD_IS_GENERIC(method) il2cpp_method_is_generic(method) +#define VM_METHOD_IS_INFLATED(method) il2cpp_method_is_inflated(method) +#define VM_METHOD_IS_STRING_CTOR(method) il2cpp_method_is_string_ctor(method) +#define VM_INFLATED_METHOD_GET_DECLARING(imethod) il2cpp_method_get_generic_definition(imethod) +#define VM_INFLATED_METHOD_GET_CLASS_INST(imethod) il2cpp_method_get_generic_class_inst(imethod) +#define VM_FIELD_GET_NAME(field) il2cpp_mono_field_get_name(field) +#define VM_FIELD_GET_PARENT(field) il2cpp_field_get_parent(field) +#define VM_FIELD_GET_TYPE(field) il2cpp_field_get_type(field) +#define VM_FIELD_GET_ADDRESS(obj, field) il2cpp_field_get_address(obj, field) +#define VM_FIELD_IS_DELETED(field) il2cpp_field_is_deleted(field) +#define VM_FIELD_GET_OFFSET(field) il2cpp_field_get_offset(field) +#define VM_TYPE_GET_ATTRS(type) il2cpp_mono_type_get_attrs(type) +#define VM_TYPE_GET_TYPE(type) il2cpp_type_get_type(type) +#define VM_TYPE_IS_BYREF(type) il2cpp_type_is_byref(type) +#define VM_TYPE_GET_GENERIC_CLASS(type) il2cpp_type_get_generic_class(type) +#define VM_OBJECT_GET_DOMAIN(object) il2cpp_mono_domain_get() +#define VM_OBJECT_GET_CLASS(object) il2cpp_object_get_class(object) +#define VM_OBJECT_GET_TYPE(object) il2cpp_mono_object_get_type(object) +#define VM_GENERIC_CLASS_GET_INST(gklass) il2cpp_generic_class_get_inst(gklass) +#define VM_GENERIC_CLASS_GET_CONTAINER_CLASS(gklass) il2cpp_generic_class_get_container_class(gklass) +#define VM_GENERIC_CONTAINER_GET_TYPE_ARGC(container) il2cpp_generic_container_get_type_argc(container) +#define VM_GENERIC_INST_TYPE_ARGC(inst) il2cpp_generic_inst_type_argc(inst) +#define VM_GENERIC_INST_TYPE_ARG(inst, i) il2cpp_generic_inst_type_arg(inst, i) +#define VM_DEFAULTS_OBJECT_CLASS il2cpp_defaults_object_class() +#define VM_DEFAULTS_EXCEPTION_CLASS il2cpp_defaults_exception_class() +#define VM_DEFAULTS_CORLIB_IMAGE il2cpp_defaults_corlib_image() +#define VM_DEFAULTS_VOID_CLASS il2cpp_defaults_void_class() +#define VM_ARRAY_GET_RANK(arr) il2cpp_array_rank(arr) +#define VM_ARRAY_BOUND_LENGTH(arr, i) il2cpp_array_bound_length(arr, i) +#define VM_ARRAY_BOUND_LOWER_BOUND(arr, i) il2cpp_array_bound_lower_bound(arr, i) +#define VM_IMAGE_GET_NAME(image) il2cpp_image_name(image) +#define VM_IMAGE_GET_MODULE_NAME(image) il2cpp_image_name(image) +#define VM_IMAGE_GET_ASSEMBLY(image) il2cpp_image_assembly(image) +#define VM_PROPERTY_GET_NAME(prop) il2cpp_property_get_name(prop) +#define VM_PROPERTY_GET_GET_METHOD(prop) il2cpp_property_get_get_method(prop) +#define VM_PROPERTY_GET_SET_METHOD(prop) il2cpp_property_get_set_method(prop) +#define VM_PROPERTY_GET_ATTRS(prop) il2cpp_property_get_flags(prop) +#else +#define VM_THREAD_GET_INTERNAL(thread) thread->internal_thread +#define VM_INTERNAL_THREAD_SET_STATE_BACKGROUND(internal_thread) internal_thread->state |= ThreadState_Background +#define VM_INTERNAL_THREAD_SET_FLAG_DONT_MANAGE(internal_thread) internal_thread->flags |= MONO_THREAD_FLAG_DONT_MANAGE +#define VM_INTERNAL_THREAD_GET_ID(internal_thread) internal_thread->tid +#define VM_INTERNAL_THREAD_GET_STATE(internal_thread) internal_thread->state +#define VM_INTERNAL_THREAD_GET_THREADPOOL_THREAD(internal_thread) internal_thread->threadpool_thread +#define VM_DOMAIN_GET_AGENT_INFO(domain) domain_jit_info (domain)->agent_info +#define VM_DOMAIN_SET_AGENT_INFO(domain, value) domain_jit_info (domain)->agent_info = value +#define VM_DOMAIN_GET_NAME(domain) domain->friendly_name +#define VM_DOMAIN_GET_CORLIB(domain) domain->domain->mbr.obj.vtable->klass->image->assembly +#define VM_DOMAIN_GET_ASSEMBLIES(domain, iter) mono_domain_get_assemblies_iter(domain, iter) +#define VM_ASSEMBLY_GET_NAME(assembly) assembly->aname.name +#define VM_ASSEMBLY_FREE_NAME(name) +#define VM_ASSEMBLY_IS_DYNAMIC(assembly) assembly->image->dynamic +#define VM_ASSEMBLY_GET_IMAGE(assembly) assembly->image +#define VM_ASSEMBLY_NAME_GET_NAME(assembly) (assembly)->aname.name +#define VM_ASSEMBLY_NAME_GET_MAJOR(assembly) (assembly)->aname.major +#define VM_ASSEMBLY_NAME_GET_MINOR(assembly) (assembly)->aname.minor +#define VM_ASSEMBLY_NAME_GET_BUILD(assembly) (assembly)->aname.build +#define VM_ASSEMBLY_NAME_GET_REVISION(assembly) (assembly)->aname.revision +#define VM_ASSEMBLY_NAME_GET_CULTURE(assembly) (assembly)->aname.culture +#define VM_ASSEMBLY_NAME_GET_PUBLIC_KEY_TOKEN(assembly, i) (assembly)->aname.public_key_token[i] +#define VM_ASSEMBLY_NAME_GET_PUBLIC_KEY_TOKEN_STRING(assembly) (char*)(assembly)->aname.public_key_token +#define VM_ASSEMBLY_NAME_GET_FLAGS(assembly) (assembly)->aname.flags +#define VM_CLASS_GET_TYPE(klass) &(klass)->byval_arg +#define VM_CLASS_GET_THIS_ARG(klass) &(klass)->this_arg +#define VM_CLASS_GET_PARENT(klass) (klass)->parent +#define VM_CLASS_GET_IMAGE(klass) (klass)->image +#define VM_CLASS_IS_VALUETYPE(klass) klass->valuetype +#define VM_CLASS_IS_INTERFACE(klass) MONO_CLASS_IS_INTERFACE(klass) +#define VM_CLASS_GET_NAME(klass) (klass)->name +#define VM_CLASS_GET_INTERFACES(klass, iter) mono_class_get_interfaces(klass, iter) +#define VM_CLASS_GET_ENUMTYPE(klass) (klass)->enumtype +#define VM_METHOD_GET_WRAPPER_TYPE(method) method->wrapper_type +#define VM_METHOD_GET_DECLARING_TYPE(method) (method)->klass +#define VM_METHOD_GET_FLAGS(method) (method)->flags +#define VM_METHOD_GET_NAME(method) (method)->name +#define VM_METHOD_IS_GENERIC(method) method->is_generic +#define VM_METHOD_IS_INFLATED(method) method->is_inflated +#define VM_METHOD_IS_STRING_CTOR(method) method->string_ctor +#define VM_INFLATED_METHOD_GET_DECLARING(imethod) (imethod)->declaring +#define VM_INFLATED_METHOD_GET_CLASS_INST(imethod) (imethod)->context.class_inst +#define VM_FIELD_GET_NAME(field) field->name +#define VM_FIELD_GET_PARENT(field) (field)->parent +#define VM_FIELD_GET_TYPE(field) (field)->type +#define VM_FIELD_GET_ADDRESS(obj, field) (guint8*)(obj) + (f)->offset +#define VM_FIELD_IS_DELETED(field) mono_field_is_deleted(field) +#define VM_FIELD_GET_OFFSET(field) (field)->offset +#define VM_TYPE_GET_ATTRS(type) type->attrs +#define VM_TYPE_GET_TYPE(typeparam) (typeparam)->type +#define VM_TYPE_IS_BYREF(type) (type)->byref +#define VM_TYPE_GET_GENERIC_CLASS(type) (type)->data.generic_class +#define VM_OBJECT_GET_DOMAIN(object) ((MonoObject*)object)->vtable->domain +#define VM_OBJECT_GET_CLASS(object) ((MonoObject*)object)->vtable->klass +#define VM_OBJECT_GET_TYPE(object) ((MonoReflectionType*)object->vtable->type)->type +#define VM_GENERIC_CONTAINER_GET_TYPE_ARGC(container) container->type_argc +#define VM_GENERIC_CLASS_GET_INST(gklass) (gklass)->context.class_inst +#define VM_GENERIC_CLASS_GET_CONTAINER_CLASS(gklass) (gklass)->container_class +#define VM_GENERIC_INST_TYPE_ARGC(inst) (inst)->type_argc +#define VM_GENERIC_INST_TYPE_ARG(inst, i) (inst)->type_argv[i] +#define VM_DEFAULTS_OBJECT_CLASS mono_defaults.object_class +#define VM_DEFAULTS_EXCEPTION_CLASS mono_defaults.exception_class +#define VM_DEFAULTS_CORLIB_IMAGE mono_defaults.corlib +#define VM_DEFAULTS_VOID_CLASS mono_defaults.void_class +#define VM_ARRAY_GET_RANK(arr) (arr)->obj.vtable->klass->rank +#define VM_CLASS_GET_ELEMENT_CLASS(klass) (klass)->element_class +#define VM_ARRAY_BOUND_LENGTH(arr, i) arr->bounds[i].length +#define VM_ARRAY_BOUND_LOWER_BOUND(arr, i) arr->bounds[i].lower_bound +#define VM_IMAGE_GET_NAME(image) (image)->name +#define VM_IMAGE_GET_MODULE_NAME(image) (image)->module_name +#define VM_IMAGE_GET_ASSEMBLY(image) (image)->assembly +#define VM_PROPERTY_GET_NAME(prop) (prop)->name +#define VM_PROPERTY_GET_GET_METHOD(prop) (prop)->get +#define VM_PROPERTY_GET_SET_METHOD(prop) (prop)->set +#define VM_PROPERTY_GET_ATTRS(prop) (prop)->attrs +#endif + +#if defined(RUNTIME_IL2CPP) + +#define MonoType Il2CppMonoType +#define MonoClass Il2CppMonoClass +#define MonoMethodHeader Il2CppMonoMethodHeader +#define MonoVTable Il2CppMonoVTable +#define MonoAssembly Il2CppMonoAssembly +#define MonoProperty Il2CppMonoProperty +#define MonoString Il2CppMonoString +#define MonoAppDomain Il2CppMonoAppDomain +#define MonoDomain Il2CppMonoDomain +#define MonoImage Il2CppMonoImage +#define MonoMethodSignature Il2CppMonoMethodSignature +#define MonoMethod Il2CppMonoMethod +#define MonoClassField Il2CppMonoClassField +#define MonoArrayType Il2CppMonoArrayType +#define MonoGenericParam Il2CppMonoGenericParam +#define MonoGenericInst Il2CppMonoGenericInst +#define MonoGenericContext Il2CppMonoGenericContext +#define MonoGenericClass Il2CppMonoGenericClass +#define MonoAssemblyName Il2CppMonoAssemblyNameReplacement +#define MonoMarshalByRefObject Il2CppMonoMarshalByRefObject +#define MonoObject Il2CppMonoObject +#define MonoArray Il2CppMonoArray +#define MonoCustomAttrInfo Il2CppMonoCustomAttrInfo +#define MonoThread Il2CppMonoThread +#define MonoInternalThread Il2CppMonoInternalThread +#define MonoGHashTable Il2CppMonoGHashTable +#define MonoGenericContainer Il2CppMonoGenericContainer +#define MonoReflectionAssemblyHandle Il2CppMonoReflectionAssemblyHandle +#define MonoReflectionType Il2CppMonoReflectionType +#define MonoProfiler Il2CppMonoProfiler +#define MonoJitTlsData Il2CppMonoJitTlsData +#define MonoRuntimeExceptionHandlingCallbacks Il2CppMonoRuntimeExceptionHandlingCallbacks +#define MonoCustomAttrEntry Il2CppMonoCustomAttrEntry +#define StackFrameInfo Il2CppMonoStackFrameInfo +#define MonoMethodInflated Il2CppMonoMethodInflated +#define MonoException Il2CppMonoException +#define CattrNamedArg Il2CppCattrNamedArg +#define MonoExceptionClause Il2CppMonoExceptionClause +#define debug_options il2cpp_mono_debug_options +#define MonoTypeNameParse Il2CppMonoTypeNameParse + +#define mono_image_get_entry_point il2cpp_mono_image_get_entry_point +#define mono_image_get_filename il2cpp_mono_image_get_filename +#define mono_image_get_guid il2cpp_mono_image_get_guid +#define mono_type_get_class il2cpp_mono_type_get_class +#define mono_type_is_struct il2cpp_mono_type_is_struct +#define mono_type_is_reference il2cpp_mono_type_is_reference +#define mono_metadata_free_mh il2cpp_mono_metadata_free_mh +#define mono_method_signature il2cpp_mono_method_signature +#define mono_method_get_param_names il2cpp_mono_method_get_param_names +#define mono_type_generic_inst_is_valuetype il2cpp_mono_type_generic_inst_is_valuetype +#define mono_method_get_header_checked il2cpp_mono_method_get_header_checked +#define mono_class_init il2cpp_mono_class_init +#define mono_class_vtable il2cpp_mono_class_vtable +#define mono_class_get_field_from_name il2cpp_mono_class_get_field_from_name +#define mono_array_element_size il2cpp_mono_array_element_size +#define mono_class_instance_size il2cpp_mono_class_instance_size +#define mono_class_value_size il2cpp_mono_class_value_size +#define mono_class_is_assignable_from il2cpp_mono_class_is_assignable_from +#define mono_class_from_mono_type il2cpp_mono_class_from_mono_type +#define mono_class_get_flags il2cpp_class_get_flags +#define mono_class_num_fields il2cpp_mono_class_num_fields +#define mono_class_num_methods il2cpp_mono_class_num_methods +#define mono_class_num_properties il2cpp_mono_class_num_properties +#define mono_class_get_fields il2cpp_mono_class_get_fields +#define mono_class_get_methods il2cpp_mono_class_get_methods +#define mono_class_get_properties il2cpp_mono_class_get_properties +#define mono_class_get_nested_types il2cpp_class_get_nested_types_accepts_generic +#define mono_field_get_name il2cpp_mono_field_get_name +#define mono_class_get_method_from_name il2cpp_class_get_method_from_name +#define mono_string_chars il2cpp_mono_string_chars +#define mono_class_is_abstract il2cpp_class_is_abstract +#define mono_string_length il2cpp_mono_string_length +#define mono_array_addr_with_size il2cpp_mono_array_addr_with_size +#define mono_array_length il2cpp_mono_array_length +#define mono_string_new il2cpp_mono_string_new +#define mono_string_new_checked il2cpp_mono_string_new_checked +#define mono_string_to_utf8_checked il2cpp_mono_string_to_utf8_checked +#define mono_object_hash il2cpp_mono_object_hash +#define mono_object_unbox il2cpp_mono_object_unbox +#define mono_object_get_virtual_method il2cpp_object_get_virtual_method +#define mono_field_set_value il2cpp_mono_field_set_value +#define mono_field_static_set_value il2cpp_mono_field_static_set_value +#define mono_gchandle_new_weakref il2cpp_mono_gchandle_new_weakref +#define mono_gchandle_get_target il2cpp_mono_gchandle_get_target +#define mono_gchandle_free il2cpp_mono_gchandle_free +#define mono_gc_wbarrier_generic_store il2cpp_mono_gc_wbarrier_generic_store +#define mono_reflection_parse_type_checked il2cpp_mono_reflection_parse_type_checked +#define mono_reflection_free_type_info il2cpp_mono_reflection_free_type_info +#define mono_custom_attrs_has_attr il2cpp_mono_custom_attrs_has_attr +#define mono_custom_attrs_free il2cpp_mono_custom_attrs_free +#define mono_get_root_domain il2cpp_mono_get_root_domain +#define mono_runtime_quit il2cpp_mono_runtime_quit +#define mono_runtime_is_shutting_down il2cpp_mono_runtime_is_shutting_down +#define mono_domain_get il2cpp_mono_domain_get +#define mono_domain_set il2cpp_mono_domain_set +#define mono_domain_foreach il2cpp_mono_domain_foreach +#define mono_jit_info_table_find il2cpp_mono_jit_info_table_find +#define mono_jit_info_get_method il2cpp_mono_jit_info_get_method +#define mono_debug_lookup_method il2cpp_mono_debug_lookup_method +#define mono_debug_find_method il2cpp_mono_debug_find_method +#define mono_debug_free_method_jit_info il2cpp_mono_debug_free_method_jit_info +#define mono_debug_lookup_locals il2cpp_mono_debug_lookup_locals +#define mono_debug_lookup_method_async_debug_info il2cpp_mono_debug_lookup_method_async_debug_info +#define mono_debug_method_lookup_location il2cpp_mono_debug_method_lookup_location +#define mono_debug_il_offset_from_address il2cpp_mono_debug_il_offset_from_address +#define mono_debug_free_source_location il2cpp_mono_debug_free_source_location +#define mono_set_is_debugger_attached il2cpp_mono_set_is_debugger_attached +#define mono_type_full_name il2cpp_mono_type_full_name +#define mono_method_full_name il2cpp_mono_method_full_name +#define mono_debug_get_seq_points il2cpp_mono_debug_get_seq_points +#define mono_debug_free_locals il2cpp_mono_debug_free_locals +#define mono_debug_free_method_async_debug_info il2cpp_mono_debug_free_method_async_debug_info +#define mono_thread_current il2cpp_mono_thread_current +#define mono_thread_get_main il2cpp_mono_thread_get_main +#define mono_thread_attach il2cpp_mono_thread_attach +#define mono_domain_lock il2cpp_mono_domain_lock +#define mono_domain_unlock il2cpp_mono_domain_unlock +#define mono_jit_info_table_find_internal il2cpp_mono_jit_info_table_find_internal +#define mono_aligned_addr_hash il2cpp_mono_aligned_addr_hash +#define mono_metadata_get_generic_inst il2cpp_mono_metadata_get_generic_inst +#define mono_get_method_checked il2cpp_mono_get_method_checked +#define mono_class_interface_offset_with_variance il2cpp_mono_class_interface_offset_with_variance +#define mono_class_setup_supertypes il2cpp_mono_class_setup_supertypes +#define mono_class_setup_vtable il2cpp_mono_class_setup_vtable +#define mono_class_setup_methods il2cpp_mono_class_setup_methods +#define mono_class_field_is_special_static il2cpp_mono_class_field_is_special_static +#define mono_class_field_get_special_static_type il2cpp_mono_class_field_get_special_static_type +#define mono_class_get_context il2cpp_mono_class_get_context +#define mono_method_get_context il2cpp_mono_method_get_context +#define mono_method_get_generic_container il2cpp_mono_method_get_generic_container +#define mono_class_inflate_generic_method_full_checked il2cpp_mono_class_inflate_generic_method_full_checked +#define mono_class_inflate_generic_method_checked il2cpp_mono_class_inflate_generic_method_checked +#define mono_loader_lock il2cpp_mono_loader_lock +#define mono_loader_unlock il2cpp_mono_loader_unlock +#define mono_loader_lock_track_ownership il2cpp_mono_loader_lock_track_ownership +#define mono_loader_lock_is_owned_by_self il2cpp_mono_loader_lock_is_owned_by_self +#define mono_method_get_wrapper_data il2cpp_mono_method_get_wrapper_data +#define mono_type_get_name_full il2cpp_mono_type_get_name_full +#define mono_class_is_nullable il2cpp_mono_class_is_nullable +#define mono_class_get_generic_container il2cpp_mono_class_get_generic_container +#define mono_class_setup_interfaces il2cpp_mono_class_setup_interfaces +#define mono_class_get_methods_by_name il2cpp_mono_class_get_methods_by_name +#define mono_ldtoken_checked il2cpp_mono_ldtoken_checked +#define mono_class_from_generic_parameter_internal il2cpp_mono_class_from_generic_parameter_internal +#define mono_class_load_from_name il2cpp_mono_class_load_from_name +#define mono_class_try_load_from_name il2cpp_class_from_name +#define mono_class_get_generic_class il2cpp_mono_class_get_generic_class +#define mono_thread_internal_current il2cpp_mono_thread_internal_current +#define mono_thread_internal_is_current il2cpp_mono_thread_internal_is_current +#define mono_thread_internal_abort il2cpp_mono_thread_internal_abort +#define mono_thread_internal_reset_abort il2cpp_mono_thread_internal_reset_abort +#define mono_thread_get_name il2cpp_mono_thread_get_name +#define mono_thread_set_name_internal il2cpp_mono_thread_set_name_internal +#define mono_thread_suspend_all_other_threads il2cpp_mono_thread_suspend_all_other_threads +#define mono_stack_mark_record_size il2cpp_mono_stack_mark_record_size +#define mono_get_eh_callbacks il2cpp_mono_get_eh_callbacks +#define mono_reflection_create_custom_attr_data_args il2cpp_mono_reflection_create_custom_attr_data_args +#define mono_nullable_init il2cpp_mono_nullable_init +#define mono_value_box_checked il2cpp_mono_value_box_checked +#define mono_field_static_get_value_checked il2cpp_mono_field_static_get_value_checked +#define mono_field_static_get_value_for_thread il2cpp_mono_field_static_get_value_for_thread +#define mono_field_get_value_object_checked il2cpp_mono_field_get_value_object_checked +#define mono_object_new_checked il2cpp_mono_object_new_checked +#define mono_ldstr_checked il2cpp_mono_ldstr_checked +#define mono_runtime_try_invoke il2cpp_mono_runtime_try_invoke +#define mono_runtime_invoke_checked il2cpp_mono_runtime_invoke_checked +#define mono_gc_base_init il2cpp_mono_gc_base_init +#define mono_gc_register_root il2cpp_mono_gc_register_root +#define mono_gc_deregister_root il2cpp_mono_gc_deregister_root +#define mono_environment_exitcode_get il2cpp_mono_environment_exitcode_get +#define mono_environment_exitcode_set il2cpp_mono_environment_exitcode_set +#define mono_threadpool_suspend il2cpp_mono_threadpool_suspend +#define mono_threadpool_resume il2cpp_mono_threadpool_resume +#define mono_assembly_get_image il2cpp_mono_assembly_get_image +#define mono_runtime_try_shutdown il2cpp_mono_runtime_try_shutdown +#define mono_verifier_is_method_valid_generic_instantiation il2cpp_mono_verifier_is_method_valid_generic_instantiation +#define mono_reflection_get_type_checked il2cpp_mono_reflection_get_type_checked +#define mono_custom_attrs_from_method_checked il2cpp_mono_custom_attrs_from_method_checked +#define mono_custom_attrs_from_class_checked il2cpp_mono_custom_attrs_from_class_checked +#define mono_custom_attrs_from_property_checked il2cpp_mono_custom_attrs_from_property_checked +#define mono_custom_attrs_from_field_checked il2cpp_mono_custom_attrs_from_field_checked +#define mono_assembly_get_object_handle il2cpp_mono_assembly_get_object_handle +#define mono_type_get_object_checked il2cpp_mono_type_get_object_checked +#define mono_network_init il2cpp_mono_network_init +#define mono_w32socket_set_blocking il2cpp_mono_w32socket_set_blocking + +#define mono_get_runtime_build_info il2cpp_mono_get_runtime_build_info +#define mono_marshal_method_from_wrapper il2cpp_mono_marshal_method_from_wrapper +#define mini_get_debug_options il2cpp_mini_get_debug_options +#define mono_jit_find_compiled_method_with_jit_info il2cpp_mono_jit_find_compiled_method_with_jit_info +#define mono_get_lmf_addr il2cpp_mono_get_lmf_addr +#define mono_set_lmf il2cpp_mono_set_lmf +#define mono_aot_get_method_checked il2cpp_mono_aot_get_method_checked +#define mono_arch_setup_resume_sighandler_ctx il2cpp_mono_arch_setup_resume_sighandler_ctx +#define mono_arch_set_breakpoint il2cpp_mono_arch_set_breakpoint +#define mono_arch_clear_breakpoint il2cpp_mono_arch_clear_breakpoint +#define mono_arch_start_single_stepping il2cpp_mono_arch_start_single_stepping +#define mono_arch_stop_single_stepping il2cpp_mono_arch_stop_single_stepping +#define mono_arch_skip_breakpoint il2cpp_mono_arch_skip_breakpoint +#define mono_arch_skip_single_step il2cpp_mono_arch_skip_single_step +#define mono_arch_init_lmf_ext il2cpp_mono_arch_init_lmf_ext +#define mono_arch_context_get_int_reg il2cpp_mono_arch_context_get_int_reg +#define mono_arch_context_set_int_reg il2cpp_mono_arch_context_set_int_reg +#define mono_walk_stack_with_ctx il2cpp_mono_walk_stack_with_ctx +#define mono_walk_stack_with_state il2cpp_mono_walk_stack_with_state +#define mono_thread_state_init_from_current il2cpp_mono_thread_state_init_from_current +#define mono_thread_state_init_from_monoctx il2cpp_mono_thread_state_init_from_monoctx +#define mini_jit_info_table_find il2cpp_mini_jit_info_table_find +#define mono_restore_context il2cpp_mono_restore_context +#define mono_find_jit_info_ext il2cpp_mono_find_jit_info_ext +#define mono_method_get_declaring_generic_method il2cpp_mono_method_get_declaring_generic_method +#define jinfo_get_method il2cpp_jinfo_get_method +#define mono_defaults il2cpp_mono_defaults +#define mono_find_prev_seq_point_for_native_offset il2cpp_mono_find_prev_seq_point_for_native_offset +#define mono_w32socket_accept_internal il2cpp_mono_w32socket_accept_internal +#define mono_find_next_seq_point_for_native_offset il2cpp_mono_find_next_seq_point_for_native_offset +#define mono_class_has_parent il2cpp_mono_class_has_parent +#define mono_class_is_gtd il2cpp_class_is_generic +#define mono_class_is_ginst il2cpp_class_is_inflated +#define mono_generic_container_get_param il2cpp_mono_generic_container_get_param +#define mono_find_seq_point il2cpp_mono_find_seq_point +#define mono_seq_point_iterator_init il2cpp_mono_seq_point_iterator_init +#define mono_seq_point_iterator_next il2cpp_mono_seq_point_iterator_next +#define mono_seq_point_init_next il2cpp_mono_seq_point_init_next +#define mono_get_seq_points il2cpp_mono_get_seq_points +#define G_BREAKPOINT IL2CPP_G_BREAKPOINT +#define mono_thread_info_safe_suspend_and_run il2cpp_mono_thread_info_safe_suspend_and_run +#define mono_error_cleanup il2cpp_mono_error_cleanup +#define mono_error_convert_to_exception il2cpp_mono_error_convert_to_exception +#define mono_error_get_message il2cpp_mono_error_get_message +#define mono_error_assert_ok_pos il2cpp_mono_error_assert_ok_pos +#define mono_class_get_namespace il2cpp_class_get_namespace +#define mono_class_get_name il2cpp_class_get_name +#define mono_object_get_class il2cpp_object_get_class +#define mono_field_get_parent il2cpp_field_get_parent +#define mono_class_get_parent il2cpp_class_get_parent +#define mono_field_get_type il2cpp_field_get_type +#define mono_method_get_name il2cpp_method_get_name +#define mono_class_get_type il2cpp_class_get_type +#define mono_method_get_class il2cpp_method_get_class +#define mono_class_get_type il2cpp_class_get_type +#define mono_class_get_image il2cpp_class_get_image +#define mono_image_get_assembly il2cpp_image_get_assembly +#define mono_image_get_name il2cpp_image_get_name +#define mono_type_get_type il2cpp_type_get_type +#define mono_class_get_rank il2cpp_class_get_rank +#define mono_class_get_element_class il2cpp_class_get_element_class +#define mono_class_get_type_token il2cpp_class_get_type_token +#define mono_type_is_byref il2cpp_type_is_byref +#define mono_class_is_enum il2cpp_class_is_enum +#define mono_method_get_flags il2cpp_method_get_flags +#define mono_method_get_token il2cpp_method_get_token +#define mono_method_is_generic il2cpp_method_is_generic +#define mono_method_is_inflated il2cpp_method_is_inflated + +#define mono_domain_assemblies_lock +#define mono_domain_assemblies_unlock + +#define mono_get_string_class il2cpp_mono_get_string_class + +Il2CppMonoMethod* il2cpp_mono_image_get_entry_point (Il2CppMonoImage *image); +const char* il2cpp_mono_image_get_filename (Il2CppMonoImage *image); +const char* il2cpp_mono_image_get_guid (Il2CppMonoImage *image); +Il2CppMonoClass* il2cpp_mono_type_get_class (Il2CppMonoType *type); +mono_bool il2cpp_mono_type_is_struct (Il2CppMonoType *type); +mono_bool il2cpp_mono_type_is_reference (Il2CppMonoType *type); +void il2cpp_mono_metadata_free_mh (Il2CppMonoMethodHeader *mh); +Il2CppMonoMethodSignature* il2cpp_mono_method_signature (Il2CppMonoMethod *m); +void il2cpp_mono_method_get_param_names (Il2CppMonoMethod *method, const char **names); +mono_bool il2cpp_mono_type_generic_inst_is_valuetype (Il2CppMonoType *type); +Il2CppMonoMethodHeader* il2cpp_mono_method_get_header_checked (Il2CppMonoMethod *method, MonoError *error); +gboolean il2cpp_mono_class_init (Il2CppMonoClass *klass); +Il2CppMonoVTable* il2cpp_mono_class_vtable (Il2CppMonoDomain *domain, Il2CppMonoClass *klass); +Il2CppMonoClassField* il2cpp_mono_class_get_field_from_name (Il2CppMonoClass *klass, const char *name); +int32_t il2cpp_mono_array_element_size (Il2CppMonoClass *ac); +int32_t il2cpp_mono_class_instance_size (Il2CppMonoClass *klass); +int32_t il2cpp_mono_class_value_size (Il2CppMonoClass *klass, uint32_t *align); +gboolean il2cpp_mono_class_is_assignable_from (Il2CppMonoClass *klass, Il2CppMonoClass *oklass); +Il2CppMonoClass* il2cpp_mono_class_from_mono_type (Il2CppMonoType *type); +int il2cpp_mono_class_num_fields (Il2CppMonoClass *klass); +int il2cpp_mono_class_num_methods (Il2CppMonoClass *klass); +int il2cpp_mono_class_num_properties (Il2CppMonoClass *klass); +Il2CppMonoClassField* il2cpp_mono_class_get_fields (Il2CppMonoClass* klass, gpointer *iter); +Il2CppMonoMethod* il2cpp_mono_class_get_methods (Il2CppMonoClass* klass, gpointer *iter); +Il2CppMonoProperty* il2cpp_mono_class_get_properties (Il2CppMonoClass* klass, gpointer *iter); +const char* il2cpp_mono_field_get_name (Il2CppMonoClassField *field); +mono_unichar2* il2cpp_mono_string_chars (Il2CppMonoString *s); +int il2cpp_mono_string_length (Il2CppMonoString *s); +char* il2cpp_mono_array_addr_with_size (Il2CppMonoArray *array, int size, uintptr_t idx); +uintptr_t il2cpp_mono_array_length (Il2CppMonoArray *array); +Il2CppMonoString* il2cpp_mono_string_new (Il2CppMonoDomain *domain, const char *text); +Il2CppMonoString* il2cpp_mono_string_new (Il2CppMonoDomain *domain, const char *text); +Il2CppMonoString* il2cpp_mono_string_new_checked (Il2CppMonoDomain *domain, const char *text, MonoError *merror); +char* il2cpp_mono_string_to_utf8_checked (Il2CppMonoString *string_obj, MonoError *error); +int il2cpp_mono_object_hash (Il2CppMonoObject* obj); +void* il2cpp_mono_object_unbox (Il2CppMonoObject *obj); +void il2cpp_mono_field_set_value (Il2CppMonoObject *obj, Il2CppMonoClassField *field, void *value); +void il2cpp_mono_field_static_set_value (Il2CppMonoVTable *vt, Il2CppMonoClassField *field, void *value); +uint32_t il2cpp_mono_gchandle_new_weakref (Il2CppMonoObject *obj, mono_bool track_resurrection); +Il2CppMonoObject* il2cpp_mono_gchandle_get_target (uint32_t gchandle); +void il2cpp_mono_gchandle_free (uint32_t gchandle); +void il2cpp_mono_gc_wbarrier_generic_store (void* ptr, Il2CppMonoObject* value); +int il2cpp_mono_reflection_parse_type_checked (char *name, Il2CppMonoTypeNameParse *info, MonoError *error); +void il2cpp_mono_reflection_free_type_info (Il2CppMonoTypeNameParse *info); +mono_bool il2cpp_mono_custom_attrs_has_attr (Il2CppMonoCustomAttrInfo *ainfo, Il2CppMonoClass *attr_klass); +void il2cpp_mono_custom_attrs_free (Il2CppMonoCustomAttrInfo *ainfo); +Il2CppMonoDomain* il2cpp_mono_get_root_domain (void); +void il2cpp_mono_runtime_quit (void); +gboolean il2cpp_mono_runtime_is_shutting_down (void); +Il2CppMonoDomain* il2cpp_mono_domain_get (void); +gboolean il2cpp_mono_domain_set (Il2CppMonoDomain *domain, gboolean force); +void il2cpp_mono_domain_foreach(Il2CppMonoDomainFunc func, gpointer user_data); +MonoJitInfo* il2cpp_mono_jit_info_table_find(Il2CppMonoDomain* domain, char* addr); +Il2CppMonoMethod* il2cpp_mono_jit_info_get_method(MonoJitInfo* ji); +MonoDebugMethodInfo* il2cpp_mono_debug_lookup_method(Il2CppMonoMethod* method); +MonoDebugMethodJitInfo* il2cpp_mono_debug_find_method(Il2CppMonoMethod* method, Il2CppMonoDomain* domain); +void il2cpp_mono_debug_free_method_jit_info(MonoDebugMethodJitInfo* jit); +MonoDebugLocalsInfo* il2cpp_mono_debug_lookup_locals(Il2CppMonoMethod* method); +MonoDebugMethodAsyncInfo* il2cpp_mono_debug_lookup_method_async_debug_info(Il2CppMonoMethod* method); +MonoDebugSourceLocation* il2cpp_mono_debug_method_lookup_location(MonoDebugMethodInfo* minfo, int il_offset); +gint32 il2cpp_mono_debug_il_offset_from_address(Il2CppMonoMethod* method, Il2CppMonoDomain* domain, guint32 native_offset); +void il2cpp_mono_debug_free_source_location(MonoDebugSourceLocation* location); +void il2cpp_mono_set_is_debugger_attached(gboolean attached); +char* il2cpp_mono_type_full_name(Il2CppMonoType* type); +char* il2cpp_mono_method_full_name(Il2CppMonoMethod* method, gboolean signature); +void il2cpp_mono_debug_get_seq_points(MonoDebugMethodInfo* minfo, char** source_file, GPtrArray** source_file_list, int** source_files, MonoSymSeqPoint** seq_points, int* n_seq_points); +void il2cpp_mono_debug_free_locals(MonoDebugLocalsInfo* info); +void il2cpp_mono_debug_free_method_async_debug_info(MonoDebugMethodAsyncInfo* info); +Il2CppMonoThread* il2cpp_mono_thread_current(); +Il2CppMonoThread* il2cpp_mono_thread_get_main(); +Il2CppMonoThread* il2cpp_mono_thread_attach(Il2CppMonoDomain* domain); +void il2cpp_mono_domain_lock(Il2CppMonoDomain* domain); +void il2cpp_mono_domain_unlock(Il2CppMonoDomain* domain); +MonoJitInfo* il2cpp_mono_jit_info_table_find_internal(Il2CppMonoDomain* domain, char* addr, gboolean try_aot, gboolean allow_trampolines); +guint il2cpp_mono_aligned_addr_hash(gconstpointer ptr); +Il2CppMonoGenericInst* il2cpp_mono_metadata_get_generic_inst(int type_argc, Il2CppMonoType** type_argv); +Il2CppMonoMethod* il2cpp_mono_get_method_checked(Il2CppMonoImage* image, guint32 token, Il2CppMonoClass* klass, Il2CppMonoGenericContext* context, MonoError* error); +int il2cpp_mono_class_interface_offset_with_variance(Il2CppMonoClass* klass, Il2CppMonoClass* itf, gboolean* non_exact_match); +void il2cpp_mono_class_setup_supertypes(Il2CppMonoClass* klass); +void il2cpp_mono_class_setup_vtable(Il2CppMonoClass* klass); +void il2cpp_mono_class_setup_methods(Il2CppMonoClass* klass); +gboolean il2cpp_mono_class_field_is_special_static(Il2CppMonoClassField* field); +guint32 il2cpp_mono_class_field_get_special_static_type(Il2CppMonoClassField* field); +Il2CppMonoGenericContext* il2cpp_mono_class_get_context(Il2CppMonoClass* klass); +Il2CppMonoGenericContext* il2cpp_mono_method_get_context(Il2CppMonoMethod* method); +Il2CppMonoGenericContainer* il2cpp_mono_method_get_generic_container(Il2CppMonoMethod* method); +Il2CppMonoMethod* il2cpp_mono_class_inflate_generic_method_full_checked(Il2CppMonoMethod* method, Il2CppMonoClass* klass_hint, Il2CppMonoGenericContext* context, MonoError* error); +Il2CppMonoMethod* il2cpp_mono_class_inflate_generic_method_checked(Il2CppMonoMethod* method, Il2CppMonoGenericContext* context, MonoError* error); +void il2cpp_mono_loader_lock(); +void il2cpp_mono_loader_unlock(); +void il2cpp_mono_loader_lock_track_ownership(gboolean track); +gboolean il2cpp_mono_loader_lock_is_owned_by_self(); +gpointer il2cpp_mono_method_get_wrapper_data(Il2CppMonoMethod* method, guint32 id); +char* il2cpp_mono_type_get_name_full(Il2CppMonoType* type, MonoTypeNameFormat format); +gboolean il2cpp_mono_class_is_nullable(Il2CppMonoClass* klass); +Il2CppMonoGenericContainer* il2cpp_mono_class_get_generic_container(Il2CppMonoClass* klass); +void il2cpp_mono_class_setup_interfaces(Il2CppMonoClass* klass, MonoError* error); +GPtrArray* il2cpp_mono_class_get_methods_by_name(Il2CppMonoClass* klass, const char* name, guint32 bflags, gboolean ignore_case, gboolean allow_ctors, MonoError* error); +gpointer il2cpp_mono_ldtoken_checked(Il2CppMonoImage* image, guint32 token, Il2CppMonoClass** handle_class, Il2CppMonoGenericContext* context, MonoError* error); +Il2CppMonoClass* il2cpp_mono_class_from_generic_parameter_internal(Il2CppMonoGenericParam* param); +Il2CppMonoClass* il2cpp_mono_class_load_from_name(Il2CppMonoImage* image, const char* name_space, const char* name); +Il2CppMonoGenericClass* il2cpp_mono_class_get_generic_class(Il2CppMonoClass* klass); +Il2CppMonoInternalThread* il2cpp_mono_thread_internal_current(); +gboolean il2cpp_mono_thread_internal_is_current(Il2CppMonoInternalThread* thread); +void il2cpp_mono_thread_internal_abort(Il2CppMonoInternalThread* thread, gboolean appdomain_unload); +void il2cpp_mono_thread_internal_reset_abort(Il2CppMonoInternalThread* thread); +gunichar2* il2cpp_mono_thread_get_name(Il2CppMonoInternalThread* this_obj, guint32* name_len); +void il2cpp_mono_thread_set_name_internal(Il2CppMonoInternalThread* this_obj, Il2CppMonoString* name, gboolean permanent, gboolean reset, MonoError* error); +void il2cpp_mono_thread_suspend_all_other_threads(); +void il2cpp_mono_stack_mark_record_size(MonoThreadInfo* info, HandleStackMark* stackmark, const char* func_name); +Il2CppMonoRuntimeExceptionHandlingCallbacks* il2cpp_mono_get_eh_callbacks(); +void il2cpp_mono_reflection_create_custom_attr_data_args(Il2CppMonoImage* image, Il2CppMonoMethod* method, const guchar* data, guint32 len, Il2CppMonoArray** typed_args, Il2CppMonoArray** named_args, CattrNamedArg** named_arg_info, MonoError* error); +void il2cpp_mono_nullable_init(guint8* buf, Il2CppMonoObject* value, Il2CppMonoClass* klass); +Il2CppMonoObject* il2cpp_mono_value_box_checked(Il2CppMonoDomain* domain, Il2CppMonoClass* klass, gpointer value, MonoError* error); +void il2cpp_mono_field_static_get_value_checked(Il2CppMonoVTable* vt, Il2CppMonoClassField* field, void* value, MonoError* error); +void il2cpp_mono_field_static_get_value_for_thread(Il2CppMonoInternalThread* thread, Il2CppMonoVTable* vt, Il2CppMonoClassField* field, void* value, MonoError* error); +Il2CppMonoObject* il2cpp_mono_field_get_value_object_checked(Il2CppMonoDomain* domain, Il2CppMonoClassField* field, Il2CppMonoObject* obj, MonoError* error); +Il2CppMonoObject* il2cpp_mono_object_new_checked(Il2CppMonoDomain* domain, Il2CppMonoClass* klass, MonoError* error); +Il2CppMonoString* il2cpp_mono_ldstr_checked(Il2CppMonoDomain* domain, Il2CppMonoImage* image, guint32 idx, MonoError* error); +Il2CppMonoObject* il2cpp_mono_runtime_try_invoke(Il2CppMonoMethod* method, void* obj, void** params, Il2CppMonoObject** exc, MonoError* error); +Il2CppMonoObject* il2cpp_mono_runtime_invoke_checked(Il2CppMonoMethod* method, void* obj, void** params, MonoError* error); +void il2cpp_mono_gc_base_init(); +int il2cpp_mono_gc_register_root(char* start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, const char* msg); +void il2cpp_mono_gc_deregister_root(char* addr); +gint32 il2cpp_mono_environment_exitcode_get(); +void il2cpp_mono_environment_exitcode_set(gint32 value); +void il2cpp_mono_threadpool_suspend(); +void il2cpp_mono_threadpool_resume(); +Il2CppMonoImage* il2cpp_mono_assembly_get_image(Il2CppMonoAssembly* assembly); +gboolean il2cpp_mono_runtime_try_shutdown(); +gboolean il2cpp_mono_verifier_is_method_valid_generic_instantiation(Il2CppMonoMethod* method); +Il2CppMonoType* il2cpp_mono_reflection_get_type_checked(Il2CppMonoImage* rootimage, Il2CppMonoImage* image, Il2CppMonoTypeNameParse* info, gboolean ignorecase, gboolean* type_resolve, MonoError* error); +Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_method_checked(Il2CppMonoMethod* method, MonoError* error); +Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_class_checked(Il2CppMonoClass* klass, MonoError* error); +Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_property_checked(Il2CppMonoClass* klass, Il2CppMonoProperty* property, MonoError* error); +Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_field_checked(Il2CppMonoClass* klass, Il2CppMonoClassField* field, MonoError* error); +Il2CppMonoReflectionAssemblyHandle il2cpp_mono_assembly_get_object_handle(Il2CppMonoDomain* domain, Il2CppMonoAssembly* assembly, MonoError* error); +Il2CppMonoReflectionType* il2cpp_mono_type_get_object_checked(Il2CppMonoDomain* domain, Il2CppMonoType* type, MonoError* error); +void il2cpp_mono_network_init(); +gint il2cpp_mono_w32socket_set_blocking(SOCKET sock, gboolean blocking); + +char* il2cpp_mono_get_runtime_build_info(); +Il2CppMonoMethod* il2cpp_mono_marshal_method_from_wrapper(Il2CppMonoMethod* wrapper); +MonoDebugOptions* il2cpp_mini_get_debug_options(); +gpointer il2cpp_mono_jit_find_compiled_method_with_jit_info(Il2CppMonoDomain* domain, Il2CppMonoMethod* method, MonoJitInfo** ji); +MonoLMF** il2cpp_mono_get_lmf_addr(); +void il2cpp_mono_set_lmf(MonoLMF* lmf); +gpointer il2cpp_mono_aot_get_method_checked(Il2CppMonoDomain* domain, Il2CppMonoMethod* method, MonoError* error); +void il2cpp_mono_arch_setup_resume_sighandler_ctx(MonoContext* ctx, gpointer func); +void il2cpp_mono_arch_set_breakpoint(MonoJitInfo* ji, guint8* ip); +void il2cpp_mono_arch_clear_breakpoint(MonoJitInfo* ji, guint8* ip); +void il2cpp_mono_arch_start_single_stepping(); +void il2cpp_mono_arch_stop_single_stepping(); +void il2cpp_mono_arch_skip_breakpoint(MonoContext* ctx, MonoJitInfo* ji); +void il2cpp_mono_arch_skip_single_step(MonoContext* ctx); +void il2cpp_mono_arch_init_lmf_ext(MonoLMFExt* ext, gpointer prev_lmf); +mgreg_t il2cpp_mono_arch_context_get_int_reg(MonoContext* ctx, int reg); +void il2cpp_mono_arch_context_set_int_reg(MonoContext* ctx, int reg, mgreg_t val); +void il2cpp_mono_walk_stack_with_ctx(Il2CppMonoJitStackWalk func, MonoContext* start_ctx, MonoUnwindOptions unwind_options, void* user_data); +void il2cpp_mono_walk_stack_with_state(Il2CppMonoJitStackWalk func, MonoThreadUnwindState* state, MonoUnwindOptions unwind_options, void* user_data); +gboolean il2cpp_mono_thread_state_init_from_current(MonoThreadUnwindState* ctx); +gboolean il2cpp_mono_thread_state_init_from_monoctx(MonoThreadUnwindState* ctx, MonoContext* mctx); +MonoJitInfo* il2cpp_mini_jit_info_table_find(Il2CppMonoDomain* domain, char* addr, Il2CppMonoDomain** out_domain); +void il2cpp_mono_restore_context(MonoContext* ctx); +gboolean il2cpp_mono_find_jit_info_ext(Il2CppMonoDomain* domain, Il2CppMonoJitTlsData* jit_tls, MonoJitInfo* prev_ji, MonoContext* ctx, MonoContext* new_ctx, char** trace, MonoLMF** lmf, mgreg_t** save_locations, StackFrameInfo* frame); +Il2CppMonoMethod* il2cpp_mono_method_get_declaring_generic_method(Il2CppMonoMethod* method); +Il2CppMonoMethod* il2cpp_jinfo_get_method (MonoJitInfo *ji); +gboolean il2cpp_mono_find_prev_seq_point_for_native_offset (Il2CppMonoDomain *domain, Il2CppMonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point); +SOCKET il2cpp_mono_w32socket_accept_internal (SOCKET s, struct sockaddr *addr, socklen_t *addrlen, gboolean blocking); +gboolean il2cpp_mono_find_next_seq_point_for_native_offset (Il2CppMonoDomain *domain, Il2CppMonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point); +gboolean il2cpp_mono_class_has_parent (Il2CppMonoClass *klass, Il2CppMonoClass *parent); +Il2CppMonoGenericParam* il2cpp_mono_generic_container_get_param (Il2CppMonoGenericContainer *gc, int i); +gboolean il2cpp_mono_find_seq_point (Il2CppMonoDomain *domain, Il2CppMonoMethod *method, gint32 il_offset, MonoSeqPointInfo **info, SeqPoint *seq_point); +void il2cpp_mono_seq_point_iterator_init (SeqPointIterator* it, MonoSeqPointInfo* info); +gboolean il2cpp_mono_seq_point_iterator_next (SeqPointIterator* it); +void il2cpp_mono_seq_point_init_next (MonoSeqPointInfo* info, SeqPoint sp, SeqPoint* next); +MonoSeqPointInfo* il2cpp_mono_get_seq_points (Il2CppMonoDomain *domain, Il2CppMonoMethod *method); +void IL2CPP_G_BREAKPOINT(); +void il2cpp_mono_thread_info_safe_suspend_and_run (MonoNativeThreadId id, gboolean interrupt_kernel, MonoSuspendThreadCallback callback, gpointer user_data); +void il2cpp_mono_error_cleanup (MonoError *oerror); +Il2CppMonoException* il2cpp_mono_error_convert_to_exception (MonoError *target_error); +const char* il2cpp_mono_error_get_message (MonoError *oerror); +void il2cpp_mono_error_assert_ok_pos (MonoError *error, const char* filename, int lineno); +Il2CppSequencePointC* il2cpp_get_sequence_points(void* *iter); +Il2CppSequencePointC* il2cpp_get_method_sequence_points(Il2CppMonoMethod* method, void* *iter); +Il2CppMonoGenericInst* il2cpp_generic_class_get_inst(Il2CppMonoGenericClass *monoGenClass); +guint il2cpp_generic_inst_type_argc(Il2CppMonoGenericInst *monoInst); +Il2CppMonoType* il2cpp_generic_inst_type_arg(Il2CppMonoGenericInst *monoInst, int i); +Il2CppMonoType* il2cpp_class_this_arg(Il2CppMonoClass *monoClass); +Il2CppMonoClass* il2cpp_class_get_nested_types_accepts_generic(Il2CppMonoClass *monoClass, void* *iter); +Il2CppMonoClass* il2cpp_defaults_object_class(); +guint8 il2cpp_array_rank(Il2CppMonoArray *monoArr); +mono_array_size_t il2cpp_array_bound_length(Il2CppMonoArray *monoArr, int i); +mono_array_lower_bound_t il2cpp_array_bound_lower_bound(Il2CppMonoArray *monoArr, int i); +const char* il2cpp_assembly_name_name(Il2CppMonoAssembly *monoAssembly); +uint16_t il2cpp_assembly_name_major(Il2CppMonoAssembly *monoAssembly); +uint16_t il2cpp_assembly_name_minor(Il2CppMonoAssembly *monoAssembly); +uint16_t il2cpp_assembly_name_build(Il2CppMonoAssembly *monoAssembly); +uint16_t il2cpp_assembly_name_revision(Il2CppMonoAssembly *monoAssembly); +const char* il2cpp_assembly_name_culture(Il2CppMonoAssembly *monoAssembly); +mono_byte il2cpp_assembly_name_public_key_token(Il2CppMonoAssembly *monoAssembly, int i); +const char* il2cpp_assembly_name_public_key_token_string(Il2CppMonoAssembly *monoAssembly); +uint32_t il2cpp_assembly_name_flags(Il2CppMonoAssembly *monoAssembly); +const char* il2cpp_image_name(Il2CppMonoImage *monoImage); +Il2CppMonoAssembly* il2cpp_image_assembly(Il2CppMonoImage *monoImage); +guint8* il2cpp_field_get_address(Il2CppMonoObject *obj, Il2CppMonoClassField *monoField); +Il2CppMonoType* il2cpp_mono_object_get_type(Il2CppMonoObject* object); +Il2CppMonoClass* il2cpp_defaults_exception_class(); +Il2CppMonoImage* il2cpp_defaults_corlib_image(); +int il2cpp_generic_container_get_type_argc(Il2CppMonoGenericClass* container); +uint32_t il2cpp_method_get_flags_no_iflags (const Il2CppMonoMethod * method); +bool il2cpp_method_is_string_ctor (const Il2CppMonoMethod * method); +Il2CppMonoClass* il2cpp_defaults_void_class(); +void il2cpp_set_var(guint8* newValue, void *value, Il2CppMonoType *localVariableTypeMono); +Il2CppMonoMethod* il2cpp_get_interface_method(Il2CppMonoClass* klass, Il2CppMonoClass* itf, int slot); +gboolean il2cpp_field_is_deleted(Il2CppMonoClassField *field); +Il2CppMonoGenericClass* il2cpp_type_get_generic_class(Il2CppMonoType *type); +gboolean il2cpp_class_get_enumtype(Il2CppMonoClass *klass); +Il2CppMonoClass* il2cpp_iterate_loaded_classes(void* *iter); +Il2CppMonoAssembly* il2cpp_domain_get_assemblies_iter(Il2CppMonoAppDomain *domain, void* *iter); +const char** il2cpp_get_source_files_for_type(Il2CppMonoClass *klass, int *count); +Il2CppMonoInternalThread* il2cpp_mono_thread_get_internal(Il2CppMonoThread* thread); +uint32_t il2cpp_internal_thread_get_state(Il2CppMonoInternalThread* thread); +il2cpp_internal_thread_get_threadpool_thread(Il2CppMonoInternalThread* thread); +Il2CppMonoMethod* il2cpp_method_get_generic_definition(Il2CppMonoMethodInflated *imethod); +Il2CppMonoGenericInst* il2cpp_method_get_generic_class_inst(Il2CppMonoMethodInflated *imethod); +Il2CppMonoClass* il2cpp_generic_class_get_container_class(Il2CppMonoGenericClass *gclass); + +Il2CppMonoClass* il2cpp_mono_get_string_class (void); + +#endif // RUNTIME_IL2CPP diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp new file mode 100644 index 000000000000..d0abe72071d5 --- /dev/null +++ b/mono/mini/il2cpp-stubs.cpp @@ -0,0 +1,1722 @@ +#if defined(RUNTIME_IL2CPP) + +#include "il2cpp-config.h" +#include +#include "gc/GCHandle.h" +#include "gc/GarbageCollector.h" +#include "gc/WriteBarrier.h" +#include "gc/gc_wrapper.h" +#include "metadata/FieldLayout.h" +#include "vm/Assembly.h" +#include "vm/AssemblyName.h" +#include "vm/Class.h" +#include "vm/Domain.h" +#include "vm/Field.h" +#include "vm/GenericContainer.h" +#include "vm/GenericClass.h" +#include "vm/Image.h" +#include "vm/Method.h" +#include "vm/Object.h" +#include "vm/Profiler.h" +#include "vm/Reflection.h" +#include "vm/Runtime.h" +#include "vm/String.h" +#include "vm/Thread.h" +#include "vm/ThreadPoolMs.h" +#include "vm/Type.h" +#include "vm-utils/Debugger.h" +#include "metadata/GenericMetadata.h" + +extern "C" { + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "il2cpp-c-types.h" +#include + +static MonoGHashTable *method_signatures; + +static il2cpp::os::Mutex s_il2cpp_mono_loader_lock(false); +static uint64_t s_il2cpp_mono_loader_lock_tid = 0; + +Il2CppMonoMethod* il2cpp_mono_image_get_entry_point (Il2CppMonoImage *image) +{ + return (Il2CppMonoMethod*)il2cpp::vm::Image::GetEntryPoint((Il2CppImage*)image); +} + +const char* il2cpp_mono_image_get_filename (Il2CppMonoImage *monoImage) +{ + Il2CppImage *image = (Il2CppImage*)monoImage; + return image->name; +} + +const char* il2cpp_mono_image_get_guid (Il2CppMonoImage *image) +{ + return "00000000-0000-0000-0000-000000000000"; //IL2CPP doesn't have image GUIDs +} + +Il2CppMonoClass* il2cpp_mono_type_get_class (Il2CppMonoType *type) +{ + return (Il2CppMonoClass*) il2cpp::vm::Type::GetClass((Il2CppType*)type); +} + +mono_bool il2cpp_mono_type_is_struct (Il2CppMonoType *type) +{ + return il2cpp::vm::Type::IsStruct((Il2CppType*)type); +} + +mono_bool il2cpp_mono_type_is_reference (Il2CppMonoType *type) +{ + return il2cpp::vm::Type::IsReference((Il2CppType*)type); +} + +void il2cpp_mono_metadata_free_mh (Il2CppMonoMethodHeader *mh) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +Il2CppMonoMethodSignature* il2cpp_mono_method_signature (Il2CppMonoMethod *m) +{ + MethodInfo* method = (MethodInfo*)m; + + if (method_signatures == NULL) + method_signatures = mono_g_hash_table_new_type(NULL, NULL, MONO_HASH_KEY_GC, MONO_ROOT_SOURCE_DEBUGGER, "method-to-signature for il2cpp table"); + + Il2CppMonoMethodSignature* existing_signature = (Il2CppMonoMethodSignature*)mono_g_hash_table_lookup(method_signatures, method); + if (existing_signature != NULL) + return existing_signature; + + Il2CppMonoMethodSignature* sig = g_new(Il2CppMonoMethodSignature, 1); + + sig->call_convention = MONO_CALL_DEFAULT; + sig->hasthis = il2cpp::vm::Method::IsInstance(method); + sig->ret = (Il2CppMonoType*)il2cpp::vm::Method::GetReturnType(method); + + sig->generic_param_count = 0; + + if (method->is_generic) + { + sig->generic_param_count = il2cpp::vm::Method::GetGenericParamCount(method); + } + else if (method->is_inflated) + { + if (method->genericMethod->context.method_inst) + sig->generic_param_count += method->genericMethod->context.method_inst->type_argc; + + if (method->genericMethod->context.class_inst) + sig->generic_param_count += method->genericMethod->context.class_inst->type_argc; + } + + sig->param_count = il2cpp::vm::Method::GetParamCount(method); + sig->params = g_new(Il2CppMonoType*, sig->param_count); + for (int i = 0; i < sig->param_count; ++i) + sig->params[i] = (Il2CppMonoType*)il2cpp::vm::Method::GetParam(method, i); + + mono_g_hash_table_insert(method_signatures, method, sig); + + return sig; +} + +static void il2cpp_mono_free_method_signature(gpointer unused1, gpointer value, gpointer unused2) +{ + Il2CppMonoMethodSignature* sig = (Il2CppMonoMethodSignature*)value; + g_free(sig->params); + g_free(sig); +} + +void il2cpp_mono_free_method_signatures() +{ + if (method_signatures != NULL) + { + mono_g_hash_table_foreach(method_signatures, il2cpp_mono_free_method_signature, NULL); + mono_g_hash_table_destroy(method_signatures); + } +} + +void il2cpp_mono_method_get_param_names (Il2CppMonoMethod *m, const char **names) +{ + MethodInfo* method = (MethodInfo*)m; + uint32_t numberOfParameters = il2cpp::vm::Method::GetParamCount(method); + for (int i = 0; i < numberOfParameters; ++i) + names[i] = il2cpp::vm::Method::GetParamName(method, i); +} + +mono_bool il2cpp_mono_type_generic_inst_is_valuetype (Il2CppMonoType *monoType) +{ + static const int kBitIsValueType = 1; + Il2CppType *type = (Il2CppType*)monoType; + const Il2CppTypeDefinition *typeDef = il2cpp::vm::MetadataCache::GetTypeDefinitionFromIndex(type->data.generic_class->typeDefinitionIndex); + return (typeDef->bitfield >> (kBitIsValueType - 1)) & 0x1; +} + +Il2CppMonoMethodHeader* il2cpp_mono_method_get_header_checked (Il2CppMonoMethod *method, MonoError *error) +{ + return NULL; +} + +gboolean il2cpp_mono_class_init (Il2CppMonoClass *klass) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +Il2CppMonoVTable* il2cpp_mono_class_vtable (Il2CppMonoDomain *domain, Il2CppMonoClass *klass) +{ + return (Il2CppMonoVTable*)((Il2CppClass*)klass)->vtable; +} + +Il2CppMonoClassField* il2cpp_mono_class_get_field_from_name (Il2CppMonoClass *klass, const char *name) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +int32_t il2cpp_mono_array_element_size (Il2CppMonoClass *monoClass) +{ + Il2CppClass *klass = (Il2CppClass*)monoClass; + return klass->element_size; +} + +int32_t il2cpp_mono_class_instance_size (Il2CppMonoClass *klass) +{ + return il2cpp::vm::Class::GetInstanceSize((Il2CppClass*)klass); +} + +int32_t il2cpp_mono_class_value_size (Il2CppMonoClass *klass, uint32_t *align) +{ + return il2cpp::vm::Class::GetValueSize((Il2CppClass*)klass, align); +} + +gboolean il2cpp_mono_class_is_assignable_from (Il2CppMonoClass *klass, Il2CppMonoClass *oklass) +{ + return il2cpp::vm::Class::IsAssignableFrom((Il2CppClass*)klass, (Il2CppClass*)oklass); +} + +Il2CppMonoClass* il2cpp_mono_class_from_mono_type (Il2CppMonoType *type) +{ + return (Il2CppMonoClass*)il2cpp::vm::Class::FromIl2CppType((Il2CppType*)type); +} + +int il2cpp_mono_class_num_fields (Il2CppMonoClass *klass) +{ + return il2cpp::vm::Class::GetNumFields((Il2CppClass*)klass); +} + +int il2cpp_mono_class_num_methods (Il2CppMonoClass *klass) +{ + return il2cpp::vm::Class::GetNumMethods((Il2CppClass*)klass); +} + +int il2cpp_mono_class_num_properties (Il2CppMonoClass *klass) +{ + return il2cpp::vm::Class::GetNumProperties((Il2CppClass*)klass); +} + +Il2CppMonoClassField* il2cpp_mono_class_get_fields (Il2CppMonoClass* klass, gpointer *iter) +{ + return (Il2CppMonoClassField*)il2cpp::vm::Class::GetFields((Il2CppClass*)klass, iter); +} + +Il2CppMonoMethod* il2cpp_mono_class_get_methods (Il2CppMonoClass* klass, gpointer *iter) +{ + return (Il2CppMonoMethod*)il2cpp::vm::Class::GetMethods((Il2CppClass*)klass, iter); +} + +Il2CppMonoProperty* il2cpp_mono_class_get_properties (Il2CppMonoClass* klass, gpointer *iter) +{ + return (Il2CppMonoProperty*)il2cpp::vm::Class::GetProperties((Il2CppClass*)klass, iter); +} + +const char* il2cpp_mono_field_get_name (Il2CppMonoClassField *field) +{ + return il2cpp::vm::Field::GetName((FieldInfo*)field); +} + +mono_unichar2* il2cpp_mono_string_chars (Il2CppMonoString *monoStr) +{ + Il2CppString *str = (Il2CppString*)monoStr; + return (mono_unichar2*)str->chars; +} + +int il2cpp_mono_string_length (Il2CppMonoString *monoStr) +{ + Il2CppString *str = (Il2CppString*)monoStr; + return str->length; +} + +char* il2cpp_mono_array_addr_with_size (Il2CppMonoArray *array, int size, uintptr_t idx) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +uintptr_t il2cpp_mono_array_length (Il2CppMonoArray *array) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +Il2CppMonoString* il2cpp_mono_string_new (Il2CppMonoDomain *domain, const char *text) +{ + return (Il2CppMonoString*)il2cpp::vm::String::New(text); +} + + +Il2CppMonoString* il2cpp_mono_string_new_checked (Il2CppMonoDomain *domain, const char *text, MonoError *merror) +{ + error_init(merror); + return il2cpp_mono_string_new (domain, text); +} + +char* il2cpp_mono_string_to_utf8_checked (Il2CppMonoString *string_obj, MonoError *error) +{ + error_init(error); + Il2CppString *str = (Il2CppString*)string_obj; + std::string s = il2cpp::utils::StringUtils::Utf16ToUtf8(str->chars, str->length); + return g_strdup(s.c_str()); +} + +int il2cpp_mono_object_hash (Il2CppMonoObject* obj) +{ + return (int)((intptr_t)obj >> 3); +} + +void* il2cpp_mono_object_unbox (Il2CppMonoObject *monoObj) +{ + Il2CppObject *obj = (Il2CppObject*)monoObj; + return il2cpp::vm::Object::Unbox(obj); +} + +void il2cpp_mono_field_set_value (Il2CppMonoObject *obj, Il2CppMonoClassField *field, void *value) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_field_static_set_value (Il2CppMonoVTable *vt, Il2CppMonoClassField *field, void *value) +{ + il2cpp::vm::Field::StaticSetValue((FieldInfo*)field, value); +} + +uint32_t il2cpp_mono_gchandle_new_weakref (Il2CppMonoObject *obj, mono_bool track_resurrection) +{ + return il2cpp::gc::GCHandle::NewWeakref((Il2CppObject*)obj, track_resurrection == 0 ? false : true); +} + +Il2CppMonoObject* il2cpp_mono_gchandle_get_target (uint32_t gchandle) +{ + return (Il2CppMonoObject*)il2cpp::gc::GCHandle::GetTarget(gchandle); +} + +void il2cpp_mono_gchandle_free (uint32_t gchandle) +{ + il2cpp::gc::GCHandle::Free(gchandle); +} + +void il2cpp_mono_gc_wbarrier_generic_store (void* ptr, Il2CppMonoObject* value) +{ + il2cpp::gc::WriteBarrier::GenericStore(ptr, (Il2CppObject*)value); +} + +int il2cpp_mono_reflection_parse_type_checked (char *name, Il2CppMonoTypeNameParse *monoInfo, MonoError *error) +{ + error_init(error); + il2cpp::vm::TypeNameParseInfo *pInfo = new il2cpp::vm::TypeNameParseInfo(); + std::string nameStr = name; + std::replace(nameStr.begin(), nameStr.end(), '/', '+'); + il2cpp::vm::TypeNameParser parser(nameStr, *pInfo, false); + monoInfo->assembly.name = NULL; + monoInfo->il2cppTypeNameParseInfo = pInfo; + return parser.Parse(); +} + +void il2cpp_mono_reflection_free_type_info (Il2CppMonoTypeNameParse *info) +{ + delete (il2cpp::vm::TypeNameParseInfo*)info->il2cppTypeNameParseInfo; +} + +mono_bool il2cpp_mono_custom_attrs_has_attr (Il2CppMonoCustomAttrInfo *ainfo, Il2CppMonoClass *attr_klass) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +void il2cpp_mono_custom_attrs_free (Il2CppMonoCustomAttrInfo *ainfo) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +Il2CppMonoDomain* il2cpp_mono_get_root_domain (void) +{ + return (Il2CppMonoDomain*)il2cpp::vm::Domain::GetCurrent(); +} + +void il2cpp_mono_runtime_quit (void) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +gboolean il2cpp_mono_runtime_is_shutting_down (void) +{ + return il2cpp::vm::Runtime::IsShuttingDown() ? TRUE : FALSE; +} + +Il2CppMonoDomain* il2cpp_mono_domain_get (void) +{ + return il2cpp_mono_get_root_domain(); +} + +gboolean il2cpp_mono_domain_set (Il2CppMonoDomain *domain, gboolean force) +{ + IL2CPP_ASSERT(domain == il2cpp_mono_get_root_domain()); + return TRUE; +} + +void il2cpp_mono_domain_foreach(MonoDomainFunc func, gpointer user_data) +{ + func((MonoDomain*)il2cpp_mono_get_root_domain(), user_data); +} + +MonoJitInfo* il2cpp_mono_jit_info_table_find(Il2CppMonoDomain* domain, char* addr) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +Il2CppMonoMethod* il2cpp_mono_jit_info_get_method(MonoJitInfo* ji) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +MonoDebugMethodInfo* il2cpp_mono_debug_lookup_method(Il2CppMonoMethod* method) +{ + return NULL; +} + +MonoDebugMethodJitInfo* il2cpp_mono_debug_find_method(Il2CppMonoMethod* method, Il2CppMonoDomain* domain) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +void il2cpp_mono_debug_free_method_jit_info(MonoDebugMethodJitInfo* jit) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +MonoDebugLocalsInfo* il2cpp_mono_debug_lookup_locals(Il2CppMonoMethod* method) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +MonoDebugMethodAsyncInfo* il2cpp_mono_debug_lookup_method_async_debug_info(Il2CppMonoMethod* method) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +MonoDebugSourceLocation* il2cpp_mono_debug_method_lookup_location(MonoDebugMethodInfo* minfo, int il_offset) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +gint32 il2cpp_mono_debug_il_offset_from_address(Il2CppMonoMethod* method, Il2CppMonoDomain* domain, guint32 native_offset) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +void il2cpp_mono_debug_free_source_location(MonoDebugSourceLocation* location) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_set_is_debugger_attached(gboolean attached) +{ + il2cpp::utils::Debugger::SetIsDebuggerAttached(attached == TRUE); +} + +char* il2cpp_mono_type_full_name(Il2CppMonoType* type) +{ + std::string name = il2cpp::vm::Type::GetName((Il2CppType*)type, IL2CPP_TYPE_NAME_FORMAT_FULL_NAME); + return g_strdup(name.c_str()); +} + +char* il2cpp_mono_method_full_name(Il2CppMonoMethod* method, gboolean signature) +{ + return g_strdup(((MethodInfo*)method)->name); +} + +void il2cpp_mono_debug_get_seq_points(MonoDebugMethodInfo* minfo, char** source_file, GPtrArray** source_file_list, int** source_files, MonoSymSeqPoint** seq_points, int* n_seq_points) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_debug_free_locals(MonoDebugLocalsInfo* info) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_debug_free_method_async_debug_info(MonoDebugMethodAsyncInfo* info) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +Il2CppMonoThread* il2cpp_mono_thread_current() +{ + return (Il2CppMonoThread*)il2cpp::vm::Thread::Current(); +} + +Il2CppMonoThread* il2cpp_mono_thread_get_main() +{ + return (Il2CppMonoThread*)il2cpp::vm::Thread::Main(); +} + +Il2CppMonoThread* il2cpp_mono_thread_attach(Il2CppMonoDomain* domain) +{ + return (Il2CppMonoThread*)il2cpp::vm::Thread::Attach((Il2CppDomain*)domain); +} + +Il2CppMonoInternalThread* il2cpp_mono_thread_get_internal(Il2CppMonoThread* thread) +{ + return (Il2CppMonoInternalThread*)(((Il2CppThread*)thread)->internal_thread); +} + +void il2cpp_mono_domain_lock(Il2CppMonoDomain* domain) +{ +} + +void il2cpp_mono_domain_unlock(Il2CppMonoDomain* domain) +{ +} + +MonoJitInfo* il2cpp_mono_jit_info_table_find_internal(Il2CppMonoDomain* domain, char* addr, gboolean try_aot, gboolean allow_trampolines) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +guint il2cpp_mono_aligned_addr_hash(gconstpointer ptr) +{ + return GPOINTER_TO_UINT(ptr) >> 3; +} + +Il2CppMonoGenericInst* il2cpp_mono_metadata_get_generic_inst(int type_argc, Il2CppMonoType** type_argv) +{ + return (Il2CppMonoGenericInst*)il2cpp::vm::MetadataCache::GetGenericInst((Il2CppType**)type_argv, type_argc); +} + +Il2CppMonoMethod* il2cpp_mono_get_method_checked(Il2CppMonoImage* image, guint32 token, Il2CppMonoClass* klass, Il2CppMonoGenericContext* context, MonoError* error) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +SgenDescriptor il2cpp_mono_gc_make_root_descr_all_refs(int numbits) +{ + return NULL; +} + +int il2cpp_mono_gc_register_root_wbarrier (char *start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, const char *msg) +{ + il2cpp::gc::GarbageCollector::RegisterRoot(start, size); + return 1; +} + +MonoGCDescriptor il2cpp_mono_gc_make_vector_descr (void) +{ + return 0; +} + +int il2cpp_mono_class_interface_offset_with_variance(Il2CppMonoClass* klass, Il2CppMonoClass* itf, gboolean* non_exact_match) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +void il2cpp_mono_class_setup_supertypes(Il2CppMonoClass* klass) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_class_setup_vtable(Il2CppMonoClass* klass) +{ + il2cpp::vm::Class::Init((Il2CppClass*)klass); +} + +void il2cpp_mono_class_setup_methods(Il2CppMonoClass* klass) +{ + il2cpp::vm::Class::SetupMethods((Il2CppClass*)klass); +} + +gboolean il2cpp_mono_class_field_is_special_static(Il2CppMonoClassField* field) +{ + return il2cpp::vm::Field::IsNormalStatic((FieldInfo*)field) ? FALSE : TRUE; +} + +guint32 il2cpp_mono_class_field_get_special_static_type(Il2CppMonoClassField* field) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +Il2CppMonoGenericContext* il2cpp_mono_class_get_context(Il2CppMonoClass* klass) +{ + return (Il2CppMonoGenericContext*)&((Il2CppClass*)klass)->generic_class->context; +} + +Il2CppMonoGenericContext* il2cpp_mono_method_get_context(Il2CppMonoMethod* monoMethod) +{ + MethodInfo * method = (MethodInfo*)monoMethod; + + if (!method->is_inflated || method->is_generic) + return NULL; + + return (Il2CppMonoGenericContext*) &((MethodInfo*)method)->genericMethod->context; +} + +Il2CppMonoGenericContainer* il2cpp_mono_method_get_generic_container(Il2CppMonoMethod* monoMethod) +{ + MethodInfo * method = (MethodInfo*)monoMethod; + + if (method->is_inflated || !method->is_generic) + return NULL; + + return (Il2CppMonoGenericContainer*) method->genericContainer; +} + +Il2CppMonoMethod* il2cpp_mono_class_inflate_generic_method_full_checked(Il2CppMonoMethod* method, Il2CppMonoClass* klass_hint, Il2CppMonoGenericContext* context, MonoError* error) +{ + error_init(error); + return (Il2CppMonoMethod*) il2cpp::metadata::GenericMetadata::Inflate((MethodInfo*)method, (Il2CppClass*)klass_hint, (Il2CppGenericContext*)context); +} + +Il2CppMonoMethod* il2cpp_mono_class_inflate_generic_method_checked(Il2CppMonoMethod* method, Il2CppMonoGenericContext* context, MonoError* error) +{ + error_init(error); + return (Il2CppMonoMethod*)il2cpp::metadata::GenericMetadata::Inflate((MethodInfo*)method, NULL, (Il2CppGenericContext*)context); +} + +void il2cpp_mono_loader_lock() +{ + s_il2cpp_mono_loader_lock.Lock(); + s_il2cpp_mono_loader_lock_tid = il2cpp::os::Thread::CurrentThreadId(); +} + +void il2cpp_mono_loader_unlock() +{ + s_il2cpp_mono_loader_lock_tid = 0; + s_il2cpp_mono_loader_lock.Unlock(); +} + +void il2cpp_mono_loader_lock_track_ownership(gboolean track) +{ +} + +gboolean il2cpp_mono_loader_lock_is_owned_by_self() +{ + return s_il2cpp_mono_loader_lock_tid == il2cpp::os::Thread::CurrentThreadId(); +} + +gpointer il2cpp_mono_method_get_wrapper_data(Il2CppMonoMethod* method, guint32 id) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +char* il2cpp_mono_type_get_name_full(Il2CppMonoType* type, MonoTypeNameFormat format) +{ + std::string name = il2cpp::vm::Type::GetName((Il2CppType*)type, (Il2CppTypeNameFormat)format); + return g_strdup(name.c_str()); +} + +gboolean il2cpp_mono_class_is_nullable(Il2CppMonoClass* klass) +{ + return il2cpp::vm::Class::IsNullable((Il2CppClass*)klass); +} + +Il2CppMonoGenericContainer* il2cpp_mono_class_get_generic_container(Il2CppMonoClass* klass) +{ + return (Il2CppMonoGenericContainer*)il2cpp::vm::Class::GetGenericContainer((Il2CppClass*)klass); +} + +void il2cpp_mono_class_setup_interfaces(Il2CppMonoClass* klass, MonoError* error) +{ + error_init(error); + il2cpp::vm::Class::SetupInterfaces((Il2CppClass*)klass); +} + +enum { + BFLAGS_IgnoreCase = 1, + BFLAGS_DeclaredOnly = 2, + BFLAGS_Instance = 4, + BFLAGS_Static = 8, + BFLAGS_Public = 0x10, + BFLAGS_NonPublic = 0x20, + BFLAGS_FlattenHierarchy = 0x40, + BFLAGS_InvokeMethod = 0x100, + BFLAGS_CreateInstance = 0x200, + BFLAGS_GetField = 0x400, + BFLAGS_SetField = 0x800, + BFLAGS_GetProperty = 0x1000, + BFLAGS_SetProperty = 0x2000, + BFLAGS_ExactBinding = 0x10000, + BFLAGS_SuppressChangeType = 0x20000, + BFLAGS_OptionalParamBinding = 0x40000 +}; + +static gboolean +method_nonpublic (MethodInfo* method, gboolean start_klass) +{ + switch (method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) { + case METHOD_ATTRIBUTE_ASSEM: + return (start_klass || il2cpp_defaults.generic_ilist_class); + case METHOD_ATTRIBUTE_PRIVATE: + return start_klass; + case METHOD_ATTRIBUTE_PUBLIC: + return FALSE; + default: + return TRUE; + } +} + +GPtrArray* il2cpp_mono_class_get_methods_by_name(Il2CppMonoClass* il2cppMonoKlass, const char* name, guint32 bflags, gboolean ignore_case, gboolean allow_ctors, MonoError* error) +{ + GPtrArray *array; + Il2CppClass *klass = (Il2CppClass*)il2cppMonoKlass; + Il2CppClass *startklass; + MethodInfo *method; + gpointer iter; + int match, nslots; + /*FIXME, use MonoBitSet*/ + /*guint32 method_slots_default [8]; + guint32 *method_slots = NULL;*/ + int (*compare_func) (const char *s1, const char *s2) = NULL; + + array = g_ptr_array_new (); + startklass = klass; + error_init (error); + + if (name != NULL) + compare_func = (ignore_case) ? mono_utf8_strcasecmp : strcmp; + + /*il2cpp_mono_class_setup_methods (klass); + il2cpp_mono_class_setup_vtable (klass); + + if (is_generic_parameter (&klass->byval_arg)) + nslots = mono_class_get_vtable_size (klass->parent); + else + nslots = MONO_CLASS_IS_INTERFACE (klass) ? mono_class_num_methods (klass) : mono_class_get_vtable_size (klass); + if (nslots >= sizeof (method_slots_default) * 8) { + method_slots = g_new0 (guint32, nslots / 32 + 1); + } else { + method_slots = method_slots_default; + memset (method_slots, 0, sizeof (method_slots_default)); + }*/ +handle_parent: + il2cpp_mono_class_setup_methods ((Il2CppMonoClass*)klass); + il2cpp_mono_class_setup_vtable ((Il2CppMonoClass*)klass); + + iter = NULL; + while ((method = (MethodInfo*)il2cpp_mono_class_get_methods ((Il2CppMonoClass*)klass, &iter))) { + match = 0; + /*if (method->slot != -1) { + g_assert (method->slot < nslots); + if (method_slots [method->slot >> 5] & (1 << (method->slot & 0x1f))) + continue; + if (!(method->flags & METHOD_ATTRIBUTE_NEW_SLOT)) + method_slots [method->slot >> 5] |= 1 << (method->slot & 0x1f); + }*/ + + if (!allow_ctors && method->name [0] == '.' && (strcmp (method->name, ".ctor") == 0 || strcmp (method->name, ".cctor") == 0)) + continue; + if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) { + if (bflags & BFLAGS_Public) + match++; + } else if ((bflags & BFLAGS_NonPublic) && method_nonpublic (method, (klass == startklass))) { + match++; + } + if (!match) + continue; + match = 0; + if (method->flags & METHOD_ATTRIBUTE_STATIC) { + if (bflags & BFLAGS_Static) + if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass)) + match++; + } else { + if (bflags & BFLAGS_Instance) + match++; + } + + if (!match) + continue; + + if (name != NULL) { + if (compare_func (name, method->name)) + continue; + } + + match = 0; + g_ptr_array_add (array, method); + } + if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent)) + goto handle_parent; + /*if (method_slots != method_slots_default) + g_free (method_slots);*/ + + return array; +} + +gpointer il2cpp_mono_ldtoken_checked(Il2CppMonoImage* image, guint32 token, Il2CppMonoClass** handle_class, Il2CppMonoGenericContext* context, MonoError* error) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +Il2CppMonoClass* il2cpp_mono_class_from_generic_parameter_internal(Il2CppMonoGenericParam* param) +{ + return (Il2CppMonoClass*)il2cpp::vm::Class::FromGenericParameter((Il2CppGenericParameter*)param); +} + +Il2CppMonoClass* il2cpp_mono_class_load_from_name(Il2CppMonoImage* image, const char* name_space, const char* name) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +Il2CppMonoGenericClass* il2cpp_mono_class_get_generic_class(Il2CppMonoClass* monoClass) +{ + Il2CppClass *klass = (Il2CppClass*)monoClass; + return (Il2CppMonoGenericClass*)klass->generic_class; +} + +Il2CppMonoInternalThread* il2cpp_mono_thread_internal_current() +{ + return (Il2CppMonoInternalThread*)(((Il2CppThread*)il2cpp_mono_thread_current())->internal_thread); +} + +gboolean il2cpp_mono_thread_internal_is_current(Il2CppMonoInternalThread* thread) +{ + return il2cpp_mono_thread_internal_current () == thread; +} + +void il2cpp_mono_thread_internal_abort(Il2CppMonoInternalThread* thread, gboolean appdomain_unload) +{ + il2cpp::vm::Thread::RequestAbort((Il2CppInternalThread*)thread); +} + +void il2cpp_mono_thread_internal_reset_abort(Il2CppMonoInternalThread* thread) +{ + il2cpp::vm::Thread::ResetAbort((Il2CppInternalThread*)thread); +} + +gunichar2* il2cpp_mono_thread_get_name(Il2CppMonoInternalThread* this_obj, guint32* name_len) +{ + return NULL; +} + +void il2cpp_mono_thread_set_name_internal(Il2CppMonoInternalThread* this_obj, Il2CppMonoString* name, gboolean permanent, gboolean reset, MonoError* error) +{ + il2cpp::vm::Thread::SetName((Il2CppInternalThread*)this_obj, (Il2CppString*)name); + error_init(error); +} + +void il2cpp_mono_thread_suspend_all_other_threads() +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_stack_mark_record_size(MonoThreadInfo* info, HandleStackMark* stackmark, const char* func_name) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +Il2CppMonoRuntimeExceptionHandlingCallbacks* il2cpp_mono_get_eh_callbacks() +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +void il2cpp_mono_reflection_create_custom_attr_data_args(Il2CppMonoImage* image, Il2CppMonoMethod* method, const guchar* data, guint32 len, Il2CppMonoArray** typed_args, Il2CppMonoArray** named_args, CattrNamedArg** named_arg_info, MonoError* error) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_nullable_init(guint8* buf, Il2CppMonoObject* value, Il2CppMonoClass* klass) +{ + il2cpp::vm::Object::NullableInit(buf, (Il2CppObject*)value, (Il2CppClass*)klass); +} + +Il2CppMonoObject* il2cpp_mono_value_box_checked(Il2CppMonoDomain* domain, Il2CppMonoClass* klass, gpointer value, MonoError* error) +{ + error_init(error); + return (Il2CppMonoObject*)il2cpp::vm::Object::Box((Il2CppClass*)klass, value); +} + +void il2cpp_mono_field_static_get_value_checked(Il2CppMonoVTable* vt, Il2CppMonoClassField* field, void* value, MonoError* error) +{ + error_init(error); + il2cpp::vm::Field::StaticGetValue((FieldInfo*)field, value); +} + +void il2cpp_mono_field_static_get_value_for_thread(Il2CppMonoInternalThread* thread, Il2CppMonoVTable* vt, Il2CppMonoClassField* field, void* value, MonoError* error) +{ + error_init(error); + il2cpp::vm::Field::StaticGetValueForThread((FieldInfo*)field, value, (Il2CppInternalThread*)thread); +} + +Il2CppMonoObject* il2cpp_mono_field_get_value_object_checked(Il2CppMonoDomain* domain, Il2CppMonoClassField* field, Il2CppMonoObject* obj, MonoError* error) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +Il2CppMonoObject* il2cpp_mono_object_new_checked(Il2CppMonoDomain* domain, Il2CppMonoClass* klass, MonoError* error) +{ + error_init(error); + return (Il2CppMonoObject*)il2cpp::vm::Object::New((Il2CppClass*)klass); +} + +Il2CppMonoString* il2cpp_mono_ldstr_checked(Il2CppMonoDomain* domain, Il2CppMonoImage* image, guint32 idx, MonoError* error) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +Il2CppMonoObject* il2cpp_mono_runtime_try_invoke(Il2CppMonoMethod* method, void* obj, void** params, Il2CppMonoObject** exc, MonoError* error) +{ + error_init(error); + + if (((MethodInfo*)method)->declaring_type->valuetype) + obj = static_cast(obj) - 1; + + return (Il2CppMonoObject*)il2cpp::vm::Runtime::Invoke((MethodInfo*)method, obj, params, (Il2CppException**)exc); +} + +Il2CppMonoObject* il2cpp_mono_runtime_invoke_checked(Il2CppMonoMethod* method, void* obj, void** params, MonoError* error) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +void il2cpp_mono_gc_base_init() +{ +} + +static il2cpp::os::Mutex s_il2cpp_gc_root_lock(false); +int il2cpp_mono_gc_register_root(char* start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, const char* msg) +{ + il2cpp::gc::GarbageCollector::RegisterRoot(start, size); + return 1; +} + +void il2cpp_mono_gc_deregister_root(char* addr) +{ + il2cpp::gc::GarbageCollector::UnregisterRoot(addr); +} + +#ifndef HOST_WIN32 +int il2cpp_mono_gc_pthread_create (pthread_t *new_thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} +#endif + +gboolean il2cpp_mono_gc_is_moving() +{ + return FALSE; +} + +gint32 il2cpp_mono_environment_exitcode_get() +{ + return il2cpp::vm::Runtime::GetExitCode(); +} + +void il2cpp_mono_environment_exitcode_set(gint32 value) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_threadpool_suspend() +{ +#if NET_4_0 + il2cpp::vm::ThreadPoolMs::Suspend(); +#endif // NET_4_0 +} + +void il2cpp_mono_threadpool_resume() +{ +#if NET_4_0 + il2cpp::vm::ThreadPoolMs::Resume(); +#endif // NET_4_0 +} + +Il2CppMonoImage* il2cpp_mono_assembly_get_image(Il2CppMonoAssembly* assembly) +{ + return (Il2CppMonoImage*)il2cpp::vm::Assembly::GetImage((Il2CppAssembly*)assembly); +} + +gboolean il2cpp_mono_runtime_try_shutdown() +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +gboolean il2cpp_mono_verifier_is_method_valid_generic_instantiation(Il2CppMonoMethod* method) +{ + if (!method) + return FALSE; + + if (!((MethodInfo*)method)->is_generic && ((MethodInfo*)method)->is_inflated && ((MethodInfo*)method)->methodPointer) + return TRUE; + + return FALSE; +} + +Il2CppMonoType* il2cpp_mono_reflection_get_type_checked(Il2CppMonoImage* rootimage, Il2CppMonoImage* image, Il2CppMonoTypeNameParse* info, gboolean ignorecase, gboolean* type_resolve, MonoError* error) +{ + error_init(error); + + Il2CppClass *klass = il2cpp::vm::Image::FromTypeNameParseInfo((Il2CppImage*)image, *((il2cpp::vm::TypeNameParseInfo*)info->il2cppTypeNameParseInfo), ignorecase); + if (!klass) + return NULL; + + return (Il2CppMonoType*)il2cpp::vm::Class::GetType(klass); +} + +Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_method_checked(Il2CppMonoMethod* method, MonoError* error) +{ + error_init(error); + return NULL; +} + +Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_class_checked(Il2CppMonoClass* klass, MonoError* error) +{ + error_init(error); + return NULL; +} + +Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_property_checked(Il2CppMonoClass* klass, Il2CppMonoProperty* property, MonoError* error) +{ + error_init(error); + return NULL; +} + +Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_field_checked(Il2CppMonoClass* klass, Il2CppMonoClassField* field, MonoError* error) +{ + error_init(error); + return NULL; +} + +Il2CppMonoReflectionAssemblyHandle il2cpp_mono_assembly_get_object_handle(Il2CppMonoDomain* domain, Il2CppMonoAssembly* assembly, MonoError* error) +{ + return (Il2CppMonoReflectionAssemblyHandle)il2cpp::vm::Reflection::GetAssemblyObject((const Il2CppAssembly *)assembly); +} + +Il2CppMonoReflectionType* il2cpp_mono_type_get_object_checked(Il2CppMonoDomain* domain, Il2CppMonoType* type, MonoError* error) +{ + error_init(error); + return (Il2CppMonoReflectionType*)il2cpp::vm::Reflection::GetTypeObject((const Il2CppType*)type); +} + +void il2cpp_mono_network_init() +{ +} + +gint il2cpp_mono_w32socket_set_blocking(void* sock, gboolean blocking) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +char* il2cpp_mono_get_runtime_build_info() +{ + return g_strdup_printf ("%s (%s)", "0.0", "IL2CPP"); +} + +Il2CppMonoMethod* il2cpp_mono_marshal_method_from_wrapper(Il2CppMonoMethod* wrapper) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +MonoDebugOptions* il2cpp_mini_get_debug_options() +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +gpointer il2cpp_mono_jit_find_compiled_method_with_jit_info(Il2CppMonoDomain* domain, Il2CppMonoMethod* method, MonoJitInfo** ji) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +MonoLMF** il2cpp_mono_get_lmf_addr() +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +void il2cpp_mono_set_lmf(MonoLMF* lmf) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +gpointer il2cpp_mono_aot_get_method_checked(Il2CppMonoDomain* domain, Il2CppMonoMethod* method, MonoError* error) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +void il2cpp_mono_arch_setup_resume_sighandler_ctx(MonoContext* ctx, gpointer func) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_arch_set_breakpoint(MonoJitInfo* ji, guint8* ip) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_arch_clear_breakpoint(MonoJitInfo* ji, guint8* ip) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_arch_start_single_stepping() +{ + //IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_arch_stop_single_stepping() +{ + //IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_arch_skip_breakpoint(MonoContext* ctx, MonoJitInfo* ji) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_arch_skip_single_step(MonoContext* ctx) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_arch_init_lmf_ext(MonoLMFExt* ext, gpointer prev_lmf) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +mgreg_t il2cpp_mono_arch_context_get_int_reg(MonoContext* ctx, int reg) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +void il2cpp_mono_arch_context_set_int_reg(MonoContext* ctx, int reg, mgreg_t val) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_walk_stack_with_ctx(Il2CppMonoJitStackWalk func, MonoContext* start_ctx, MonoUnwindOptions unwind_options, void* user_data) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_walk_stack_with_state(Il2CppMonoJitStackWalk func, MonoThreadUnwindState* state, MonoUnwindOptions unwind_options, void* user_data) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +gboolean il2cpp_mono_thread_state_init_from_current(MonoThreadUnwindState* ctx) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +gboolean il2cpp_mono_thread_state_init_from_monoctx(MonoThreadUnwindState* ctx, MonoContext* mctx) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +MonoJitInfo* il2cpp_mini_jit_info_table_find(Il2CppMonoDomain* domain, char* addr, Il2CppMonoDomain** out_domain) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +void il2cpp_mono_restore_context(MonoContext* ctx) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +gboolean il2cpp_mono_find_jit_info_ext(Il2CppMonoDomain* domain, MonoJitTlsData* jit_tls, MonoJitInfo* prev_ji, MonoContext* ctx, MonoContext* new_ctx, char** trace, MonoLMF** lmf, mgreg_t** save_locations, StackFrameInfo* frame) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +Il2CppMonoMethod* il2cpp_mono_method_get_declaring_generic_method(Il2CppMonoMethod* method) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +gboolean il2cpp_mono_error_ok (MonoError *error) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +Il2CppMonoMethod* il2cpp_jinfo_get_method (MonoJitInfo *ji) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +gboolean il2cpp_mono_find_prev_seq_point_for_native_offset (Il2CppMonoDomain *domain, Il2CppMonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +void il2cpp_mono_error_cleanup (MonoError *oerror) +{ +} + +void il2cpp_mono_error_init (MonoError *error) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void* il2cpp_mono_w32socket_accept_internal (void* s, struct sockaddr *addr, void *addrlen, gboolean blocking) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +gboolean il2cpp_mono_find_next_seq_point_for_native_offset (Il2CppMonoDomain *domain, Il2CppMonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +gboolean il2cpp_mono_class_has_parent (Il2CppMonoClass *klass, Il2CppMonoClass *parent) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +Il2CppMonoGenericParam* il2cpp_mono_generic_container_get_param (Il2CppMonoGenericContainer *gc, int i) +{ + return (Il2CppMonoGenericParam*)il2cpp::vm::GenericContainer::GetGenericParameter((Il2CppGenericContainer*)gc, i); +} + +gboolean il2cpp_mono_find_seq_point (Il2CppMonoDomain *domain, Il2CppMonoMethod *method, gint32 il_offset, MonoSeqPointInfo **info, SeqPoint *seq_point) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +void il2cpp_mono_seq_point_iterator_init (SeqPointIterator* it, MonoSeqPointInfo* info) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +gboolean il2cpp_mono_seq_point_iterator_next (SeqPointIterator* it) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return 0; +} + +void il2cpp_mono_seq_point_init_next (MonoSeqPointInfo* info, SeqPoint sp, SeqPoint* next) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +MonoSeqPointInfo* il2cpp_mono_get_seq_points (Il2CppMonoDomain *domain, Il2CppMonoMethod *method) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +void IL2CPP_G_BREAKPOINT() +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); +} + +void il2cpp_mono_thread_info_safe_suspend_and_run (MonoNativeThreadId id, gboolean interrupt_kernel, MonoSuspendThreadCallback callback, gpointer user_data) +{ + callback(NULL, user_data); +} + +Il2CppMonoException* il2cpp_mono_error_convert_to_exception (MonoError *target_error) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +const char* il2cpp_mono_error_get_message (MonoError *oerror) +{ + IL2CPP_ASSERT(0 && "This method is not yet implemented"); + return NULL; +} + +void il2cpp_mono_error_assert_ok_pos (MonoError *error, const char* filename, int lineno) +{ + if (error->error_code == MONO_ERROR_NONE) + return; + + g_error ("%s:%d\n", filename, lineno); +} + +void* il2cpp_mono_gc_alloc_fixed (size_t size, void* descr, MonoGCRootSource source, const char *msg) +{ + return il2cpp_gc_alloc_fixed(size); +} + +typedef void* (*Il2CppMonoGCLockedCallbackFunc) (void *data); +void* il2cpp_mono_gc_invoke_with_gc_lock (Il2CppMonoGCLockedCallbackFunc func, void *data) +{ + return il2cpp::gc::GarbageCollector::CallWithAllocLockHeld (func, data); +} + +// These functions expose the IL2CPP VM C++ API to C + +void il2cpp_internal_thread_set_state_background(Il2CppMonoThread* thread) +{ + il2cpp::vm::Thread::SetState((Il2CppInternalThread*)thread, il2cpp::vm::kThreadStateBackground); +} + +void* il2cpp_domain_get_agent_info(Il2CppMonoAppDomain* domain) +{ + return ((Il2CppDomain*)domain)->agent_info; +} + +void il2cpp_domain_set_agent_info(Il2CppMonoAppDomain* domain, void* agentInfo) +{ + ((Il2CppDomain*)domain)->agent_info = agentInfo; +} + +Il2CppMonoAssembly* il2cpp_domain_get_assemblies_iter(Il2CppMonoAppDomain *domain, void* *iter) +{ + if (!iter) + return NULL; + + il2cpp::vm::AssemblyVector* assemblies = il2cpp::vm::Assembly::GetAllAssemblies(); + + if (!*iter) + { + il2cpp::vm::AssemblyVector::iterator *pIter = new il2cpp::vm::AssemblyVector::iterator(); + *pIter = assemblies->begin(); + *iter = pIter; + return (Il2CppMonoAssembly*)**pIter; + } + + il2cpp::vm::AssemblyVector::iterator *pIter = (il2cpp::vm::AssemblyVector::iterator*)*iter; + (*pIter)++; + if (*pIter != assemblies->end()) + { + return (Il2CppMonoAssembly*)(**pIter); + } + else + { + delete pIter; + *iter = NULL; + } + + return NULL; +} + +void il2cpp_start_debugger_thread() +{ + il2cpp::utils::Debugger::StartDebuggerThread(); +} + +uintptr_t il2cpp_internal_thread_get_thread_id(Il2CppMonoInternalThread* thread) +{ + return il2cpp::vm::Thread::GetId((Il2CppInternalThread*)thread); +} + +uint32_t il2cpp_internal_thread_get_state(Il2CppMonoInternalThread* thread) +{ + return il2cpp::vm::Thread::GetState((Il2CppInternalThread*)thread); +} + +bool il2cpp_internal_thread_get_threadpool_thread(Il2CppMonoInternalThread* thread) +{ + return ((Il2CppInternalThread*)thread)->threadpool_thread; +} + +void* il2cpp_gc_alloc_fixed(size_t size) +{ + return il2cpp::gc::GarbageCollector::AllocateFixed(size, NULL); +} + +void il2cpp_gc_free_fixed(void* address) +{ + il2cpp::gc::GarbageCollector::FreeFixed(address); +} + +char* il2cpp_assembly_get_name(Il2CppMonoAssembly* assembly) +{ + std::string name = il2cpp::vm::AssemblyName::AssemblyNameToString(((Il2CppAssembly*)assembly)->aname); + return g_strdup(name.c_str()); +} + +const char* il2cpp_domain_get_name(Il2CppMonoDomain* domain) +{ + return ((Il2CppDomain*)domain)->friendly_name; +} + +int il2cpp_mono_type_get_attrs(Il2CppMonoType* type) +{ + return ((Il2CppType*)type)->attrs; +} + +Il2CppSequencePointC* il2cpp_get_sequence_points(void* *iter) +{ + return (Il2CppSequencePointC*)il2cpp::utils::Debugger::GetSequencePoints(iter); +} + +Il2CppSequencePointC* il2cpp_get_method_sequence_points(Il2CppMonoMethod* method, void* *iter) +{ + if (!method) + return (Il2CppSequencePointC*)il2cpp::utils::Debugger::GetSequencePoints(iter); + else + return (Il2CppSequencePointC*)il2cpp::utils::Debugger::GetSequencePoints((const MethodInfo*)method, iter); +} + +gboolean il2cpp_mono_methods_match(Il2CppMonoMethod* left, Il2CppMonoMethod* right) +{ + MethodInfo* leftMethod = (MethodInfo*)left; + MethodInfo* rightMethod = (MethodInfo*)right; + + if (rightMethod == leftMethod) + return TRUE; + if (rightMethod == NULL || leftMethod == NULL) + return FALSE; + if (rightMethod->is_inflated && !rightMethod->is_generic && rightMethod->genericMethod->methodDefinition == leftMethod) + return TRUE; + if (leftMethod->is_inflated && !leftMethod->is_generic && leftMethod->genericMethod->methodDefinition == rightMethod) + return TRUE; + if (leftMethod->is_generic && rightMethod->is_inflated && rightMethod->methodPointer && + leftMethod->declaring_type == rightMethod->declaring_type && + strcmp(leftMethod->name, rightMethod->name) == 0) + { + if (leftMethod->parameters_count != rightMethod->parameters_count) + return FALSE; + + for(int i = 0;i < leftMethod->parameters_count;++i) + { + if ((leftMethod->parameters[i].parameter_type->type != IL2CPP_TYPE_MVAR) && (leftMethod->parameters[i].parameter_type->type != IL2CPP_TYPE_VAR) && (leftMethod->parameters[i].parameter_type != rightMethod->parameters[i].parameter_type)) + return FALSE; + } + + return TRUE; + } + + return FALSE; +} + +Il2CppMonoGenericInst* il2cpp_generic_class_get_inst(Il2CppMonoGenericClass *monoGenClass) +{ + Il2CppGenericClass *klass = (Il2CppGenericClass*) monoGenClass; + return (Il2CppMonoGenericInst*)klass->context.class_inst; +} + +guint il2cpp_generic_inst_type_argc(Il2CppMonoGenericInst *monoInst) +{ + Il2CppGenericInst *inst = (Il2CppGenericInst*)monoInst; + return inst->type_argc; +} + +Il2CppMonoType* il2cpp_generic_inst_type_arg(Il2CppMonoGenericInst *monoInst, int i) +{ + Il2CppGenericInst *inst = (Il2CppGenericInst*)monoInst; + return (Il2CppMonoType*)inst->type_argv[i]; +} + +Il2CppMonoType* il2cpp_class_this_arg(Il2CppMonoClass *monoClass) +{ + Il2CppClass *klass = (Il2CppClass*)monoClass; + return (Il2CppMonoType*)klass->this_arg; +} + +Il2CppMonoClass* il2cpp_class_get_nested_types_accepts_generic(Il2CppMonoClass *monoClass, void* *iter) +{ + Il2CppClass *klass = (Il2CppClass*)monoClass; + if (klass->generic_class) + return NULL; + + return (Il2CppMonoClass*)il2cpp::vm::Class::GetNestedTypes(klass, iter); +} + +Il2CppMonoClass* il2cpp_defaults_object_class() +{ + return (Il2CppMonoClass*)il2cpp_defaults.object_class; +} + +guint8 il2cpp_array_rank(Il2CppMonoArray *monoArr) +{ + Il2CppArray *arr = (Il2CppArray*)monoArr; + return arr->klass->rank; +} + +mono_array_size_t il2cpp_array_bound_length(Il2CppMonoArray *monoArr, int i) +{ + Il2CppArray *arr = (Il2CppArray*)monoArr; + return arr->bounds[i].length; +} + +mono_array_lower_bound_t il2cpp_array_bound_lower_bound(Il2CppMonoArray *monoArr, int i) +{ + Il2CppArray *arr = (Il2CppArray*)monoArr; + return arr->bounds[i].lower_bound; +} + +const char* il2cpp_assembly_name_name(Il2CppMonoAssembly *monoAssembly) +{ + Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; + return il2cpp::vm::MetadataCache::GetStringFromIndex(assembly->aname.nameIndex); +} + +uint16_t il2cpp_assembly_name_major(Il2CppMonoAssembly *monoAssembly) +{ + Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; + return assembly->aname.major; +} + +uint16_t il2cpp_assembly_name_minor(Il2CppMonoAssembly *monoAssembly) +{ + Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; + return assembly->aname.minor; +} + +uint16_t il2cpp_assembly_name_build(Il2CppMonoAssembly *monoAssembly) +{ + Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; + return assembly->aname.build; +} + +uint16_t il2cpp_assembly_name_revision(Il2CppMonoAssembly *monoAssembly) +{ + Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; + return assembly->aname.revision; +} + +const char* il2cpp_assembly_name_culture(Il2CppMonoAssembly *monoAssembly) +{ + Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; + return il2cpp::vm::MetadataCache::GetStringFromIndex(assembly->aname.cultureIndex); +} + +mono_byte il2cpp_assembly_name_public_key_token(Il2CppMonoAssembly *monoAssembly, int i) +{ + Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; + return assembly->aname.publicKeyToken[i]; +} + +const char* il2cpp_assembly_name_public_key_token_string(Il2CppMonoAssembly *monoAssembly) +{ + Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; + return il2cpp::vm::MetadataCache::GetStringFromIndex(assembly->aname.publicKeyIndex); +} + +uint32_t il2cpp_assembly_name_flags(Il2CppMonoAssembly *monoAssembly) +{ + Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; + return assembly->aname.flags; +} + +const char* il2cpp_image_name(Il2CppMonoImage *monoImage) +{ + Il2CppImage *image = (Il2CppImage*)monoImage; + return image->name; +} + +Il2CppMonoAssembly* il2cpp_image_assembly(Il2CppMonoImage *monoImage) +{ + Il2CppImage *image = (Il2CppImage*)monoImage; + return (Il2CppMonoAssembly*)il2cpp::vm::MetadataCache::GetAssemblyFromIndex(image->assemblyIndex); +} + +guint8* il2cpp_field_get_address(Il2CppMonoObject *obj, Il2CppMonoClassField *monoField) +{ + FieldInfo *field = (FieldInfo*)monoField; + return (guint8*)obj + field->offset; +} + +Il2CppMonoType* il2cpp_mono_object_get_type(Il2CppMonoObject* object) +{ + return (Il2CppMonoType*)(((Il2CppObject*)object)->klass->byval_arg); +} + +Il2CppMonoClass* il2cpp_defaults_exception_class() +{ + return (Il2CppMonoClass*)il2cpp_defaults.exception_class; +} + +Il2CppMonoImage* il2cpp_defaults_corlib_image() +{ + return (Il2CppMonoImage*)il2cpp_defaults.corlib; +} + +uint32_t il2cpp_method_get_flags_no_iflags(const Il2CppMonoMethod * method) +{ + return ((MethodInfo*)method)->flags; +} + +bool il2cpp_method_is_string_ctor(const Il2CppMonoMethod * method) +{ + MethodInfo* methodInfo = (MethodInfo*)method; + return methodInfo->declaring_type == il2cpp_defaults.string_class && !strcmp (methodInfo->name, ".ctor"); +} + +Il2CppMonoClass* il2cpp_defaults_void_class() +{ + return (Il2CppMonoClass*)il2cpp_defaults.void_class; +} + +void il2cpp_set_var(guint8* newValue, void *value, Il2CppMonoType *localVariableTypeMono) +{ + il2cpp::metadata::SizeAndAlignment sa = il2cpp::metadata::FieldLayout::GetTypeSizeAndAlignment((const Il2CppType*)localVariableTypeMono); + if (((Il2CppType*)localVariableTypeMono)->byref) + memcpy(*(void**)value, newValue, sa.size); + else + memcpy(value, newValue, sa.size); +} + +Il2CppMonoMethod* il2cpp_get_interface_method(Il2CppMonoClass* klass, Il2CppMonoClass* itf, int slot) +{ + const VirtualInvokeData* data = il2cpp::vm::Class::GetInterfaceInvokeDataFromVTable((Il2CppClass*)klass, (Il2CppClass*)itf, slot); + if (!data) + return NULL; + + return (Il2CppMonoMethod*)data->method; +} + +gboolean il2cpp_field_is_deleted(Il2CppMonoClassField *field) +{ + return il2cpp::vm::Field::IsDeleted((FieldInfo*)field); +} + +int il2cpp_generic_container_get_type_argc(Il2CppMonoGenericClass* container) +{ + return ((Il2CppGenericContainer*)container)->type_argc; +} + +Il2CppMonoGenericClass* il2cpp_type_get_generic_class(Il2CppMonoType *type) +{ + return (Il2CppMonoGenericClass*)((Il2CppType*)type)->data.generic_class; +} + +gboolean il2cpp_class_get_enumtype(Il2CppMonoClass *klass) +{ + return ((Il2CppClass*)klass)->enumtype; +} + +struct TypeIterState +{ + il2cpp::vm::AssemblyVector* assemblies; + il2cpp::vm::AssemblyVector::iterator assembly; + Il2CppImage* image; + il2cpp::vm::TypeVector types; + il2cpp::vm::TypeVector::iterator type; +}; + +Il2CppMonoClass* il2cpp_iterate_loaded_classes(void* *iter) +{ + if (!iter) + return NULL; + + if (!*iter) + { + TypeIterState *state = new TypeIterState(); + state->assemblies = il2cpp::vm::Assembly::GetAllAssemblies(); + state->assembly = state->assemblies->begin(); + state->image = il2cpp::vm::Assembly::GetImage(*state->assembly); + il2cpp::vm::Image::GetTypes(state->image, true, &state->types); + state->type = state->types.begin(); + *iter = state; + return (Il2CppMonoClass*)*state->type; + } + + TypeIterState *state = (TypeIterState*)*iter; + + state->type++; + if (state->type == state->types.end()) + { + state->assembly++; + if (state->assembly == state->assemblies->end()) + { + delete state; + *iter = NULL; + return NULL; + } + + state->image = il2cpp::vm::Assembly::GetImage(*state->assembly); + il2cpp::vm::Image::GetTypes(state->image, true, &state->types); + state->type = state->types.begin(); + } + + return (Il2CppMonoClass*)*state->type; +} + +const char** il2cpp_get_source_files_for_type(Il2CppMonoClass *klass, int *count) +{ + return il2cpp::utils::Debugger::GetTypeSourceFiles((Il2CppClass*)klass, *count); +} + +Il2CppMonoMethod* il2cpp_method_get_generic_definition(Il2CppMonoMethodInflated *imethod) +{ + MethodInfo *method = (MethodInfo*)imethod; + + if (!method->is_inflated || method->is_generic) + return NULL; + + return (Il2CppMonoMethod*)((MethodInfo*)imethod)->genericMethod->methodDefinition; +} + + +Il2CppMonoGenericInst* il2cpp_method_get_generic_class_inst(Il2CppMonoMethodInflated *imethod) +{ + MethodInfo *method = (MethodInfo*)imethod; + + if (!method->is_inflated || method->is_generic) + return NULL; + + return (Il2CppMonoGenericInst*)method->genericMethod->context.class_inst; +} + +Il2CppMonoClass* il2cpp_generic_class_get_container_class(Il2CppMonoGenericClass *gclass) +{ + return (Il2CppMonoClass*)il2cpp::vm::GenericClass::GetTypeDefinition((Il2CppGenericClass*)gclass); +} + + +Il2CppMonoClass* il2cpp_mono_get_string_class (void) +{ + return (Il2CppMonoClass*)il2cpp_defaults.string_class; +} + +} + +#endif // RUNTIME_IL2CPP diff --git a/mono/mini/mini-unity.c b/mono/mini/mini-unity.c new file mode 100644 index 000000000000..84cd5567bbb4 --- /dev/null +++ b/mono/mini/mini-unity.c @@ -0,0 +1,32 @@ +#include +#include + +#ifdef WIN32 + +extern LONG CALLBACK seh_vectored_exception_handler(EXCEPTION_POINTERS* ep); +LONG mono_unity_seh_handler(EXCEPTION_POINTERS* ep) +{ +#if defined(TARGET_X86) || defined(TARGET_AMD64) + return seh_vectored_exception_handler(ep); +#else + g_assert_not_reached(); +#endif +} + +int (*gUnhandledExceptionHandler)(EXCEPTION_POINTERS*) = NULL; + +void mono_unity_set_unhandled_exception_handler(void* handler) +{ + gUnhandledExceptionHandler = handler; +} + +#endif // WIN32 + +extern gboolean unity_shutting_down; + +MONO_API void +mono_unity_jit_cleanup (MonoDomain *domain) +{ + unity_shutting_down = TRUE; + mono_jit_cleanup (domain); +} diff --git a/mono/mini/pmip_my_callstack.c b/mono/mini/pmip_my_callstack.c new file mode 100644 index 000000000000..6e7cdcb23338 --- /dev/null +++ b/mono/mini/pmip_my_callstack.c @@ -0,0 +1,134 @@ +#include "pmip_my_callstack.h" +#include "mono/metadata/mono-debug.h" + +static char * +pmip_pretty(MonoMethod* method) +{ + char *lineNumber; + char* filePath; + char* methodName; + char* assemblyName; + char* formattedPMIP; + MonoDebugSourceLocation* debugSourceLocation; + MonoDebugMethodInfo* debugMethodInfo; + MonoDomain *domain; + + domain = mono_domain_get(); + if (!domain) + domain = mono_get_root_domain(); + + methodName = mono_method_full_name(method, TRUE); + + debugSourceLocation = mono_debug_lookup_source_location(method, 0, domain); + debugMethodInfo = mono_debug_lookup_method(method); + + assemblyName = method->klass->image->module_name; + lineNumber = debugSourceLocation ? g_strdup_printf("%d", debugSourceLocation->row) : g_strdup(""); + filePath = debugSourceLocation ? g_strdup(debugSourceLocation->source_file) : g_strdup(""); + + formattedPMIP = g_strdup_printf("[%s] %s Line %s File %s", assemblyName, methodName, lineNumber, filePath); + + mono_debug_free_source_location(debugSourceLocation); + g_free(methodName); + g_free(lineNumber); + g_free(filePath); + + return formattedPMIP; +} + +#if !defined(DISABLE_JIT) && defined(HOST_WIN32) + +static gboolean enabled; +static mono_mutex_t mutex; +static FILE* fd; + +#define pmip_my_callstack_lock() mono_os_mutex_lock (&mutex) +#define pmip_my_callstack_unlock() mono_os_mutex_unlock (&mutex) + +void +mono_pmip_my_callstack_init (const char *options) +{ + char* file_name = g_strdup_printf("pmip.%d", GetCurrentProcessId()); + char* path = g_build_filename(g_get_tmp_dir(), file_name, NULL); + + mono_os_mutex_init_recursive(&mutex); + + fd = _fsopen(path, "w", _SH_DENYNO); + + g_free(file_name); + g_free(path); + + if (fd) + enabled = TRUE; +} + +void +mono_pmip_my_callstack_save_method_info (MonoCompile *cfg) +{ + char* pretty_name; + + if (!enabled) + return; + + pretty_name = pmip_pretty(cfg->method); + + pmip_my_callstack_lock (); + fprintf(fd, "%p;%p;%s\n", cfg->native_code, ((char*)cfg->native_code) + cfg->code_size, pretty_name); + fflush (fd); + pmip_my_callstack_unlock (); + + g_free(pretty_name); +} + +void +mono_pmip_my_callstack_remove_method (MonoDomain *domain, MonoMethod *method, MonoJitDynamicMethodInfo *info) +{ +} + +void +mono_pmip_my_callstack_save_trampoline_info (MonoTrampInfo *info) +{ + if (!enabled) + return; + + pmip_my_callstack_lock (); + fprintf (fd, "%p;%p;%s\n", info->code, ((char*)info->code) + info->code_size, info->name ? info->name : ""); + fflush (fd); + pmip_my_callstack_unlock (); +} + +void +mono_pmip_my_callstack_save_specific_trampoline_info (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, gpointer code, guint32 code_len) +{ + +} + +#else + +void +mono_pmip_my_callstack_init (const char *options) +{ + g_error ("Only Available On Windows With Jit Enabled"); +} + +void +mono_pmip_my_callstack_save_method_info (MonoCompile *cfg) +{ +} + +void +mono_pmip_my_callstack_save_trampoline_info (MonoTrampInfo *info) +{ +} + +void +mono_pmip_my_callstack_remove_method (MonoDomain *domain, MonoMethod *method, MonoJitDynamicMethodInfo *info) +{ +} + +void +mono_pmip_my_callstack_save_specific_trampoline_info (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, gpointer code, guint32 code_len) +{ +} + +#endif diff --git a/mono/mini/pmip_my_callstack.h b/mono/mini/pmip_my_callstack.h new file mode 100644 index 000000000000..b7984db0d24e --- /dev/null +++ b/mono/mini/pmip_my_callstack.h @@ -0,0 +1,17 @@ +#ifndef __MONO_PMIP_MY_CALLSTACK_H__ +#define __MONO_PMIP_MY_CALLSTACK_H__ + +#include "config.h" +#include "mini.h" + +void mono_pmip_my_callstack_init (const char *options); + +void mono_pmip_my_callstack_save_method_info (MonoCompile *cfg); + +void mono_pmip_my_callstack_save_trampoline_info (MonoTrampInfo *info); + +void mono_pmip_my_callstack_remove_method (MonoDomain *domain, MonoMethod *method, MonoJitDynamicMethodInfo *info); + +void mono_pmip_my_callstack_save_specific_trampoline_info (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, gpointer code, guint32 code_len); + +#endif diff --git a/mono/utils/gc_wrapper.h b/mono/utils/gc_wrapper.h index 0bc7a45d2254..0e14fbf0a911 100644 --- a/mono/utils/gc_wrapper.h +++ b/mono/utils/gc_wrapper.h @@ -11,7 +11,29 @@ #include #ifdef HAVE_BOEHM_GC +#ifdef HAVE_BDWGC_GC +/* Use unity's updated Boehm GC from IL2CPP */ +#define ALL_INTERIOR_POINTERS 1 +#define GC_GCJ_SUPPORT 1 +#define JAVA_FINALIZATION 1 +#define NO_EXECUTE_PERMISSION 1 +#define GC_NO_THREADS_DISCOVERY 1 +#define IGNORE_DYNAMIC_LOADING 1 +#define GC_DONT_REGISTER_MAIN_STATIC_DATA 1 +#define GC_VERSION_MAJOR 7 +#define GC_VERSION_MINOR 4 +#define GC_VERSION_MICRO 0 +#define GC_THREADS 1 +#define USE_MMAP 1 +#define USE_MUNMAP 1 +#define GC_EventType GCEventType + +# include +# include +# include +#else /* HAVE_BDWGC_GC */ +/*Use Mono's Boehm */ # ifdef _MSC_VER # include # else @@ -48,6 +70,7 @@ #if defined(HOST_WIN32) #define CreateThread GC_CreateThread #endif +#endif /* HAVE_BDWGC_GC */ #elif defined(HAVE_SGEN_GC) diff --git a/mono/utils/mono-compiler.h b/mono/utils/mono-compiler.h index f659cdeaf1d6..51439b5f6d67 100644 --- a/mono/utils/mono-compiler.h +++ b/mono/utils/mono-compiler.h @@ -36,7 +36,9 @@ #endif #include +#if _MSC_VER < 1900 /* VS 2015 */ #define trunc(x) (((x) < 0) ? ceil((x)) : floor((x))) +#endif #if _MSC_VER < 1800 /* VS 2013 */ #define isnan(x) _isnan(x) #define isinf(x) (_isnan(x) ? 0 : (_fpclass(x) == _FPCLASS_NINF) ? -1 : (_fpclass(x) == _FPCLASS_PINF) ? 1 : 0) diff --git a/mono/utils/mono-dl-unity.c b/mono/utils/mono-dl-unity.c new file mode 100644 index 000000000000..6f3c33e9849f --- /dev/null +++ b/mono/utils/mono-dl-unity.c @@ -0,0 +1,75 @@ +#include +#include "mono/utils/mono-dl.h" + +#if defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS) + +const char* +mono_dl_get_so_prefix (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return NULL; +} + +const char** +mono_dl_get_so_suffixes (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return NULL; +} + +void* +mono_dl_open_file (const char *file, int flags) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return NULL; +} + +void +mono_dl_close_handle (MonoDl *module) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +void* +mono_dl_lookup_symbol_in_process (const char *symbol_name) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return NULL; +} + +void* +mono_dl_lookup_symbol (MonoDl *module, const char *symbol_name) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return NULL; +} + +int +mono_dl_convert_flags (int flags) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +char* +mono_dl_current_error_string (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return NULL; +} + +int +mono_dl_get_executable_path (char *buf, int buflen) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +const char* +mono_dl_get_system_dir (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return NULL; +} + +#endif /* PLATFORM_UNITY && UNITY_USE_PLATFORM_STUBS */ diff --git a/mono/utils/mono-error.c b/mono/utils/mono-error.c index b63be628a46d..aeab3a8762a1 100644 --- a/mono/utils/mono-error.c +++ b/mono/utils/mono-error.c @@ -60,12 +60,16 @@ mono_error_prepare (MonoErrorInternal *error) static MonoClass* get_class (MonoErrorInternal *error) { +#ifndef RUNTIME_IL2CPP MonoClass *klass = NULL; if (is_managed_exception (error)) klass = mono_object_class (mono_gchandle_get_target (error->exn.instance_handle)); else klass = error->exn.klass; return klass; +#else + g_assert_not_reached (); +#endif } static const char* @@ -115,6 +119,7 @@ mono_error_init (MonoError *error) void mono_error_cleanup (MonoError *oerror) { +#ifndef RUNTIME_IL2CPP MonoErrorInternal *error = (MonoErrorInternal*)oerror; short int orig_error_code = error->error_code; gboolean free_strings = error->flags & MONO_ERROR_FREE_STRINGS; @@ -153,7 +158,9 @@ mono_error_cleanup (MonoError *oerror) g_free ((char*)error->member_signature); error->type_name = error->assembly_name = error->member_name = error->exception_name_space = error->exception_name = error->first_argument = error->member_signature = NULL; error->exn.klass = NULL; - +#else + g_assert_not_reached (); +#endif } gboolean @@ -387,23 +394,31 @@ mono_error_set_field_load (MonoError *oerror, MonoClass *klass, const char *fiel void mono_error_set_bad_image_name (MonoError *oerror, const char *assembly_name, const char *msg_format, ...) { +#ifndef RUNTIME_IL2CPP MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_BAD_IMAGE; mono_error_set_assembly_name (oerror, assembly_name); set_error_message (); +#else + g_assert_not_reached (); +#endif } void mono_error_set_bad_image (MonoError *oerror, MonoImage *image, const char *msg_format, ...) { +#ifndef RUNTIME_IL2CPP MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_BAD_IMAGE; error->assembly_name = image ? mono_image_get_name (image) : ""; set_error_message (); +#else + g_assert_not_reached (); +#endif } void @@ -521,21 +536,29 @@ mono_error_set_invalid_cast (MonoError *oerror) void mono_error_set_exception_instance (MonoError *oerror, MonoException *exc) { +#ifndef RUNTIME_IL2CPP MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_EXCEPTION_INSTANCE; error->exn.instance_handle = mono_gchandle_new (exc ? &exc->object : NULL, FALSE); +#else + g_assert_not_reached (); +#endif } void mono_error_set_exception_handle (MonoError *oerror, MonoExceptionHandle exc) { +#ifndef RUNTIME_IL2CPP MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); error->error_code = MONO_ERROR_EXCEPTION_INSTANCE; error->exn.instance_handle = mono_gchandle_from_handle (MONO_HANDLE_CAST(MonoObject, exc), FALSE); +#else + g_assert_not_reached (); +#endif } void @@ -576,6 +599,7 @@ mono_error_set_argument_null (MonoError *oerror, const char *argument, const cha void mono_error_set_not_verifiable (MonoError *oerror, MonoMethod *method, const char *msg_format, ...) { +#ifndef RUNTIME_IL2CPP MonoErrorInternal *error = (MonoErrorInternal*)oerror; mono_error_prepare (error); @@ -586,6 +610,9 @@ mono_error_set_not_verifiable (MonoError *oerror, MonoMethod *method, const char } set_error_message (); +#else + g_assert_not_reached (); +#endif } @@ -636,6 +663,7 @@ set_message_on_exception (MonoException *exception, MonoErrorInternal *error, Mo MonoException* mono_error_prepare_exception (MonoError *oerror, MonoError *error_out) { +#ifndef RUNTIME_IL2CPP MonoErrorInternal *error = (MonoErrorInternal*)oerror; MonoException* exception = NULL; @@ -677,11 +705,11 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out) break; } } - exception = mono_exception_from_name_four_strings_checked (mono_defaults.corlib, "System", "MissingMethodException", type_name, method_name, signature, message, error_out); + exception = mono_exception_from_name_four_strings_checked (mono_get_corlib (), "System", "MissingMethodException", type_name, method_name, signature, message, error_out); if (exception) set_message_on_exception (exception, error, error_out); } else { - exception = mono_exception_from_name_msg (mono_defaults.corlib, "System", "MissingMethodException", error->full_message); + exception = mono_exception_from_name_msg (mono_get_corlib (), "System", "MissingMethodException", error->full_message); } break; @@ -697,11 +725,11 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out) break; } - exception = mono_exception_from_name_two_strings_checked (mono_defaults.corlib, "System", "MissingFieldException", type_name, field_name, error_out); + exception = mono_exception_from_name_two_strings_checked (mono_get_corlib (), "System", "MissingFieldException", type_name, field_name, error_out); if (exception) set_message_on_exception (exception, error, error_out); } else { - exception = mono_exception_from_name_msg (mono_defaults.corlib, "System", "MissingFieldException", error->full_message); + exception = mono_exception_from_name_msg (mono_get_corlib (), "System", "MissingFieldException", error->full_message); } break; @@ -725,7 +753,7 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out) if (exception && error->full_message != NULL && strcmp (error->full_message, "")) set_message_on_exception (exception, error, error_out); } else { - exception = mono_exception_from_name_msg (mono_defaults.corlib, "System", "TypeLoadException", error->full_message); + exception = mono_exception_from_name_msg (mono_get_corlib (), "System", "TypeLoadException", error->full_message); } break; @@ -749,12 +777,12 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out) if (error->error_code == MONO_ERROR_FILE_NOT_FOUND) exception = mono_exception_from_name_two_strings_checked (mono_get_corlib (), "System.IO", "FileNotFoundException", msg, assembly_name, error_out); else - exception = mono_exception_from_name_two_strings_checked (mono_defaults.corlib, "System", "BadImageFormatException", msg, assembly_name, error_out); + exception = mono_exception_from_name_two_strings_checked (mono_get_corlib (), "System", "BadImageFormatException", msg, assembly_name, error_out); } else { if (error->error_code == MONO_ERROR_FILE_NOT_FOUND) exception = mono_exception_from_name_msg (mono_get_corlib (), "System.IO", "FileNotFoundException", error->full_message); else - exception = mono_exception_from_name_msg (mono_defaults.corlib, "System", "BadImageFormatException", error->full_message); + exception = mono_exception_from_name_msg (mono_get_corlib (), "System", "BadImageFormatException", error->full_message); } break; @@ -785,7 +813,7 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out) mono_error_set_out_of_memory (error_out, "Could not allocate message"); break; } - exception = mono_exception_from_name_msg (mono_defaults.corlib, "System.Security", "VerificationException", message); + exception = mono_exception_from_name_msg (mono_get_corlib (), "System.Security", "VerificationException", message); g_free (message); g_free (type_name); break; @@ -794,7 +822,7 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out) if (!error->exception_name_space || !error->exception_name) mono_error_set_execution_engine (error_out, "MonoError with generic error but no exception name was supplied"); else - exception = mono_exception_from_name_msg (mono_defaults.corlib, error->exception_name_space, error->exception_name, error->full_message); + exception = mono_exception_from_name_msg (mono_get_corlib (), error->exception_name_space, error->exception_name, error->full_message); break; case MONO_ERROR_EXCEPTION_INSTANCE: @@ -808,9 +836,9 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out) case MONO_ERROR_INVALID_PROGRAM: { gboolean lacks_message = error->flags & MONO_ERROR_INCOMPLETE; if (lacks_message) - return mono_exception_from_name_msg (mono_defaults.corlib, "System", "InvalidProgramException", ""); + return mono_exception_from_name_msg (mono_get_corlib (), "System", "InvalidProgramException", ""); else - return mono_exception_from_name_msg (mono_defaults.corlib, "System", "InvalidProgramException", error->full_message); + return mono_exception_from_name_msg (mono_get_corlib (), "System", "InvalidProgramException", error->full_message); } default: mono_error_set_execution_engine (error_out, "Invalid error-code %d", error->error_code); @@ -821,6 +849,10 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out) if (!exception) mono_error_set_out_of_memory (error_out, "Could not allocate exception object"); return exception; +#else + g_assert_not_reached (); + return NULL; +#endif } /* @@ -872,6 +904,7 @@ mono_error_move (MonoError *dest, MonoError *src) MonoErrorBoxed* mono_error_box (const MonoError *ierror, MonoImage *image) { +#ifndef RUNTIME_IL2CPP MonoErrorInternal *from = (MonoErrorInternal*)ierror; /* Don't know how to box a gchandle */ g_assert (!is_managed_exception (from)); @@ -904,6 +937,10 @@ mono_error_box (const MonoError *ierror, MonoImage *image) #undef DUP_STR return box; +#else + g_assert_not_reached (); + return NULL; +#endif } diff --git a/mono/utils/mono-log-unity.c b/mono/utils/mono-log-unity.c new file mode 100644 index 000000000000..daddaf011aec --- /dev/null +++ b/mono/utils/mono-log-unity.c @@ -0,0 +1,24 @@ +#include "mono-logger-internals.h" + +#if defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS) + +void +mono_log_open_syslog(const char *ident, void *userData) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + +} + +void +mono_log_write_syslog(const char *domain, GLogLevelFlags level, mono_bool hdr, const char *message) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +void +mono_log_close_syslog() +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +#endif /* PLATFORM_UNITY && UNITY_USE_PLATFORM_STUBS */ diff --git a/mono/utils/mono-path.c b/mono/utils/mono-path.c index d0dd89b4c0da..66a4a9f90751 100644 --- a/mono/utils/mono-path.c +++ b/mono/utils/mono-path.c @@ -113,7 +113,7 @@ static gchar * resolve_symlink (const char *path) { char *p, *concat, *dir; - char buffer [PATH_MAX+1]; + char buffer [/*PATH_MAX+1*/ 257]; int n, iterations = 0; p = g_strdup (path); diff --git a/mono/utils/mono-publib.h b/mono/utils/mono-publib.h index 14613b2bee01..19f804059320 100644 --- a/mono/utils/mono-publib.h +++ b/mono/utils/mono-publib.h @@ -67,6 +67,8 @@ typedef unsigned __int64 uint64_t; #define MONO_API #endif +#define UNITY_MONO_API MONO_API + typedef int32_t mono_bool; typedef uint8_t mono_byte; typedef uint16_t mono_unichar2; diff --git a/mono/utils/mono-threads-posix.c b/mono/utils/mono-threads-posix.c index 6804024e156a..e89c9504c037 100644 --- a/mono/utils/mono-threads-posix.c +++ b/mono/utils/mono-threads-posix.c @@ -22,9 +22,11 @@ #include +/* #if defined(HOST_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64) #define USE_TKILL_ON_ANDROID 1 #endif +*/ #ifdef USE_TKILL_ON_ANDROID extern int tkill (pid_t tid, int signal); @@ -76,7 +78,11 @@ mono_thread_platform_create_thread (MonoThreadStart thread_fn, gpointer thread_d #endif /* HAVE_PTHREAD_ATTR_SETSTACKSIZE */ /* Actually start the thread */ +#ifdef RUNTIME_IL2CPP + res = pthread_create (&thread, &attr, (gpointer (*)(gpointer)) thread_fn, thread_data); +#else res = mono_gc_pthread_create (&thread, &attr, (gpointer (*)(gpointer)) thread_fn, thread_data); +#endif if (res) { res = pthread_attr_destroy (&attr); if (res != 0) diff --git a/mono/utils/mono-threads-unity.c b/mono/utils/mono-threads-unity.c new file mode 100644 index 000000000000..b2bacccc251a --- /dev/null +++ b/mono/utils/mono-threads-unity.c @@ -0,0 +1,171 @@ +#include + +#if defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS) + +void +mono_threads_suspend_init (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +gboolean +mono_threads_suspend_begin_async_suspend (MonoThreadInfo *info, gboolean interrupt_kernel) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +gboolean +mono_threads_suspend_check_suspend_result (MonoThreadInfo *info) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +void +mono_threads_suspend_abort_syscall (MonoThreadInfo *info) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +gboolean +mono_threads_suspend_needs_abort_syscall (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +gboolean +mono_threads_suspend_begin_async_resume (MonoThreadInfo *info) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +void +mono_threads_suspend_register (MonoThreadInfo *info) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +void +mono_threads_suspend_free (MonoThreadInfo *info) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +void +mono_threads_suspend_init_signals (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +gint +mono_threads_suspend_search_alternative_signal (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + g_assert_not_reached (); +} + +gint +mono_threads_suspend_get_suspend_signal (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return -1; +} + +gint +mono_threads_suspend_get_restart_signal (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return -1; +} + +gint +mono_threads_suspend_get_abort_signal (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return -1; +} + +int +mono_threads_platform_create_thread (MonoThreadStart thread_fn, gpointer thread_data, gsize* const stack_size, MonoNativeThreadId *out_tid) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return-1; +} + + +MonoNativeThreadId +mono_native_thread_id_get (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +gboolean +mono_native_thread_id_equals (MonoNativeThreadId id1, MonoNativeThreadId id2) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +gboolean +mono_native_thread_create (MonoNativeThreadId *tid, gpointer func, gpointer arg) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +gboolean +mono_native_thread_join (MonoNativeThreadId tid) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +void +mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +void +mono_threads_platform_init (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +gboolean +mono_threads_platform_in_critical_region (MonoNativeThreadId tid) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +gboolean +mono_threads_platform_yield (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +void +mono_threads_platform_exit (gsize exit_code) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +int +mono_threads_get_max_stack_size (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +void +mono_native_thread_set_name (MonoNativeThreadId tid, const char *name) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +#endif //PLATFORM_UNITY && UNITY_USE_PLATFORM_STUBS diff --git a/mono/utils/networking-unity.c b/mono/utils/networking-unity.c new file mode 100644 index 000000000000..f37b3d662090 --- /dev/null +++ b/mono/utils/networking-unity.c @@ -0,0 +1,47 @@ +#include + +#if defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS) + +int +mono_get_address_info (const char *hostname, int port, int flags, MonoAddressInfo **result) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +void * +mono_get_local_interfaces (int family, int *interface_count) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return NULL; +} + +gboolean +mono_networking_addr_to_str (MonoAddress *address, char *buffer, socklen_t buflen) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return FALSE; +} + +int +mono_networking_get_tcp_protocol (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +int +mono_networking_get_ip_protocol (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +int +mono_networking_get_ipv6_protocol (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return 0; +} + +#endif /* PLATFORM_UNITY && UNITY_USE_PLATFORM_STUBS */ diff --git a/mono/utils/os-event-unity.c b/mono/utils/os-event-unity.c new file mode 100644 index 000000000000..94409c191356 --- /dev/null +++ b/mono/utils/os-event-unity.c @@ -0,0 +1,43 @@ +#include "os-event.h" + +#if defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS) + +void +mono_os_event_init (MonoOSEvent *event, gboolean initial) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +void +mono_os_event_destroy (MonoOSEvent *event) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +void +mono_os_event_set (MonoOSEvent *event) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +void +mono_os_event_reset (MonoOSEvent *event) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +MonoOSEventWaitRet +mono_os_event_wait_one (MonoOSEvent *event, guint32 timeout, gboolean alertable) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return MONO_OS_EVENT_WAIT_RET_TIMEOUT; +} + +MonoOSEventWaitRet +mono_os_event_wait_multiple (MonoOSEvent **events, gsize nevents, gboolean waitall, guint32 timeout, gboolean alertable) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); + return MONO_OS_EVENT_WAIT_RET_TIMEOUT; +} + +#endif /* PLATFORM_UNITY && UNITY_USE_PLATFORM_STUBS */ diff --git a/mono/utils/unity-rand.c b/mono/utils/unity-rand.c new file mode 100644 index 000000000000..37b67bc1014a --- /dev/null +++ b/mono/utils/unity-rand.c @@ -0,0 +1,96 @@ +/* + * mono-rand-unity.c: + * + */ + + +#include +#include "mono-error.h" +#include + +/** + * mono_rand_open: + * + * Returns: True if random source is global, false if mono_rand_init can be called repeatedly to get randomness instances. + * + * Initializes entire RNG system. Must be called once per process before calling mono_rand_init. + */ +gboolean mono_rand_open (void) +{ + return UnityPalOpenCryptographyProvider(); +} + +/** + * mono_rand_init: + * @seed: A string containing seed data + * @seed_size: Length of seed string + * + * Returns: On success, a non-NULL handle which can be used to fetch random data from mono_rand_try_get_bytes. On failure, NULL. + * + * Initializes an RNG client. + */ +gpointer +mono_rand_init (guchar *seed, gint seed_size) +{ + return UnityPalGetCryptographyProvider(); +} + +/** + * mono_rand_try_get_bytes: + * @handle: A pointer to an RNG handle. Handle is set to NULL on failure. + * @buffer: A buffer into which to write random data. + * @buffer_size: Number of bytes to write into buffer. + * @error: Set on error. + * + * Returns: FALSE on failure and sets @error, TRUE on success. + * + * Extracts bytes from an RNG handle. + */ +gboolean +mono_rand_try_get_bytes (gpointer *handle, guchar *buffer, gint buffer_size, MonoError *error) +{ + mono_error_init (error); + return UnityPalCryptographyFillBufferWithRandomBytes(*handle, buffer_size, buffer); +} + +/** + * mono_rand_close: + * @handle: An RNG handle. + * @buffer: A buffer into which to write random data. + * @buffer_size: Number of bytes to write into buffer. + * + * Releases an RNG handle. + */ +void +mono_rand_close (gpointer handle) +{ + UnityPalReleaseCryptographyProvider(handle); +} + + +/** + * mono_rand_try_get_uint32: + * @handle: A pointer to an RNG handle. Handle is set to NULL on failure. + * @val: A pointer to a 32-bit unsigned int, to which the result will be written. + * @min: Result will be greater than or equal to this value. + * @max: Result will be less than or equal to this value. + * + * Returns: FALSE on failure, TRUE on success. + * + * Extracts one 32-bit unsigned int from an RNG handle. + */ +gboolean +mono_rand_try_get_uint32 (gpointer *handle, guint32 *val, guint32 min, guint32 max, MonoError *error) +{ + g_assert (val); + if (!mono_rand_try_get_bytes (handle, (guchar*) val, sizeof (guint32), error)) + return FALSE; + + double randomDouble = ((gdouble) *val) / ( ((double)G_MAXUINT32) + 1 ); // Range is [0,1) + *val = (guint32) (randomDouble * (max - min + 1) + min); + + g_assert (*val >= min); + g_assert (*val <= max); + + return TRUE; +} diff --git a/mono/utils/unity-time.c b/mono/utils/unity-time.c new file mode 100644 index 000000000000..0d0b1b4b0d2e --- /dev/null +++ b/mono/utils/unity-time.c @@ -0,0 +1,45 @@ +#include +#include + +#include + +#ifdef HAVE_SYS_TIME_H + #include +#endif + +#include "Time-c-api.h" + +gint64 +mono_msec_ticks (void) +{ + return (gint64) UnityPalGetTicksMillisecondsMonotonic(); +} + +/* Returns the number of 100ns ticks from unspecified time: this should be monotonic */ +gint64 +mono_100ns_ticks (void) +{ + return (gint64) UnityPalGetTicks100NanosecondsMonotonic(); +} + +/* Returns the number of 100ns ticks since 1/1/1601, UTC timezone */ +gint64 +mono_100ns_datetime (void) +{ + return (gint64) UnityPalGetTicks100NanosecondsDateTime(); +} + +gint64 +mono_msec_boottime (void) +{ + return (gint64) UnityPalGetTicksMillisecondsMonotonic(); +} + +#ifndef HOST_WIN32 +gint64 mono_100ns_datetime_from_timeval (struct timeval tv) +{ + g_assert_not_reached(); + return 0; +} +#endif + diff --git a/msvc/.gitignore b/msvc/.gitignore index bcd711d0f5a8..423fe4bf689c 100644 --- a/msvc/.gitignore +++ b/msvc/.gitignore @@ -13,3 +13,4 @@ mono.VC.db /package/ /build/ /dist/ +/.vs/ diff --git a/msvc/libgcbdwgc.vcxproj b/msvc/libgcbdwgc.vcxproj new file mode 100644 index 000000000000..3adf562efea5 --- /dev/null +++ b/msvc/libgcbdwgc.vcxproj @@ -0,0 +1,170 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {CF169633-14AF-4DB8-BEF9-26A6C8FE4C90} + libgcbdwgc + Win32Proj + 8.1 + libgcbdwgc + + + + StaticLibrary + Unicode + v140 + + + StaticLibrary + Unicode + v140 + + + StaticLibrary + Unicode + v140 + + + StaticLibrary + Unicode + v140 + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(MONO_BUILD_DIR_PREFIX)$(Platform)\lib\$(Configuration)\ + $(MONO_BUILD_DIR_PREFIX)$(Platform)\obj\$(ProjectName)\$(Configuration)\ + $(MONO_BUILD_DIR_PREFIX)$(Platform)\lib\$(Configuration)\ + $(MONO_BUILD_DIR_PREFIX)$(Platform)\obj\$(ProjectName)\$(Configuration)\ + $(MONO_BUILD_DIR_PREFIX)$(Platform)\lib\$(Configuration)\ + $(MONO_BUILD_DIR_PREFIX)$(Platform)\obj\$(ProjectName)\$(Configuration)\ + $(MONO_BUILD_DIR_PREFIX)$(Platform)\lib\$(Configuration)\ + $(MONO_BUILD_DIR_PREFIX)$(Platform)\obj\$(ProjectName)\$(Configuration)\ + + + $(VC_IncludePath);$(WindowsSDK_IncludePath); + + + + Disabled + $(MONO_LIBBDWGC_INCLUDE_DIR);$(MONO_LIBATOMICS_INCLUDE_DIR);%(AdditionalIncludeDirectories) + WIN32_THREADS;ALL_INTERIOR_POINTERS=1;GC_GCJ_SUPPORT=1;JAVA_FINALIZATION=1;NO_EXECUTE_PERMISSION=1;GC_NO_THREADS_DISCOVERY=1;IGNORE_DYNAMIC_LOADING=1;GC_DONT_REGISTER_MAIN_STATIC_DATA=1;GC_VERSION_MAJOR=7;GC_VERSION_MINOR=4;GC_VERSION_MICRO=0;GC_THREADS=1;USE_MMAP=1;USE_MUNMAP=1;GC_INSIDE_DLL=1 + true + EnableFastChecks + + + ProgramDatabase + CompileAsC + 4311;4312;4996;4005;%(DisableSpecificWarnings) + Level1 + $(IntDir)$(TargetName).pdb + + + + + $(OutDir)$(TargetName)$(TargetExt) + + + + + MinSpace + $(MONO_LIBBDWGC_INCLUDE_DIR);$(MONO_LIBATOMICS_INCLUDE_DIR);%(AdditionalIncludeDirectories) + WIN32_THREADS;ALL_INTERIOR_POINTERS=1;GC_GCJ_SUPPORT=1;JAVA_FINALIZATION=1;NO_EXECUTE_PERMISSION=1;GC_NO_THREADS_DISCOVERY=1;IGNORE_DYNAMIC_LOADING=1;GC_DONT_REGISTER_MAIN_STATIC_DATA=1;GC_VERSION_MAJOR=7;GC_VERSION_MINOR=4;GC_VERSION_MICRO=0;GC_THREADS=1;USE_MMAP=1;USE_MUNMAP=1; + + + ProgramDatabase + CompileAsC + $(IntDir)$(TargetName).pdb + + + + + $(OutDir)$(TargetName)$(TargetExt) + + + + + X64 + + + Disabled + $(MONO_LIBBDWGC_INCLUDE_DIR);$(MONO_LIBATOMICS_INCLUDE_DIR);%(AdditionalIncludeDirectories) + WIN32_THREADS;ALL_INTERIOR_POINTERS=1;GC_GCJ_SUPPORT=1;JAVA_FINALIZATION=1;NO_EXECUTE_PERMISSION=1;GC_NO_THREADS_DISCOVERY=1;IGNORE_DYNAMIC_LOADING=1;GC_DONT_REGISTER_MAIN_STATIC_DATA=1;GC_VERSION_MAJOR=7;GC_VERSION_MINOR=4;GC_VERSION_MICRO=0;GC_THREADS=1;USE_MMAP=1;USE_MUNMAP=1; + true + EnableFastChecks + + + ProgramDatabase + CompileAsC + 4311;4312;4996;4005;%(DisableSpecificWarnings) + $(IntDir)$(TargetName).pdb + + + + + $(OutDir)$(TargetName)$(TargetExt) + + + + + X64 + + + MinSpace + $(MONO_LIBBDWGC_INCLUDE_DIR);$(MONO_LIBATOMICS_INCLUDE_DIR);%(AdditionalIncludeDirectories) + WIN32_THREADS;ALL_INTERIOR_POINTERS=1;GC_GCJ_SUPPORT=1;JAVA_FINALIZATION=1;NO_EXECUTE_PERMISSION=1;GC_NO_THREADS_DISCOVERY=1;IGNORE_DYNAMIC_LOADING=1;GC_DONT_REGISTER_MAIN_STATIC_DATA=1;GC_VERSION_MAJOR=7;GC_VERSION_MINOR=4;GC_VERSION_MICRO=0;GC_THREADS=1;USE_MMAP=1;USE_MUNMAP=1; + + + ProgramDatabase + CompileAsC + $(IntDir)$(TargetName).pdb + + + + + $(OutDir)$(TargetName)$(TargetExt) + + + + + + + + + \ No newline at end of file diff --git a/msvc/libgcbdwgc.vcxproj.filters b/msvc/libgcbdwgc.vcxproj.filters new file mode 100644 index 000000000000..5b782e942120 --- /dev/null +++ b/msvc/libgcbdwgc.vcxproj.filters @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/msvc/libmini-unity.targets b/msvc/libmini-unity.targets new file mode 100644 index 000000000000..bf51e51a9b1e --- /dev/null +++ b/msvc/libmini-unity.targets @@ -0,0 +1,6 @@ + + + + + + diff --git a/msvc/libmini-unity.targets.filters b/msvc/libmini-unity.targets.filters new file mode 100644 index 000000000000..89b85f1a05df --- /dev/null +++ b/msvc/libmini-unity.targets.filters @@ -0,0 +1,13 @@ + + + + + Source Files$(MonoMiniFilterSubFolder)\unity + + + + + {A8B401A4-3AAA-431C-90B2-9834DAFF7D84} + + + diff --git a/msvc/libmini.targets b/msvc/libmini.targets index 5202159d86ec..e7a1b046d4f4 100644 --- a/msvc/libmini.targets +++ b/msvc/libmini.targets @@ -6,4 +6,5 @@ + diff --git a/msvc/libmini.targets.filters b/msvc/libmini.targets.filters index 972f58bf8616..5c6f247cbbe1 100644 --- a/msvc/libmini.targets.filters +++ b/msvc/libmini.targets.filters @@ -6,6 +6,7 @@ + {b64924de-7e02-416b-9779-4cc7fe0270e6} diff --git a/msvc/libmono-dynamic.vcxproj b/msvc/libmono-dynamic.vcxproj index 186bd7ffc316..3743f43468ed 100644 --- a/msvc/libmono-dynamic.vcxproj +++ b/msvc/libmono-dynamic.vcxproj @@ -113,7 +113,7 @@ false - $(GC_LIB);%(AdditionalDependencies) + $(GC_LIB);%(AdditionalDependencies) %(AdditionalLibraryDirectories) @@ -152,7 +152,7 @@ false - $(GC_LIB);%(AdditionalDependencies) + $(GC_LIB);%(AdditionalDependencies) %(AdditionalLibraryDirectories) @@ -183,7 +183,7 @@ - $(GC_LIB);%(AdditionalDependencies) + $(GC_LIB);%(AdditionalDependencies) %(AdditionalLibraryDirectories) @@ -222,7 +222,7 @@ - $(GC_LIB);%(AdditionalDependencies) + $(GC_LIB);%(AdditionalDependencies) %(AdditionalLibraryDirectories) diff --git a/msvc/libmono-static.vcxproj b/msvc/libmono-static.vcxproj index 0c606ddb6af1..558325428785 100644 --- a/msvc/libmono-static.vcxproj +++ b/msvc/libmono-static.vcxproj @@ -201,6 +201,9 @@ {eb56000b-c80b-4e8b-908d-d84d31b517d3} + + {CF169633-14AF-4DB8-BEF9-26A6C8FE4C90} + {c36612bd-22d3-4b95-85e2-7fdc4fc5d740} diff --git a/msvc/libmonoruntime-unity.targets b/msvc/libmonoruntime-unity.targets new file mode 100644 index 000000000000..1537b0610a30 --- /dev/null +++ b/msvc/libmonoruntime-unity.targets @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/msvc/libmonoruntime-unity.targets.filters b/msvc/libmonoruntime-unity.targets.filters new file mode 100644 index 000000000000..ebfb58fe7014 --- /dev/null +++ b/msvc/libmonoruntime-unity.targets.filters @@ -0,0 +1,28 @@ + + + + + Source Files$(MonoRuntimeFilterSubFolder)\unity + + + Source Files$(MonoRuntimeFilterSubFolder)\unity + + + Header Files$(MonoRuntimeFilterSubFolder)\unity + + + Source Files$(MonoRuntimeFilterSubFolder)\unity + + + Header Files$(MonoRuntimeFilterSubFolder)\unity + + + + + {8F21E3A7-2BB9-403D-8339-DE0C45C84CCB} + + + {A38D033E-5AFC-4BEB-9F12-9A76F00E7749} + + + diff --git a/msvc/libmonoruntime.targets b/msvc/libmonoruntime.targets index 3dcf845605ab..cde45a537b1f 100644 --- a/msvc/libmonoruntime.targets +++ b/msvc/libmonoruntime.targets @@ -3,4 +3,5 @@ + diff --git a/msvc/libmonoruntime.targets.filters b/msvc/libmonoruntime.targets.filters index 2653ecb2d840..8787fa1d7e8c 100644 --- a/msvc/libmonoruntime.targets.filters +++ b/msvc/libmonoruntime.targets.filters @@ -3,6 +3,7 @@ + {992766FD-0584-4B49-A4F7-B59947CD8488} diff --git a/msvc/mono.props b/msvc/mono.props index c9bd97e59e98..b96720b8871a 100644 --- a/msvc/mono.props +++ b/msvc/mono.props @@ -6,13 +6,13 @@ $(MSBuildProjectDirectory)/./dist/ - sgen + bdwgc true true - false + true false @@ -25,9 +25,11 @@ $(MONO_DIR)/mono/eglib $(MONO_DIR)/libgc/include $(MONO_DIR)/libgc/src + $(MONO_DIR)/external/bdwgc/include + $(MONO_DIR)/external/bdwgc/src + $(MONO_DIR)/external/bdwgc/libatomic_ops/src $(MONO_INCLUDE_DIR)/jit $(MONO_INCLUDE_DIR)/jit - $(MONO_LIBGC_INCLUDE_DIR) $(MONO_EGLIB_SOURCE_DIR) @@ -38,7 +40,7 @@ MultiThreadedDebugDLL MultiThreadedDLL - + HAVE_SGEN_GC;HAVE_MOVING_COLLECTOR;HAVE_WRITE_BARRIERS;HAVE_CONC_GC_AS_DEFAULT $(SGEN_DEFINES) libgcmonosgen.lib @@ -49,8 +51,16 @@ HAVE_BOEHM_GC $(BOEHM_DEFINES) libgc.lib + $(MONO_LIBGC_INCLUDE_DIR) -boehm $(MONO_BUILD_DIR_PREFIX)boehm/ + + + HAVE_BDWGC_GC;HAVE_BOEHM_GC + libgcbdwgc.lib + $(MONO_LIBBDWGC_INCLUDE_DIR);$(MONO_LIBATOMICS_INCLUDE_DIR) + -bdwgc + $(MONO_BUILD_DIR_PREFIX)bdwgc/ libmonoutils.lib;libmonoruntime$(MONO_TARGET_SUFFIX).lib;libmini$(MONO_TARGET_SUFFIX).lib;$(GC_LIB) diff --git a/msvc/mono.sln b/msvc/mono.sln index ac103fb6ea69..184a1931d829 100644 --- a/msvc/mono.sln +++ b/msvc/mono.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.15 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EmbeddedSamples", "EmbeddedSamples", "{5FE09AA5-C3C9-45EA-A323-36A11B653CEC}" EndProject @@ -194,6 +194,11 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmini", "libmini.vcxproj", "{88D2EB79-592D-45F8-B849-AE021C1D983A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libmono-dynamic", "libmono-dynamic.vcxproj", "{675F4175-FFB1-480D-AD36-F397578844D4}" + ProjectSection(ProjectDependencies) = postProject + {CF169633-14AF-4DB8-BEF9-26A6C8FE4C90} = {CF169633-14AF-4DB8-BEF9-26A6C8FE4C90} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libgcbdwgc", "libgcbdwgc.vcxproj", "{CF169633-14AF-4DB8-BEF9-26A6C8FE4C90}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -411,6 +416,14 @@ Global {675F4175-FFB1-480D-AD36-F397578844D4}.Release|Win32.Build.0 = Release|Win32 {675F4175-FFB1-480D-AD36-F397578844D4}.Release|x64.ActiveCfg = Release|x64 {675F4175-FFB1-480D-AD36-F397578844D4}.Release|x64.Build.0 = Release|x64 + {CF169633-14AF-4DB8-BEF9-26A6C8FE4C90}.Debug|Win32.ActiveCfg = Debug|Win32 + {CF169633-14AF-4DB8-BEF9-26A6C8FE4C90}.Debug|Win32.Build.0 = Debug|Win32 + {CF169633-14AF-4DB8-BEF9-26A6C8FE4C90}.Debug|x64.ActiveCfg = Debug|x64 + {CF169633-14AF-4DB8-BEF9-26A6C8FE4C90}.Debug|x64.Build.0 = Debug|x64 + {CF169633-14AF-4DB8-BEF9-26A6C8FE4C90}.Release|Win32.ActiveCfg = Release|Win32 + {CF169633-14AF-4DB8-BEF9-26A6C8FE4C90}.Release|Win32.Build.0 = Release|Win32 + {CF169633-14AF-4DB8-BEF9-26A6C8FE4C90}.Release|x64.ActiveCfg = Release|x64 + {CF169633-14AF-4DB8-BEF9-26A6C8FE4C90}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -449,8 +462,10 @@ Global {DC50997D-8A0D-4EB6-849B-9D7FBC39CE53} = {DE3617B4-17A8-4E5F-A00F-BA43D956881F} {88D2EB79-592D-45F8-B849-AE021C1D983A} = {0EBA83B7-0EB4-4C83-A900-77300A97E8B1} {675F4175-FFB1-480D-AD36-F397578844D4} = {DE3617B4-17A8-4E5F-A00F-BA43D956881F} + {CF169633-14AF-4DB8-BEF9-26A6C8FE4C90} = {21DF4C80-0EC9-4BFE-8552-2D47FCEF419A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E4974D6A-1C06-4A4A-BE57-FAE790743A90} AMDCaProjectFile = C:\Users\Owner\Development\monogit\mono\msvc\CodeAnalyst\mono.caw AMDCaPersistentStartup = mono AMDCaPersistentConfig = Debug|Win32 diff --git a/runtime/Makefile.am b/runtime/Makefile.am index 6b8ad6372825..dbb8a2624b0d 100644 --- a/runtime/Makefile.am +++ b/runtime/Makefile.am @@ -56,6 +56,14 @@ if INSTALL_TESTING_AOT_FULL build_profiles += testing_aot_full endif +if INSTALL_UNITYJIT +build_profiles += unityjit +endif + +if INSTALL_UNITYAOT +build_profiles += unityaot +endif + if INSTALL_WINAOT build_profiles += winaot endif From d1fd3bbd6481f8ae745f7996af95c52a41871912 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 28 Nov 2017 08:39:41 -0500 Subject: [PATCH 002/582] Fix merge issue --- mono/metadata/profiler.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/mono/metadata/profiler.h b/mono/metadata/profiler.h index 165c4eaca2f7..56e2d2133c86 100644 --- a/mono/metadata/profiler.h +++ b/mono/metadata/profiler.h @@ -41,17 +41,8 @@ typedef struct { typedef mono_bool (*MonoProfilerCoverageFilterCallback) (MonoProfiler *prof, MonoMethod *method); typedef void (*MonoProfilerCoverageCallback) (MonoProfiler *prof, const MonoProfilerCoverageData *data); -/* - * Retrieves all coverage data for the specified method and invokes the given - * callback for each entry. Source location information will only be filled out - * if the given method has debug info available. Returns TRUE if the given - * method was instrumented for code coverage; otherwise, FALSE. - * - * Please note that the structure passed to the callback is only valid for the - * duration of the callback. - * - * This function is not async safe. - */ +MONO_API mono_bool mono_profiler_enable_coverage (void); +MONO_API void mono_profiler_set_coverage_filter_callback (MonoProfilerHandle handle, MonoProfilerCoverageFilterCallback cb); #ifndef RUNTIME_IL2CPP MONO_API mono_bool mono_profiler_get_coverage_data (MonoProfilerHandle handle, MonoMethod *method, MonoProfilerCoverageCallback cb); #endif From 06c98ab72ce83fb7cdbc17db03b1df5055d0a435 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 28 Nov 2017 09:47:58 -0500 Subject: [PATCH 003/582] Set API_BIN_PROFILE for unity profiles --- mcs/build/profiles/unityaot.make | 1 + mcs/build/profiles/unityjit.make | 1 + 2 files changed, 2 insertions(+) diff --git a/mcs/build/profiles/unityaot.make b/mcs/build/profiles/unityaot.make index 54128f7d25a7..53440db35621 100644 --- a/mcs/build/profiles/unityaot.make +++ b/mcs/build/profiles/unityaot.make @@ -29,6 +29,7 @@ PROFILE_MCS_FLAGS = \ -nostdlib \ $(DEFAULT_REFERENCES) \ $(PLATFORM_DEBUG_FLAGS) +API_BIN_PROFILE = net_4_x FRAMEWORK_VERSION = 2.1 diff --git a/mcs/build/profiles/unityjit.make b/mcs/build/profiles/unityjit.make index 5bc7a4250d6e..8186213f0f35 100644 --- a/mcs/build/profiles/unityjit.make +++ b/mcs/build/profiles/unityjit.make @@ -11,6 +11,7 @@ profile-check: DEFAULT_REFERENCES = -r:$(topdir)/class/lib/$(PROFILE)/mscorlib.dll PROFILE_MCS_FLAGS = -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:UNITY_JIT -d:UNITY -d:WIN_PLATFORM -nowarn:1699 -nostdlib $(DEFAULT_REFERENCES) $(PLATFORM_DEBUG_FLAGS) +API_BIN_PROFILE = net_4_x FRAMEWORK_VERSION = 4.5 XBUILD_VERSION = 4.0 From 950b474d64337a0b50ea827c57a7763e61d44176 Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Tue, 28 Nov 2017 15:49:53 -0500 Subject: [PATCH 004/582] Enable mixed callstack plugin support on unity-master branch (#720) --- mono/mini/Makefile.am.in | 4 +- mono/mini/mini-runtime.c | 5 + mono/mini/mini-trampolines.c | 2 + mono/mini/mini.c | 2 + mono/mini/mixed_callstack_plugin.c | 184 +++++++++++++++++++++++++++++ mono/mini/mixed_callstack_plugin.h | 18 +++ mono/mini/pmip_my_callstack.c | 134 --------------------- mono/mini/pmip_my_callstack.h | 17 --- msvc/libmini-unity.targets | 2 + msvc/libmini-unity.targets.filters | 6 + 10 files changed, 221 insertions(+), 153 deletions(-) create mode 100644 mono/mini/mixed_callstack_plugin.c create mode 100644 mono/mini/mixed_callstack_plugin.h delete mode 100644 mono/mini/pmip_my_callstack.c delete mode 100644 mono/mini/pmip_my_callstack.h diff --git a/mono/mini/Makefile.am.in b/mono/mini/Makefile.am.in index c3bca5a13773..c777a8369caf 100755 --- a/mono/mini/Makefile.am.in +++ b/mono/mini/Makefile.am.in @@ -561,8 +561,8 @@ common_sources = \ type-checking.c \ lldb.h \ lldb.c \ - pmip_my_callstack.h \ - pmip_my_callstack.c \ + mixed_callstack_plugin.h \ + mixed_callstack_plugin.c \ memory-access.c \ mini-profiler.c diff --git a/mono/mini/mini-runtime.c b/mono/mini/mini-runtime.c index a7463e8614da..33eb4c800dd4 100644 --- a/mono/mini/mini-runtime.c +++ b/mono/mini/mini-runtime.c @@ -84,6 +84,7 @@ #include "mini-llvm.h" #include "debugger-agent.h" #include "lldb.h" +#include "mixed_callstack_plugin.h" #ifdef MONO_ARCH_LLVM_SUPPORTED #ifdef ENABLE_LLVM @@ -498,6 +499,7 @@ mono_tramp_info_register_internal (MonoTrampInfo *info, MonoDomain *domain, gboo mono_save_trampoline_xdebug_info (info); mono_lldb_save_trampoline_info (info); + mixed_callstack_plugin_save_trampoline_info (info); #ifdef MONO_ARCH_HAVE_UNWIND_TABLE if (!aot) @@ -3907,6 +3909,9 @@ mini_init (const char *filename, const char *runtime_version) mono_lldb_init (""); mono_dont_free_domains = TRUE; } + if (g_hasenv ("UNITY_MIXED_CALLSTACK")) { + mixed_callstack_plugin_init (""); + } #ifdef XDEBUG_ENABLED char *mono_xdebug = g_getenv ("MONO_XDEBUG"); diff --git a/mono/mini/mini-trampolines.c b/mono/mini/mini-trampolines.c index e15bd5dc6fe7..0c02fcf8bf0c 100644 --- a/mono/mini/mini-trampolines.c +++ b/mono/mini/mini-trampolines.c @@ -21,6 +21,7 @@ #include "mini.h" #include "lldb.h" +#include "mixed_callstack_plugin.h" #ifndef DISABLE_INTERPRETER #include "interp/interp.h" @@ -1384,6 +1385,7 @@ mono_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type, M else code = mono_arch_create_specific_trampoline (arg1, tramp_type, domain, &len); mono_lldb_save_specific_trampoline_info (arg1, tramp_type, domain, code, len); + mixed_callstack_plugin_save_specific_trampoline_info (arg1, tramp_type, domain, code, len); if (code_len) *code_len = len; return code; diff --git a/mono/mini/mini.c b/mono/mini/mini.c index 8ad2f86db6c0..a405a5398d18 100644 --- a/mono/mini/mini.c +++ b/mono/mini/mini.c @@ -78,6 +78,7 @@ #include "llvm-runtime.h" #include "mini-llvm.h" #include "lldb.h" +#include "mixed_callstack_plugin.h" MonoCallSpec *mono_jit_trace_calls; MonoMethodDesc *mono_inject_async_exc_method; @@ -3859,6 +3860,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl if (!cfg->compile_aot) { mono_save_xdebug_info (cfg); mono_lldb_save_method_info (cfg); + mixed_callstack_plugin_save_method_info (cfg); } if (cfg->verbose_level >= 2) { diff --git a/mono/mini/mixed_callstack_plugin.c b/mono/mini/mixed_callstack_plugin.c new file mode 100644 index 000000000000..c4377f008e39 --- /dev/null +++ b/mono/mini/mixed_callstack_plugin.c @@ -0,0 +1,184 @@ +#include "mixed_callstack_plugin.h" +#include "mono/metadata/mono-debug.h" +#include "mono/metadata/profiler.h" + +static char * +pmip_pretty(MonoCompile* monoCompile) +{ + char* methodName; + char* assemblyName; + char* formattedPMIP; + MonoDebugSourceLocation* debugSourceLocation; + MonoDebugMethodInfo* debugMethodInfo; + MonoDomain* domain; + MonoMethod* method = monoCompile->method; + + domain = mono_domain_get(); + if (!domain) + domain = mono_get_root_domain(); + + methodName = mono_method_full_name(method, TRUE); + + debugSourceLocation = mono_debug_lookup_source_location(method, 0, domain); + debugMethodInfo = mono_debug_lookup_method(method); + + assemblyName = method->klass->image->module_name; + + formattedPMIP = g_strdup_printf("[%s] %s", assemblyName, methodName); + + mono_debug_free_source_location(debugSourceLocation); + g_free(methodName); + + return formattedPMIP; +} + +#if !defined(DISABLE_JIT) && defined(HOST_WIN32) + +static gboolean enabled; +static mono_mutex_t mutex; +static HANDLE fileHandle; +int pmipFileNum; + +#define mixed_callstack_plugin_lock() mono_os_mutex_lock (&mutex) +#define mixed_callstack_plugin_unlock() mono_os_mutex_unlock (&mutex) + +void +create_next_pmip_file() +{ + char* file_name = g_strdup_printf("pmip_%d_%d.txt", GetCurrentProcessId(), pmipFileNum++); + char* path = g_build_filename(g_get_tmp_dir(), file_name, NULL); + char* version = "UnityMixedCallstacks:1.0\n"; + long bytesWritten = 0; + + mixed_callstack_plugin_lock (); + + if(fileHandle) + CloseHandle(fileHandle); + + fileHandle = CreateFileA(path, + GENERIC_WRITE, + FILE_SHARE_DELETE | FILE_SHARE_READ, + NULL, + CREATE_ALWAYS, + FILE_FLAG_DELETE_ON_CLOSE, + NULL); + + if (INVALID_HANDLE_VALUE != fileHandle) + enabled = TRUE; + + WriteFile(fileHandle, version, strlen(version), &bytesWritten, NULL); + + mixed_callstack_plugin_unlock (); + + g_free(file_name); + g_free(path); +} + +void +mixed_callstack_plugin_init (const char *options) +{ + pmipFileNum = 0; + + mono_os_mutex_init_recursive(&mutex); + + MonoProfilerHandle prof = mono_profiler_create(NULL); + mono_profiler_set_domain_unloaded_callback(prof, mixed_callstack_plugin_on_domain_unload_end); + + create_next_pmip_file(); +} + +void +mixed_callstack_plugin_on_domain_unload_end() +{ + if(!enabled) + return; + + create_next_pmip_file(); +} + +void +mixed_callstack_plugin_save_method_info (MonoCompile *cfg) +{ + char* pretty_name; + char* frame; + long bytesWritten = 0; + + if (!enabled) + return; + + pretty_name = pmip_pretty(cfg); + + mixed_callstack_plugin_lock (); + frame = g_strdup_printf("%p;%p;%s\n", cfg->native_code, ((char*)cfg->native_code) + cfg->code_size, pretty_name); + WriteFile(fileHandle, frame, strlen(frame), &bytesWritten, NULL); + FlushFileBuffers(fileHandle); + + mixed_callstack_plugin_unlock (); + + g_free(pretty_name); + g_free(frame); +} + +void +mixed_callstack_plugin_remove_method (MonoDomain *domain, MonoMethod *method, MonoJitDynamicMethodInfo *info) +{ +} + +void +mixed_callstack_plugin_save_trampoline_info (MonoTrampInfo *info) +{ + char* frame; + long bytesWritten = 0; + + if (!enabled) + return; + + mixed_callstack_plugin_lock (); + frame = g_strdup_printf ("%p;%p;%s\n", info->code, ((char*)info->code) + info->code_size, info->name ? info->name : ""); + WriteFile(fileHandle, frame, strlen(frame), &bytesWritten, NULL); + FlushFileBuffers(fileHandle); + mixed_callstack_plugin_unlock (); + + g_free(frame); +} + +void +mixed_callstack_plugin_save_specific_trampoline_info (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, gpointer code, guint32 code_len) +{ + +} + +#else + +void +mixed_callstack_plugin_init (const char *options) +{ + g_error ("Only Available On Windows With Jit Enabled"); +} + +void +mixed_callstack_plugin_on_domain_unload_end() +{ +} + +void +mixed_callstack_plugin_save_method_info (MonoCompile *cfg) +{ +} + +void +mixed_callstack_plugin_save_trampoline_info (MonoTrampInfo *info) +{ +} + +void +mixed_callstack_plugin_remove_method (MonoDomain *domain, MonoMethod *method, MonoJitDynamicMethodInfo *info) +{ +} + +void +mixed_callstack_plugin_save_specific_trampoline_info (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, gpointer code, guint32 code_len) +{ +} + +#endif diff --git a/mono/mini/mixed_callstack_plugin.h b/mono/mini/mixed_callstack_plugin.h new file mode 100644 index 000000000000..89935824e7dd --- /dev/null +++ b/mono/mini/mixed_callstack_plugin.h @@ -0,0 +1,18 @@ +#ifndef __MIXED_CALLSTACK_PLUGIN_H__ +#define __MIXED_CALLSTACK_PLUGIN_H__ + +#include "config.h" +#include "mini.h" + +void mixed_callstack_plugin_init (const char *options); + +void mixed_callstack_plugin_save_method_info (MonoCompile *cfg); + +void mixed_callstack_plugin_save_trampoline_info (MonoTrampInfo *info); + +void mixed_callstack_plugin_remove_method (MonoDomain *domain, MonoMethod *method, MonoJitDynamicMethodInfo *info); + +void mixed_callstack_plugin_save_specific_trampoline_info (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, gpointer code, guint32 code_len); + +void mixed_callstack_plugin_on_domain_unload_end(); +#endif diff --git a/mono/mini/pmip_my_callstack.c b/mono/mini/pmip_my_callstack.c deleted file mode 100644 index 6e7cdcb23338..000000000000 --- a/mono/mini/pmip_my_callstack.c +++ /dev/null @@ -1,134 +0,0 @@ -#include "pmip_my_callstack.h" -#include "mono/metadata/mono-debug.h" - -static char * -pmip_pretty(MonoMethod* method) -{ - char *lineNumber; - char* filePath; - char* methodName; - char* assemblyName; - char* formattedPMIP; - MonoDebugSourceLocation* debugSourceLocation; - MonoDebugMethodInfo* debugMethodInfo; - MonoDomain *domain; - - domain = mono_domain_get(); - if (!domain) - domain = mono_get_root_domain(); - - methodName = mono_method_full_name(method, TRUE); - - debugSourceLocation = mono_debug_lookup_source_location(method, 0, domain); - debugMethodInfo = mono_debug_lookup_method(method); - - assemblyName = method->klass->image->module_name; - lineNumber = debugSourceLocation ? g_strdup_printf("%d", debugSourceLocation->row) : g_strdup(""); - filePath = debugSourceLocation ? g_strdup(debugSourceLocation->source_file) : g_strdup(""); - - formattedPMIP = g_strdup_printf("[%s] %s Line %s File %s", assemblyName, methodName, lineNumber, filePath); - - mono_debug_free_source_location(debugSourceLocation); - g_free(methodName); - g_free(lineNumber); - g_free(filePath); - - return formattedPMIP; -} - -#if !defined(DISABLE_JIT) && defined(HOST_WIN32) - -static gboolean enabled; -static mono_mutex_t mutex; -static FILE* fd; - -#define pmip_my_callstack_lock() mono_os_mutex_lock (&mutex) -#define pmip_my_callstack_unlock() mono_os_mutex_unlock (&mutex) - -void -mono_pmip_my_callstack_init (const char *options) -{ - char* file_name = g_strdup_printf("pmip.%d", GetCurrentProcessId()); - char* path = g_build_filename(g_get_tmp_dir(), file_name, NULL); - - mono_os_mutex_init_recursive(&mutex); - - fd = _fsopen(path, "w", _SH_DENYNO); - - g_free(file_name); - g_free(path); - - if (fd) - enabled = TRUE; -} - -void -mono_pmip_my_callstack_save_method_info (MonoCompile *cfg) -{ - char* pretty_name; - - if (!enabled) - return; - - pretty_name = pmip_pretty(cfg->method); - - pmip_my_callstack_lock (); - fprintf(fd, "%p;%p;%s\n", cfg->native_code, ((char*)cfg->native_code) + cfg->code_size, pretty_name); - fflush (fd); - pmip_my_callstack_unlock (); - - g_free(pretty_name); -} - -void -mono_pmip_my_callstack_remove_method (MonoDomain *domain, MonoMethod *method, MonoJitDynamicMethodInfo *info) -{ -} - -void -mono_pmip_my_callstack_save_trampoline_info (MonoTrampInfo *info) -{ - if (!enabled) - return; - - pmip_my_callstack_lock (); - fprintf (fd, "%p;%p;%s\n", info->code, ((char*)info->code) + info->code_size, info->name ? info->name : ""); - fflush (fd); - pmip_my_callstack_unlock (); -} - -void -mono_pmip_my_callstack_save_specific_trampoline_info (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, gpointer code, guint32 code_len) -{ - -} - -#else - -void -mono_pmip_my_callstack_init (const char *options) -{ - g_error ("Only Available On Windows With Jit Enabled"); -} - -void -mono_pmip_my_callstack_save_method_info (MonoCompile *cfg) -{ -} - -void -mono_pmip_my_callstack_save_trampoline_info (MonoTrampInfo *info) -{ -} - -void -mono_pmip_my_callstack_remove_method (MonoDomain *domain, MonoMethod *method, MonoJitDynamicMethodInfo *info) -{ -} - -void -mono_pmip_my_callstack_save_specific_trampoline_info (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, gpointer code, guint32 code_len) -{ -} - -#endif diff --git a/mono/mini/pmip_my_callstack.h b/mono/mini/pmip_my_callstack.h deleted file mode 100644 index b7984db0d24e..000000000000 --- a/mono/mini/pmip_my_callstack.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __MONO_PMIP_MY_CALLSTACK_H__ -#define __MONO_PMIP_MY_CALLSTACK_H__ - -#include "config.h" -#include "mini.h" - -void mono_pmip_my_callstack_init (const char *options); - -void mono_pmip_my_callstack_save_method_info (MonoCompile *cfg); - -void mono_pmip_my_callstack_save_trampoline_info (MonoTrampInfo *info); - -void mono_pmip_my_callstack_remove_method (MonoDomain *domain, MonoMethod *method, MonoJitDynamicMethodInfo *info); - -void mono_pmip_my_callstack_save_specific_trampoline_info (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, gpointer code, guint32 code_len); - -#endif diff --git a/msvc/libmini-unity.targets b/msvc/libmini-unity.targets index bf51e51a9b1e..e0d66997ccb1 100644 --- a/msvc/libmini-unity.targets +++ b/msvc/libmini-unity.targets @@ -2,5 +2,7 @@ + + diff --git a/msvc/libmini-unity.targets.filters b/msvc/libmini-unity.targets.filters index 89b85f1a05df..85d28c72f684 100644 --- a/msvc/libmini-unity.targets.filters +++ b/msvc/libmini-unity.targets.filters @@ -4,6 +4,12 @@ Source Files$(MonoMiniFilterSubFolder)\unity + + Header Files$(MonoMiniFilterSubFolder)\common + + + Source Files$(MonoMiniFilterSubFolder)\common + From 8bc43b8e2a8bbb9018378787c729c90d24d41f67 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 28 Nov 2017 14:45:41 -0500 Subject: [PATCH 005/582] Add missing plugin callback during pinvoke resolution --- mono/metadata/loader.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mono/metadata/loader.c b/mono/metadata/loader.c index c5fed9c30e9f..73733e49318a 100644 --- a/mono/metadata/loader.c +++ b/mono/metadata/loader.c @@ -1263,6 +1263,22 @@ mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, const char } } + if (mono_get_find_plugin_callback ()) + { + const char* unity_new_scope = mono_get_find_plugin_callback () (new_scope); + if (unity_new_scope == NULL) + { + if (exc_class) + { + *exc_class = "DllNotFoundException"; + *exc_arg = new_scope; + } + return NULL; + } + + new_scope = unity_new_scope; + } + /* * Try loading the module using a variety of names */ From b92f5cfecf4a64a63eafc358da0a527d6e055446 Mon Sep 17 00:00:00 2001 From: Brian Raderman Date: Wed, 29 Nov 2017 09:04:32 -0500 Subject: [PATCH 006/582] * Enabling SingleStepRegress654694 test. Fixing an issue in breakpoint/step event processing that was causing this to fail. * Re-enabling the set_this part of the VTypes test. This also needed a tweak in the debugger agent to pass. --- mono/mini/debugger-agent.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 94c64bedf332..f577081438d3 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -4924,6 +4924,8 @@ clear_breakpoints_for_domain (MonoDomain *domain) if (inst->domain == domain) { #ifndef IL2CPP_MONO_DEBUGGER remove_breakpoint (inst); +#else + inst->seq_point->isActive = FALSE; #endif g_free (inst); @@ -11048,7 +11050,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) void *var; #endif - t = &frame->actual_method->klass->byval_arg; + t = VM_CLASS_GET_TYPE(VM_METHOD_GET_DECLARING_TYPE(frame->actual_method)); /* Checked by the sender */ g_assert (MONO_TYPE_ISSTRUCT (t)); @@ -11071,7 +11073,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) } #else GetVariable (tls, frame, kMethodVariableKindC_This, 0, &t, &var); - il2cpp_set_var (val_buf, var, t); + il2cpp_set_var(val_buf, var, VM_CLASS_GET_THIS_ARG(VM_METHOD_GET_DECLARING_TYPE(frame->actual_method))); #endif break; } @@ -11884,7 +11886,7 @@ unity_process_breakpoint_inner(DebuggerTlsData *tls, gboolean from_signal, Il2Cp for (j = 0; j < bp->children->len; ++j) { inst = (BreakpointInstance *)g_ptr_array_index(bp->children, j); - if (inst->il_offset == bp->il_offset) { + if (inst->il_offset == sequencePoint->ilOffset) { if (bp->req->event_kind == EVENT_KIND_STEP) { for (int j = 0; j < bp->children->len; ++j) { From c735825b0d3260182a89fda1d734dc3b82735bfa Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Thu, 30 Nov 2017 14:06:28 -0500 Subject: [PATCH 007/582] Add Unity specific branch information to README.md --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/README.md b/README.md index facec5b23836..d5ba68624ba6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,53 @@ +Unity +============================ +This is Unity Technologies fork of the open source mono project. + +### Versions +Each Unity release contains two versions of Mono. One older version (Mono) is embedded into the Editor and Players. Another newer version (MonoBleedingEdge) is used to run tools and tests. + +In newer Unity versions (2017.1+) this MonoBleedingEdge version can be used in the Editor and Players via enabling an Experimental player setting. + +### Branch Naming Convention +Branches for released Unity versions are of the form unity-\\[-mbe\][-staging\]. The '-staging' suffix is used as a branch for PRs to target with potential changes. The '-mbe' suffix indicates the branch is for the MonoBleedingEdge version of Mono mentioned above. + +### Branches + +#### Trunk +* [unity-staging (PR to this branch for Mono)](https://github.com/Unity-Technologies/mono/tree/unity-staging) +* [unity-trunk](https://github.com/Unity-Technologies/mono/tree/unity-trunk) +* [unity-master-staging (PR to this branch for MonoBleedingEdge)](https://github.com/Unity-Technologies/mono/tree/unity-master-staging) +* [unity-master](https://github.com/Unity-Technologies/mono/tree/unity-master) + +#### 2017.3 +* [unity-2017.3-staging](https://github.com/Unity-Technologies/mono/tree/unity-2017.3-staging) +* [unity-2017.3](https://github.com/Unity-Technologies/mono/tree/unity-2017.3) +* [unity-2017.3-mbe-staging](https://github.com/Unity-Technologies/mono/tree/unity-2017.3-mbe-staging) +* [unity-2017.3-mbe](https://github.com/Unity-Technologies/mono/tree/unity-2017.3-mbe) + +#### 2017.2 +* [unity-2017.2-staging](https://github.com/Unity-Technologies/mono/tree/unity-2017.2-staging) +* [unity-2017.2](https://github.com/Unity-Technologies/mono/tree/unity-2017.2) +* [unity-2017.2-mbe-staging](https://github.com/Unity-Technologies/mono/tree/unity-2017.2-mbe-staging) +* [unity-2017.2-mbe](https://github.com/Unity-Technologies/mono/tree/unity-2017.2-mbe) + +#### 2017.1 +* [unity-2017.1-staging](https://github.com/Unity-Technologies/mono/tree/unity-2017.1-staging) +* [unity-2017.1](https://github.com/Unity-Technologies/mono/tree/unity-2017.1) +* [unity-2017.1-mbe-staging](https://github.com/Unity-Technologies/mono/tree/unity-2017.1-mbe-staging) +* [unity-2017.1-mbe](https://github.com/Unity-Technologies/mono/tree/unity-2017.1-mbe) + +#### 5.6 +* [unity-5.6-staging](https://github.com/Unity-Technologies/mono/tree/unity-5.6-staging) +* [unity-5.6](https://github.com/Unity-Technologies/mono/tree/unity-5.6) +* [unity-5.6-mbe-staging](https://github.com/Unity-Technologies/mono/tree/unity-5.6-mbe-staging) +* [unity-5.6-mbe](https://github.com/Unity-Technologies/mono/tree/unity-5.6-mbe) + + + + +Mono +============================ + Mono is a software platform designed to allow developers to easily create cross platform applications. It is an open source implementation of Microsoft's .NET Framework based on the ECMA From e1cc84f8d32e4b15780093e0b6b65e0a6e46532d Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Thu, 30 Nov 2017 15:11:02 -0500 Subject: [PATCH 008/582] Add mono_custom_attrs_get_attrs API that was missed during rebase onto master. https://github.com/Unity-Technologies/mono/commit/1449b13fec64915a61b45612ae5c509d9c7a52f9 --- mono/metadata/unity-utils.c | 20 ++++++++++++++++++++ mono/metadata/unity-utils.h | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/mono/metadata/unity-utils.c b/mono/metadata/unity-utils.c index b1f8729d4175..e17f8b39eb83 100644 --- a/mono/metadata/unity-utils.c +++ b/mono/metadata/unity-utils.c @@ -142,6 +142,26 @@ mono_unity_g_free(void *ptr) g_free (ptr); } + +MONO_API MonoClass* +mono_custom_attrs_get_attrs (MonoCustomAttrInfo *ainfo, gpointer *iter) +{ + int index = -1; + if (!iter) + return NULL; + if (!*iter) + { + *iter = 1; + return ainfo->attrs[0].ctor->klass; + } + + index = GPOINTER_TO_INT (*iter); + if (index >= ainfo->num_attrs) + return NULL; + *iter = GINT_TO_POINTER (index + 1); + return ainfo->attrs[index].ctor->klass; +} + MONO_API gboolean mono_class_is_inflated (MonoClass *klass) { diff --git a/mono/metadata/unity-utils.h b/mono/metadata/unity-utils.h index f87533855d53..7b32452fd68c 100644 --- a/mono/metadata/unity-utils.h +++ b/mono/metadata/unity-utils.h @@ -163,7 +163,8 @@ MONO_API MonoClass* mono_unity_class_get(MonoImage* image, guint32 type_token); MONO_API gpointer mono_unity_alloc(gsize size); MONO_API void mono_unity_g_free (void *ptr); -// hack, FIXME jon +MONO_API MonoClass* mono_custom_attrs_get_attrs (MonoCustomAttrInfo *ainfo, gpointer *iter); + typedef size_t (*RemapPathFunction)(const char* path, char* buffer, size_t buffer_len); MONO_API void mono_unity_register_path_remapper (RemapPathFunction func); gboolean From 9f00a39661482186988436c64ccbb2757eba191f Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 1 Dec 2017 12:28:13 -0500 Subject: [PATCH 009/582] IL2CPP Debugger VSTU stepping tweaks * Using a count for sequence point activation instead of a boolean. This fixes an issue when single stepping starts from a breakpoint. The previous breakpoints would be cleared and not be hit when we returned to them. * Filtering out the method enter/exit sequence points and only honoring them when a method entry/exit request is active. This fixes issues with VSTU "invalid frames" when stepping into/out of a function. --- mono/mini/debugger-agent.c | 47 +++++++++++++++++++++++++++----------- mono/mini/il2cpp-stubs.cpp | 4 ++-- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index f577081438d3..32a7df55650d 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -4729,7 +4729,7 @@ set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req, MonoError inst->domain = mono_domain_get(); inst->seq_point = seqPoint; - seqPoint->isActive = TRUE; + seqPoint->isActive++; mono_loader_lock(); g_ptr_array_add(bp->children, inst); @@ -4818,7 +4818,7 @@ static MonoBreakpoint* set_breakpoint_fast(Il2CppSequencePointC *sp, EventReques inst->domain = mono_domain_get(); inst->seq_point = sp; - sp->isActive = TRUE; + sp->isActive++; mono_loader_lock(); g_ptr_array_add(bp->children, inst); @@ -4854,7 +4854,7 @@ clear_breakpoint (MonoBreakpoint *bp) #ifndef IL2CPP_MONO_DEBUGGER remove_breakpoint(inst); #else - inst->seq_point->isActive = FALSE; + inst->seq_point->isActive--; #endif g_free (inst); @@ -4925,7 +4925,7 @@ clear_breakpoints_for_domain (MonoDomain *domain) #ifndef IL2CPP_MONO_DEBUGGER remove_breakpoint (inst); #else - inst->seq_point->isActive = FALSE; + inst->seq_point->isActive--; #endif g_free (inst); @@ -5099,15 +5099,6 @@ ss_update_il2cpp(SingleStepReq *req, DebuggerTlsData *tls, MonoContext *ctx, Il2 } } - if (req->depth == STEP_DEPTH_INTO && req->size == STEP_SIZE_MIN && ss_req->start_method) - { - if (ss_req->start_method == sequencePoint->method && req->nframes && tls->il2cpp_context.frameCount == req->nframes) - {//Check also frame count(could be recursion) - DEBUG_PRINTF(1, "[%p] Seq point at nonempty stack %x while stepping in, continuing single stepping.\n", (gpointer)(gsize)mono_native_thread_id_get(), sequencePoint->ilOffset); - return FALSE; - } - } - if (req->size != STEP_SIZE_LINE) return TRUE; @@ -5771,6 +5762,9 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, uint64_t return; } + if(!ss_update_il2cpp(ss_req,tls,ctx,sequence_pt)) + return; + process_event(EVENT_KIND_STEP, sequence_pt->method, sequence_pt->ilOffset, NULL, events, suspend_policy, sequencePointId); #endif } @@ -9993,6 +9987,9 @@ static void GetSequencePointsAndSourceFilesUniqueSequencePoints(MonoMethod* meth Il2CppSequencePointC *seqPoint; while (seqPoint = il2cpp_get_method_sequence_points(method, &seqPointIter)) { + if(seqPoint->ilOffset == METHOD_ENTRY_IL_OFFSET || seqPoint->ilOffset == METHOD_EXIT_IL_OFFSET) + continue; + if (il2cpp_mono_methods_match(seqPoint->method, method)) g_ptr_array_add(*sequencePoints, seqPoint); } @@ -11991,6 +11988,30 @@ gboolean unity_debugger_agent_is_global_breakpoint_active() return ss_req->global; } +gboolean unity_sequence_point_active(Il2CppSequencePointC *seqPoint) +{ + gboolean global = unity_debugger_agent_is_global_breakpoint_active(); + + if ((seqPoint->ilOffset != METHOD_ENTRY_IL_OFFSET) && (seqPoint->ilOffset != METHOD_EXIT_IL_OFFSET)) + return seqPoint->isActive || global; + + int i = 0; + while (i < event_requests->len) + { + EventRequest *req = (EventRequest *)g_ptr_array_index (event_requests, i); + + if ((req->event_kind == EVENT_KIND_METHOD_ENTRY && seqPoint->ilOffset == METHOD_ENTRY_IL_OFFSET) || + (req->event_kind == EVENT_KIND_METHOD_EXIT && seqPoint->ilOffset == METHOD_EXIT_IL_OFFSET)) + { + return seqPoint->isActive || global; + } + + ++i; + } + + return FALSE; +} + #endif // IL2CPP_MONO_DEBUGGER #else /* DISABLE_DEBUGGER_AGENT */ diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index d0abe72071d5..b4b65b7f147f 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -972,8 +972,8 @@ Il2CppMonoImage* il2cpp_mono_assembly_get_image(Il2CppMonoAssembly* assembly) gboolean il2cpp_mono_runtime_try_shutdown() { - IL2CPP_ASSERT(0 && "This method is not yet implemented"); - return 0; + il2cpp::vm::Runtime::Shutdown(); + return TRUE; } gboolean il2cpp_mono_verifier_is_method_valid_generic_instantiation(Il2CppMonoMethod* method) From 94229eb09b5073f56e1a9d86a0332f73c88a0a5c Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Mon, 4 Dec 2017 08:53:19 -0500 Subject: [PATCH 010/582] Debugger changes to absorb il2cpp structs (#726) --- mono/mini/il2cpp-c-types.h | 41 ++++++-------------------------------- mono/mini/il2cpp-stubs.cpp | 2 +- 2 files changed, 7 insertions(+), 36 deletions(-) diff --git a/mono/mini/il2cpp-c-types.h b/mono/mini/il2cpp-c-types.h index 76661334d728..219f64a8f1e8 100644 --- a/mono/mini/il2cpp-c-types.h +++ b/mono/mini/il2cpp-c-types.h @@ -1,10 +1,14 @@ #ifndef __IL2CPP_MONO_DEBUGGER_OPAQUE_TYPES_H__ #define __IL2CPP_MONO_DEBUGGER_OPAQUE_TYPES_H__ +#if defined(RUNTIME_IL2CPP) +#include "il2cpp-class-internals.h" +#endif // RUNTIME_IL2CPP + #define IL2CPP_MONO_PUBLIC_KEY_TOKEN_LENGTH 17 -typedef struct _Il2CppMonoType Il2CppMonoType; -typedef struct _Il2CppMonoClass Il2CppMonoClass; +typedef struct Il2CppType Il2CppMonoType; +typedef struct Il2CppClass Il2CppMonoClass; typedef struct _Il2CppMonoAssemblyName Il2CppMonoAssemblyNameReplacement; typedef struct _Il2CppMonoAssembly Il2CppMonoAssembly; typedef struct _Il2CppMonoDomain Il2CppMonoDomain; @@ -329,39 +333,6 @@ struct _Il2CppMonoGenericClass Il2CppMonoClass *container_class; }; -struct _Il2CppMonoType -{ - union { - Il2CppMonoClass *klass; - Il2CppMonoType *type; - Il2CppMonoArrayType *array; - Il2CppMonoMethodSignature *method; - Il2CppMonoGenericParam *generic_param; - Il2CppMonoGenericClass *generic_class; - } data; - unsigned int attrs : 16; - MonoTypeEnum type : 8; - unsigned int byref : 1; -}; - -struct _Il2CppMonoClass -{ - const char *name; - Il2CppMonoType byval_arg; - Il2CppMonoImage *image; - guint valuetype : 1; - guint enumtype : 1; - guint16 interface_count; - Il2CppMonoClass **interfaces; - const char *name_space; - Il2CppMonoClass *parent; - guint8 rank; - guint32 type_token; - Il2CppMonoClass *element_class; - Il2CppMonoMethod **vtable; - Il2CppMonoType this_arg; -}; - struct _Il2CppMonoTypeNameParse { Il2CppMonoAssemblyNameReplacement assembly; diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index b4b65b7f147f..188844c682e5 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -1555,7 +1555,7 @@ const char* il2cpp_image_name(Il2CppMonoImage *monoImage) Il2CppMonoAssembly* il2cpp_image_assembly(Il2CppMonoImage *monoImage) { Il2CppImage *image = (Il2CppImage*)monoImage; - return (Il2CppMonoAssembly*)il2cpp::vm::MetadataCache::GetAssemblyFromIndex(image->assemblyIndex); + return (Il2CppMonoAssembly*)image->assembly; } guint8* il2cpp_field_get_address(Il2CppMonoObject *obj, Il2CppMonoClassField *monoField) From 8f4f8ec785dbc4e3182224cba42056ab5be41e48 Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Tue, 5 Dec 2017 08:40:29 -0500 Subject: [PATCH 011/582] Absorb More IL2CPP types (#728) --- mono/mini/debugger-agent.c | 10 ++++++++ mono/mini/il2cpp-c-types.h | 52 ++++++++------------------------------ 2 files changed, 21 insertions(+), 41 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 32a7df55650d..94a880997ed8 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -761,7 +761,9 @@ static void invalidate_each_thread (gpointer key, gpointer value, gpointer user_ static void assembly_load (MonoProfiler *prof, MonoAssembly *assembly); +#ifndef IL2CPP_MONO_DEBUGGER static void assembly_unload (MonoProfiler *prof, MonoAssembly *assembly); +#endif static void emit_assembly_load (gpointer assembly, gpointer user_data); @@ -1033,7 +1035,9 @@ mono_debugger_agent_init (void) mono_profiler_set_thread_started_callback (prof, thread_startup); mono_profiler_set_thread_stopped_callback (prof, thread_end); mono_profiler_set_assembly_loaded_callback (prof, assembly_load); + #ifndef IL2CPP_MONO_DEBUGGER mono_profiler_set_assembly_unloading_callback (prof, assembly_unload); + #endif mono_profiler_set_jit_done_callback (prof, jit_done); mono_profiler_set_jit_failed_callback (prof, jit_failed); @@ -2428,11 +2432,13 @@ decode_ptr_id (guint8 *buf, guint8 **endbuf, guint8 *limit, IdType type, MonoDom res = (Id *)g_ptr_array_index (ids [type], GPOINTER_TO_INT (id - 1)); dbg_unlock (); +#ifndef IL2CPP_MONO_DEBUGGER if (res->domain == NULL || res->domain->state == MONO_APPDOMAIN_UNLOADED) { DEBUG_PRINTF (1, "ERR_UNLOADED, id=%d, type=%d.\n", id, type); *err = ERR_UNLOADED; return NULL; } +#endif if (domain) *domain = res->domain; @@ -4230,6 +4236,7 @@ assembly_load (MonoProfiler *prof, MonoAssembly *assembly) dbg_unlock (); } +#ifndef IL2CPP_MONO_DEBUGGER static void assembly_unload (MonoProfiler *prof, MonoAssembly *assembly) { @@ -4241,6 +4248,7 @@ assembly_unload (MonoProfiler *prof, MonoAssembly *assembly) clear_event_requests_for_assembly (assembly); clear_types_for_assembly (assembly); } +#endif static void send_type_load (MonoClass *klass) @@ -7937,6 +7945,7 @@ type_comes_from_assembly (gpointer klass, gpointer also_klass, gpointer assembly * * Clears types from loaded_classes for a given assembly */ +#ifndef IL2CPP_MONO_DEBUGGER static void clear_types_for_assembly (MonoAssembly *assembly) { @@ -7953,6 +7962,7 @@ clear_types_for_assembly (MonoAssembly *assembly) g_hash_table_foreach_remove (info->loaded_classes, type_comes_from_assembly, assembly); mono_loader_unlock (); } +#endif static void add_thread (gpointer key, gpointer value, gpointer user_data) diff --git a/mono/mini/il2cpp-c-types.h b/mono/mini/il2cpp-c-types.h index 219f64a8f1e8..27f015ed3bd7 100644 --- a/mono/mini/il2cpp-c-types.h +++ b/mono/mini/il2cpp-c-types.h @@ -3,6 +3,7 @@ #if defined(RUNTIME_IL2CPP) #include "il2cpp-class-internals.h" +#include "il2cpp-object-internals.h" #endif // RUNTIME_IL2CPP #define IL2CPP_MONO_PUBLIC_KEY_TOKEN_LENGTH 17 @@ -12,49 +13,44 @@ typedef struct Il2CppClass Il2CppMonoClass; typedef struct _Il2CppMonoAssemblyName Il2CppMonoAssemblyNameReplacement; typedef struct _Il2CppMonoAssembly Il2CppMonoAssembly; typedef struct _Il2CppMonoDomain Il2CppMonoDomain; -typedef struct _Il2CppMonoImage Il2CppMonoImage; +typedef struct Il2CppImage Il2CppMonoImage; typedef struct _Il2CppMonoMethodSignature Il2CppMonoMethodSignature; typedef struct _Il2CppMonoMethod Il2CppMonoMethod; typedef struct _Il2CppMonoClassField Il2CppMonoClassField; -typedef struct _Il2CppMonoArrayType Il2CppMonoArrayType; -typedef struct _Il2CppMonoGenericParam Il2CppMonoGenericParam; +typedef struct Il2CppArrayType Il2CppMonoArrayType; +typedef struct Il2CppGenericParam Il2CppMonoGenericParam; typedef struct _Il2CppMonoGenericInst Il2CppMonoGenericInst; typedef struct _Il2CppMonoGenericContext Il2CppMonoGenericContext; typedef struct _Il2CppMonoGenericClass Il2CppMonoGenericClass; typedef struct _Il2CppMonoMethodHeader Il2CppMonoMethodHeader; typedef struct _Il2CppMonoVTable Il2CppMonoVTable; typedef struct _Il2CppMonoProperty Il2CppMonoProperty; -typedef struct _Il2CppMonoString Il2CppMonoString; +typedef struct Il2CppString Il2CppMonoString; typedef struct _Il2CppMonoAppDomain Il2CppMonoAppDomain; typedef struct _Il2CppMonoMarshalByRefObject Il2CppMonoMarshalByRefObject; typedef struct _Il2CppMonoObject Il2CppMonoObject; typedef struct _Il2CppMonoArray Il2CppMonoArray; typedef struct _Il2CppMonoCustomAttrInfo Il2CppMonoCustomAttrInfo; typedef struct _Il2CppMonoThread Il2CppMonoThread; -typedef struct _Il2CppMonoGHashTable Il2CppMonoGHashTable; -typedef struct _Il2CppMonoGenericContainer Il2CppMonoGenericContainer; -typedef struct _Il2CppMonoReflectionAssembly Il2CppMonoReflectionAssembly; +typedef struct Il2CppGHashTable Il2CppMonoGHashTable; +typedef struct Il2CppGenericContainer Il2CppMonoGenericContainer; +typedef struct Il2CppReflectionAssembly Il2CppMonoReflectionAssembly; typedef struct _Il2CppMonoReflectionType Il2CppMonoReflectionType; -typedef struct _Il2CppMonoProfiler Il2CppMonoProfiler; +typedef struct Il2CppProfiler Il2CppMonoProfiler; typedef struct _Il2CppMonoJitTlsData Il2CppMonoJitTlsData; typedef struct _Il2CppMonoRuntimeExceptionHandlingCallbacks Il2CppMonoRuntimeExceptionHandlingCallbacks; typedef struct _Il2CppMonoInternalThread Il2CppMonoInternalThread; typedef struct _Il2CppMonoCustomAttrEntry Il2CppMonoCustomAttrEntry; typedef struct _Il2CppMonoStackFrameInfo Il2CppMonoStackFrameInfo; -typedef struct _Il2CppMonoDefaults Il2CppMonoDefaults; +typedef struct Il2CppDefaults Il2CppMonoDefaults; typedef struct _Il2CppMonoMethodInflated Il2CppMonoMethodInflated; typedef struct _Il2CppMonoException Il2CppMonoException; typedef struct _Il2CppCattrNamedArg Il2CppCattrNamedArg; typedef struct _Il2CppMonoExceptionClause Il2CppMonoExceptionClause; typedef struct _Il2CppMonoTypeNameParse Il2CppMonoTypeNameParse; -struct _Il2CppMonoString { void *dummy; }; -struct _Il2CppMonoArrayType { void *dummy; }; -struct _Il2CppMonoGenericParam { void *dummy; }; -struct _Il2CppMonoGHashTable { void *dummy; }; -struct _Il2CppMonoProfiler { void *dummy; }; + struct _Il2CppMonoJitTlsData { void *dummy; }; -struct _Il2CppMonoReflectionAssembly { void *dummy; }; struct _Il2CppMonoExceptionClause { @@ -69,11 +65,6 @@ struct _Il2CppMonoExceptionClause } data; }; -struct _Il2CppMonoGenericContainer -{ - int type_argc : 29; -}; - struct _Il2CppCattrNamedArg { Il2CppMonoType *type; @@ -103,19 +94,6 @@ struct _Il2CppMonoMethodInflated Il2CppMonoGenericContext context; }; -struct _Il2CppMonoDefaults -{ - Il2CppMonoImage *corlib; - Il2CppMonoClass *object_class; - Il2CppMonoClass *string_class; - Il2CppMonoClass *void_class; - Il2CppMonoClass *exception_class; - Il2CppMonoClass *runtimetype_class; - Il2CppMonoClass *typehandle_class; - Il2CppMonoClass *fieldhandle_class; - Il2CppMonoClass *methodhandle_class; -}; - struct _Il2CppMonoStackFrameInfo { MonoStackFrameType type; @@ -281,14 +259,6 @@ struct _Il2CppMonoDomain Il2CppMonoAppDomain *domain; }; -struct _Il2CppMonoImage -{ - Il2CppMonoAssembly *assembly; - char *name; - const char *module_name; - guint8 dynamic : 1; -}; - struct _Il2CppMonoMethodSignature { Il2CppMonoType *ret; From b69f2582f78ceec93606fba3e8d254d589b3b436 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 5 Dec 2017 09:11:40 -0500 Subject: [PATCH 012/582] Reconciling thread changes from recent Mono master merge Detaching the debugger thread before it exits so cleanup is performed properly. --- mono/mini/debugger-agent.c | 6 +++++- mono/mini/il2cpp-compat.h | 3 ++- mono/mini/il2cpp-stubs.cpp | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 94a880997ed8..130c0281e905 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -11654,7 +11654,7 @@ debugger_thread (void *arg) DEBUG_PRINTF (1, "[dbg] Agent thread started, pid=%p\n", (gpointer) (gsize) mono_native_thread_id_get ()); debugger_thread_id = mono_native_thread_id_get (); #ifdef IL2CPP_MONO_DEBUGGER - mono_thread_attach (il2cpp_mono_get_root_domain ()); + MonoThread *thread = mono_thread_attach (il2cpp_mono_get_root_domain ()); #endif MonoInternalThread *internal = mono_thread_internal_current (); @@ -11835,6 +11835,10 @@ debugger_thread (void *arg) start_debugger_thread (); } +#ifdef IL2CPP_MONO_DEBUGGER + mono_thread_detach (thread); +#endif + return 0; } #ifdef IL2CPP_MONO_DEBUGGER diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index 730dd634ef26..beac331da3db 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -284,6 +284,7 @@ #define mono_thread_current il2cpp_mono_thread_current #define mono_thread_get_main il2cpp_mono_thread_get_main #define mono_thread_attach il2cpp_mono_thread_attach +#define mono_thread_detach il2cpp_mono_thread_detach #define mono_domain_lock il2cpp_mono_domain_lock #define mono_domain_unlock il2cpp_mono_domain_unlock #define mono_jit_info_table_find_internal il2cpp_mono_jit_info_table_find_internal @@ -656,7 +657,7 @@ il2cpp_internal_thread_get_threadpool_thread(Il2CppMonoInternalThread* thread); Il2CppMonoMethod* il2cpp_method_get_generic_definition(Il2CppMonoMethodInflated *imethod); Il2CppMonoGenericInst* il2cpp_method_get_generic_class_inst(Il2CppMonoMethodInflated *imethod); Il2CppMonoClass* il2cpp_generic_class_get_container_class(Il2CppMonoGenericClass *gclass); - +void il2cpp_mono_thread_detach(Il2CppMonoThread* thread); Il2CppMonoClass* il2cpp_mono_get_string_class (void); #endif // RUNTIME_IL2CPP diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index 188844c682e5..1921697181e5 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -490,6 +490,11 @@ Il2CppMonoThread* il2cpp_mono_thread_attach(Il2CppMonoDomain* domain) return (Il2CppMonoThread*)il2cpp::vm::Thread::Attach((Il2CppDomain*)domain); } +void il2cpp_mono_thread_detach(Il2CppMonoThread* thread) +{ + il2cpp::vm::Thread::Detach((Il2CppThread*)thread); +} + Il2CppMonoInternalThread* il2cpp_mono_thread_get_internal(Il2CppMonoThread* thread) { return (Il2CppMonoInternalThread*)(((Il2CppThread*)thread)->internal_thread); From d6493f6f5eca65e6e02995bf7b3f4c44e34f8c94 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 5 Dec 2017 17:07:28 -0500 Subject: [PATCH 013/582] Enabling support for scopes in methods in the debugger Local variables need iloffsets to define scopes and the method info returned by the debugger lists all of the available scopes in terms of il offsets as well. --- mono/mini/debugger-agent.c | 36 ++++++++++++++++++++++++++++-------- mono/mini/il2cpp-c-types.h | 16 ++++++++++++++++ 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 130c0281e905..582bda2a1755 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -10026,7 +10026,7 @@ static void GetSequencePointsAndSourceFilesUniqueSequencePoints(MonoMethod* meth } } -static const Il2CppMethodExecutionContextInfoC* GetExecutionContextInfo(MonoMethod* method, uint32_t* count) +static void GetExecutionContextAndHeaderInfo(MonoMethod* method, uint32_t* executionContextInfoCount, const Il2CppMethodExecutionContextInfoC **executionContextInfo, const Il2CppMethodHeaderInfoC **headerInfo) { void *seqPointIter = NULL; Il2CppSequencePointC *seqPoint; @@ -10034,13 +10034,16 @@ static const Il2CppMethodExecutionContextInfoC* GetExecutionContextInfo(MonoMeth { if (il2cpp_mono_methods_match(seqPoint->method, method)) { - *count = seqPoint->executionContextInfoCount; - return seqPoint->executionContextInfos; + *executionContextInfoCount = seqPoint->executionContextInfoCount; + *executionContextInfo = seqPoint->executionContextInfos; + *headerInfo = seqPoint->header; + return; } } g_assert(FALSE); // shouldn't be ever reached } + #endif // IL2CPP_MONO_DEBUGGER static ErrorCode @@ -10281,10 +10284,25 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g g_free (locals_map); #else uint32_t executionInfoCount, localVariableCount = 0, i; - const Il2CppMethodExecutionContextInfoC* executionContextInfo = GetExecutionContextInfo(method, &executionInfoCount); + const Il2CppMethodExecutionContextInfoC* executionContextInfo; + const Il2CppMethodHeaderInfoC* headerInfo; + + GetExecutionContextAndHeaderInfo(method, &executionInfoCount, &executionContextInfo, &headerInfo); if (CHECK_PROTOCOL_VERSION(2, 43)) { - buffer_add_int(buf, 0); + if (headerInfo) + { + buffer_add_int(buf, headerInfo->numScopes); + for (i = 0; i < headerInfo->numScopes; ++i) + { + buffer_add_int(buf, headerInfo->scopes[i].startOffset); + buffer_add_int(buf, headerInfo->scopes[i].endOffset); + } + } + else + { + buffer_add_int(buf, 0); + } } for (i = 0; i < executionInfoCount; i++) @@ -10307,10 +10325,12 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g buffer_add_string(buf, executionContextInfo[i].name); } - for (i = 0; i < localVariableCount; i++) + for (i = 0; i < executionInfoCount; i++) { - buffer_add_int(buf, 0); - buffer_add_int(buf, 0); + if (executionContextInfo[i].variableKind == kMethodVariableKindC_LocalVariable) { + buffer_add_int(buf, executionContextInfo[i].start); + buffer_add_int(buf, executionContextInfo[i].end); + } } #endif // !IL2CPP_MONO_DEBUGGER break; diff --git a/mono/mini/il2cpp-c-types.h b/mono/mini/il2cpp-c-types.h index 27f015ed3bd7..e58a452c808c 100644 --- a/mono/mini/il2cpp-c-types.h +++ b/mono/mini/il2cpp-c-types.h @@ -327,12 +327,28 @@ typedef struct const Il2CppMonoType* const* const type; const char* const name; const MethodVariableKindC variableKind; + const int start; + const int end; } Il2CppMethodExecutionContextInfoC; +typedef struct +{ + int startOffset; + int endOffset; +} Il2CppMethodScopeC; + +typedef struct +{ + int codeSize; + int numScopes; + Il2CppMethodScopeC *scopes; +} Il2CppMethodHeaderInfoC; + typedef struct { const Il2CppMethodExecutionContextInfoC* const executionContextInfos; const uint32_t executionContextInfoCount; + const Il2CppMethodHeaderInfoC *header; const Il2CppMonoMethod* method; const char* const sourceFile; const uint8_t sourceFileHash[16]; From 807962a3776943d821cba64341655dd2e1fbd623 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 5 Dec 2017 23:05:36 -0500 Subject: [PATCH 014/582] Remove asserts in mono_unity_thread_fast_attach and mono_unity_thread_fast_detach. --- mono/metadata/unity-utils.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/mono/metadata/unity-utils.c b/mono/metadata/unity-utils.c index e17f8b39eb83..4fbfdb1781f4 100644 --- a/mono/metadata/unity-utils.c +++ b/mono/metadata/unity-utils.c @@ -1129,8 +1129,6 @@ mono_unity_alloc(gsize size) MONO_API void mono_unity_thread_fast_attach (MonoDomain *domain) { - g_assert_not_reached (); -#if 1 MonoInternalThread *thread; g_assert (domain); @@ -1143,14 +1141,11 @@ mono_unity_thread_fast_attach (MonoDomain *domain) g_assert (mono_domain_set (domain, FALSE)); //mono_profiler_thread_fast_attach (thread->tid); -#endif } MONO_API void mono_unity_thread_fast_detach () { - g_assert_not_reached (); -#if 1 MonoInternalThread *thread; MonoDomain *current_domain; @@ -1168,7 +1163,6 @@ mono_unity_thread_fast_detach () // the thread to stay alive and keep running while the domain can be unloaded g_assert (mono_domain_set (mono_get_root_domain (), FALSE)); mono_thread_pop_appdomain_ref (); -#endif } // hack, FIXME jon From 72b3afef46db9fc72370c145b1273e9e47b33c38 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 5 Dec 2017 23:07:27 -0500 Subject: [PATCH 015/582] Expose mono_object_is_alive as some clients use this API for diagnostics. --- mono/metadata/gc-internals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mono/metadata/gc-internals.h b/mono/metadata/gc-internals.h index cc137bdb3dcb..eac1107ad1cb 100644 --- a/mono/metadata/gc-internals.h +++ b/mono/metadata/gc-internals.h @@ -90,7 +90,7 @@ extern void mono_gc_set_stack_end (void *stack_end); /* only valid after the RECLAIM_START GC event and before RECLAIM_END * Not exported in public headers, but can be linked to (unsupported). */ -gboolean mono_object_is_alive (MonoObject* obj); +MONO_API gboolean mono_object_is_alive (MonoObject* obj); gboolean mono_gc_is_finalizer_thread (MonoThread *thread); void mono_gchandle_set_target (guint32 gchandle, MonoObject *obj); From 02bd94f156a19ba1f4cc2b97663a7eb853163f27 Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Wed, 6 Dec 2017 09:12:34 -0500 Subject: [PATCH 016/582] Debugger Use IL2CPP Types 4 (#730) * use more il2cpp types * Renamed method->declaring_type to method->klass (#731) --- mono/mini/debugger-agent.c | 4 +- mono/mini/il2cpp-c-types.h | 130 +++---------------------------------- mono/mini/il2cpp-stubs.cpp | 6 +- 3 files changed, 15 insertions(+), 125 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 130c0281e905..195a939faf6c 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -1035,9 +1035,9 @@ mono_debugger_agent_init (void) mono_profiler_set_thread_started_callback (prof, thread_startup); mono_profiler_set_thread_stopped_callback (prof, thread_end); mono_profiler_set_assembly_loaded_callback (prof, assembly_load); - #ifndef IL2CPP_MONO_DEBUGGER +#ifndef IL2CPP_MONO_DEBUGGER mono_profiler_set_assembly_unloading_callback (prof, assembly_unload); - #endif +#endif mono_profiler_set_jit_done_callback (prof, jit_done); mono_profiler_set_jit_failed_callback (prof, jit_failed); diff --git a/mono/mini/il2cpp-c-types.h b/mono/mini/il2cpp-c-types.h index 27f015ed3bd7..02f5ceae7efd 100644 --- a/mono/mini/il2cpp-c-types.h +++ b/mono/mini/il2cpp-c-types.h @@ -15,31 +15,31 @@ typedef struct _Il2CppMonoAssembly Il2CppMonoAssembly; typedef struct _Il2CppMonoDomain Il2CppMonoDomain; typedef struct Il2CppImage Il2CppMonoImage; typedef struct _Il2CppMonoMethodSignature Il2CppMonoMethodSignature; -typedef struct _Il2CppMonoMethod Il2CppMonoMethod; -typedef struct _Il2CppMonoClassField Il2CppMonoClassField; +typedef struct MethodInfo Il2CppMonoMethod; +typedef struct FieldInfo Il2CppMonoClassField; typedef struct Il2CppArrayType Il2CppMonoArrayType; typedef struct Il2CppGenericParam Il2CppMonoGenericParam; -typedef struct _Il2CppMonoGenericInst Il2CppMonoGenericInst; -typedef struct _Il2CppMonoGenericContext Il2CppMonoGenericContext; -typedef struct _Il2CppMonoGenericClass Il2CppMonoGenericClass; +typedef struct Il2CppGenericInst Il2CppMonoGenericInst; +typedef struct Il2CppGenericContext Il2CppMonoGenericContext; +typedef struct Il2CppGenericClass Il2CppMonoGenericClass; typedef struct _Il2CppMonoMethodHeader Il2CppMonoMethodHeader; typedef struct _Il2CppMonoVTable Il2CppMonoVTable; -typedef struct _Il2CppMonoProperty Il2CppMonoProperty; +typedef struct Il2CppPropertyInfo Il2CppMonoProperty; typedef struct Il2CppString Il2CppMonoString; typedef struct _Il2CppMonoAppDomain Il2CppMonoAppDomain; typedef struct _Il2CppMonoMarshalByRefObject Il2CppMonoMarshalByRefObject; typedef struct _Il2CppMonoObject Il2CppMonoObject; -typedef struct _Il2CppMonoArray Il2CppMonoArray; +typedef struct Il2CppArraySize Il2CppMonoArray; typedef struct _Il2CppMonoCustomAttrInfo Il2CppMonoCustomAttrInfo; -typedef struct _Il2CppMonoThread Il2CppMonoThread; +typedef struct Il2CppThread Il2CppMonoThread; typedef struct Il2CppGHashTable Il2CppMonoGHashTable; typedef struct Il2CppGenericContainer Il2CppMonoGenericContainer; typedef struct Il2CppReflectionAssembly Il2CppMonoReflectionAssembly; -typedef struct _Il2CppMonoReflectionType Il2CppMonoReflectionType; +typedef struct Il2CppReflectionType Il2CppMonoReflectionType; typedef struct Il2CppProfiler Il2CppMonoProfiler; typedef struct _Il2CppMonoJitTlsData Il2CppMonoJitTlsData; typedef struct _Il2CppMonoRuntimeExceptionHandlingCallbacks Il2CppMonoRuntimeExceptionHandlingCallbacks; -typedef struct _Il2CppMonoInternalThread Il2CppMonoInternalThread; +typedef struct Il2CppInternalThread Il2CppMonoInternalThread; typedef struct _Il2CppMonoCustomAttrEntry Il2CppMonoCustomAttrEntry; typedef struct _Il2CppMonoStackFrameInfo Il2CppMonoStackFrameInfo; typedef struct Il2CppDefaults Il2CppMonoDefaults; @@ -83,11 +83,6 @@ struct _Il2CppMonoException Il2CppMonoObject object; }; -struct _Il2CppMonoGenericContext { - Il2CppMonoGenericInst *class_inst; - Il2CppMonoGenericInst *method_inst; -}; - struct _Il2CppMonoMethodInflated { Il2CppMonoMethod *declaring; @@ -126,60 +121,6 @@ struct _Il2CppMonoCustomAttrInfo Il2CppMonoCustomAttrEntry attrs [MONO_ZERO_LEN_ARRAY]; }; -struct _Il2CppMonoReflectionType -{ - Il2CppMonoType *type; -}; - -struct _Il2CppMonoInternalThread -{ - Il2CppMonoObject obj; - int lock_thread_id; - void* handle; - void* native_handle; - Il2CppMonoArray* cached_culture_info; - uint16_t* name; - int name_len; - uint32_t state; - Il2CppMonoObject* abort_exc; - int abort_state_handle; - uint64_t tid; - intptr_t debugger_thread; - void** static_data; - void* runtime_thread_info; - Il2CppMonoObject* current_appcontext; - Il2CppMonoObject* root_domain_thread; - Il2CppMonoArray* _serialized_principal; - int _serialized_principal_version; - void* appdomain_refs; - int32_t interruption_requested; - void* synch_cs; - uint8_t threadpool_thread; - uint8_t thread_interrupt_requested; - int stack_size; - uint8_t apartment_state; - int critical_region_level; - int managed_id; - uint32_t small_id; - void* manage_callback; - void* interrupt_on_stop; - void* flags; - void* thread_pinning_ref; - void* abort_protected_block_count; - int32_t priority; - void* owned_mutexes; - void * suspended; - int32_t self_suspended; - size_t thread_state; - size_t unused2; - void* last; -}; - -struct _Il2CppMonoThread -{ - Il2CppMonoInternalThread *internal_thread; -}; - typedef gboolean (*Il2CppMonoInternalStackWalk) (Il2CppMonoStackFrameInfo *frame, MonoContext *ctx, gpointer data); struct _Il2CppMonoRuntimeExceptionHandlingCallbacks @@ -187,15 +128,6 @@ struct _Il2CppMonoRuntimeExceptionHandlingCallbacks void (*il2cpp_mono_walk_stack_with_state) (Il2CppMonoInternalStackWalk func, MonoThreadUnwindState *state, MonoUnwindOptions options, void *user_data); }; - -struct _Il2CppMonoArray -{ - Il2CppMonoObject obj; - MonoArrayBounds *bounds; - mono_array_size_t max_length; - double vector [MONO_ZERO_LEN_ARRAY]; -}; - struct _Il2CppMonoMarshalByRefObject { Il2CppMonoObject obj; @@ -220,14 +152,6 @@ struct _Il2CppMonoVTable guint init_failed : 1; }; -struct _Il2CppMonoProperty -{ - const char *name; - Il2CppMonoMethod *get; - Il2CppMonoMethod *set; - guint32 attrs; -}; - struct _Il2CppMonoAppDomain { Il2CppMonoMarshalByRefObject mbr; @@ -269,40 +193,6 @@ struct _Il2CppMonoMethodSignature Il2CppMonoType **params; }; -struct _Il2CppMonoMethod -{ - Il2CppMonoClass *klass; - const char *name; - guint16 flags; - guint16 iflags; - guint32 token; - unsigned int wrapper_type:5; - unsigned int is_inflated:1; - unsigned int is_generic:1; -}; - -struct _Il2CppMonoClassField -{ - Il2CppMonoType *type; - int offset; - const char *name; - Il2CppMonoClass *parent; -}; - -struct _Il2CppMonoGenericInst -{ - guint type_argc : 22; - guint is_open : 1; - Il2CppMonoType *type_argv [MONO_ZERO_LEN_ARRAY]; -}; - - -struct _Il2CppMonoGenericClass -{ - Il2CppMonoGenericContext context; - Il2CppMonoClass *container_class; -}; - struct _Il2CppMonoTypeNameParse { Il2CppMonoAssemblyNameReplacement assembly; diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index 1921697181e5..99a1f115050a 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -905,7 +905,7 @@ Il2CppMonoObject* il2cpp_mono_runtime_try_invoke(Il2CppMonoMethod* method, void* { error_init(error); - if (((MethodInfo*)method)->declaring_type->valuetype) + if (((MethodInfo*)method)->klass->valuetype) obj = static_cast(obj) - 1; return (Il2CppMonoObject*)il2cpp::vm::Runtime::Invoke((MethodInfo*)method, obj, params, (Il2CppException**)exc); @@ -1423,7 +1423,7 @@ gboolean il2cpp_mono_methods_match(Il2CppMonoMethod* left, Il2CppMonoMethod* rig if (leftMethod->is_inflated && !leftMethod->is_generic && leftMethod->genericMethod->methodDefinition == rightMethod) return TRUE; if (leftMethod->is_generic && rightMethod->is_inflated && rightMethod->methodPointer && - leftMethod->declaring_type == rightMethod->declaring_type && + leftMethod->klass == rightMethod->klass && strcmp(leftMethod->name, rightMethod->name) == 0) { if (leftMethod->parameters_count != rightMethod->parameters_count) @@ -1592,7 +1592,7 @@ uint32_t il2cpp_method_get_flags_no_iflags(const Il2CppMonoMethod * method) bool il2cpp_method_is_string_ctor(const Il2CppMonoMethod * method) { MethodInfo* methodInfo = (MethodInfo*)method; - return methodInfo->declaring_type == il2cpp_defaults.string_class && !strcmp (methodInfo->name, ".ctor"); + return methodInfo->klass == il2cpp_defaults.string_class && !strcmp (methodInfo->name, ".ctor"); } Il2CppMonoClass* il2cpp_defaults_void_class() From 9302500e2e9f8a08a7c4b3d81ce293335249a3e6 Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Thu, 7 Dec 2017 18:11:20 -0500 Subject: [PATCH 017/582] [Debugger] Merge all MACRO and c struct changes (#746) * use more il2cpp types * Renamed method->declaring_type to method->klass * Remove Il2CppMonoType * Remove VM_CLASS macros, and IL2CppMonoClass * Remove VM_IMAGE macros and IL2CPPMonoImage * Remove VM_METHOD macros and Il2CppMonoMethod * Remove VM_METHOD macros and Il2CppMonoMethod * Remove VM_GENERIC and VM_ARRAY macros and remove Il2CppMonoArray, Il2CppMonoGeneric * Remove VM_PROPERTY macros and Il2CppMonoProperty * Remove Il2cppMonoString * Remove VM_ARRAY Macros and Il2CppMonoArray * Remove VM_THREAD and VM_INTERNAL_THREAD macros and Il2CppMonoThread and Il2CppMonoInternalThread * cleanup profiler, reflectiontype, ghashtable * Remove VM_DOMAIN_GET_ASS...macro fix not taking the address of byval_arg and this_arg * Fix property test broken due to defining wrong propertyinfo struct --- mono/mini/debugger-agent.c | 260 +++++++++++----------- mono/mini/il2cpp-c-types.h | 90 ++++---- mono/mini/il2cpp-compat.h | 381 +++++++++++--------------------- mono/mini/il2cpp-stubs.cpp | 430 +++++++++++++++---------------------- 4 files changed, 475 insertions(+), 686 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 325e0c5fd163..532e80796ec2 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -99,7 +99,7 @@ #include -#define THREAD_TO_INTERNAL(thread) VM_THREAD_GET_INTERNAL(thread) +#define THREAD_TO_INTERNAL(thread) thread->internal_thread #include "debugger-agent.h" @@ -3342,7 +3342,7 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) if (tls->frames && tls->frames_up_to_date) return; - DEBUG_PRINTF (1, "Frames for %p(tid=%lx):\n", thread, VM_INTERNAL_THREAD_GET_ID(thread)); + DEBUG_PRINTF (1, "Frames for %p(tid=%lx):\n", thread, thread->tid); user_data.tls = tls; user_data.frames = NULL; @@ -3715,7 +3715,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv } else if (mod->kind == MOD_KIND_TYPE_NAME_ONLY && ei && ei->klass) { char *s; - s = mono_type_full_name (VM_CLASS_GET_TYPE(ei->klass)); + s = mono_type_full_name (&ei->klass->byval_arg); if (!g_hash_table_lookup (mod->data.type_names, s)) filtered = TRUE; g_free (s); @@ -4063,7 +4063,7 @@ thread_startup (MonoProfiler *prof, uintptr_t tid) if (is_debugger_thread ()) return; - g_assert (mono_native_thread_id_equals (MONO_UINT_TO_NATIVE_THREAD_ID (tid), MONO_UINT_TO_NATIVE_THREAD_ID (VM_INTERNAL_THREAD_GET_ID(thread)))); + g_assert (mono_native_thread_id_equals (MONO_UINT_TO_NATIVE_THREAD_ID (tid), MONO_UINT_TO_NATIVE_THREAD_ID (thread->tid))); mono_loader_lock (); old_thread = (MonoInternalThread *)mono_g_hash_table_lookup (tid_to_thread, GUINT_TO_POINTER (tid)); @@ -4311,7 +4311,7 @@ send_assemblies_for_domain (MonoDomain *domain, void *user_data) void *iter = NULL; MonoAssembly *ass; - while (ass = VM_DOMAIN_GET_ASSEMBLIES(domain, &iter)) + while (ass = mono_domain_get_assemblies_iter(domain, &iter)) emit_assembly_load(ass, NULL); mono_domain_assemblies_unlock (domain); @@ -5759,7 +5759,7 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, uint64_t gboolean found = FALSE; for (int k = 0; ss_req->user_assemblies[k]; k++) { - if (ss_req->user_assemblies[k] == VM_IMAGE_GET_ASSEMBLY(VM_CLASS_GET_IMAGE(VM_METHOD_GET_DECLARING_TYPE(sequence_pt->method)))) + if (ss_req->user_assemblies[k] == sequence_pt->method->klass->image->assembly) { found = TRUE; break; @@ -6721,7 +6721,7 @@ unity_debugger_agent_handle_exception(MonoException *exc, Il2CppSequencePointC * if (assemblies) { for (k = 0; assemblies[k]; ++k) - if (assemblies[k] == VM_IMAGE_GET_ASSEMBLY(VM_CLASS_GET_IMAGE(VM_METHOD_GET_DECLARING_TYPE(sequencePoint->method)))) + if (assemblies[k] == sequencePoint->method->klass->image->assembly) found = TRUE; } if (!found) @@ -7070,7 +7070,7 @@ static void buffer_add_value_full (Buffer *buf, MonoType *t, void *addr, MonoDom } buffer_add_byte (buf, MONO_TYPE_VALUETYPE); - buffer_add_byte (buf, VM_CLASS_GET_ENUMTYPE(klass)); + buffer_add_byte (buf, klass->enumtype); buffer_add_typeid (buf, domain, klass); nfields = 0; @@ -7213,7 +7213,7 @@ static void buffer_add_value_full(Buffer *buf, MonoType *t, void *addr, MonoDoma } else { - Il2CppMonoClass *klass = il2cpp_object_get_class(obj); + MonoClass *klass = il2cpp_object_get_class(obj); if (il2cpp_class_is_valuetype(klass)) { t = il2cpp_class_get_type(il2cpp_object_get_class(obj)); @@ -7274,16 +7274,16 @@ static void buffer_add_value_full(Buffer *buf, MonoType *t, void *addr, MonoDoma } buffer_add_byte(buf, MONO_TYPE_VALUETYPE); - buffer_add_byte(buf, VM_CLASS_GET_ENUMTYPE(klass)); + buffer_add_byte(buf, klass->enumtype); buffer_add_typeid(buf, domain, klass); nfields = 0; iter = NULL; while ((f = mono_class_get_fields(klass, &iter))) { - if (VM_TYPE_GET_ATTRS(VM_FIELD_GET_TYPE(f)) & FIELD_ATTRIBUTE_STATIC) + if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) continue; - if (VM_FIELD_IS_DELETED(f)) + if (mono_field_is_deleted(f)) continue; nfields++; } @@ -7292,11 +7292,11 @@ static void buffer_add_value_full(Buffer *buf, MonoType *t, void *addr, MonoDoma iter = NULL; while ((f = mono_class_get_fields(klass, &iter))) { - if (VM_TYPE_GET_ATTRS(VM_FIELD_GET_TYPE(f)) & FIELD_ATTRIBUTE_STATIC) + if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) continue; - if (VM_FIELD_IS_DELETED(f)) + if (mono_field_is_deleted(f)) continue; - buffer_add_value_full(buf, VM_FIELD_GET_TYPE(f), (guint8*)addr + VM_FIELD_GET_OFFSET(f) - sizeof(MonoObject), domain, FALSE, parent_vtypes); + buffer_add_value_full(buf, f->type, (guint8*)addr + f->offset - sizeof(MonoObject), domain, FALSE, parent_vtypes); } if (boxed_vtype) @@ -7381,11 +7381,11 @@ decode_vtype (MonoType *t, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8 nfields = decode_int (buf, &buf, limit); while ((f = mono_class_get_fields (klass, &iter))) { - if (VM_TYPE_GET_ATTRS(VM_FIELD_GET_TYPE(f)) & FIELD_ATTRIBUTE_STATIC) + if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) continue; - if (VM_FIELD_IS_DELETED(f)) + if (mono_field_is_deleted(f)) continue; - err = decode_value (VM_FIELD_GET_TYPE(f), domain, (guint8*)addr + VM_FIELD_GET_OFFSET(f) - sizeof (MonoObject), buf, &buf, limit); + err = decode_value (f->type, domain, (guint8*)addr + f->offset - sizeof (MonoObject), buf, &buf, limit); if (err != ERR_NONE) return err; nfields --; @@ -7402,19 +7402,19 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr, { ErrorCode err; - if (type != VM_TYPE_GET_TYPE(t) && !MONO_TYPE_IS_REFERENCE (t) && - !(VM_TYPE_GET_TYPE(t) == MONO_TYPE_I && type == MONO_TYPE_VALUETYPE) && - !(VM_TYPE_GET_TYPE(t) == MONO_TYPE_U && type == MONO_TYPE_VALUETYPE) && - !(VM_TYPE_GET_TYPE(t) == MONO_TYPE_PTR && type == MONO_TYPE_I8) && - !(VM_TYPE_GET_TYPE(t) == MONO_TYPE_GENERICINST && type == MONO_TYPE_VALUETYPE) && - !(VM_TYPE_GET_TYPE(t) == MONO_TYPE_VALUETYPE && type == MONO_TYPE_OBJECT)) { + if (type != t->type && !MONO_TYPE_IS_REFERENCE (t) && + !(t->type == MONO_TYPE_I && type == MONO_TYPE_VALUETYPE) && + !(t->type == MONO_TYPE_U && type == MONO_TYPE_VALUETYPE) && + !(t->type == MONO_TYPE_PTR && type == MONO_TYPE_I8) && + !(t->type == MONO_TYPE_GENERICINST && type == MONO_TYPE_VALUETYPE) && + !(t->type == MONO_TYPE_VALUETYPE && type == MONO_TYPE_OBJECT)) { char *name = mono_type_full_name (t); DEBUG_PRINTF (1, "[%p] Expected value of type %s, got 0x%0x.\n", (gpointer) (gsize) mono_native_thread_id_get (), name, type); g_free (name); return ERR_INVALID_ARGUMENT; } - switch (VM_TYPE_GET_TYPE(t)) { + switch (t->type) { case MONO_TYPE_BOOLEAN: *(guint8*)addr = decode_int (buf, &buf, limit); break; @@ -7483,7 +7483,7 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr, if (!obj) return ERR_INVALID_ARGUMENT; if (VM_OBJECT_GET_CLASS(obj) != mono_class_from_mono_type (t)) { - DEBUG_PRINTF (1, "Expected type '%s', got object '%s'\n", mono_type_full_name (t), VM_CLASS_GET_NAME(VM_OBJECT_GET_CLASS(obj))); + DEBUG_PRINTF (1, "Expected type '%s', got object '%s'\n", mono_type_full_name (t), VM_OBJECT_GET_CLASS(obj)->name); return ERR_INVALID_ARGUMENT; } memcpy (addr, mono_object_unbox (obj), mono_class_value_size (VM_OBJECT_GET_CLASS(obj), NULL)); @@ -7577,8 +7577,8 @@ decode_value (MonoType *t, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8 ErrorCode err; int type = decode_byte (buf, &buf, limit); - if (VM_TYPE_GET_TYPE(t) == MONO_TYPE_GENERICINST && mono_class_is_nullable (mono_class_from_mono_type (t))) { - MonoType *targ = VM_GENERIC_INST_TYPE_ARG(VM_GENERIC_CLASS_GET_INST(VM_TYPE_GET_GENERIC_CLASS(t)), 0); + if (t->type == MONO_TYPE_GENERICINST && mono_class_is_nullable (mono_class_from_mono_type (t))) { + MonoType *targ = t->data.generic_class->context.class_inst->type_argv[0]; guint8 *nullable_buf; /* @@ -7997,7 +7997,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 * Invoke this method directly, currently only Environment.Exit () is supported. */ this_arg = NULL; - DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (invoke->method, TRUE), this_arg ? VM_CLASS_GET_NAME(VM_OBJECT_GET_CLASS(this_arg)) : ""); + DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (invoke->method, TRUE), this_arg ? VM_OBJECT_GET_CLASS(this_arg)->name : ""); mono_runtime_try_invoke (invoke->method, NULL, invoke->args, &exc, &error); mono_error_assert_ok (&error); @@ -8010,79 +8010,79 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 return err; sig = mono_method_signature (m); - if (VM_CLASS_IS_VALUETYPE(VM_METHOD_GET_DECLARING_TYPE(m))) - this_buf = (guint8 *)g_alloca (mono_class_instance_size (VM_METHOD_GET_DECLARING_TYPE(m))); + if (m->klass->valuetype) + this_buf = (guint8 *)g_alloca (mono_class_instance_size (m->klass)); else this_buf = (guint8 *)g_alloca (sizeof (MonoObject*)); - if (VM_CLASS_IS_VALUETYPE(VM_METHOD_GET_DECLARING_TYPE(m)) && (VM_METHOD_GET_FLAGS(m) & METHOD_ATTRIBUTE_STATIC)) { + if (m->klass->valuetype && (m->flags & METHOD_ATTRIBUTE_STATIC)) { /* Should be null */ int type = decode_byte (p, &p, end); if (type != VALUE_TYPE_ID_NULL) { DEBUG_PRINTF (1, "[%p] Error: Static vtype method invoked with this argument.\n", (gpointer) (gsize) mono_native_thread_id_get ()); return ERR_INVALID_ARGUMENT; } - memset (this_buf, 0, mono_class_instance_size (VM_METHOD_GET_DECLARING_TYPE(m))); - } else if (VM_CLASS_IS_VALUETYPE(VM_METHOD_GET_DECLARING_TYPE(m)) && !strcmp (VM_METHOD_GET_NAME(m), ".ctor")) { + memset (this_buf, 0, mono_class_instance_size (m->klass)); + } else if (m->klass->valuetype && !strcmp (m->name, ".ctor")) { /* Could be null */ guint8 *tmp_p; int type = decode_byte (p, &tmp_p, end); if (type == VALUE_TYPE_ID_NULL) { - memset (this_buf, 0, mono_class_instance_size (VM_METHOD_GET_DECLARING_TYPE(m))); + memset (this_buf, 0, mono_class_instance_size (m->klass)); p = tmp_p; } else { - err = decode_value(VM_CLASS_GET_TYPE(VM_METHOD_GET_DECLARING_TYPE(m)), domain, this_buf, p, &p, end); + err = decode_value(&m->klass->byval_arg, domain, this_buf, p, &p, end); if (err != ERR_NONE) return err; } } else { - err = decode_value (VM_CLASS_GET_TYPE(VM_METHOD_GET_DECLARING_TYPE(m)), domain, this_buf, p, &p, end); + err = decode_value (&m->klass->byval_arg, domain, this_buf, p, &p, end); if (err != ERR_NONE) return err; } - if (!VM_CLASS_IS_VALUETYPE(VM_METHOD_GET_DECLARING_TYPE(m))) + if (!m->klass->valuetype) this_arg = *(MonoObject**)this_buf; else this_arg = NULL; - if (VM_CLASS_IS_INTERFACE (VM_METHOD_GET_DECLARING_TYPE(m))) { + if (MONO_CLASS_IS_INTERFACE (m->klass)) { if (!this_arg) { DEBUG_PRINTF (1, "[%p] Error: Interface method invoked without this argument.\n", (gpointer) (gsize) mono_native_thread_id_get ()); return ERR_INVALID_ARGUMENT; } m = mono_object_get_virtual_method (this_arg, m); /* Transform this to the format the rest of the code expects it to be */ - if (VM_CLASS_IS_VALUETYPE(VM_METHOD_GET_DECLARING_TYPE(m))) { - this_buf = (guint8 *)g_alloca (mono_class_instance_size (VM_METHOD_GET_DECLARING_TYPE(m))); - memcpy (this_buf, mono_object_unbox (this_arg), mono_class_instance_size (VM_METHOD_GET_DECLARING_TYPE(m))); + if (m->klass->valuetype) { + this_buf = (guint8 *)g_alloca (mono_class_instance_size (m->klass)); + memcpy (this_buf, mono_object_unbox (this_arg), mono_class_instance_size (m->klass)); } - } else if ((VM_METHOD_GET_FLAGS(m) & METHOD_ATTRIBUTE_VIRTUAL) && !VM_CLASS_IS_VALUETYPE(VM_METHOD_GET_DECLARING_TYPE(m)) && invoke->flags & INVOKE_FLAG_VIRTUAL) { + } else if ((m->flags & METHOD_ATTRIBUTE_VIRTUAL) && !m->klass->valuetype && invoke->flags & INVOKE_FLAG_VIRTUAL) { if (!this_arg) { DEBUG_PRINTF (1, "[%p] Error: invoke with INVOKE_FLAG_VIRTUAL flag set without this argument.\n", (gpointer) (gsize) mono_native_thread_id_get ()); return ERR_INVALID_ARGUMENT; } m = mono_object_get_virtual_method (this_arg, m); - if (VM_CLASS_IS_VALUETYPE(VM_METHOD_GET_DECLARING_TYPE(m))) { - this_buf = (guint8 *)g_alloca (mono_class_instance_size (VM_METHOD_GET_DECLARING_TYPE(m))); - memcpy (this_buf, mono_object_unbox (this_arg), mono_class_instance_size (VM_METHOD_GET_DECLARING_TYPE(m))); + if (m->klass->valuetype) { + this_buf = (guint8 *)g_alloca (mono_class_instance_size (m->klass)); + memcpy (this_buf, mono_object_unbox (this_arg), mono_class_instance_size (m->klass)); } } - DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (m, TRUE), this_arg ? VM_CLASS_GET_NAME(VM_OBJECT_GET_CLASS(this_arg)) : ""); + DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (m, TRUE), this_arg ? VM_OBJECT_GET_CLASS(this_arg)->name : ""); if (this_arg && VM_OBJECT_GET_DOMAIN(this_arg) != domain) NOT_IMPLEMENTED; - if (!VM_CLASS_IS_VALUETYPE(VM_METHOD_GET_DECLARING_TYPE(m)) && !(VM_METHOD_GET_FLAGS(m) & METHOD_ATTRIBUTE_STATIC) && !this_arg) { - if (!strcmp (VM_METHOD_GET_NAME(m), ".ctor")) { - if (mono_class_is_abstract (VM_METHOD_GET_DECLARING_TYPE(m))) + if (!m->klass->valuetype && !(m->flags & METHOD_ATTRIBUTE_STATIC) && !this_arg) { + if (!strcmp (m->name, ".ctor")) { + if (mono_class_is_abstract (m->klass)) return ERR_INVALID_ARGUMENT; else { MonoError error; - this_arg = mono_object_new_checked (domain, VM_METHOD_GET_DECLARING_TYPE(m), &error); + this_arg = mono_object_new_checked (domain, m->klass, &error); mono_error_assert_ok (&error); } } else { @@ -8090,7 +8090,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 } } - if (this_arg && !obj_is_of_type (this_arg, VM_CLASS_GET_TYPE(VM_METHOD_GET_DECLARING_TYPE(m)))) + if (this_arg && !obj_is_of_type (this_arg, &m->klass->byval_arg)) return ERR_INVALID_ARGUMENT; nargs = decode_int (p, &p, end); @@ -8108,7 +8108,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 if (args [i] && VM_OBJECT_GET_DOMAIN(((MonoObject*)args [i])) != domain) NOT_IMPLEMENTED; - if (VM_TYPE_IS_BYREF(sig->params [i])) { + if (sig->params [i]->byref) { arg_buf [i] = (guint8 *)g_alloca (sizeof (mgreg_t)); *(gpointer*)arg_buf [i] = args [i]; args [i] = arg_buf [i]; @@ -8157,17 +8157,17 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 #endif mono_stopwatch_start (&watch); - res = mono_runtime_try_invoke (m, VM_CLASS_IS_VALUETYPE (VM_METHOD_GET_DECLARING_TYPE (m)) ? (gpointer)this_buf : (gpointer)this_arg, args, &exc, &error); + res = mono_runtime_try_invoke (m, m->klass->valuetype ? (gpointer)this_buf : (gpointer)this_arg, args, &exc, &error); if (!mono_error_ok (&error) && exc == NULL) { exc = (MonoObject*) mono_error_convert_to_exception (&error); } else { mono_error_cleanup (&error); /* FIXME report error */ } mono_stopwatch_stop (&watch); - DEBUG_PRINTF (1, "[%p] Invoke result: %p, exc: %s, time: %ld ms.\n", (gpointer) (gsize) mono_native_thread_id_get (), res, exc ? VM_CLASS_GET_NAME (VM_OBJECT_GET_CLASS (exc)) : NULL, (long)mono_stopwatch_elapsed_ms (&watch)); + DEBUG_PRINTF (1, "[%p] Invoke result: %p, exc: %s, time: %ld ms.\n", (gpointer) (gsize) mono_native_thread_id_get (), res, exc ? VM_OBJECT_GET_CLASS (exc)->name : NULL, (long)mono_stopwatch_elapsed_ms (&watch)); if (exc) { buffer_add_byte (buf, 0); - buffer_add_value (buf, VM_CLASS_GET_TYPE (VM_DEFAULTS_OBJECT_CLASS), &exc, domain); + buffer_add_value (buf, &VM_DEFAULTS_OBJECT_CLASS->byval_arg, &exc, domain); } else { gboolean out_this = FALSE; gboolean out_args = FALSE; @@ -8179,18 +8179,18 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 buffer_add_byte (buf, 1 + (out_this ? 2 : 0) + (out_args ? 4 : 0)); if (VM_METHOD_IS_STRING_CTOR(m)) { buffer_add_value (buf, &mono_get_string_class ()->byval_arg, &res, domain); - } else if (VM_TYPE_GET_TYPE (sig->ret) == MONO_TYPE_VOID && !VM_METHOD_IS_STRING_CTOR(m)) { - if (!strcmp (VM_METHOD_GET_NAME (m), ".ctor")) { - if (!VM_CLASS_IS_VALUETYPE (VM_METHOD_GET_DECLARING_TYPE (m))) - buffer_add_value (buf, VM_CLASS_GET_TYPE (VM_DEFAULTS_OBJECT_CLASS), &this_arg, domain); + } else if ( sig->ret->type == MONO_TYPE_VOID && !VM_METHOD_IS_STRING_CTOR(m)) { + if (!strcmp (m->name, ".ctor")) { + if (!m->klass->valuetype) + buffer_add_value (buf, &VM_DEFAULTS_OBJECT_CLASS->byval_arg, &this_arg, domain); else - buffer_add_value (buf, VM_CLASS_GET_TYPE (VM_METHOD_GET_DECLARING_TYPE (m)), this_buf, domain); + buffer_add_value (buf, &m->klass->byval_arg, this_buf, domain); } else { - buffer_add_value (buf, VM_CLASS_GET_TYPE (VM_DEFAULTS_VOID_CLASS), NULL, domain); + buffer_add_value (buf, &VM_DEFAULTS_VOID_CLASS->byval_arg, NULL, domain); } } else if (MONO_TYPE_IS_REFERENCE (sig->ret)) { buffer_add_value (buf, sig->ret, &res, domain); - } else if (VM_CLASS_IS_VALUETYPE (mono_class_from_mono_type (sig->ret)) || VM_TYPE_GET_TYPE (sig->ret) == MONO_TYPE_PTR || VM_TYPE_GET_TYPE (sig->ret) == MONO_TYPE_FNPTR) { + } else if (mono_class_from_mono_type (sig->ret)->valuetype || sig->ret->type == MONO_TYPE_PTR || sig->ret->type == MONO_TYPE_FNPTR) { if (mono_class_is_nullable (mono_class_from_mono_type (sig->ret))) { MonoClass *k = mono_class_from_mono_type (sig->ret); guint8 *nullable_buf = (guint8 *)g_alloca (mono_class_value_size (k, NULL)); @@ -8207,13 +8207,13 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 } if (out_this) /* Return the new value of the receiver after the call */ - buffer_add_value (buf, VM_CLASS_GET_TYPE(VM_METHOD_GET_DECLARING_TYPE(m)), this_buf, domain); + buffer_add_value (buf, &m->klass->byval_arg, this_buf, domain); if (out_args) { buffer_add_int (buf, nargs); for (i = 0; i < nargs; ++i) { if (MONO_TYPE_IS_REFERENCE (sig->params [i])) buffer_add_value (buf, sig->params [i], &args [i], domain); - else if (VM_TYPE_IS_BYREF(sig->params [i])) + else if (sig->params [i]->byref) /* add_value () does an indirection */ buffer_add_value (buf, sig->params [i], &arg_buf [i], domain); else @@ -8781,7 +8781,7 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf) mono_domain_assemblies_lock (domain); void *iter = NULL; - while (ass = VM_DOMAIN_GET_ASSEMBLIES (domain, &iter)) + while (ass = mono_domain_get_assemblies_iter (domain, &iter)) { if (VM_ASSEMBLY_GET_IMAGE (ass)) { @@ -9316,12 +9316,12 @@ module_commands (int command, guint8 *p, guint8 *end, Buffer *buf) MonoImage *image = decode_moduleid (p, &p, end, &domain, &err); char *basename; - basename = g_path_get_basename (VM_IMAGE_GET_NAME(image)); + basename = g_path_get_basename (image->name); buffer_add_string (buf, basename); // name buffer_add_string (buf, VM_IMAGE_GET_MODULE_NAME(image)); // scopename - buffer_add_string (buf, VM_IMAGE_GET_NAME(image)); // fqname + buffer_add_string (buf, image->name); // fqname buffer_add_string (buf, mono_image_get_guid (image)); // guid - buffer_add_assemblyid (buf, domain, VM_IMAGE_GET_ASSEMBLY(image)); // assembly + buffer_add_assemblyid (buf, domain, image->assembly); // assembly g_free (basename); break; } @@ -9458,7 +9458,7 @@ collect_interfaces (MonoClass *klass, GHashTable *ifaces, MonoError *error) return; gpointer iter = NULL; - while (ic = VM_CLASS_GET_INTERFACES(klass, &iter)) { + while (ic = mono_class_get_interfaces(klass, &iter)) { g_hash_table_insert (ifaces, ic, ic); collect_interfaces (ic, ifaces, error); @@ -9538,17 +9538,17 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint int count, i; if (mono_class_is_ginst (klass)) { - MonoGenericInst *inst = VM_GENERIC_CLASS_GET_INST(mono_class_get_generic_class(klass)); + MonoGenericInst *inst = mono_class_get_generic_class(klass)->context.class_inst; - count = VM_GENERIC_INST_TYPE_ARGC(inst); + count = inst->type_argc; buffer_add_int (buf, count); for (i = 0; i < count; i++) - buffer_add_typeid (buf, domain, mono_class_from_mono_type (VM_GENERIC_INST_TYPE_ARG(inst, i))); + buffer_add_typeid (buf, domain, mono_class_from_mono_type (inst->type_argv[i])); } else if (mono_class_is_gtd (klass)) { MonoGenericContainer *container = mono_class_get_generic_container (klass); MonoClass *pklass; - count = VM_GENERIC_CONTAINER_GET_TYPE_ARGC(container); + count = container->type_argc; buffer_add_int (buf, count); for (i = 0; i < count; i++) { pklass = mono_class_from_generic_parameter_internal (mono_generic_container_get_param (container, i)); @@ -9591,9 +9591,9 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint while ((f = mono_class_get_fields (klass, &iter))) { buffer_add_fieldid (buf, domain, f); - buffer_add_string (buf, VM_FIELD_GET_NAME(f)); + buffer_add_string (buf, f->name); buffer_add_typeid (buf, domain, mono_class_from_mono_type (mono_field_get_type(f))); - buffer_add_int (buf, VM_TYPE_GET_ATTRS(mono_field_get_type(f))); + buffer_add_int (buf, mono_field_get_type(f)->attrs); i ++; } g_assert (i == nfields); @@ -9611,10 +9611,10 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint while ((p = mono_class_get_properties (klass, &iter))) { buffer_add_propertyid (buf, domain, p); - buffer_add_string (buf, VM_PROPERTY_GET_NAME(p)); - buffer_add_methodid (buf, domain, VM_PROPERTY_GET_GET_METHOD(p)); - buffer_add_methodid (buf, domain, VM_PROPERTY_GET_SET_METHOD(p)); - buffer_add_int (buf, VM_PROPERTY_GET_ATTRS(p)); + buffer_add_string (buf, p->name); + buffer_add_methodid (buf, domain, p->get); + buffer_add_methodid (buf, domain, p->set); + buffer_add_int (buf, p->attrs); i ++; } g_assert (i == nprops); @@ -9715,11 +9715,11 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint if (err != ERR_NONE) return err; - if (!(VM_TYPE_GET_ATTRS(VM_FIELD_GET_TYPE(f)) & FIELD_ATTRIBUTE_STATIC)) + if (!(f->type->attrs & FIELD_ATTRIBUTE_STATIC)) return ERR_INVALID_FIELDID; #ifdef IL2CPP_MONO_DEBUGGER - if (!thread && VM_FIELD_GET_OFFSET(f) == THREAD_STATIC_FIELD_OFFSET) + if (!thread && f->offset == THREAD_STATIC_FIELD_OFFSET) return ERR_INVALID_FIELDID; #else special_static_type = mono_class_field_get_special_static_type (f); @@ -9730,8 +9730,8 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint #endif /* Check that the field belongs to the object */ found = FALSE; - for (k = klass; k; k = VM_CLASS_GET_PARENT(k)) { - if (k == VM_FIELD_GET_PARENT(f)) { + for (k = klass; k; k = k->parent) { + if (k == f->parent) { found = TRUE; break; } @@ -9739,12 +9739,12 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint if (!found) return ERR_INVALID_FIELDID; - vtable = mono_class_vtable (domain, VM_FIELD_GET_PARENT(f)); - val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (VM_FIELD_GET_TYPE(f)))); + vtable = mono_class_vtable (domain, f->parent); + val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type))); mono_field_static_get_value_for_thread (thread ? thread : mono_thread_internal_current (), vtable, f, val, &error); if (!is_ok (&error)) return ERR_INVALID_FIELDID; - buffer_add_value (buf, VM_FIELD_GET_TYPE(f), val, domain); + buffer_add_value (buf, f->type, val, domain); g_free (val); } break; @@ -9763,7 +9763,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint if (err != ERR_NONE) return err; - if (!(VM_TYPE_GET_ATTRS(mono_field_get_type(f)) & FIELD_ATTRIBUTE_STATIC)) + if (!(mono_field_get_type(f)->attrs & FIELD_ATTRIBUTE_STATIC)) return ERR_INVALID_FIELDID; if (mono_class_field_is_special_static (f)) return ERR_INVALID_FIELDID; @@ -9869,7 +9869,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint tclass = klass; - for (parent = tclass; parent; parent = VM_CLASS_GET_PARENT(parent)) { + for (parent = tclass; parent; parent = parent->parent) { mono_class_setup_interfaces (parent, &error); if (!mono_error_ok (&error)) return ERR_LOADER_ERROR; @@ -10344,8 +10344,8 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g gboolean is_inflated = FALSE; if (CHECK_PROTOCOL_VERSION (2, 12)) { guint8 attrs = 0; - is_generic = VM_METHOD_IS_GENERIC(method); - is_inflated = VM_METHOD_IS_INFLATED(method); + is_generic = method->is_generic; + is_inflated = method->is_inflated; if (is_generic) attrs |= (1 << 0); if (mono_method_signature (method)->generic_param_count) @@ -10361,7 +10361,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g result = VM_INFLATED_METHOD_GET_DECLARING(imethod); if (VM_INFLATED_METHOD_GET_CLASS_INST(imethod)) { - MonoClass *klass = VM_METHOD_GET_DECLARING_TYPE((MonoMethod *) imethod); + MonoClass *klass = ((MonoMethod *) imethod)->klass; /*Generic methods gets the context of the GTD.*/ if (mono_class_get_context (klass)) { MonoError error; @@ -10382,11 +10382,11 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g if (is_inflated) { MonoGenericInst *inst = mono_method_get_context (method)->method_inst; if (inst) { - count = VM_GENERIC_INST_TYPE_ARGC(inst); + count = inst->type_argc; buffer_add_int (buf, count); for (i = 0; i < count; i++) - buffer_add_typeid (buf, domain, mono_class_from_mono_type (VM_GENERIC_INST_TYPE_ARG(inst, i))); + buffer_add_typeid (buf, domain, mono_class_from_mono_type (inst->type_argv[i])); } else { buffer_add_int (buf, 0); } @@ -10564,7 +10564,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g } ginst = mono_metadata_get_generic_inst (type_argc, type_argv); g_free (type_argv); - tmp_context.class_inst = mono_class_is_ginst (VM_METHOD_GET_DECLARING_TYPE(method)) ? VM_GENERIC_CLASS_GET_INST(mono_class_get_generic_class (VM_METHOD_GET_DECLARING_TYPE(method))) : NULL; + tmp_context.class_inst = mono_class_is_ginst (method->klass) ? mono_class_get_generic_class (method->klass)->context.class_inst : NULL; tmp_context.method_inst = ginst; inflated = mono_class_inflate_generic_method_checked (method, &tmp_context, &error); @@ -10684,16 +10684,16 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf) break; } case CMD_THREAD_GET_STATE: - buffer_add_int (buf, VM_INTERNAL_THREAD_GET_STATE(thread)); + buffer_add_int (buf, thread->state); break; case CMD_THREAD_GET_INFO: - buffer_add_byte (buf, VM_INTERNAL_THREAD_GET_THREADPOOL_THREAD(thread)); + buffer_add_byte (buf, thread->threadpool_thread); break; case CMD_THREAD_GET_ID: buffer_add_long (buf, (guint64)(gsize)thread); break; case CMD_THREAD_GET_TID: - buffer_add_long (buf, (guint64)VM_INTERNAL_THREAD_GET_ID(thread)); + buffer_add_long (buf, (guint64)thread->tid); break; case CMD_THREAD_SET_IP: { #ifndef IL2CPP_MONO_DEBUGGER @@ -10773,7 +10773,7 @@ static uint32_t GetExecutionContextIndex(const Il2CppSequencePointC* sequencePoi } } -static void GetVariable(DebuggerTlsData* tls, StackFrame* frame, MethodVariableKindC variableKind, uint32_t variablePosition, Il2CppMonoType** type, void** var) +static void GetVariable(DebuggerTlsData* tls, StackFrame* frame, MethodVariableKindC variableKind, uint32_t variablePosition, MonoType** type, void** var) { for (int frame_index = 0; frame_index < tls->il2cpp_context.frameCount; ++frame_index) { @@ -10935,10 +10935,10 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) case CMD_STACK_FRAME_GET_THIS: { if (frame->method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE) return ERR_ABSENT_INFORMATION; - if (VM_CLASS_IS_VALUETYPE (VM_METHOD_GET_DECLARING_TYPE (frame->api_method))) { + if (frame->api_method->klass->valuetype) { if (!sig->hasthis) { MonoObject *p = NULL; - buffer_add_value (buf, VM_CLASS_GET_TYPE (VM_DEFAULTS_OBJECT_CLASS), &p, frame->domain); + buffer_add_value (buf, &VM_DEFAULTS_OBJECT_CLASS->byval_arg, &p, frame->domain); } else { #ifndef IL2CPP_MONO_DEBUGGER if (frame->ji->is_interp) { @@ -10955,7 +10955,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) { if (tls->il2cpp_context.sequencePoints[frame_index]->method == frame->actual_method) { - buffer_add_value_full (buf, VM_CLASS_GET_THIS_ARG (VM_METHOD_GET_DECLARING_TYPE (frame->actual_method)), tls->il2cpp_context.executionContexts[frame_index]->values[0], frame->domain, TRUE, NULL); + buffer_add_value_full (buf, &frame->actual_method->klass->this_arg, tls->il2cpp_context.executionContexts[frame_index]->values[0], frame->domain, TRUE, NULL); break; } } @@ -10964,7 +10964,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) } else { if (!sig->hasthis) { MonoObject *p = NULL; - buffer_add_value (buf, VM_CLASS_GET_TYPE (VM_METHOD_GET_DECLARING_TYPE (frame->actual_method)), &p, frame->domain); + buffer_add_value (buf, &frame->actual_method->klass->byval_arg, &p, frame->domain); } else { #ifndef IL2CPP_MONO_DEBUGGER if (frame->ji->is_interp) { @@ -11077,7 +11077,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) void *var; #endif - t = VM_CLASS_GET_TYPE(VM_METHOD_GET_DECLARING_TYPE(frame->actual_method)); + t = &frame->actual_method->klass->byval_arg; /* Checked by the sender */ g_assert (MONO_TYPE_ISSTRUCT (t)); @@ -11100,7 +11100,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) } #else GetVariable (tls, frame, kMethodVariableKindC_This, 0, &t, &var); - il2cpp_set_var(val_buf, var, VM_CLASS_GET_THIS_ARG(VM_METHOD_GET_DECLARING_TYPE(frame->actual_method))); + il2cpp_set_var(val_buf, var, &frame->actual_method->klass->this_arg); #endif break; } @@ -11132,8 +11132,8 @@ array_commands (int command, guint8 *p, guint8 *end, Buffer *buf) buffer_add_int (buf, 0); } else { for (i = 0; i < VM_ARRAY_GET_RANK(arr); ++i) { - buffer_add_int (buf, VM_ARRAY_BOUND_LENGTH(arr, i)); - buffer_add_int (buf, VM_ARRAY_BOUND_LOWER_BOUND(arr, i)); + buffer_add_int (buf, arr->bounds[i].length); + buffer_add_int (buf, arr->bounds[i].lower_bound); } } break; @@ -11148,7 +11148,7 @@ array_commands (int command, guint8 *p, guint8 *end, Buffer *buf) esize = mono_array_element_size (VM_OBJECT_GET_CLASS(arr)); for (i = index; i < index + len; ++i) { elem = (gpointer*)((char*)arr->vector + (i * esize)); - buffer_add_value (buf, VM_CLASS_GET_TYPE(VM_CLASS_GET_ELEMENT_CLASS(VM_OBJECT_GET_CLASS(arr))), elem, VM_OBJECT_GET_DOMAIN(arr)); + buffer_add_value (buf, &VM_OBJECT_GET_CLASS(arr)->element_class->byval_arg, elem, VM_OBJECT_GET_DOMAIN(arr)); } break; case CMD_ARRAY_REF_SET_VALUES: @@ -11162,7 +11162,7 @@ array_commands (int command, guint8 *p, guint8 *end, Buffer *buf) esize = mono_array_element_size (VM_OBJECT_GET_CLASS(arr)); for (i = index; i < index + len; ++i) { elem = (gpointer*)((char*)arr->vector + (i * esize)); - decode_value (VM_CLASS_GET_TYPE(VM_CLASS_GET_ELEMENT_CLASS(VM_OBJECT_GET_CLASS(arr))), VM_OBJECT_GET_DOMAIN(arr), (guint8 *)elem, p, &p, end); + decode_value (&VM_OBJECT_GET_CLASS(arr)->element_class->byval_arg, VM_OBJECT_GET_DOMAIN(arr), (guint8 *)elem, p, &p, end); } break; default: @@ -11279,8 +11279,8 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) /* Check that the field belongs to the object */ found = FALSE; - for (k = obj_type; k; k = VM_CLASS_GET_PARENT(k)) { - if (k == VM_FIELD_GET_PARENT(f)) { + for (k = obj_type; k; k = k->parent) { + if (k == f->parent) { found = TRUE; break; } @@ -11288,22 +11288,22 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (!found) return ERR_INVALID_FIELDID; - if (VM_TYPE_GET_ATTRS(VM_FIELD_GET_TYPE(f)) & FIELD_ATTRIBUTE_STATIC) { + if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) { guint8 *val; MonoVTable *vtable; if (mono_class_field_is_special_static (f)) return ERR_INVALID_FIELDID; - g_assert (VM_TYPE_GET_ATTRS(VM_FIELD_GET_TYPE(f)) & FIELD_ATTRIBUTE_STATIC); - vtable = mono_class_vtable (VM_OBJECT_GET_DOMAIN(obj), VM_FIELD_GET_PARENT(f)); - val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (VM_FIELD_GET_TYPE(f)))); + g_assert (f->type->attrs & FIELD_ATTRIBUTE_STATIC); + vtable = mono_class_vtable (VM_OBJECT_GET_DOMAIN(obj), f->parent); + val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type))); mono_field_static_get_value_checked (vtable, f, val, &error); if (!is_ok (&error)) { mono_error_cleanup (&error); /* FIXME report the error */ return ERR_INVALID_OBJECT; } - buffer_add_value (buf, VM_FIELD_GET_TYPE(f), val, VM_OBJECT_GET_DOMAIN(obj)); + buffer_add_value (buf, f->type, val, VM_OBJECT_GET_DOMAIN(obj)); g_free (val); } else { guint8 *field_value = NULL; @@ -11321,9 +11321,9 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) #endif } else - field_value = VM_FIELD_GET_ADDRESS(obj, f); + field_value = (guint8*)(obj) + f->offset; - buffer_add_value (buf, VM_FIELD_GET_TYPE(f), field_value, VM_OBJECT_GET_DOMAIN(obj)); + buffer_add_value (buf, f->type, field_value, VM_OBJECT_GET_DOMAIN(obj)); } } break; @@ -11337,8 +11337,8 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) /* Check that the field belongs to the object */ found = FALSE; - for (k = obj_type; k; k = VM_CLASS_GET_PARENT(k)) { - if (k == VM_FIELD_GET_PARENT(f)) { + for (k = obj_type; k; k = k->parent) { + if (k == f->parent) { found = TRUE; break; } @@ -11346,18 +11346,18 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (!found) return ERR_INVALID_FIELDID; - if (VM_TYPE_GET_ATTRS(VM_FIELD_GET_TYPE(f)) & FIELD_ATTRIBUTE_STATIC) { + if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) { guint8 *val; MonoVTable *vtable; if (mono_class_field_is_special_static (f)) return ERR_INVALID_FIELDID; - g_assert (VM_TYPE_GET_ATTRS(VM_FIELD_GET_TYPE(f)) & FIELD_ATTRIBUTE_STATIC); - vtable = mono_class_vtable (VM_OBJECT_GET_DOMAIN(obj), VM_FIELD_GET_PARENT(f)); + g_assert (f->type->attrs & FIELD_ATTRIBUTE_STATIC); + vtable = mono_class_vtable (VM_OBJECT_GET_DOMAIN(obj), f->parent); - val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (VM_FIELD_GET_TYPE(f)))); - err = decode_value (VM_FIELD_GET_TYPE(f), VM_OBJECT_GET_DOMAIN(obj), val, p, &p, end); + val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type))); + err = decode_value (f->type, VM_OBJECT_GET_DOMAIN(obj), val, p, &p, end); if (err != ERR_NONE) { g_free (val); return err; @@ -11365,7 +11365,7 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) mono_field_static_set_value (vtable, f, val); g_free (val); } else { - err = decode_value (VM_FIELD_GET_TYPE(f), VM_OBJECT_GET_DOMAIN(obj), (guint8*)obj + VM_FIELD_GET_OFFSET(f), p, &p, end); + err = decode_value (f->type, VM_OBJECT_GET_DOMAIN(obj), (guint8*)obj + f->offset, p, &p, end); if (err != ERR_NONE) return err; } @@ -11686,8 +11686,8 @@ debugger_thread (void *arg) mono_thread_set_name_internal (internal, str, TRUE, FALSE, &error); mono_error_assert_ok (&error); - VM_INTERNAL_THREAD_SET_STATE_BACKGROUND (internal); - VM_INTERNAL_THREAD_SET_FLAG_DONT_MANAGE (internal); + internal->state |= ThreadState_Background; + internal->flags |= MONO_THREAD_FLAG_DONT_MANAGE; if (agent_config.defer) { if (!wait_for_attach ()) { @@ -11703,7 +11703,7 @@ debugger_thread (void *arg) appdomain_load(NULL, domain); AgentDomainInfo *info = VM_DOMAIN_GET_AGENT_INFO(domain); void *iter = NULL; - Il2CppMonoClass *klass; + MonoClass *klass; while(klass = il2cpp_iterate_loaded_classes(&iter)) g_hash_table_insert(info->loaded_classes, klass, klass); } @@ -11888,7 +11888,7 @@ unity_process_breakpoint_inner(DebuggerTlsData *tls, gboolean from_signal, Il2Cp if (from_signal) g_assert_not_reached(); - if (VM_METHOD_GET_WRAPPER_TYPE(method) || tls->disable_breakpoints) + if (method->wrapper_type || tls->disable_breakpoints) return; bp_reqs = g_ptr_array_new(); diff --git a/mono/mini/il2cpp-c-types.h b/mono/mini/il2cpp-c-types.h index b00262d6c42d..7e57f2595c25 100644 --- a/mono/mini/il2cpp-c-types.h +++ b/mono/mini/il2cpp-c-types.h @@ -8,38 +8,40 @@ #define IL2CPP_MONO_PUBLIC_KEY_TOKEN_LENGTH 17 -typedef struct Il2CppType Il2CppMonoType; -typedef struct Il2CppClass Il2CppMonoClass; +//Converted to il2cpp types +#define MonoType Il2CppType +#define MonoClass Il2CppClass +#define MonoImage Il2CppImage +#define MonoMethod MethodInfo +#define MonoClassField FieldInfo +#define MonoArrayType Il2CppArrayType +#define MonoGenericParam Il2CppGenericParameter +#define MonoGenericInst Il2CppGenericInst +#define MonoGenericContext Il2CppGenericContext +#define MonoGenericClass Il2CppGenericClass +#define MonoGenericContainer Il2CppGenericContainer +#define MonoProperty PropertyInfo +#define MonoString Il2CppString +#define MonoArray Il2CppArraySize +#define MonoThread Il2CppThread +#define MonoInternalThread Il2CppInternalThread +#define MonoReflectionType Il2CppReflectionType +#define MonoProfiler Il2CppProfiler + +//still stubs everywhere typedef struct _Il2CppMonoAssemblyName Il2CppMonoAssemblyNameReplacement; typedef struct _Il2CppMonoAssembly Il2CppMonoAssembly; typedef struct _Il2CppMonoDomain Il2CppMonoDomain; -typedef struct Il2CppImage Il2CppMonoImage; typedef struct _Il2CppMonoMethodSignature Il2CppMonoMethodSignature; -typedef struct MethodInfo Il2CppMonoMethod; -typedef struct FieldInfo Il2CppMonoClassField; -typedef struct Il2CppArrayType Il2CppMonoArrayType; -typedef struct Il2CppGenericParam Il2CppMonoGenericParam; -typedef struct Il2CppGenericInst Il2CppMonoGenericInst; -typedef struct Il2CppGenericContext Il2CppMonoGenericContext; -typedef struct Il2CppGenericClass Il2CppMonoGenericClass; typedef struct _Il2CppMonoMethodHeader Il2CppMonoMethodHeader; typedef struct _Il2CppMonoVTable Il2CppMonoVTable; -typedef struct Il2CppPropertyInfo Il2CppMonoProperty; -typedef struct Il2CppString Il2CppMonoString; typedef struct _Il2CppMonoAppDomain Il2CppMonoAppDomain; typedef struct _Il2CppMonoMarshalByRefObject Il2CppMonoMarshalByRefObject; typedef struct _Il2CppMonoObject Il2CppMonoObject; -typedef struct Il2CppArraySize Il2CppMonoArray; typedef struct _Il2CppMonoCustomAttrInfo Il2CppMonoCustomAttrInfo; -typedef struct Il2CppThread Il2CppMonoThread; -typedef struct Il2CppGHashTable Il2CppMonoGHashTable; -typedef struct Il2CppGenericContainer Il2CppMonoGenericContainer; typedef struct Il2CppReflectionAssembly Il2CppMonoReflectionAssembly; -typedef struct Il2CppReflectionType Il2CppMonoReflectionType; -typedef struct Il2CppProfiler Il2CppMonoProfiler; typedef struct _Il2CppMonoJitTlsData Il2CppMonoJitTlsData; typedef struct _Il2CppMonoRuntimeExceptionHandlingCallbacks Il2CppMonoRuntimeExceptionHandlingCallbacks; -typedef struct Il2CppInternalThread Il2CppMonoInternalThread; typedef struct _Il2CppMonoCustomAttrEntry Il2CppMonoCustomAttrEntry; typedef struct _Il2CppMonoStackFrameInfo Il2CppMonoStackFrameInfo; typedef struct Il2CppDefaults Il2CppMonoDefaults; @@ -61,15 +63,15 @@ struct _Il2CppMonoExceptionClause uint32_t handler_len; union { uint32_t filter_offset; - Il2CppMonoClass *catch_class; + MonoClass *catch_class; } data; }; struct _Il2CppCattrNamedArg { - Il2CppMonoType *type; - Il2CppMonoClassField *field; - Il2CppMonoProperty *prop; + MonoType *type; + MonoClassField *field; + MonoProperty *prop; }; struct _Il2CppMonoObject @@ -85,16 +87,16 @@ struct _Il2CppMonoException struct _Il2CppMonoMethodInflated { - Il2CppMonoMethod *declaring; - Il2CppMonoGenericContext context; + MonoMethod *declaring; + MonoGenericContext context; }; struct _Il2CppMonoStackFrameInfo { MonoStackFrameType type; MonoJitInfo *ji; - Il2CppMonoMethod *method; - Il2CppMonoMethod *actual_method; + MonoMethod *method; + MonoMethod *actual_method; Il2CppMonoDomain *domain; gboolean managed; gboolean async_context; @@ -110,7 +112,7 @@ struct _Il2CppMonoStackFrameInfo struct _Il2CppMonoCustomAttrEntry { - Il2CppMonoMethod *ctor; + MonoMethod *ctor; uint32_t data_size; const mono_byte* data; }; @@ -140,12 +142,12 @@ struct _Il2CppMonoMethodHeader guint16 num_locals; Il2CppMonoExceptionClause *clauses; unsigned int num_clauses : 15; - Il2CppMonoType *locals [MONO_ZERO_LEN_ARRAY]; + MonoType *locals [MONO_ZERO_LEN_ARRAY]; }; struct _Il2CppMonoVTable { - Il2CppMonoClass *klass; + MonoClass *klass; Il2CppMonoDomain *domain; guint8 initialized; gpointer type; @@ -169,7 +171,7 @@ struct _Il2CppMonoAssemblyName struct _Il2CppMonoAssembly { Il2CppMonoAssemblyNameReplacement aname; - Il2CppMonoImage *image; + MonoImage *image; }; struct _Il2CppMonoDomain @@ -185,12 +187,12 @@ struct _Il2CppMonoDomain struct _Il2CppMonoMethodSignature { - Il2CppMonoType *ret; + MonoType *ret; guint16 param_count; unsigned int generic_param_count : 16; unsigned int call_convention : 6; unsigned int hasthis : 1; - Il2CppMonoType **params; + MonoType **params; }; struct _Il2CppMonoTypeNameParse @@ -214,7 +216,7 @@ typedef enum typedef struct { - const Il2CppMonoType* const* const type; + const MonoType* const* const type; const char* const name; const MethodVariableKindC variableKind; const int start; @@ -239,7 +241,7 @@ typedef struct const Il2CppMethodExecutionContextInfoC* const executionContextInfos; const uint32_t executionContextInfoCount; const Il2CppMethodHeaderInfoC *header; - const Il2CppMonoMethod* method; + const MonoMethod* method; const char* const sourceFile; const uint8_t sourceFileHash[16]; const int32_t lineStart, lineEnd; @@ -267,28 +269,26 @@ TYPED_HANDLE_DECL (Il2CppMonoReflectionAssembly); Il2CppMonoDefaults il2cpp_mono_defaults; MonoDebugOptions il2cpp_mono_debug_options; -typedef void (*Il2CppMonoProfileFunc) (Il2CppMonoProfiler *prof); -typedef void (*Il2CppMonoProfileAppDomainFunc) (Il2CppMonoProfiler *prof, Il2CppMonoDomain *domain); -typedef void (*Il2CppMonoProfileAppDomainResult) (Il2CppMonoProfiler *prof, Il2CppMonoDomain *domain, int result); -typedef void (*Il2CppMonoProfileAssemblyFunc) (Il2CppMonoProfiler *prof, Il2CppMonoAssembly *assembly); -typedef void (*Il2CppMonoProfileJitResult) (Il2CppMonoProfiler *prof, Il2CppMonoMethod *method, MonoJitInfo* jinfo, int result); -typedef void (*Il2CppMonoProfileAssemblyResult) (Il2CppMonoProfiler *prof, Il2CppMonoAssembly *assembly, int result); -typedef void (*Il2CppMonoProfileThreadFunc) (Il2CppMonoProfiler *prof, uintptr_t tid); +typedef void (*Il2CppMonoProfileFunc) (MonoProfiler *prof); +typedef void (*Il2CppMonoProfileAppDomainFunc) (MonoProfiler *prof, Il2CppMonoDomain *domain); +typedef void (*Il2CppMonoProfileAppDomainResult) (MonoProfiler *prof, Il2CppMonoDomain *domain, int result); +typedef void (*Il2CppMonoProfileAssemblyFunc) (MonoProfiler *prof, Il2CppMonoAssembly *assembly); +typedef void (*Il2CppMonoProfileJitResult) (MonoProfiler *prof, MonoMethod *method, MonoJitInfo* jinfo, int result); +typedef void (*Il2CppMonoProfileAssemblyResult) (MonoProfiler *prof, Il2CppMonoAssembly *assembly, int result); +typedef void (*Il2CppMonoProfileThreadFunc) (MonoProfiler *prof, uintptr_t tid); typedef gboolean (*Il2CppMonoJitStackWalk) (Il2CppMonoStackFrameInfo *frame, MonoContext *ctx, gpointer data); typedef void (*Il2CppMonoDomainFunc) (Il2CppMonoDomain *domain, void* user_data); typedef void (*emit_assembly_load_callback)(void*, void*); typedef void(*emit_type_load_callback)(void*, void*, void*); -void il2cpp_set_thread_state_background(Il2CppMonoThread* thread); +void il2cpp_set_thread_state_background(MonoThread* thread); void* il2cpp_domain_get_agent_info(Il2CppMonoAppDomain* domain); void il2cpp_domain_set_agent_info(Il2CppMonoAppDomain* domain, void* agentInfo); void il2cpp_start_debugger_thread(); -uintptr_t il2cpp_internal_thread_get_thread_id(Il2CppMonoInternalThread* thread); void* il2cpp_gc_alloc_fixed(size_t size); void il2cpp_gc_free_fixed(void* address); char* il2cpp_assembly_get_name(Il2CppMonoAssembly* assembly); const char* il2cpp_domain_get_name(Il2CppMonoDomain* domain); -int il2cpp_mono_type_get_attrs(Il2CppMonoType* type); #endif \ No newline at end of file diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index beac331da3db..66b3d68e76f3 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -13,17 +13,10 @@ #define THREAD_STATIC_FIELD_OFFSET -1 -#define VM_THREAD_GET_INTERNAL(thread) il2cpp_mono_thread_get_internal(thread) -#define VM_INTERNAL_THREAD_SET_STATE_BACKGROUND(internal_thread) il2cpp_internal_thread_set_state_background(internal_thread) -#define VM_INTERNAL_THREAD_SET_FLAG_DONT_MANAGE(thread) -#define VM_INTERNAL_THREAD_GET_ID(internal_thread) il2cpp_internal_thread_get_thread_id(internal_thread) -#define VM_INTERNAL_THREAD_GET_STATE(internal_thread) il2cpp_internal_thread_get_state(internal_thread) -#define VM_INTERNAL_THREAD_GET_THREADPOOL_THREAD(internal_thread) il2cpp_internal_thread_get_threadpool_thread(internal_thread) #define VM_DOMAIN_GET_AGENT_INFO(domain) il2cpp_domain_get_agent_info(domain) #define VM_DOMAIN_SET_AGENT_INFO(domain, value) il2cpp_domain_set_agent_info(domain, value) #define VM_DOMAIN_GET_NAME(domain) il2cpp_domain_get_name(domain) #define VM_DOMAIN_GET_CORLIB(domain) il2cpp_image_get_assembly(il2cpp_get_corlib()) -#define VM_DOMAIN_GET_ASSEMBLIES(domain, iter) il2cpp_domain_get_assemblies_iter(domain, iter) #define VM_ASSEMBLY_GET_NAME(assembly) il2cpp_assembly_get_name(assembly) #define VM_ASSEMBLY_FREE_NAME(name) g_free(name) #define VM_ASSEMBLY_IS_DYNAMIC(assembly) FALSE @@ -37,69 +30,25 @@ #define VM_ASSEMBLY_NAME_GET_PUBLIC_KEY_TOKEN(assembly, i) il2cpp_assembly_name_public_key_token(assembly, i) #define VM_ASSEMBLY_NAME_GET_PUBLIC_KEY_TOKEN_STRING(assembly) il2cpp_assembly_name_public_key_token_string(assembly) #define VM_ASSEMBLY_NAME_GET_FLAGS(assembly) il2cpp_assembly_name_flags(assembly) -#define VM_CLASS_GET_TYPE(klass) il2cpp_class_get_type(klass) -#define VM_CLASS_GET_THIS_ARG(klass) il2cpp_class_this_arg(klass) -#define VM_CLASS_GET_ELEMENT_CLASS(klass) il2cpp_class_get_element_class(klass) -#define VM_CLASS_GET_PARENT(klass) il2cpp_class_get_parent(klass) -#define VM_CLASS_GET_IMAGE(klass) il2cpp_class_get_image(klass) -#define VM_CLASS_IS_VALUETYPE(klass) il2cpp_class_is_valuetype(klass) -#define VM_CLASS_IS_INTERFACE(klass) il2cpp_class_is_interface(klass) -#define VM_CLASS_GET_NAME(klass) il2cpp_class_get_name(klass) -#define VM_CLASS_GET_INTERFACES(klass, iter) il2cpp_class_get_interfaces(klass, iter) -#define VM_CLASS_GET_ENUMTYPE(klass) il2cpp_class_get_enumtype(klass) -#define VM_METHOD_GET_WRAPPER_TYPE(method) FALSE -#define VM_METHOD_GET_DECLARING_TYPE(method) il2cpp_method_get_declaring_type(method) -#define VM_METHOD_GET_FLAGS(method) il2cpp_method_get_flags_no_iflags(method) -#define VM_METHOD_GET_NAME(method) il2cpp_method_get_name(method) -#define VM_METHOD_IS_GENERIC(method) il2cpp_method_is_generic(method) -#define VM_METHOD_IS_INFLATED(method) il2cpp_method_is_inflated(method) #define VM_METHOD_IS_STRING_CTOR(method) il2cpp_method_is_string_ctor(method) #define VM_INFLATED_METHOD_GET_DECLARING(imethod) il2cpp_method_get_generic_definition(imethod) #define VM_INFLATED_METHOD_GET_CLASS_INST(imethod) il2cpp_method_get_generic_class_inst(imethod) -#define VM_FIELD_GET_NAME(field) il2cpp_mono_field_get_name(field) -#define VM_FIELD_GET_PARENT(field) il2cpp_field_get_parent(field) -#define VM_FIELD_GET_TYPE(field) il2cpp_field_get_type(field) -#define VM_FIELD_GET_ADDRESS(obj, field) il2cpp_field_get_address(obj, field) -#define VM_FIELD_IS_DELETED(field) il2cpp_field_is_deleted(field) -#define VM_FIELD_GET_OFFSET(field) il2cpp_field_get_offset(field) -#define VM_TYPE_GET_ATTRS(type) il2cpp_mono_type_get_attrs(type) -#define VM_TYPE_GET_TYPE(type) il2cpp_type_get_type(type) -#define VM_TYPE_IS_BYREF(type) il2cpp_type_is_byref(type) -#define VM_TYPE_GET_GENERIC_CLASS(type) il2cpp_type_get_generic_class(type) #define VM_OBJECT_GET_DOMAIN(object) il2cpp_mono_domain_get() #define VM_OBJECT_GET_CLASS(object) il2cpp_object_get_class(object) #define VM_OBJECT_GET_TYPE(object) il2cpp_mono_object_get_type(object) -#define VM_GENERIC_CLASS_GET_INST(gklass) il2cpp_generic_class_get_inst(gklass) #define VM_GENERIC_CLASS_GET_CONTAINER_CLASS(gklass) il2cpp_generic_class_get_container_class(gklass) -#define VM_GENERIC_CONTAINER_GET_TYPE_ARGC(container) il2cpp_generic_container_get_type_argc(container) -#define VM_GENERIC_INST_TYPE_ARGC(inst) il2cpp_generic_inst_type_argc(inst) -#define VM_GENERIC_INST_TYPE_ARG(inst, i) il2cpp_generic_inst_type_arg(inst, i) #define VM_DEFAULTS_OBJECT_CLASS il2cpp_defaults_object_class() #define VM_DEFAULTS_EXCEPTION_CLASS il2cpp_defaults_exception_class() #define VM_DEFAULTS_CORLIB_IMAGE il2cpp_defaults_corlib_image() #define VM_DEFAULTS_VOID_CLASS il2cpp_defaults_void_class() #define VM_ARRAY_GET_RANK(arr) il2cpp_array_rank(arr) -#define VM_ARRAY_BOUND_LENGTH(arr, i) il2cpp_array_bound_length(arr, i) -#define VM_ARRAY_BOUND_LOWER_BOUND(arr, i) il2cpp_array_bound_lower_bound(arr, i) -#define VM_IMAGE_GET_NAME(image) il2cpp_image_name(image) +//Fixme module name as image name seems bad #define VM_IMAGE_GET_MODULE_NAME(image) il2cpp_image_name(image) -#define VM_IMAGE_GET_ASSEMBLY(image) il2cpp_image_assembly(image) -#define VM_PROPERTY_GET_NAME(prop) il2cpp_property_get_name(prop) -#define VM_PROPERTY_GET_GET_METHOD(prop) il2cpp_property_get_get_method(prop) -#define VM_PROPERTY_GET_SET_METHOD(prop) il2cpp_property_get_set_method(prop) -#define VM_PROPERTY_GET_ATTRS(prop) il2cpp_property_get_flags(prop) #else -#define VM_THREAD_GET_INTERNAL(thread) thread->internal_thread -#define VM_INTERNAL_THREAD_SET_STATE_BACKGROUND(internal_thread) internal_thread->state |= ThreadState_Background -#define VM_INTERNAL_THREAD_SET_FLAG_DONT_MANAGE(internal_thread) internal_thread->flags |= MONO_THREAD_FLAG_DONT_MANAGE -#define VM_INTERNAL_THREAD_GET_ID(internal_thread) internal_thread->tid -#define VM_INTERNAL_THREAD_GET_STATE(internal_thread) internal_thread->state -#define VM_INTERNAL_THREAD_GET_THREADPOOL_THREAD(internal_thread) internal_thread->threadpool_thread #define VM_DOMAIN_GET_AGENT_INFO(domain) domain_jit_info (domain)->agent_info #define VM_DOMAIN_SET_AGENT_INFO(domain, value) domain_jit_info (domain)->agent_info = value #define VM_DOMAIN_GET_NAME(domain) domain->friendly_name #define VM_DOMAIN_GET_CORLIB(domain) domain->domain->mbr.obj.vtable->klass->image->assembly -#define VM_DOMAIN_GET_ASSEMBLIES(domain, iter) mono_domain_get_assemblies_iter(domain, iter) #define VM_ASSEMBLY_GET_NAME(assembly) assembly->aname.name #define VM_ASSEMBLY_FREE_NAME(name) #define VM_ASSEMBLY_IS_DYNAMIC(assembly) assembly->image->dynamic @@ -113,91 +62,34 @@ #define VM_ASSEMBLY_NAME_GET_PUBLIC_KEY_TOKEN(assembly, i) (assembly)->aname.public_key_token[i] #define VM_ASSEMBLY_NAME_GET_PUBLIC_KEY_TOKEN_STRING(assembly) (char*)(assembly)->aname.public_key_token #define VM_ASSEMBLY_NAME_GET_FLAGS(assembly) (assembly)->aname.flags -#define VM_CLASS_GET_TYPE(klass) &(klass)->byval_arg -#define VM_CLASS_GET_THIS_ARG(klass) &(klass)->this_arg -#define VM_CLASS_GET_PARENT(klass) (klass)->parent -#define VM_CLASS_GET_IMAGE(klass) (klass)->image -#define VM_CLASS_IS_VALUETYPE(klass) klass->valuetype -#define VM_CLASS_IS_INTERFACE(klass) MONO_CLASS_IS_INTERFACE(klass) -#define VM_CLASS_GET_NAME(klass) (klass)->name -#define VM_CLASS_GET_INTERFACES(klass, iter) mono_class_get_interfaces(klass, iter) -#define VM_CLASS_GET_ENUMTYPE(klass) (klass)->enumtype -#define VM_METHOD_GET_WRAPPER_TYPE(method) method->wrapper_type -#define VM_METHOD_GET_DECLARING_TYPE(method) (method)->klass -#define VM_METHOD_GET_FLAGS(method) (method)->flags -#define VM_METHOD_GET_NAME(method) (method)->name -#define VM_METHOD_IS_GENERIC(method) method->is_generic -#define VM_METHOD_IS_INFLATED(method) method->is_inflated #define VM_METHOD_IS_STRING_CTOR(method) method->string_ctor #define VM_INFLATED_METHOD_GET_DECLARING(imethod) (imethod)->declaring #define VM_INFLATED_METHOD_GET_CLASS_INST(imethod) (imethod)->context.class_inst -#define VM_FIELD_GET_NAME(field) field->name -#define VM_FIELD_GET_PARENT(field) (field)->parent -#define VM_FIELD_GET_TYPE(field) (field)->type -#define VM_FIELD_GET_ADDRESS(obj, field) (guint8*)(obj) + (f)->offset -#define VM_FIELD_IS_DELETED(field) mono_field_is_deleted(field) -#define VM_FIELD_GET_OFFSET(field) (field)->offset -#define VM_TYPE_GET_ATTRS(type) type->attrs -#define VM_TYPE_GET_TYPE(typeparam) (typeparam)->type -#define VM_TYPE_IS_BYREF(type) (type)->byref -#define VM_TYPE_GET_GENERIC_CLASS(type) (type)->data.generic_class #define VM_OBJECT_GET_DOMAIN(object) ((MonoObject*)object)->vtable->domain #define VM_OBJECT_GET_CLASS(object) ((MonoObject*)object)->vtable->klass #define VM_OBJECT_GET_TYPE(object) ((MonoReflectionType*)object->vtable->type)->type -#define VM_GENERIC_CONTAINER_GET_TYPE_ARGC(container) container->type_argc -#define VM_GENERIC_CLASS_GET_INST(gklass) (gklass)->context.class_inst #define VM_GENERIC_CLASS_GET_CONTAINER_CLASS(gklass) (gklass)->container_class -#define VM_GENERIC_INST_TYPE_ARGC(inst) (inst)->type_argc -#define VM_GENERIC_INST_TYPE_ARG(inst, i) (inst)->type_argv[i] #define VM_DEFAULTS_OBJECT_CLASS mono_defaults.object_class #define VM_DEFAULTS_EXCEPTION_CLASS mono_defaults.exception_class #define VM_DEFAULTS_CORLIB_IMAGE mono_defaults.corlib #define VM_DEFAULTS_VOID_CLASS mono_defaults.void_class #define VM_ARRAY_GET_RANK(arr) (arr)->obj.vtable->klass->rank -#define VM_CLASS_GET_ELEMENT_CLASS(klass) (klass)->element_class -#define VM_ARRAY_BOUND_LENGTH(arr, i) arr->bounds[i].length -#define VM_ARRAY_BOUND_LOWER_BOUND(arr, i) arr->bounds[i].lower_bound -#define VM_IMAGE_GET_NAME(image) (image)->name #define VM_IMAGE_GET_MODULE_NAME(image) (image)->module_name -#define VM_IMAGE_GET_ASSEMBLY(image) (image)->assembly -#define VM_PROPERTY_GET_NAME(prop) (prop)->name -#define VM_PROPERTY_GET_GET_METHOD(prop) (prop)->get -#define VM_PROPERTY_GET_SET_METHOD(prop) (prop)->set -#define VM_PROPERTY_GET_ATTRS(prop) (prop)->attrs #endif #if defined(RUNTIME_IL2CPP) -#define MonoType Il2CppMonoType -#define MonoClass Il2CppMonoClass #define MonoMethodHeader Il2CppMonoMethodHeader #define MonoVTable Il2CppMonoVTable #define MonoAssembly Il2CppMonoAssembly -#define MonoProperty Il2CppMonoProperty -#define MonoString Il2CppMonoString #define MonoAppDomain Il2CppMonoAppDomain #define MonoDomain Il2CppMonoDomain -#define MonoImage Il2CppMonoImage #define MonoMethodSignature Il2CppMonoMethodSignature -#define MonoMethod Il2CppMonoMethod -#define MonoClassField Il2CppMonoClassField -#define MonoArrayType Il2CppMonoArrayType -#define MonoGenericParam Il2CppMonoGenericParam -#define MonoGenericInst Il2CppMonoGenericInst -#define MonoGenericContext Il2CppMonoGenericContext -#define MonoGenericClass Il2CppMonoGenericClass #define MonoAssemblyName Il2CppMonoAssemblyNameReplacement #define MonoMarshalByRefObject Il2CppMonoMarshalByRefObject #define MonoObject Il2CppMonoObject -#define MonoArray Il2CppMonoArray #define MonoCustomAttrInfo Il2CppMonoCustomAttrInfo -#define MonoThread Il2CppMonoThread -#define MonoInternalThread Il2CppMonoInternalThread -#define MonoGHashTable Il2CppMonoGHashTable -#define MonoGenericContainer Il2CppMonoGenericContainer #define MonoReflectionAssemblyHandle Il2CppMonoReflectionAssemblyHandle -#define MonoReflectionType Il2CppMonoReflectionType -#define MonoProfiler Il2CppMonoProfiler #define MonoJitTlsData Il2CppMonoJitTlsData #define MonoRuntimeExceptionHandlingCallbacks Il2CppMonoRuntimeExceptionHandlingCallbacks #define MonoCustomAttrEntry Il2CppMonoCustomAttrEntry @@ -410,8 +302,9 @@ #define mono_method_get_name il2cpp_method_get_name #define mono_class_get_type il2cpp_class_get_type #define mono_method_get_class il2cpp_method_get_class -#define mono_class_get_type il2cpp_class_get_type #define mono_class_get_image il2cpp_class_get_image +#define mono_class_get_interfaces il2cpp_class_get_interfaces +#define MONO_CLASS_IS_INTERFACE il2cpp_class_is_interface #define mono_image_get_assembly il2cpp_image_get_assembly #define mono_image_get_name il2cpp_image_get_name #define mono_type_get_type il2cpp_type_get_type @@ -424,57 +317,59 @@ #define mono_method_get_token il2cpp_method_get_token #define mono_method_is_generic il2cpp_method_is_generic #define mono_method_is_inflated il2cpp_method_is_inflated +#define mono_field_is_deleted il2cpp_field_is_deleted +#define mono_domain_get_assemblies_iter il2cpp_domain_get_assemblies_iter #define mono_domain_assemblies_lock #define mono_domain_assemblies_unlock #define mono_get_string_class il2cpp_mono_get_string_class -Il2CppMonoMethod* il2cpp_mono_image_get_entry_point (Il2CppMonoImage *image); -const char* il2cpp_mono_image_get_filename (Il2CppMonoImage *image); -const char* il2cpp_mono_image_get_guid (Il2CppMonoImage *image); -Il2CppMonoClass* il2cpp_mono_type_get_class (Il2CppMonoType *type); -mono_bool il2cpp_mono_type_is_struct (Il2CppMonoType *type); -mono_bool il2cpp_mono_type_is_reference (Il2CppMonoType *type); +MonoMethod* il2cpp_mono_image_get_entry_point (MonoImage *image); +const char* il2cpp_mono_image_get_filename (MonoImage *image); +const char* il2cpp_mono_image_get_guid (MonoImage *image); +MonoClass* il2cpp_mono_type_get_class (MonoType *type); +mono_bool il2cpp_mono_type_is_struct (MonoType *type); +mono_bool il2cpp_mono_type_is_reference (MonoType *type); void il2cpp_mono_metadata_free_mh (Il2CppMonoMethodHeader *mh); -Il2CppMonoMethodSignature* il2cpp_mono_method_signature (Il2CppMonoMethod *m); -void il2cpp_mono_method_get_param_names (Il2CppMonoMethod *method, const char **names); -mono_bool il2cpp_mono_type_generic_inst_is_valuetype (Il2CppMonoType *type); -Il2CppMonoMethodHeader* il2cpp_mono_method_get_header_checked (Il2CppMonoMethod *method, MonoError *error); -gboolean il2cpp_mono_class_init (Il2CppMonoClass *klass); -Il2CppMonoVTable* il2cpp_mono_class_vtable (Il2CppMonoDomain *domain, Il2CppMonoClass *klass); -Il2CppMonoClassField* il2cpp_mono_class_get_field_from_name (Il2CppMonoClass *klass, const char *name); -int32_t il2cpp_mono_array_element_size (Il2CppMonoClass *ac); -int32_t il2cpp_mono_class_instance_size (Il2CppMonoClass *klass); -int32_t il2cpp_mono_class_value_size (Il2CppMonoClass *klass, uint32_t *align); -gboolean il2cpp_mono_class_is_assignable_from (Il2CppMonoClass *klass, Il2CppMonoClass *oklass); -Il2CppMonoClass* il2cpp_mono_class_from_mono_type (Il2CppMonoType *type); -int il2cpp_mono_class_num_fields (Il2CppMonoClass *klass); -int il2cpp_mono_class_num_methods (Il2CppMonoClass *klass); -int il2cpp_mono_class_num_properties (Il2CppMonoClass *klass); -Il2CppMonoClassField* il2cpp_mono_class_get_fields (Il2CppMonoClass* klass, gpointer *iter); -Il2CppMonoMethod* il2cpp_mono_class_get_methods (Il2CppMonoClass* klass, gpointer *iter); -Il2CppMonoProperty* il2cpp_mono_class_get_properties (Il2CppMonoClass* klass, gpointer *iter); -const char* il2cpp_mono_field_get_name (Il2CppMonoClassField *field); -mono_unichar2* il2cpp_mono_string_chars (Il2CppMonoString *s); -int il2cpp_mono_string_length (Il2CppMonoString *s); -char* il2cpp_mono_array_addr_with_size (Il2CppMonoArray *array, int size, uintptr_t idx); -uintptr_t il2cpp_mono_array_length (Il2CppMonoArray *array); -Il2CppMonoString* il2cpp_mono_string_new (Il2CppMonoDomain *domain, const char *text); -Il2CppMonoString* il2cpp_mono_string_new (Il2CppMonoDomain *domain, const char *text); -Il2CppMonoString* il2cpp_mono_string_new_checked (Il2CppMonoDomain *domain, const char *text, MonoError *merror); -char* il2cpp_mono_string_to_utf8_checked (Il2CppMonoString *string_obj, MonoError *error); +Il2CppMonoMethodSignature* il2cpp_mono_method_signature (MonoMethod *m); +void il2cpp_mono_method_get_param_names (MonoMethod *method, const char **names); +mono_bool il2cpp_mono_type_generic_inst_is_valuetype (MonoType *type); +Il2CppMonoMethodHeader* il2cpp_mono_method_get_header_checked (MonoMethod *method, MonoError *error); +gboolean il2cpp_mono_class_init (MonoClass *klass); +Il2CppMonoVTable* il2cpp_mono_class_vtable (Il2CppMonoDomain *domain, MonoClass *klass); +MonoClassField* il2cpp_mono_class_get_field_from_name (MonoClass *klass, const char *name); +int32_t il2cpp_mono_array_element_size (MonoClass *ac); +int32_t il2cpp_mono_class_instance_size (MonoClass *klass); +int32_t il2cpp_mono_class_value_size (MonoClass *klass, uint32_t *align); +gboolean il2cpp_mono_class_is_assignable_from (MonoClass *klass, MonoClass *oklass); +MonoClass* il2cpp_mono_class_from_mono_type (MonoType *type); +int il2cpp_mono_class_num_fields (MonoClass *klass); +int il2cpp_mono_class_num_methods (MonoClass *klass); +int il2cpp_mono_class_num_properties (MonoClass *klass); +MonoClassField* il2cpp_mono_class_get_fields (MonoClass* klass, gpointer *iter); +MonoMethod* il2cpp_mono_class_get_methods (MonoClass* klass, gpointer *iter); +MonoProperty* il2cpp_mono_class_get_properties (MonoClass* klass, gpointer *iter); +const char* il2cpp_mono_field_get_name (MonoClassField *field); +mono_unichar2* il2cpp_mono_string_chars (MonoString *s); +int il2cpp_mono_string_length (MonoString *s); +char* il2cpp_mono_array_addr_with_size (MonoArray *array, int size, uintptr_t idx); +uintptr_t il2cpp_mono_array_length (MonoArray *array); +MonoString* il2cpp_mono_string_new (Il2CppMonoDomain *domain, const char *text); +MonoString* il2cpp_mono_string_new (Il2CppMonoDomain *domain, const char *text); +MonoString* il2cpp_mono_string_new_checked (Il2CppMonoDomain *domain, const char *text, MonoError *merror); +char* il2cpp_mono_string_to_utf8_checked (MonoString *string_obj, MonoError *error); int il2cpp_mono_object_hash (Il2CppMonoObject* obj); void* il2cpp_mono_object_unbox (Il2CppMonoObject *obj); -void il2cpp_mono_field_set_value (Il2CppMonoObject *obj, Il2CppMonoClassField *field, void *value); -void il2cpp_mono_field_static_set_value (Il2CppMonoVTable *vt, Il2CppMonoClassField *field, void *value); +void il2cpp_mono_field_set_value (Il2CppMonoObject *obj, MonoClassField *field, void *value); +void il2cpp_mono_field_static_set_value (Il2CppMonoVTable *vt, MonoClassField *field, void *value); uint32_t il2cpp_mono_gchandle_new_weakref (Il2CppMonoObject *obj, mono_bool track_resurrection); Il2CppMonoObject* il2cpp_mono_gchandle_get_target (uint32_t gchandle); void il2cpp_mono_gchandle_free (uint32_t gchandle); void il2cpp_mono_gc_wbarrier_generic_store (void* ptr, Il2CppMonoObject* value); int il2cpp_mono_reflection_parse_type_checked (char *name, Il2CppMonoTypeNameParse *info, MonoError *error); void il2cpp_mono_reflection_free_type_info (Il2CppMonoTypeNameParse *info); -mono_bool il2cpp_mono_custom_attrs_has_attr (Il2CppMonoCustomAttrInfo *ainfo, Il2CppMonoClass *attr_klass); +mono_bool il2cpp_mono_custom_attrs_has_attr (Il2CppMonoCustomAttrInfo *ainfo, MonoClass *attr_klass); void il2cpp_mono_custom_attrs_free (Il2CppMonoCustomAttrInfo *ainfo); Il2CppMonoDomain* il2cpp_mono_get_root_domain (void); void il2cpp_mono_runtime_quit (void); @@ -483,74 +378,74 @@ Il2CppMonoDomain* il2cpp_mono_domain_get (void); gboolean il2cpp_mono_domain_set (Il2CppMonoDomain *domain, gboolean force); void il2cpp_mono_domain_foreach(Il2CppMonoDomainFunc func, gpointer user_data); MonoJitInfo* il2cpp_mono_jit_info_table_find(Il2CppMonoDomain* domain, char* addr); -Il2CppMonoMethod* il2cpp_mono_jit_info_get_method(MonoJitInfo* ji); -MonoDebugMethodInfo* il2cpp_mono_debug_lookup_method(Il2CppMonoMethod* method); -MonoDebugMethodJitInfo* il2cpp_mono_debug_find_method(Il2CppMonoMethod* method, Il2CppMonoDomain* domain); +MonoMethod* il2cpp_mono_jit_info_get_method(MonoJitInfo* ji); +MonoDebugMethodInfo* il2cpp_mono_debug_lookup_method(MonoMethod* method); +MonoDebugMethodJitInfo* il2cpp_mono_debug_find_method(MonoMethod* method, Il2CppMonoDomain* domain); void il2cpp_mono_debug_free_method_jit_info(MonoDebugMethodJitInfo* jit); -MonoDebugLocalsInfo* il2cpp_mono_debug_lookup_locals(Il2CppMonoMethod* method); -MonoDebugMethodAsyncInfo* il2cpp_mono_debug_lookup_method_async_debug_info(Il2CppMonoMethod* method); +MonoDebugLocalsInfo* il2cpp_mono_debug_lookup_locals(MonoMethod* method); +MonoDebugMethodAsyncInfo* il2cpp_mono_debug_lookup_method_async_debug_info(MonoMethod* method); MonoDebugSourceLocation* il2cpp_mono_debug_method_lookup_location(MonoDebugMethodInfo* minfo, int il_offset); -gint32 il2cpp_mono_debug_il_offset_from_address(Il2CppMonoMethod* method, Il2CppMonoDomain* domain, guint32 native_offset); +gint32 il2cpp_mono_debug_il_offset_from_address(MonoMethod* method, Il2CppMonoDomain* domain, guint32 native_offset); void il2cpp_mono_debug_free_source_location(MonoDebugSourceLocation* location); void il2cpp_mono_set_is_debugger_attached(gboolean attached); -char* il2cpp_mono_type_full_name(Il2CppMonoType* type); -char* il2cpp_mono_method_full_name(Il2CppMonoMethod* method, gboolean signature); +char* il2cpp_mono_type_full_name(MonoType* type); +char* il2cpp_mono_method_full_name(MonoMethod* method, gboolean signature); void il2cpp_mono_debug_get_seq_points(MonoDebugMethodInfo* minfo, char** source_file, GPtrArray** source_file_list, int** source_files, MonoSymSeqPoint** seq_points, int* n_seq_points); void il2cpp_mono_debug_free_locals(MonoDebugLocalsInfo* info); void il2cpp_mono_debug_free_method_async_debug_info(MonoDebugMethodAsyncInfo* info); -Il2CppMonoThread* il2cpp_mono_thread_current(); -Il2CppMonoThread* il2cpp_mono_thread_get_main(); -Il2CppMonoThread* il2cpp_mono_thread_attach(Il2CppMonoDomain* domain); +MonoThread* il2cpp_mono_thread_current(); +MonoThread* il2cpp_mono_thread_get_main(); +MonoThread* il2cpp_mono_thread_attach(Il2CppMonoDomain* domain); void il2cpp_mono_domain_lock(Il2CppMonoDomain* domain); void il2cpp_mono_domain_unlock(Il2CppMonoDomain* domain); MonoJitInfo* il2cpp_mono_jit_info_table_find_internal(Il2CppMonoDomain* domain, char* addr, gboolean try_aot, gboolean allow_trampolines); guint il2cpp_mono_aligned_addr_hash(gconstpointer ptr); -Il2CppMonoGenericInst* il2cpp_mono_metadata_get_generic_inst(int type_argc, Il2CppMonoType** type_argv); -Il2CppMonoMethod* il2cpp_mono_get_method_checked(Il2CppMonoImage* image, guint32 token, Il2CppMonoClass* klass, Il2CppMonoGenericContext* context, MonoError* error); -int il2cpp_mono_class_interface_offset_with_variance(Il2CppMonoClass* klass, Il2CppMonoClass* itf, gboolean* non_exact_match); -void il2cpp_mono_class_setup_supertypes(Il2CppMonoClass* klass); -void il2cpp_mono_class_setup_vtable(Il2CppMonoClass* klass); -void il2cpp_mono_class_setup_methods(Il2CppMonoClass* klass); -gboolean il2cpp_mono_class_field_is_special_static(Il2CppMonoClassField* field); -guint32 il2cpp_mono_class_field_get_special_static_type(Il2CppMonoClassField* field); -Il2CppMonoGenericContext* il2cpp_mono_class_get_context(Il2CppMonoClass* klass); -Il2CppMonoGenericContext* il2cpp_mono_method_get_context(Il2CppMonoMethod* method); -Il2CppMonoGenericContainer* il2cpp_mono_method_get_generic_container(Il2CppMonoMethod* method); -Il2CppMonoMethod* il2cpp_mono_class_inflate_generic_method_full_checked(Il2CppMonoMethod* method, Il2CppMonoClass* klass_hint, Il2CppMonoGenericContext* context, MonoError* error); -Il2CppMonoMethod* il2cpp_mono_class_inflate_generic_method_checked(Il2CppMonoMethod* method, Il2CppMonoGenericContext* context, MonoError* error); +MonoGenericInst* il2cpp_mono_metadata_get_generic_inst(int type_argc, MonoType** type_argv); +MonoMethod* il2cpp_mono_get_method_checked(MonoImage* image, guint32 token, MonoClass* klass, MonoGenericContext* context, MonoError* error); +int il2cpp_mono_class_interface_offset_with_variance(MonoClass* klass, MonoClass* itf, gboolean* non_exact_match); +void il2cpp_mono_class_setup_supertypes(MonoClass* klass); +void il2cpp_mono_class_setup_vtable(MonoClass* klass); +void il2cpp_mono_class_setup_methods(MonoClass* klass); +gboolean il2cpp_mono_class_field_is_special_static(MonoClassField* field); +guint32 il2cpp_mono_class_field_get_special_static_type(MonoClassField* field); +MonoGenericContext* il2cpp_mono_class_get_context(MonoClass* klass); +MonoGenericContext* il2cpp_mono_method_get_context(MonoMethod* method); +MonoGenericContainer* il2cpp_mono_method_get_generic_container(MonoMethod* method); +MonoMethod* il2cpp_mono_class_inflate_generic_method_full_checked(MonoMethod* method, MonoClass* klass_hint, MonoGenericContext* context, MonoError* error); +MonoMethod* il2cpp_mono_class_inflate_generic_method_checked(MonoMethod* method, MonoGenericContext* context, MonoError* error); void il2cpp_mono_loader_lock(); void il2cpp_mono_loader_unlock(); void il2cpp_mono_loader_lock_track_ownership(gboolean track); gboolean il2cpp_mono_loader_lock_is_owned_by_self(); -gpointer il2cpp_mono_method_get_wrapper_data(Il2CppMonoMethod* method, guint32 id); -char* il2cpp_mono_type_get_name_full(Il2CppMonoType* type, MonoTypeNameFormat format); -gboolean il2cpp_mono_class_is_nullable(Il2CppMonoClass* klass); -Il2CppMonoGenericContainer* il2cpp_mono_class_get_generic_container(Il2CppMonoClass* klass); -void il2cpp_mono_class_setup_interfaces(Il2CppMonoClass* klass, MonoError* error); -GPtrArray* il2cpp_mono_class_get_methods_by_name(Il2CppMonoClass* klass, const char* name, guint32 bflags, gboolean ignore_case, gboolean allow_ctors, MonoError* error); -gpointer il2cpp_mono_ldtoken_checked(Il2CppMonoImage* image, guint32 token, Il2CppMonoClass** handle_class, Il2CppMonoGenericContext* context, MonoError* error); -Il2CppMonoClass* il2cpp_mono_class_from_generic_parameter_internal(Il2CppMonoGenericParam* param); -Il2CppMonoClass* il2cpp_mono_class_load_from_name(Il2CppMonoImage* image, const char* name_space, const char* name); -Il2CppMonoGenericClass* il2cpp_mono_class_get_generic_class(Il2CppMonoClass* klass); -Il2CppMonoInternalThread* il2cpp_mono_thread_internal_current(); -gboolean il2cpp_mono_thread_internal_is_current(Il2CppMonoInternalThread* thread); -void il2cpp_mono_thread_internal_abort(Il2CppMonoInternalThread* thread, gboolean appdomain_unload); -void il2cpp_mono_thread_internal_reset_abort(Il2CppMonoInternalThread* thread); -gunichar2* il2cpp_mono_thread_get_name(Il2CppMonoInternalThread* this_obj, guint32* name_len); -void il2cpp_mono_thread_set_name_internal(Il2CppMonoInternalThread* this_obj, Il2CppMonoString* name, gboolean permanent, gboolean reset, MonoError* error); +gpointer il2cpp_mono_method_get_wrapper_data(MonoMethod* method, guint32 id); +char* il2cpp_mono_type_get_name_full(MonoType* type, MonoTypeNameFormat format); +gboolean il2cpp_mono_class_is_nullable(MonoClass* klass); +MonoGenericContainer* il2cpp_mono_class_get_generic_container(MonoClass* klass); +void il2cpp_mono_class_setup_interfaces(MonoClass* klass, MonoError* error); +GPtrArray* il2cpp_mono_class_get_methods_by_name(MonoClass* klass, const char* name, guint32 bflags, gboolean ignore_case, gboolean allow_ctors, MonoError* error); +gpointer il2cpp_mono_ldtoken_checked(MonoImage* image, guint32 token, MonoClass** handle_class, MonoGenericContext* context, MonoError* error); +MonoClass* il2cpp_mono_class_from_generic_parameter_internal(MonoGenericParam* param); +MonoClass* il2cpp_mono_class_load_from_name(MonoImage* image, const char* name_space, const char* name); +MonoGenericClass* il2cpp_mono_class_get_generic_class(MonoClass* klass); +MonoInternalThread* il2cpp_mono_thread_internal_current(); +gboolean il2cpp_mono_thread_internal_is_current(MonoInternalThread* thread); +void il2cpp_mono_thread_internal_abort(MonoInternalThread* thread, gboolean appdomain_unload); +void il2cpp_mono_thread_internal_reset_abort(MonoInternalThread* thread); +gunichar2* il2cpp_mono_thread_get_name(MonoInternalThread* this_obj, guint32* name_len); +void il2cpp_mono_thread_set_name_internal(MonoInternalThread* this_obj, MonoString* name, gboolean permanent, gboolean reset, MonoError* error); void il2cpp_mono_thread_suspend_all_other_threads(); void il2cpp_mono_stack_mark_record_size(MonoThreadInfo* info, HandleStackMark* stackmark, const char* func_name); Il2CppMonoRuntimeExceptionHandlingCallbacks* il2cpp_mono_get_eh_callbacks(); -void il2cpp_mono_reflection_create_custom_attr_data_args(Il2CppMonoImage* image, Il2CppMonoMethod* method, const guchar* data, guint32 len, Il2CppMonoArray** typed_args, Il2CppMonoArray** named_args, CattrNamedArg** named_arg_info, MonoError* error); -void il2cpp_mono_nullable_init(guint8* buf, Il2CppMonoObject* value, Il2CppMonoClass* klass); -Il2CppMonoObject* il2cpp_mono_value_box_checked(Il2CppMonoDomain* domain, Il2CppMonoClass* klass, gpointer value, MonoError* error); -void il2cpp_mono_field_static_get_value_checked(Il2CppMonoVTable* vt, Il2CppMonoClassField* field, void* value, MonoError* error); -void il2cpp_mono_field_static_get_value_for_thread(Il2CppMonoInternalThread* thread, Il2CppMonoVTable* vt, Il2CppMonoClassField* field, void* value, MonoError* error); -Il2CppMonoObject* il2cpp_mono_field_get_value_object_checked(Il2CppMonoDomain* domain, Il2CppMonoClassField* field, Il2CppMonoObject* obj, MonoError* error); -Il2CppMonoObject* il2cpp_mono_object_new_checked(Il2CppMonoDomain* domain, Il2CppMonoClass* klass, MonoError* error); -Il2CppMonoString* il2cpp_mono_ldstr_checked(Il2CppMonoDomain* domain, Il2CppMonoImage* image, guint32 idx, MonoError* error); -Il2CppMonoObject* il2cpp_mono_runtime_try_invoke(Il2CppMonoMethod* method, void* obj, void** params, Il2CppMonoObject** exc, MonoError* error); -Il2CppMonoObject* il2cpp_mono_runtime_invoke_checked(Il2CppMonoMethod* method, void* obj, void** params, MonoError* error); +void il2cpp_mono_reflection_create_custom_attr_data_args(MonoImage* image, MonoMethod* method, const guchar* data, guint32 len, MonoArray** typed_args, MonoArray** named_args, CattrNamedArg** named_arg_info, MonoError* error); +void il2cpp_mono_nullable_init(guint8* buf, Il2CppMonoObject* value, MonoClass* klass); +Il2CppMonoObject* il2cpp_mono_value_box_checked(Il2CppMonoDomain* domain, MonoClass* klass, gpointer value, MonoError* error); +void il2cpp_mono_field_static_get_value_checked(Il2CppMonoVTable* vt, MonoClassField* field, void* value, MonoError* error); +void il2cpp_mono_field_static_get_value_for_thread(MonoInternalThread* thread, Il2CppMonoVTable* vt, MonoClassField* field, void* value, MonoError* error); +Il2CppMonoObject* il2cpp_mono_field_get_value_object_checked(Il2CppMonoDomain* domain, MonoClassField* field, Il2CppMonoObject* obj, MonoError* error); +Il2CppMonoObject* il2cpp_mono_object_new_checked(Il2CppMonoDomain* domain, MonoClass* klass, MonoError* error); +MonoString* il2cpp_mono_ldstr_checked(Il2CppMonoDomain* domain, MonoImage* image, guint32 idx, MonoError* error); +Il2CppMonoObject* il2cpp_mono_runtime_try_invoke(MonoMethod* method, void* obj, void** params, Il2CppMonoObject** exc, MonoError* error); +Il2CppMonoObject* il2cpp_mono_runtime_invoke_checked(MonoMethod* method, void* obj, void** params, MonoError* error); void il2cpp_mono_gc_base_init(); int il2cpp_mono_gc_register_root(char* start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, const char* msg); void il2cpp_mono_gc_deregister_root(char* addr); @@ -558,26 +453,26 @@ gint32 il2cpp_mono_environment_exitcode_get(); void il2cpp_mono_environment_exitcode_set(gint32 value); void il2cpp_mono_threadpool_suspend(); void il2cpp_mono_threadpool_resume(); -Il2CppMonoImage* il2cpp_mono_assembly_get_image(Il2CppMonoAssembly* assembly); +MonoImage* il2cpp_mono_assembly_get_image(Il2CppMonoAssembly* assembly); gboolean il2cpp_mono_runtime_try_shutdown(); -gboolean il2cpp_mono_verifier_is_method_valid_generic_instantiation(Il2CppMonoMethod* method); -Il2CppMonoType* il2cpp_mono_reflection_get_type_checked(Il2CppMonoImage* rootimage, Il2CppMonoImage* image, Il2CppMonoTypeNameParse* info, gboolean ignorecase, gboolean* type_resolve, MonoError* error); -Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_method_checked(Il2CppMonoMethod* method, MonoError* error); -Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_class_checked(Il2CppMonoClass* klass, MonoError* error); -Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_property_checked(Il2CppMonoClass* klass, Il2CppMonoProperty* property, MonoError* error); -Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_field_checked(Il2CppMonoClass* klass, Il2CppMonoClassField* field, MonoError* error); +gboolean il2cpp_mono_verifier_is_method_valid_generic_instantiation(MonoMethod* method); +MonoType* il2cpp_mono_reflection_get_type_checked(MonoImage* rootimage, MonoImage* image, Il2CppMonoTypeNameParse* info, gboolean ignorecase, gboolean* type_resolve, MonoError* error); +Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_method_checked(MonoMethod* method, MonoError* error); +Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_class_checked(MonoClass* klass, MonoError* error); +Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_property_checked(MonoClass* klass, MonoProperty* property, MonoError* error); +Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_field_checked(MonoClass* klass, MonoClassField* field, MonoError* error); Il2CppMonoReflectionAssemblyHandle il2cpp_mono_assembly_get_object_handle(Il2CppMonoDomain* domain, Il2CppMonoAssembly* assembly, MonoError* error); -Il2CppMonoReflectionType* il2cpp_mono_type_get_object_checked(Il2CppMonoDomain* domain, Il2CppMonoType* type, MonoError* error); +MonoReflectionType* il2cpp_mono_type_get_object_checked(Il2CppMonoDomain* domain, MonoType* type, MonoError* error); void il2cpp_mono_network_init(); gint il2cpp_mono_w32socket_set_blocking(SOCKET sock, gboolean blocking); char* il2cpp_mono_get_runtime_build_info(); -Il2CppMonoMethod* il2cpp_mono_marshal_method_from_wrapper(Il2CppMonoMethod* wrapper); +MonoMethod* il2cpp_mono_marshal_method_from_wrapper(MonoMethod* wrapper); MonoDebugOptions* il2cpp_mini_get_debug_options(); -gpointer il2cpp_mono_jit_find_compiled_method_with_jit_info(Il2CppMonoDomain* domain, Il2CppMonoMethod* method, MonoJitInfo** ji); +gpointer il2cpp_mono_jit_find_compiled_method_with_jit_info(Il2CppMonoDomain* domain, MonoMethod* method, MonoJitInfo** ji); MonoLMF** il2cpp_mono_get_lmf_addr(); void il2cpp_mono_set_lmf(MonoLMF* lmf); -gpointer il2cpp_mono_aot_get_method_checked(Il2CppMonoDomain* domain, Il2CppMonoMethod* method, MonoError* error); +gpointer il2cpp_mono_aot_get_method_checked(Il2CppMonoDomain* domain, MonoMethod* method, MonoError* error); void il2cpp_mono_arch_setup_resume_sighandler_ctx(MonoContext* ctx, gpointer func); void il2cpp_mono_arch_set_breakpoint(MonoJitInfo* ji, guint8* ip); void il2cpp_mono_arch_clear_breakpoint(MonoJitInfo* ji, guint8* ip); @@ -595,18 +490,18 @@ gboolean il2cpp_mono_thread_state_init_from_monoctx(MonoThreadUnwindState* ctx, MonoJitInfo* il2cpp_mini_jit_info_table_find(Il2CppMonoDomain* domain, char* addr, Il2CppMonoDomain** out_domain); void il2cpp_mono_restore_context(MonoContext* ctx); gboolean il2cpp_mono_find_jit_info_ext(Il2CppMonoDomain* domain, Il2CppMonoJitTlsData* jit_tls, MonoJitInfo* prev_ji, MonoContext* ctx, MonoContext* new_ctx, char** trace, MonoLMF** lmf, mgreg_t** save_locations, StackFrameInfo* frame); -Il2CppMonoMethod* il2cpp_mono_method_get_declaring_generic_method(Il2CppMonoMethod* method); -Il2CppMonoMethod* il2cpp_jinfo_get_method (MonoJitInfo *ji); -gboolean il2cpp_mono_find_prev_seq_point_for_native_offset (Il2CppMonoDomain *domain, Il2CppMonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point); +MonoMethod* il2cpp_mono_method_get_declaring_generic_method(MonoMethod* method); +MonoMethod* il2cpp_jinfo_get_method (MonoJitInfo *ji); +gboolean il2cpp_mono_find_prev_seq_point_for_native_offset (Il2CppMonoDomain *domain, MonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point); SOCKET il2cpp_mono_w32socket_accept_internal (SOCKET s, struct sockaddr *addr, socklen_t *addrlen, gboolean blocking); -gboolean il2cpp_mono_find_next_seq_point_for_native_offset (Il2CppMonoDomain *domain, Il2CppMonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point); -gboolean il2cpp_mono_class_has_parent (Il2CppMonoClass *klass, Il2CppMonoClass *parent); -Il2CppMonoGenericParam* il2cpp_mono_generic_container_get_param (Il2CppMonoGenericContainer *gc, int i); -gboolean il2cpp_mono_find_seq_point (Il2CppMonoDomain *domain, Il2CppMonoMethod *method, gint32 il_offset, MonoSeqPointInfo **info, SeqPoint *seq_point); +gboolean il2cpp_mono_find_next_seq_point_for_native_offset (Il2CppMonoDomain *domain, MonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point); +gboolean il2cpp_mono_class_has_parent (MonoClass *klass, MonoClass *parent); +MonoGenericParam* il2cpp_mono_generic_container_get_param (MonoGenericContainer *gc, int i); +gboolean il2cpp_mono_find_seq_point (Il2CppMonoDomain *domain, MonoMethod *method, gint32 il_offset, MonoSeqPointInfo **info, SeqPoint *seq_point); void il2cpp_mono_seq_point_iterator_init (SeqPointIterator* it, MonoSeqPointInfo* info); gboolean il2cpp_mono_seq_point_iterator_next (SeqPointIterator* it); void il2cpp_mono_seq_point_init_next (MonoSeqPointInfo* info, SeqPoint sp, SeqPoint* next); -MonoSeqPointInfo* il2cpp_mono_get_seq_points (Il2CppMonoDomain *domain, Il2CppMonoMethod *method); +MonoSeqPointInfo* il2cpp_mono_get_seq_points (Il2CppMonoDomain *domain, MonoMethod *method); void IL2CPP_G_BREAKPOINT(); void il2cpp_mono_thread_info_safe_suspend_and_run (MonoNativeThreadId id, gboolean interrupt_kernel, MonoSuspendThreadCallback callback, gpointer user_data); void il2cpp_mono_error_cleanup (MonoError *oerror); @@ -614,16 +509,10 @@ Il2CppMonoException* il2cpp_mono_error_convert_to_exception (MonoError *target_e const char* il2cpp_mono_error_get_message (MonoError *oerror); void il2cpp_mono_error_assert_ok_pos (MonoError *error, const char* filename, int lineno); Il2CppSequencePointC* il2cpp_get_sequence_points(void* *iter); -Il2CppSequencePointC* il2cpp_get_method_sequence_points(Il2CppMonoMethod* method, void* *iter); -Il2CppMonoGenericInst* il2cpp_generic_class_get_inst(Il2CppMonoGenericClass *monoGenClass); -guint il2cpp_generic_inst_type_argc(Il2CppMonoGenericInst *monoInst); -Il2CppMonoType* il2cpp_generic_inst_type_arg(Il2CppMonoGenericInst *monoInst, int i); -Il2CppMonoType* il2cpp_class_this_arg(Il2CppMonoClass *monoClass); -Il2CppMonoClass* il2cpp_class_get_nested_types_accepts_generic(Il2CppMonoClass *monoClass, void* *iter); -Il2CppMonoClass* il2cpp_defaults_object_class(); -guint8 il2cpp_array_rank(Il2CppMonoArray *monoArr); -mono_array_size_t il2cpp_array_bound_length(Il2CppMonoArray *monoArr, int i); -mono_array_lower_bound_t il2cpp_array_bound_lower_bound(Il2CppMonoArray *monoArr, int i); +Il2CppSequencePointC* il2cpp_get_method_sequence_points(MonoMethod* method, void* *iter); +MonoClass* il2cpp_class_get_nested_types_accepts_generic(MonoClass *monoClass, void* *iter); +MonoClass* il2cpp_defaults_object_class(); +guint8 il2cpp_array_rank(MonoArray *monoArr); const char* il2cpp_assembly_name_name(Il2CppMonoAssembly *monoAssembly); uint16_t il2cpp_assembly_name_major(Il2CppMonoAssembly *monoAssembly); uint16_t il2cpp_assembly_name_minor(Il2CppMonoAssembly *monoAssembly); @@ -633,31 +522,23 @@ const char* il2cpp_assembly_name_culture(Il2CppMonoAssembly *monoAssembly); mono_byte il2cpp_assembly_name_public_key_token(Il2CppMonoAssembly *monoAssembly, int i); const char* il2cpp_assembly_name_public_key_token_string(Il2CppMonoAssembly *monoAssembly); uint32_t il2cpp_assembly_name_flags(Il2CppMonoAssembly *monoAssembly); -const char* il2cpp_image_name(Il2CppMonoImage *monoImage); -Il2CppMonoAssembly* il2cpp_image_assembly(Il2CppMonoImage *monoImage); -guint8* il2cpp_field_get_address(Il2CppMonoObject *obj, Il2CppMonoClassField *monoField); -Il2CppMonoType* il2cpp_mono_object_get_type(Il2CppMonoObject* object); -Il2CppMonoClass* il2cpp_defaults_exception_class(); -Il2CppMonoImage* il2cpp_defaults_corlib_image(); -int il2cpp_generic_container_get_type_argc(Il2CppMonoGenericClass* container); -uint32_t il2cpp_method_get_flags_no_iflags (const Il2CppMonoMethod * method); -bool il2cpp_method_is_string_ctor (const Il2CppMonoMethod * method); -Il2CppMonoClass* il2cpp_defaults_void_class(); -void il2cpp_set_var(guint8* newValue, void *value, Il2CppMonoType *localVariableTypeMono); -Il2CppMonoMethod* il2cpp_get_interface_method(Il2CppMonoClass* klass, Il2CppMonoClass* itf, int slot); -gboolean il2cpp_field_is_deleted(Il2CppMonoClassField *field); -Il2CppMonoGenericClass* il2cpp_type_get_generic_class(Il2CppMonoType *type); -gboolean il2cpp_class_get_enumtype(Il2CppMonoClass *klass); -Il2CppMonoClass* il2cpp_iterate_loaded_classes(void* *iter); +const char* il2cpp_image_name(MonoImage *monoImage); +guint8* il2cpp_field_get_address(Il2CppMonoObject *obj, MonoClassField *monoField); +MonoType* il2cpp_mono_object_get_type(Il2CppMonoObject* object); +MonoClass* il2cpp_defaults_exception_class(); +MonoImage* il2cpp_defaults_corlib_image(); +bool il2cpp_method_is_string_ctor (const MonoMethod * method); +MonoClass* il2cpp_defaults_void_class(); +void il2cpp_set_var(guint8* newValue, void *value, MonoType *localVariableTypeMono); +MonoMethod* il2cpp_get_interface_method(MonoClass* klass, MonoClass* itf, int slot); +gboolean il2cpp_field_is_deleted(MonoClassField *field); +MonoClass* il2cpp_iterate_loaded_classes(void* *iter); Il2CppMonoAssembly* il2cpp_domain_get_assemblies_iter(Il2CppMonoAppDomain *domain, void* *iter); -const char** il2cpp_get_source_files_for_type(Il2CppMonoClass *klass, int *count); -Il2CppMonoInternalThread* il2cpp_mono_thread_get_internal(Il2CppMonoThread* thread); -uint32_t il2cpp_internal_thread_get_state(Il2CppMonoInternalThread* thread); -il2cpp_internal_thread_get_threadpool_thread(Il2CppMonoInternalThread* thread); -Il2CppMonoMethod* il2cpp_method_get_generic_definition(Il2CppMonoMethodInflated *imethod); -Il2CppMonoGenericInst* il2cpp_method_get_generic_class_inst(Il2CppMonoMethodInflated *imethod); -Il2CppMonoClass* il2cpp_generic_class_get_container_class(Il2CppMonoGenericClass *gclass); -void il2cpp_mono_thread_detach(Il2CppMonoThread* thread); -Il2CppMonoClass* il2cpp_mono_get_string_class (void); +const char** il2cpp_get_source_files_for_type(MonoClass *klass, int *count); +MonoMethod* il2cpp_method_get_generic_definition(Il2CppMonoMethodInflated *imethod); +MonoGenericInst* il2cpp_method_get_generic_class_inst(Il2CppMonoMethodInflated *imethod); +MonoClass* il2cpp_generic_class_get_container_class(MonoGenericClass *gclass); +void il2cpp_mono_thread_detach(MonoThread* thread); +MonoClass* il2cpp_mono_get_string_class (void); #endif // RUNTIME_IL2CPP diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index 99a1f115050a..379759cd2134 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -50,33 +50,33 @@ static MonoGHashTable *method_signatures; static il2cpp::os::Mutex s_il2cpp_mono_loader_lock(false); static uint64_t s_il2cpp_mono_loader_lock_tid = 0; -Il2CppMonoMethod* il2cpp_mono_image_get_entry_point (Il2CppMonoImage *image) +MonoMethod* il2cpp_mono_image_get_entry_point (MonoImage *image) { - return (Il2CppMonoMethod*)il2cpp::vm::Image::GetEntryPoint((Il2CppImage*)image); + return (MonoMethod*)il2cpp::vm::Image::GetEntryPoint((Il2CppImage*)image); } -const char* il2cpp_mono_image_get_filename (Il2CppMonoImage *monoImage) +const char* il2cpp_mono_image_get_filename (MonoImage *monoImage) { Il2CppImage *image = (Il2CppImage*)monoImage; return image->name; } -const char* il2cpp_mono_image_get_guid (Il2CppMonoImage *image) +const char* il2cpp_mono_image_get_guid (MonoImage *image) { return "00000000-0000-0000-0000-000000000000"; //IL2CPP doesn't have image GUIDs } -Il2CppMonoClass* il2cpp_mono_type_get_class (Il2CppMonoType *type) +MonoClass* il2cpp_mono_type_get_class (MonoType *type) { - return (Il2CppMonoClass*) il2cpp::vm::Type::GetClass((Il2CppType*)type); + return (MonoClass*) il2cpp::vm::Type::GetClass((Il2CppType*)type); } -mono_bool il2cpp_mono_type_is_struct (Il2CppMonoType *type) +mono_bool il2cpp_mono_type_is_struct (MonoType *type) { return il2cpp::vm::Type::IsStruct((Il2CppType*)type); } -mono_bool il2cpp_mono_type_is_reference (Il2CppMonoType *type) +mono_bool il2cpp_mono_type_is_reference (MonoType *type) { return il2cpp::vm::Type::IsReference((Il2CppType*)type); } @@ -86,7 +86,7 @@ void il2cpp_mono_metadata_free_mh (Il2CppMonoMethodHeader *mh) IL2CPP_ASSERT(0 && "This method is not yet implemented"); } -Il2CppMonoMethodSignature* il2cpp_mono_method_signature (Il2CppMonoMethod *m) +Il2CppMonoMethodSignature* il2cpp_mono_method_signature (MonoMethod *m) { MethodInfo* method = (MethodInfo*)m; @@ -101,7 +101,7 @@ Il2CppMonoMethodSignature* il2cpp_mono_method_signature (Il2CppMonoMethod *m) sig->call_convention = MONO_CALL_DEFAULT; sig->hasthis = il2cpp::vm::Method::IsInstance(method); - sig->ret = (Il2CppMonoType*)il2cpp::vm::Method::GetReturnType(method); + sig->ret = (MonoType*)il2cpp::vm::Method::GetReturnType(method); sig->generic_param_count = 0; @@ -119,9 +119,9 @@ Il2CppMonoMethodSignature* il2cpp_mono_method_signature (Il2CppMonoMethod *m) } sig->param_count = il2cpp::vm::Method::GetParamCount(method); - sig->params = g_new(Il2CppMonoType*, sig->param_count); + sig->params = g_new(MonoType*, sig->param_count); for (int i = 0; i < sig->param_count; ++i) - sig->params[i] = (Il2CppMonoType*)il2cpp::vm::Method::GetParam(method, i); + sig->params[i] = (MonoType*)il2cpp::vm::Method::GetParam(method, i); mono_g_hash_table_insert(method_signatures, method, sig); @@ -144,7 +144,7 @@ void il2cpp_mono_free_method_signatures() } } -void il2cpp_mono_method_get_param_names (Il2CppMonoMethod *m, const char **names) +void il2cpp_mono_method_get_param_names (MonoMethod *m, const char **names) { MethodInfo* method = (MethodInfo*)m; uint32_t numberOfParameters = il2cpp::vm::Method::GetParamCount(method); @@ -152,7 +152,7 @@ void il2cpp_mono_method_get_param_names (Il2CppMonoMethod *m, const char **names names[i] = il2cpp::vm::Method::GetParamName(method, i); } -mono_bool il2cpp_mono_type_generic_inst_is_valuetype (Il2CppMonoType *monoType) +mono_bool il2cpp_mono_type_generic_inst_is_valuetype (MonoType *monoType) { static const int kBitIsValueType = 1; Il2CppType *type = (Il2CppType*)monoType; @@ -160,126 +160,126 @@ mono_bool il2cpp_mono_type_generic_inst_is_valuetype (Il2CppMonoType *monoType) return (typeDef->bitfield >> (kBitIsValueType - 1)) & 0x1; } -Il2CppMonoMethodHeader* il2cpp_mono_method_get_header_checked (Il2CppMonoMethod *method, MonoError *error) +Il2CppMonoMethodHeader* il2cpp_mono_method_get_header_checked (MonoMethod *method, MonoError *error) { return NULL; } -gboolean il2cpp_mono_class_init (Il2CppMonoClass *klass) +gboolean il2cpp_mono_class_init (MonoClass *klass) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; } -Il2CppMonoVTable* il2cpp_mono_class_vtable (Il2CppMonoDomain *domain, Il2CppMonoClass *klass) +Il2CppMonoVTable* il2cpp_mono_class_vtable (Il2CppMonoDomain *domain, MonoClass *klass) { return (Il2CppMonoVTable*)((Il2CppClass*)klass)->vtable; } -Il2CppMonoClassField* il2cpp_mono_class_get_field_from_name (Il2CppMonoClass *klass, const char *name) +MonoClassField* il2cpp_mono_class_get_field_from_name (MonoClass *klass, const char *name) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; } -int32_t il2cpp_mono_array_element_size (Il2CppMonoClass *monoClass) +int32_t il2cpp_mono_array_element_size (MonoClass *monoClass) { Il2CppClass *klass = (Il2CppClass*)monoClass; return klass->element_size; } -int32_t il2cpp_mono_class_instance_size (Il2CppMonoClass *klass) +int32_t il2cpp_mono_class_instance_size (MonoClass *klass) { return il2cpp::vm::Class::GetInstanceSize((Il2CppClass*)klass); } -int32_t il2cpp_mono_class_value_size (Il2CppMonoClass *klass, uint32_t *align) +int32_t il2cpp_mono_class_value_size (MonoClass *klass, uint32_t *align) { return il2cpp::vm::Class::GetValueSize((Il2CppClass*)klass, align); } -gboolean il2cpp_mono_class_is_assignable_from (Il2CppMonoClass *klass, Il2CppMonoClass *oklass) +gboolean il2cpp_mono_class_is_assignable_from (MonoClass *klass, MonoClass *oklass) { return il2cpp::vm::Class::IsAssignableFrom((Il2CppClass*)klass, (Il2CppClass*)oklass); } -Il2CppMonoClass* il2cpp_mono_class_from_mono_type (Il2CppMonoType *type) +MonoClass* il2cpp_mono_class_from_mono_type (MonoType *type) { - return (Il2CppMonoClass*)il2cpp::vm::Class::FromIl2CppType((Il2CppType*)type); + return (MonoClass*)il2cpp::vm::Class::FromIl2CppType((Il2CppType*)type); } -int il2cpp_mono_class_num_fields (Il2CppMonoClass *klass) +int il2cpp_mono_class_num_fields (MonoClass *klass) { return il2cpp::vm::Class::GetNumFields((Il2CppClass*)klass); } -int il2cpp_mono_class_num_methods (Il2CppMonoClass *klass) +int il2cpp_mono_class_num_methods (MonoClass *klass) { return il2cpp::vm::Class::GetNumMethods((Il2CppClass*)klass); } -int il2cpp_mono_class_num_properties (Il2CppMonoClass *klass) +int il2cpp_mono_class_num_properties (MonoClass *klass) { return il2cpp::vm::Class::GetNumProperties((Il2CppClass*)klass); } -Il2CppMonoClassField* il2cpp_mono_class_get_fields (Il2CppMonoClass* klass, gpointer *iter) +MonoClassField* il2cpp_mono_class_get_fields (MonoClass* klass, gpointer *iter) { - return (Il2CppMonoClassField*)il2cpp::vm::Class::GetFields((Il2CppClass*)klass, iter); + return (MonoClassField*)il2cpp::vm::Class::GetFields((Il2CppClass*)klass, iter); } -Il2CppMonoMethod* il2cpp_mono_class_get_methods (Il2CppMonoClass* klass, gpointer *iter) +MonoMethod* il2cpp_mono_class_get_methods (MonoClass* klass, gpointer *iter) { - return (Il2CppMonoMethod*)il2cpp::vm::Class::GetMethods((Il2CppClass*)klass, iter); + return (MonoMethod*)il2cpp::vm::Class::GetMethods((Il2CppClass*)klass, iter); } -Il2CppMonoProperty* il2cpp_mono_class_get_properties (Il2CppMonoClass* klass, gpointer *iter) +MonoProperty* il2cpp_mono_class_get_properties (MonoClass* klass, gpointer *iter) { - return (Il2CppMonoProperty*)il2cpp::vm::Class::GetProperties((Il2CppClass*)klass, iter); + return (MonoProperty*)il2cpp::vm::Class::GetProperties((Il2CppClass*)klass, iter); } -const char* il2cpp_mono_field_get_name (Il2CppMonoClassField *field) +const char* il2cpp_mono_field_get_name (MonoClassField *field) { return il2cpp::vm::Field::GetName((FieldInfo*)field); } -mono_unichar2* il2cpp_mono_string_chars (Il2CppMonoString *monoStr) +mono_unichar2* il2cpp_mono_string_chars (MonoString *monoStr) { Il2CppString *str = (Il2CppString*)monoStr; return (mono_unichar2*)str->chars; } -int il2cpp_mono_string_length (Il2CppMonoString *monoStr) +int il2cpp_mono_string_length (MonoString *monoStr) { Il2CppString *str = (Il2CppString*)monoStr; return str->length; } -char* il2cpp_mono_array_addr_with_size (Il2CppMonoArray *array, int size, uintptr_t idx) +char* il2cpp_mono_array_addr_with_size (MonoArray *array, int size, uintptr_t idx) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; } -uintptr_t il2cpp_mono_array_length (Il2CppMonoArray *array) +uintptr_t il2cpp_mono_array_length (MonoArray *array) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; } -Il2CppMonoString* il2cpp_mono_string_new (Il2CppMonoDomain *domain, const char *text) +MonoString* il2cpp_mono_string_new (Il2CppMonoDomain *domain, const char *text) { - return (Il2CppMonoString*)il2cpp::vm::String::New(text); + return (MonoString*)il2cpp::vm::String::New(text); } -Il2CppMonoString* il2cpp_mono_string_new_checked (Il2CppMonoDomain *domain, const char *text, MonoError *merror) +MonoString* il2cpp_mono_string_new_checked (Il2CppMonoDomain *domain, const char *text, MonoError *merror) { error_init(merror); return il2cpp_mono_string_new (domain, text); } -char* il2cpp_mono_string_to_utf8_checked (Il2CppMonoString *string_obj, MonoError *error) +char* il2cpp_mono_string_to_utf8_checked (MonoString *string_obj, MonoError *error) { error_init(error); Il2CppString *str = (Il2CppString*)string_obj; @@ -298,12 +298,12 @@ void* il2cpp_mono_object_unbox (Il2CppMonoObject *monoObj) return il2cpp::vm::Object::Unbox(obj); } -void il2cpp_mono_field_set_value (Il2CppMonoObject *obj, Il2CppMonoClassField *field, void *value) +void il2cpp_mono_field_set_value (Il2CppMonoObject *obj, MonoClassField *field, void *value) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); } -void il2cpp_mono_field_static_set_value (Il2CppMonoVTable *vt, Il2CppMonoClassField *field, void *value) +void il2cpp_mono_field_static_set_value (Il2CppMonoVTable *vt, MonoClassField *field, void *value) { il2cpp::vm::Field::StaticSetValue((FieldInfo*)field, value); } @@ -345,7 +345,7 @@ void il2cpp_mono_reflection_free_type_info (Il2CppMonoTypeNameParse *info) delete (il2cpp::vm::TypeNameParseInfo*)info->il2cppTypeNameParseInfo; } -mono_bool il2cpp_mono_custom_attrs_has_attr (Il2CppMonoCustomAttrInfo *ainfo, Il2CppMonoClass *attr_klass) +mono_bool il2cpp_mono_custom_attrs_has_attr (Il2CppMonoCustomAttrInfo *ainfo, MonoClass *attr_klass) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; @@ -393,18 +393,18 @@ MonoJitInfo* il2cpp_mono_jit_info_table_find(Il2CppMonoDomain* domain, char* add return NULL; } -Il2CppMonoMethod* il2cpp_mono_jit_info_get_method(MonoJitInfo* ji) +MonoMethod* il2cpp_mono_jit_info_get_method(MonoJitInfo* ji) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; } -MonoDebugMethodInfo* il2cpp_mono_debug_lookup_method(Il2CppMonoMethod* method) +MonoDebugMethodInfo* il2cpp_mono_debug_lookup_method(MonoMethod* method) { return NULL; } -MonoDebugMethodJitInfo* il2cpp_mono_debug_find_method(Il2CppMonoMethod* method, Il2CppMonoDomain* domain) +MonoDebugMethodJitInfo* il2cpp_mono_debug_find_method(MonoMethod* method, Il2CppMonoDomain* domain) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; @@ -415,13 +415,13 @@ void il2cpp_mono_debug_free_method_jit_info(MonoDebugMethodJitInfo* jit) IL2CPP_ASSERT(0 && "This method is not yet implemented"); } -MonoDebugLocalsInfo* il2cpp_mono_debug_lookup_locals(Il2CppMonoMethod* method) +MonoDebugLocalsInfo* il2cpp_mono_debug_lookup_locals(MonoMethod* method) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; } -MonoDebugMethodAsyncInfo* il2cpp_mono_debug_lookup_method_async_debug_info(Il2CppMonoMethod* method) +MonoDebugMethodAsyncInfo* il2cpp_mono_debug_lookup_method_async_debug_info(MonoMethod* method) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; @@ -433,7 +433,7 @@ MonoDebugSourceLocation* il2cpp_mono_debug_method_lookup_location(MonoDebugMetho return NULL; } -gint32 il2cpp_mono_debug_il_offset_from_address(Il2CppMonoMethod* method, Il2CppMonoDomain* domain, guint32 native_offset) +gint32 il2cpp_mono_debug_il_offset_from_address(MonoMethod* method, Il2CppMonoDomain* domain, guint32 native_offset) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; @@ -449,13 +449,13 @@ void il2cpp_mono_set_is_debugger_attached(gboolean attached) il2cpp::utils::Debugger::SetIsDebuggerAttached(attached == TRUE); } -char* il2cpp_mono_type_full_name(Il2CppMonoType* type) +char* il2cpp_mono_type_full_name(MonoType* type) { std::string name = il2cpp::vm::Type::GetName((Il2CppType*)type, IL2CPP_TYPE_NAME_FORMAT_FULL_NAME); return g_strdup(name.c_str()); } -char* il2cpp_mono_method_full_name(Il2CppMonoMethod* method, gboolean signature) +char* il2cpp_mono_method_full_name(MonoMethod* method, gboolean signature) { return g_strdup(((MethodInfo*)method)->name); } @@ -475,31 +475,26 @@ void il2cpp_mono_debug_free_method_async_debug_info(MonoDebugMethodAsyncInfo* in IL2CPP_ASSERT(0 && "This method is not yet implemented"); } -Il2CppMonoThread* il2cpp_mono_thread_current() +MonoThread* il2cpp_mono_thread_current() { - return (Il2CppMonoThread*)il2cpp::vm::Thread::Current(); + return (MonoThread*)il2cpp::vm::Thread::Current(); } -Il2CppMonoThread* il2cpp_mono_thread_get_main() +MonoThread* il2cpp_mono_thread_get_main() { - return (Il2CppMonoThread*)il2cpp::vm::Thread::Main(); + return (MonoThread*)il2cpp::vm::Thread::Main(); } -Il2CppMonoThread* il2cpp_mono_thread_attach(Il2CppMonoDomain* domain) +MonoThread* il2cpp_mono_thread_attach(Il2CppMonoDomain* domain) { - return (Il2CppMonoThread*)il2cpp::vm::Thread::Attach((Il2CppDomain*)domain); + return (MonoThread*)il2cpp::vm::Thread::Attach((Il2CppDomain*)domain); } -void il2cpp_mono_thread_detach(Il2CppMonoThread* thread) +void il2cpp_mono_thread_detach(MonoThread* thread) { il2cpp::vm::Thread::Detach((Il2CppThread*)thread); } -Il2CppMonoInternalThread* il2cpp_mono_thread_get_internal(Il2CppMonoThread* thread) -{ - return (Il2CppMonoInternalThread*)(((Il2CppThread*)thread)->internal_thread); -} - void il2cpp_mono_domain_lock(Il2CppMonoDomain* domain) { } @@ -519,12 +514,12 @@ guint il2cpp_mono_aligned_addr_hash(gconstpointer ptr) return GPOINTER_TO_UINT(ptr) >> 3; } -Il2CppMonoGenericInst* il2cpp_mono_metadata_get_generic_inst(int type_argc, Il2CppMonoType** type_argv) +MonoGenericInst* il2cpp_mono_metadata_get_generic_inst(int type_argc, MonoType** type_argv) { - return (Il2CppMonoGenericInst*)il2cpp::vm::MetadataCache::GetGenericInst((Il2CppType**)type_argv, type_argc); + return (MonoGenericInst*)il2cpp::vm::MetadataCache::GetGenericInst((Il2CppType**)type_argv, type_argc); } -Il2CppMonoMethod* il2cpp_mono_get_method_checked(Il2CppMonoImage* image, guint32 token, Il2CppMonoClass* klass, Il2CppMonoGenericContext* context, MonoError* error) +MonoMethod* il2cpp_mono_get_method_checked(MonoImage* image, guint32 token, MonoClass* klass, MonoGenericContext* context, MonoError* error) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; @@ -546,73 +541,73 @@ MonoGCDescriptor il2cpp_mono_gc_make_vector_descr (void) return 0; } -int il2cpp_mono_class_interface_offset_with_variance(Il2CppMonoClass* klass, Il2CppMonoClass* itf, gboolean* non_exact_match) +int il2cpp_mono_class_interface_offset_with_variance(MonoClass* klass, MonoClass* itf, gboolean* non_exact_match) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; } -void il2cpp_mono_class_setup_supertypes(Il2CppMonoClass* klass) +void il2cpp_mono_class_setup_supertypes(MonoClass* klass) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); } -void il2cpp_mono_class_setup_vtable(Il2CppMonoClass* klass) +void il2cpp_mono_class_setup_vtable(MonoClass* klass) { il2cpp::vm::Class::Init((Il2CppClass*)klass); } -void il2cpp_mono_class_setup_methods(Il2CppMonoClass* klass) +void il2cpp_mono_class_setup_methods(MonoClass* klass) { il2cpp::vm::Class::SetupMethods((Il2CppClass*)klass); } -gboolean il2cpp_mono_class_field_is_special_static(Il2CppMonoClassField* field) +gboolean il2cpp_mono_class_field_is_special_static(MonoClassField* field) { return il2cpp::vm::Field::IsNormalStatic((FieldInfo*)field) ? FALSE : TRUE; } -guint32 il2cpp_mono_class_field_get_special_static_type(Il2CppMonoClassField* field) +guint32 il2cpp_mono_class_field_get_special_static_type(MonoClassField* field) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; } -Il2CppMonoGenericContext* il2cpp_mono_class_get_context(Il2CppMonoClass* klass) +MonoGenericContext* il2cpp_mono_class_get_context(MonoClass* klass) { - return (Il2CppMonoGenericContext*)&((Il2CppClass*)klass)->generic_class->context; + return (MonoGenericContext*)&((Il2CppClass*)klass)->generic_class->context; } -Il2CppMonoGenericContext* il2cpp_mono_method_get_context(Il2CppMonoMethod* monoMethod) +MonoGenericContext* il2cpp_mono_method_get_context(MonoMethod* monoMethod) { MethodInfo * method = (MethodInfo*)monoMethod; if (!method->is_inflated || method->is_generic) return NULL; - return (Il2CppMonoGenericContext*) &((MethodInfo*)method)->genericMethod->context; + return (MonoGenericContext*) &((MethodInfo*)method)->genericMethod->context; } -Il2CppMonoGenericContainer* il2cpp_mono_method_get_generic_container(Il2CppMonoMethod* monoMethod) +MonoGenericContainer* il2cpp_mono_method_get_generic_container(MonoMethod* monoMethod) { MethodInfo * method = (MethodInfo*)monoMethod; if (method->is_inflated || !method->is_generic) return NULL; - return (Il2CppMonoGenericContainer*) method->genericContainer; + return (MonoGenericContainer*) method->genericContainer; } -Il2CppMonoMethod* il2cpp_mono_class_inflate_generic_method_full_checked(Il2CppMonoMethod* method, Il2CppMonoClass* klass_hint, Il2CppMonoGenericContext* context, MonoError* error) +MonoMethod* il2cpp_mono_class_inflate_generic_method_full_checked(MonoMethod* method, MonoClass* klass_hint, MonoGenericContext* context, MonoError* error) { error_init(error); - return (Il2CppMonoMethod*) il2cpp::metadata::GenericMetadata::Inflate((MethodInfo*)method, (Il2CppClass*)klass_hint, (Il2CppGenericContext*)context); + return (MonoMethod*) il2cpp::metadata::GenericMetadata::Inflate((MethodInfo*)method, (Il2CppClass*)klass_hint, (Il2CppGenericContext*)context); } -Il2CppMonoMethod* il2cpp_mono_class_inflate_generic_method_checked(Il2CppMonoMethod* method, Il2CppMonoGenericContext* context, MonoError* error) +MonoMethod* il2cpp_mono_class_inflate_generic_method_checked(MonoMethod* method, MonoGenericContext* context, MonoError* error) { error_init(error); - return (Il2CppMonoMethod*)il2cpp::metadata::GenericMetadata::Inflate((MethodInfo*)method, NULL, (Il2CppGenericContext*)context); + return (MonoMethod*)il2cpp::metadata::GenericMetadata::Inflate((MethodInfo*)method, NULL, (Il2CppGenericContext*)context); } void il2cpp_mono_loader_lock() @@ -636,29 +631,29 @@ gboolean il2cpp_mono_loader_lock_is_owned_by_self() return s_il2cpp_mono_loader_lock_tid == il2cpp::os::Thread::CurrentThreadId(); } -gpointer il2cpp_mono_method_get_wrapper_data(Il2CppMonoMethod* method, guint32 id) +gpointer il2cpp_mono_method_get_wrapper_data(MonoMethod* method, guint32 id) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; } -char* il2cpp_mono_type_get_name_full(Il2CppMonoType* type, MonoTypeNameFormat format) +char* il2cpp_mono_type_get_name_full(MonoType* type, MonoTypeNameFormat format) { std::string name = il2cpp::vm::Type::GetName((Il2CppType*)type, (Il2CppTypeNameFormat)format); return g_strdup(name.c_str()); } -gboolean il2cpp_mono_class_is_nullable(Il2CppMonoClass* klass) +gboolean il2cpp_mono_class_is_nullable(MonoClass* klass) { return il2cpp::vm::Class::IsNullable((Il2CppClass*)klass); } -Il2CppMonoGenericContainer* il2cpp_mono_class_get_generic_container(Il2CppMonoClass* klass) +MonoGenericContainer* il2cpp_mono_class_get_generic_container(MonoClass* klass) { - return (Il2CppMonoGenericContainer*)il2cpp::vm::Class::GetGenericContainer((Il2CppClass*)klass); + return (MonoGenericContainer*)il2cpp::vm::Class::GetGenericContainer((Il2CppClass*)klass); } -void il2cpp_mono_class_setup_interfaces(Il2CppMonoClass* klass, MonoError* error) +void il2cpp_mono_class_setup_interfaces(MonoClass* klass, MonoError* error) { error_init(error); il2cpp::vm::Class::SetupInterfaces((Il2CppClass*)klass); @@ -698,7 +693,7 @@ method_nonpublic (MethodInfo* method, gboolean start_klass) } } -GPtrArray* il2cpp_mono_class_get_methods_by_name(Il2CppMonoClass* il2cppMonoKlass, const char* name, guint32 bflags, gboolean ignore_case, gboolean allow_ctors, MonoError* error) +GPtrArray* il2cpp_mono_class_get_methods_by_name(MonoClass* il2cppMonoKlass, const char* name, guint32 bflags, gboolean ignore_case, gboolean allow_ctors, MonoError* error) { GPtrArray *array; Il2CppClass *klass = (Il2CppClass*)il2cppMonoKlass; @@ -732,11 +727,11 @@ GPtrArray* il2cpp_mono_class_get_methods_by_name(Il2CppMonoClass* il2cppMonoKlas memset (method_slots, 0, sizeof (method_slots_default)); }*/ handle_parent: - il2cpp_mono_class_setup_methods ((Il2CppMonoClass*)klass); - il2cpp_mono_class_setup_vtable ((Il2CppMonoClass*)klass); + il2cpp_mono_class_setup_methods ((MonoClass*)klass); + il2cpp_mono_class_setup_vtable ((MonoClass*)klass); iter = NULL; - while ((method = (MethodInfo*)il2cpp_mono_class_get_methods ((Il2CppMonoClass*)klass, &iter))) { + while ((method = (MethodInfo*)il2cpp_mono_class_get_methods ((MonoClass*)klass, &iter))) { match = 0; /*if (method->slot != -1) { g_assert (method->slot < nslots); @@ -785,55 +780,55 @@ GPtrArray* il2cpp_mono_class_get_methods_by_name(Il2CppMonoClass* il2cppMonoKlas return array; } -gpointer il2cpp_mono_ldtoken_checked(Il2CppMonoImage* image, guint32 token, Il2CppMonoClass** handle_class, Il2CppMonoGenericContext* context, MonoError* error) +gpointer il2cpp_mono_ldtoken_checked(MonoImage* image, guint32 token, MonoClass** handle_class, MonoGenericContext* context, MonoError* error) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; } -Il2CppMonoClass* il2cpp_mono_class_from_generic_parameter_internal(Il2CppMonoGenericParam* param) +MonoClass* il2cpp_mono_class_from_generic_parameter_internal(MonoGenericParam* param) { - return (Il2CppMonoClass*)il2cpp::vm::Class::FromGenericParameter((Il2CppGenericParameter*)param); + return (MonoClass*)il2cpp::vm::Class::FromGenericParameter((Il2CppGenericParameter*)param); } -Il2CppMonoClass* il2cpp_mono_class_load_from_name(Il2CppMonoImage* image, const char* name_space, const char* name) +MonoClass* il2cpp_mono_class_load_from_name(MonoImage* image, const char* name_space, const char* name) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; } -Il2CppMonoGenericClass* il2cpp_mono_class_get_generic_class(Il2CppMonoClass* monoClass) +MonoGenericClass* il2cpp_mono_class_get_generic_class(MonoClass* monoClass) { Il2CppClass *klass = (Il2CppClass*)monoClass; - return (Il2CppMonoGenericClass*)klass->generic_class; + return (MonoGenericClass*)klass->generic_class; } -Il2CppMonoInternalThread* il2cpp_mono_thread_internal_current() +MonoInternalThread* il2cpp_mono_thread_internal_current() { - return (Il2CppMonoInternalThread*)(((Il2CppThread*)il2cpp_mono_thread_current())->internal_thread); + return (MonoInternalThread*)(((Il2CppThread*)il2cpp_mono_thread_current())->internal_thread); } -gboolean il2cpp_mono_thread_internal_is_current(Il2CppMonoInternalThread* thread) +gboolean il2cpp_mono_thread_internal_is_current(MonoInternalThread* thread) { return il2cpp_mono_thread_internal_current () == thread; } -void il2cpp_mono_thread_internal_abort(Il2CppMonoInternalThread* thread, gboolean appdomain_unload) +void il2cpp_mono_thread_internal_abort(MonoInternalThread* thread, gboolean appdomain_unload) { il2cpp::vm::Thread::RequestAbort((Il2CppInternalThread*)thread); } -void il2cpp_mono_thread_internal_reset_abort(Il2CppMonoInternalThread* thread) +void il2cpp_mono_thread_internal_reset_abort(MonoInternalThread* thread) { il2cpp::vm::Thread::ResetAbort((Il2CppInternalThread*)thread); } -gunichar2* il2cpp_mono_thread_get_name(Il2CppMonoInternalThread* this_obj, guint32* name_len) +gunichar2* il2cpp_mono_thread_get_name(MonoInternalThread* this_obj, guint32* name_len) { return NULL; } -void il2cpp_mono_thread_set_name_internal(Il2CppMonoInternalThread* this_obj, Il2CppMonoString* name, gboolean permanent, gboolean reset, MonoError* error) +void il2cpp_mono_thread_set_name_internal(MonoInternalThread* this_obj, MonoString* name, gboolean permanent, gboolean reset, MonoError* error) { il2cpp::vm::Thread::SetName((Il2CppInternalThread*)this_obj, (Il2CppString*)name); error_init(error); @@ -855,53 +850,53 @@ Il2CppMonoRuntimeExceptionHandlingCallbacks* il2cpp_mono_get_eh_callbacks() return NULL; } -void il2cpp_mono_reflection_create_custom_attr_data_args(Il2CppMonoImage* image, Il2CppMonoMethod* method, const guchar* data, guint32 len, Il2CppMonoArray** typed_args, Il2CppMonoArray** named_args, CattrNamedArg** named_arg_info, MonoError* error) +void il2cpp_mono_reflection_create_custom_attr_data_args(MonoImage* image, MonoMethod* method, const guchar* data, guint32 len, MonoArray** typed_args, MonoArray** named_args, CattrNamedArg** named_arg_info, MonoError* error) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); } -void il2cpp_mono_nullable_init(guint8* buf, Il2CppMonoObject* value, Il2CppMonoClass* klass) +void il2cpp_mono_nullable_init(guint8* buf, Il2CppMonoObject* value, MonoClass* klass) { il2cpp::vm::Object::NullableInit(buf, (Il2CppObject*)value, (Il2CppClass*)klass); } -Il2CppMonoObject* il2cpp_mono_value_box_checked(Il2CppMonoDomain* domain, Il2CppMonoClass* klass, gpointer value, MonoError* error) +Il2CppMonoObject* il2cpp_mono_value_box_checked(Il2CppMonoDomain* domain, MonoClass* klass, gpointer value, MonoError* error) { error_init(error); return (Il2CppMonoObject*)il2cpp::vm::Object::Box((Il2CppClass*)klass, value); } -void il2cpp_mono_field_static_get_value_checked(Il2CppMonoVTable* vt, Il2CppMonoClassField* field, void* value, MonoError* error) +void il2cpp_mono_field_static_get_value_checked(Il2CppMonoVTable* vt, MonoClassField* field, void* value, MonoError* error) { error_init(error); il2cpp::vm::Field::StaticGetValue((FieldInfo*)field, value); } -void il2cpp_mono_field_static_get_value_for_thread(Il2CppMonoInternalThread* thread, Il2CppMonoVTable* vt, Il2CppMonoClassField* field, void* value, MonoError* error) +void il2cpp_mono_field_static_get_value_for_thread(MonoInternalThread* thread, Il2CppMonoVTable* vt, MonoClassField* field, void* value, MonoError* error) { error_init(error); il2cpp::vm::Field::StaticGetValueForThread((FieldInfo*)field, value, (Il2CppInternalThread*)thread); } -Il2CppMonoObject* il2cpp_mono_field_get_value_object_checked(Il2CppMonoDomain* domain, Il2CppMonoClassField* field, Il2CppMonoObject* obj, MonoError* error) +Il2CppMonoObject* il2cpp_mono_field_get_value_object_checked(Il2CppMonoDomain* domain, MonoClassField* field, Il2CppMonoObject* obj, MonoError* error) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; } -Il2CppMonoObject* il2cpp_mono_object_new_checked(Il2CppMonoDomain* domain, Il2CppMonoClass* klass, MonoError* error) +Il2CppMonoObject* il2cpp_mono_object_new_checked(Il2CppMonoDomain* domain, MonoClass* klass, MonoError* error) { error_init(error); return (Il2CppMonoObject*)il2cpp::vm::Object::New((Il2CppClass*)klass); } -Il2CppMonoString* il2cpp_mono_ldstr_checked(Il2CppMonoDomain* domain, Il2CppMonoImage* image, guint32 idx, MonoError* error) +MonoString* il2cpp_mono_ldstr_checked(Il2CppMonoDomain* domain, MonoImage* image, guint32 idx, MonoError* error) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; } -Il2CppMonoObject* il2cpp_mono_runtime_try_invoke(Il2CppMonoMethod* method, void* obj, void** params, Il2CppMonoObject** exc, MonoError* error) +Il2CppMonoObject* il2cpp_mono_runtime_try_invoke(MonoMethod* method, void* obj, void** params, Il2CppMonoObject** exc, MonoError* error) { error_init(error); @@ -911,7 +906,7 @@ Il2CppMonoObject* il2cpp_mono_runtime_try_invoke(Il2CppMonoMethod* method, void* return (Il2CppMonoObject*)il2cpp::vm::Runtime::Invoke((MethodInfo*)method, obj, params, (Il2CppException**)exc); } -Il2CppMonoObject* il2cpp_mono_runtime_invoke_checked(Il2CppMonoMethod* method, void* obj, void** params, MonoError* error) +Il2CppMonoObject* il2cpp_mono_runtime_invoke_checked(MonoMethod* method, void* obj, void** params, MonoError* error) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; @@ -970,9 +965,9 @@ void il2cpp_mono_threadpool_resume() #endif // NET_4_0 } -Il2CppMonoImage* il2cpp_mono_assembly_get_image(Il2CppMonoAssembly* assembly) +MonoImage* il2cpp_mono_assembly_get_image(Il2CppMonoAssembly* assembly) { - return (Il2CppMonoImage*)il2cpp::vm::Assembly::GetImage((Il2CppAssembly*)assembly); + return (MonoImage*)il2cpp::vm::Assembly::GetImage((Il2CppAssembly*)assembly); } gboolean il2cpp_mono_runtime_try_shutdown() @@ -981,7 +976,7 @@ gboolean il2cpp_mono_runtime_try_shutdown() return TRUE; } -gboolean il2cpp_mono_verifier_is_method_valid_generic_instantiation(Il2CppMonoMethod* method) +gboolean il2cpp_mono_verifier_is_method_valid_generic_instantiation(MonoMethod* method) { if (!method) return FALSE; @@ -992,7 +987,7 @@ gboolean il2cpp_mono_verifier_is_method_valid_generic_instantiation(Il2CppMonoMe return FALSE; } -Il2CppMonoType* il2cpp_mono_reflection_get_type_checked(Il2CppMonoImage* rootimage, Il2CppMonoImage* image, Il2CppMonoTypeNameParse* info, gboolean ignorecase, gboolean* type_resolve, MonoError* error) +MonoType* il2cpp_mono_reflection_get_type_checked(MonoImage* rootimage, MonoImage* image, Il2CppMonoTypeNameParse* info, gboolean ignorecase, gboolean* type_resolve, MonoError* error) { error_init(error); @@ -1000,28 +995,28 @@ Il2CppMonoType* il2cpp_mono_reflection_get_type_checked(Il2CppMonoImage* rootima if (!klass) return NULL; - return (Il2CppMonoType*)il2cpp::vm::Class::GetType(klass); + return (MonoType*)il2cpp::vm::Class::GetType(klass); } -Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_method_checked(Il2CppMonoMethod* method, MonoError* error) +Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_method_checked(MonoMethod* method, MonoError* error) { error_init(error); return NULL; } -Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_class_checked(Il2CppMonoClass* klass, MonoError* error) +Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_class_checked(MonoClass* klass, MonoError* error) { error_init(error); return NULL; } -Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_property_checked(Il2CppMonoClass* klass, Il2CppMonoProperty* property, MonoError* error) +Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_property_checked(MonoClass* klass, MonoProperty* property, MonoError* error) { error_init(error); return NULL; } -Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_field_checked(Il2CppMonoClass* klass, Il2CppMonoClassField* field, MonoError* error) +Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_field_checked(MonoClass* klass, MonoClassField* field, MonoError* error) { error_init(error); return NULL; @@ -1032,10 +1027,10 @@ Il2CppMonoReflectionAssemblyHandle il2cpp_mono_assembly_get_object_handle(Il2Cpp return (Il2CppMonoReflectionAssemblyHandle)il2cpp::vm::Reflection::GetAssemblyObject((const Il2CppAssembly *)assembly); } -Il2CppMonoReflectionType* il2cpp_mono_type_get_object_checked(Il2CppMonoDomain* domain, Il2CppMonoType* type, MonoError* error) +MonoReflectionType* il2cpp_mono_type_get_object_checked(Il2CppMonoDomain* domain, MonoType* type, MonoError* error) { error_init(error); - return (Il2CppMonoReflectionType*)il2cpp::vm::Reflection::GetTypeObject((const Il2CppType*)type); + return (MonoReflectionType*)il2cpp::vm::Reflection::GetTypeObject((const Il2CppType*)type); } void il2cpp_mono_network_init() @@ -1053,7 +1048,7 @@ char* il2cpp_mono_get_runtime_build_info() return g_strdup_printf ("%s (%s)", "0.0", "IL2CPP"); } -Il2CppMonoMethod* il2cpp_mono_marshal_method_from_wrapper(Il2CppMonoMethod* wrapper) +MonoMethod* il2cpp_mono_marshal_method_from_wrapper(MonoMethod* wrapper) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; @@ -1065,7 +1060,7 @@ MonoDebugOptions* il2cpp_mini_get_debug_options() return NULL; } -gpointer il2cpp_mono_jit_find_compiled_method_with_jit_info(Il2CppMonoDomain* domain, Il2CppMonoMethod* method, MonoJitInfo** ji) +gpointer il2cpp_mono_jit_find_compiled_method_with_jit_info(Il2CppMonoDomain* domain, MonoMethod* method, MonoJitInfo** ji) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; @@ -1082,7 +1077,7 @@ void il2cpp_mono_set_lmf(MonoLMF* lmf) IL2CPP_ASSERT(0 && "This method is not yet implemented"); } -gpointer il2cpp_mono_aot_get_method_checked(Il2CppMonoDomain* domain, Il2CppMonoMethod* method, MonoError* error) +gpointer il2cpp_mono_aot_get_method_checked(Il2CppMonoDomain* domain, MonoMethod* method, MonoError* error) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; @@ -1178,7 +1173,7 @@ gboolean il2cpp_mono_find_jit_info_ext(Il2CppMonoDomain* domain, MonoJitTlsData* return 0; } -Il2CppMonoMethod* il2cpp_mono_method_get_declaring_generic_method(Il2CppMonoMethod* method) +MonoMethod* il2cpp_mono_method_get_declaring_generic_method(MonoMethod* method) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; @@ -1190,13 +1185,13 @@ gboolean il2cpp_mono_error_ok (MonoError *error) return 0; } -Il2CppMonoMethod* il2cpp_jinfo_get_method (MonoJitInfo *ji) +MonoMethod* il2cpp_jinfo_get_method (MonoJitInfo *ji) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; } -gboolean il2cpp_mono_find_prev_seq_point_for_native_offset (Il2CppMonoDomain *domain, Il2CppMonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point) +gboolean il2cpp_mono_find_prev_seq_point_for_native_offset (Il2CppMonoDomain *domain, MonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; @@ -1217,24 +1212,24 @@ void* il2cpp_mono_w32socket_accept_internal (void* s, struct sockaddr *addr, voi return 0; } -gboolean il2cpp_mono_find_next_seq_point_for_native_offset (Il2CppMonoDomain *domain, Il2CppMonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point) +gboolean il2cpp_mono_find_next_seq_point_for_native_offset (Il2CppMonoDomain *domain, MonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; } -gboolean il2cpp_mono_class_has_parent (Il2CppMonoClass *klass, Il2CppMonoClass *parent) +gboolean il2cpp_mono_class_has_parent (MonoClass *klass, MonoClass *parent) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; } -Il2CppMonoGenericParam* il2cpp_mono_generic_container_get_param (Il2CppMonoGenericContainer *gc, int i) +MonoGenericParam* il2cpp_mono_generic_container_get_param (MonoGenericContainer *gc, int i) { - return (Il2CppMonoGenericParam*)il2cpp::vm::GenericContainer::GetGenericParameter((Il2CppGenericContainer*)gc, i); + return (MonoGenericParam*)il2cpp::vm::GenericContainer::GetGenericParameter((Il2CppGenericContainer*)gc, i); } -gboolean il2cpp_mono_find_seq_point (Il2CppMonoDomain *domain, Il2CppMonoMethod *method, gint32 il_offset, MonoSeqPointInfo **info, SeqPoint *seq_point) +gboolean il2cpp_mono_find_seq_point (Il2CppMonoDomain *domain, MonoMethod *method, gint32 il_offset, MonoSeqPointInfo **info, SeqPoint *seq_point) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; @@ -1256,7 +1251,7 @@ void il2cpp_mono_seq_point_init_next (MonoSeqPointInfo* info, SeqPoint sp, SeqPo IL2CPP_ASSERT(0 && "This method is not yet implemented"); } -MonoSeqPointInfo* il2cpp_mono_get_seq_points (Il2CppMonoDomain *domain, Il2CppMonoMethod *method) +MonoSeqPointInfo* il2cpp_mono_get_seq_points (Il2CppMonoDomain *domain, MonoMethod *method) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; @@ -1305,11 +1300,6 @@ void* il2cpp_mono_gc_invoke_with_gc_lock (Il2CppMonoGCLockedCallbackFunc func, v // These functions expose the IL2CPP VM C++ API to C -void il2cpp_internal_thread_set_state_background(Il2CppMonoThread* thread) -{ - il2cpp::vm::Thread::SetState((Il2CppInternalThread*)thread, il2cpp::vm::kThreadStateBackground); -} - void* il2cpp_domain_get_agent_info(Il2CppMonoAppDomain* domain) { return ((Il2CppDomain*)domain)->agent_info; @@ -1355,21 +1345,6 @@ void il2cpp_start_debugger_thread() il2cpp::utils::Debugger::StartDebuggerThread(); } -uintptr_t il2cpp_internal_thread_get_thread_id(Il2CppMonoInternalThread* thread) -{ - return il2cpp::vm::Thread::GetId((Il2CppInternalThread*)thread); -} - -uint32_t il2cpp_internal_thread_get_state(Il2CppMonoInternalThread* thread) -{ - return il2cpp::vm::Thread::GetState((Il2CppInternalThread*)thread); -} - -bool il2cpp_internal_thread_get_threadpool_thread(Il2CppMonoInternalThread* thread) -{ - return ((Il2CppInternalThread*)thread)->threadpool_thread; -} - void* il2cpp_gc_alloc_fixed(size_t size) { return il2cpp::gc::GarbageCollector::AllocateFixed(size, NULL); @@ -1391,17 +1366,12 @@ const char* il2cpp_domain_get_name(Il2CppMonoDomain* domain) return ((Il2CppDomain*)domain)->friendly_name; } -int il2cpp_mono_type_get_attrs(Il2CppMonoType* type) -{ - return ((Il2CppType*)type)->attrs; -} - Il2CppSequencePointC* il2cpp_get_sequence_points(void* *iter) { return (Il2CppSequencePointC*)il2cpp::utils::Debugger::GetSequencePoints(iter); } -Il2CppSequencePointC* il2cpp_get_method_sequence_points(Il2CppMonoMethod* method, void* *iter) +Il2CppSequencePointC* il2cpp_get_method_sequence_points(MonoMethod* method, void* *iter) { if (!method) return (Il2CppSequencePointC*)il2cpp::utils::Debugger::GetSequencePoints(iter); @@ -1409,7 +1379,7 @@ Il2CppSequencePointC* il2cpp_get_method_sequence_points(Il2CppMonoMethod* method return (Il2CppSequencePointC*)il2cpp::utils::Debugger::GetSequencePoints((const MethodInfo*)method, iter); } -gboolean il2cpp_mono_methods_match(Il2CppMonoMethod* left, Il2CppMonoMethod* right) +gboolean il2cpp_mono_methods_match(MonoMethod* left, MonoMethod* right) { MethodInfo* leftMethod = (MethodInfo*)left; MethodInfo* rightMethod = (MethodInfo*)right; @@ -1441,62 +1411,26 @@ gboolean il2cpp_mono_methods_match(Il2CppMonoMethod* left, Il2CppMonoMethod* rig return FALSE; } -Il2CppMonoGenericInst* il2cpp_generic_class_get_inst(Il2CppMonoGenericClass *monoGenClass) -{ - Il2CppGenericClass *klass = (Il2CppGenericClass*) monoGenClass; - return (Il2CppMonoGenericInst*)klass->context.class_inst; -} - -guint il2cpp_generic_inst_type_argc(Il2CppMonoGenericInst *monoInst) -{ - Il2CppGenericInst *inst = (Il2CppGenericInst*)monoInst; - return inst->type_argc; -} - -Il2CppMonoType* il2cpp_generic_inst_type_arg(Il2CppMonoGenericInst *monoInst, int i) -{ - Il2CppGenericInst *inst = (Il2CppGenericInst*)monoInst; - return (Il2CppMonoType*)inst->type_argv[i]; -} - -Il2CppMonoType* il2cpp_class_this_arg(Il2CppMonoClass *monoClass) -{ - Il2CppClass *klass = (Il2CppClass*)monoClass; - return (Il2CppMonoType*)klass->this_arg; -} - -Il2CppMonoClass* il2cpp_class_get_nested_types_accepts_generic(Il2CppMonoClass *monoClass, void* *iter) +MonoClass* il2cpp_class_get_nested_types_accepts_generic(MonoClass *monoClass, void* *iter) { Il2CppClass *klass = (Il2CppClass*)monoClass; if (klass->generic_class) return NULL; - return (Il2CppMonoClass*)il2cpp::vm::Class::GetNestedTypes(klass, iter); + return (MonoClass*)il2cpp::vm::Class::GetNestedTypes(klass, iter); } -Il2CppMonoClass* il2cpp_defaults_object_class() +MonoClass* il2cpp_defaults_object_class() { - return (Il2CppMonoClass*)il2cpp_defaults.object_class; + return (MonoClass*)il2cpp_defaults.object_class; } -guint8 il2cpp_array_rank(Il2CppMonoArray *monoArr) +guint8 il2cpp_array_rank(MonoArray *monoArr) { Il2CppArray *arr = (Il2CppArray*)monoArr; return arr->klass->rank; } -mono_array_size_t il2cpp_array_bound_length(Il2CppMonoArray *monoArr, int i) -{ - Il2CppArray *arr = (Il2CppArray*)monoArr; - return arr->bounds[i].length; -} - -mono_array_lower_bound_t il2cpp_array_bound_lower_bound(Il2CppMonoArray *monoArr, int i) -{ - Il2CppArray *arr = (Il2CppArray*)monoArr; - return arr->bounds[i].lower_bound; -} - const char* il2cpp_assembly_name_name(Il2CppMonoAssembly *monoAssembly) { Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; @@ -1551,56 +1485,45 @@ uint32_t il2cpp_assembly_name_flags(Il2CppMonoAssembly *monoAssembly) return assembly->aname.flags; } -const char* il2cpp_image_name(Il2CppMonoImage *monoImage) +const char* il2cpp_image_name(MonoImage *monoImage) { Il2CppImage *image = (Il2CppImage*)monoImage; return image->name; } -Il2CppMonoAssembly* il2cpp_image_assembly(Il2CppMonoImage *monoImage) -{ - Il2CppImage *image = (Il2CppImage*)monoImage; - return (Il2CppMonoAssembly*)image->assembly; -} - -guint8* il2cpp_field_get_address(Il2CppMonoObject *obj, Il2CppMonoClassField *monoField) +guint8* il2cpp_field_get_address(Il2CppMonoObject *obj, MonoClassField *monoField) { FieldInfo *field = (FieldInfo*)monoField; return (guint8*)obj + field->offset; } -Il2CppMonoType* il2cpp_mono_object_get_type(Il2CppMonoObject* object) -{ - return (Il2CppMonoType*)(((Il2CppObject*)object)->klass->byval_arg); -} - -Il2CppMonoClass* il2cpp_defaults_exception_class() +MonoType* il2cpp_mono_object_get_type(Il2CppMonoObject* object) { - return (Il2CppMonoClass*)il2cpp_defaults.exception_class; + return (MonoType*)&(((Il2CppObject*)object)->klass->byval_arg); } -Il2CppMonoImage* il2cpp_defaults_corlib_image() +MonoClass* il2cpp_defaults_exception_class() { - return (Il2CppMonoImage*)il2cpp_defaults.corlib; + return (MonoClass*)il2cpp_defaults.exception_class; } -uint32_t il2cpp_method_get_flags_no_iflags(const Il2CppMonoMethod * method) +MonoImage* il2cpp_defaults_corlib_image() { - return ((MethodInfo*)method)->flags; + return (MonoImage*)il2cpp_defaults.corlib; } -bool il2cpp_method_is_string_ctor(const Il2CppMonoMethod * method) +bool il2cpp_method_is_string_ctor(const MonoMethod * method) { MethodInfo* methodInfo = (MethodInfo*)method; return methodInfo->klass == il2cpp_defaults.string_class && !strcmp (methodInfo->name, ".ctor"); } -Il2CppMonoClass* il2cpp_defaults_void_class() +MonoClass* il2cpp_defaults_void_class() { - return (Il2CppMonoClass*)il2cpp_defaults.void_class; + return (MonoClass*)il2cpp_defaults.void_class; } -void il2cpp_set_var(guint8* newValue, void *value, Il2CppMonoType *localVariableTypeMono) +void il2cpp_set_var(guint8* newValue, void *value, MonoType *localVariableTypeMono) { il2cpp::metadata::SizeAndAlignment sa = il2cpp::metadata::FieldLayout::GetTypeSizeAndAlignment((const Il2CppType*)localVariableTypeMono); if (((Il2CppType*)localVariableTypeMono)->byref) @@ -1609,35 +1532,20 @@ void il2cpp_set_var(guint8* newValue, void *value, Il2CppMonoType *localVariable memcpy(value, newValue, sa.size); } -Il2CppMonoMethod* il2cpp_get_interface_method(Il2CppMonoClass* klass, Il2CppMonoClass* itf, int slot) +MonoMethod* il2cpp_get_interface_method(MonoClass* klass, MonoClass* itf, int slot) { const VirtualInvokeData* data = il2cpp::vm::Class::GetInterfaceInvokeDataFromVTable((Il2CppClass*)klass, (Il2CppClass*)itf, slot); if (!data) return NULL; - return (Il2CppMonoMethod*)data->method; + return (MonoMethod*)data->method; } -gboolean il2cpp_field_is_deleted(Il2CppMonoClassField *field) +gboolean il2cpp_field_is_deleted(MonoClassField *field) { return il2cpp::vm::Field::IsDeleted((FieldInfo*)field); } -int il2cpp_generic_container_get_type_argc(Il2CppMonoGenericClass* container) -{ - return ((Il2CppGenericContainer*)container)->type_argc; -} - -Il2CppMonoGenericClass* il2cpp_type_get_generic_class(Il2CppMonoType *type) -{ - return (Il2CppMonoGenericClass*)((Il2CppType*)type)->data.generic_class; -} - -gboolean il2cpp_class_get_enumtype(Il2CppMonoClass *klass) -{ - return ((Il2CppClass*)klass)->enumtype; -} - struct TypeIterState { il2cpp::vm::AssemblyVector* assemblies; @@ -1647,7 +1555,7 @@ struct TypeIterState il2cpp::vm::TypeVector::iterator type; }; -Il2CppMonoClass* il2cpp_iterate_loaded_classes(void* *iter) +MonoClass* il2cpp_iterate_loaded_classes(void* *iter) { if (!iter) return NULL; @@ -1661,7 +1569,7 @@ Il2CppMonoClass* il2cpp_iterate_loaded_classes(void* *iter) il2cpp::vm::Image::GetTypes(state->image, true, &state->types); state->type = state->types.begin(); *iter = state; - return (Il2CppMonoClass*)*state->type; + return (MonoClass*)*state->type; } TypeIterState *state = (TypeIterState*)*iter; @@ -1682,44 +1590,44 @@ Il2CppMonoClass* il2cpp_iterate_loaded_classes(void* *iter) state->type = state->types.begin(); } - return (Il2CppMonoClass*)*state->type; + return (MonoClass*)*state->type; } -const char** il2cpp_get_source_files_for_type(Il2CppMonoClass *klass, int *count) +const char** il2cpp_get_source_files_for_type(MonoClass *klass, int *count) { return il2cpp::utils::Debugger::GetTypeSourceFiles((Il2CppClass*)klass, *count); } -Il2CppMonoMethod* il2cpp_method_get_generic_definition(Il2CppMonoMethodInflated *imethod) +MonoMethod* il2cpp_method_get_generic_definition(Il2CppMonoMethodInflated *imethod) { MethodInfo *method = (MethodInfo*)imethod; if (!method->is_inflated || method->is_generic) return NULL; - return (Il2CppMonoMethod*)((MethodInfo*)imethod)->genericMethod->methodDefinition; + return (MonoMethod*)((MethodInfo*)imethod)->genericMethod->methodDefinition; } -Il2CppMonoGenericInst* il2cpp_method_get_generic_class_inst(Il2CppMonoMethodInflated *imethod) +MonoGenericInst* il2cpp_method_get_generic_class_inst(Il2CppMonoMethodInflated *imethod) { MethodInfo *method = (MethodInfo*)imethod; if (!method->is_inflated || method->is_generic) return NULL; - return (Il2CppMonoGenericInst*)method->genericMethod->context.class_inst; + return (MonoGenericInst*)method->genericMethod->context.class_inst; } -Il2CppMonoClass* il2cpp_generic_class_get_container_class(Il2CppMonoGenericClass *gclass) +MonoClass* il2cpp_generic_class_get_container_class(MonoGenericClass *gclass) { - return (Il2CppMonoClass*)il2cpp::vm::GenericClass::GetTypeDefinition((Il2CppGenericClass*)gclass); + return (MonoClass*)il2cpp::vm::GenericClass::GetTypeDefinition((Il2CppGenericClass*)gclass); } -Il2CppMonoClass* il2cpp_mono_get_string_class (void) +MonoClass* il2cpp_mono_get_string_class (void) { - return (Il2CppMonoClass*)il2cpp_defaults.string_class; + return (MonoClass*)il2cpp_defaults.string_class; } } From d405b5d5e671693f99757917a74dc40b7cbcb36b Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Mon, 11 Dec 2017 13:32:02 -0500 Subject: [PATCH 018/582] Remove VM_ASSEMBLY macros (#747) * Remove VM_ASSEMBLY Macros and Il2CppMonoAssembly * Remove define around image->dynamic --- mono/mini/debugger-agent.c | 26 ++++++-------- mono/mini/il2cpp-c-types.h | 15 +++----- mono/mini/il2cpp-compat.h | 41 ++-------------------- mono/mini/il2cpp-stubs.cpp | 70 +++----------------------------------- 4 files changed, 21 insertions(+), 131 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 532e80796ec2..d24828f5b69f 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -2553,9 +2553,7 @@ buffer_add_assemblyid (Buffer *buf, MonoDomain *domain, MonoAssembly *assembly) id = buffer_add_ptr_id (buf, domain, ID_ASSEMBLY, assembly); if (G_UNLIKELY (log_level >= 2) && assembly) { - char* name = VM_ASSEMBLY_GET_NAME(assembly); - DEBUG_PRINTF (2, "[dbg] send assembly [%s][%s][%d]\n", name, VM_DOMAIN_GET_NAME(domain), id); - VM_ASSEMBLY_FREE_NAME(name); + DEBUG_PRINTF (2, "[dbg] send assembly [%s][%s][%d]\n", assembly->aname.name, VM_DOMAIN_GET_NAME(domain), id); } } @@ -8783,11 +8781,11 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf) void *iter = NULL; while (ass = mono_domain_get_assemblies_iter (domain, &iter)) { - if (VM_ASSEMBLY_GET_IMAGE (ass)) + if (ass->image) { MonoError probe_type_error; /* FIXME really okay to call while holding locks? */ - t = mono_reflection_get_type_checked (VM_ASSEMBLY_GET_IMAGE (ass), VM_ASSEMBLY_GET_IMAGE (ass), &info, ignore_case, &type_resolve, &probe_type_error); + t = mono_reflection_get_type_checked (ass->image, ass->image, &info, ignore_case, &type_resolve, &probe_type_error); mono_error_cleanup (&probe_type_error); if (t) { g_ptr_array_add (res_classes, mono_type_get_class (t)); @@ -9199,29 +9197,29 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) switch (command) { case CMD_ASSEMBLY_GET_LOCATION: { - buffer_add_string (buf, mono_image_get_filename (VM_ASSEMBLY_GET_IMAGE(ass))); + buffer_add_string (buf, mono_image_get_filename (ass->image)); break; } case CMD_ASSEMBLY_GET_ENTRY_POINT: { guint32 token; MonoMethod *m; - if (VM_ASSEMBLY_IS_DYNAMIC(ass)) { + if (ass->image->dynamic) { buffer_add_id (buf, 0); } else { #ifdef IL2CPP_MONO_DEBUGGER - m = il2cpp_mono_image_get_entry_point(VM_ASSEMBLY_GET_IMAGE(ass)); + m = il2cpp_mono_image_get_entry_point(ass->image); if (m == NULL) buffer_add_id (buf, 0); else buffer_add_methodid (buf, domain, m); #else - token = mono_image_get_entry_point (VM_ASSEMBLY_GET_IMAGE(ass)); + token = mono_image_get_entry_point (ass->image); if (token == 0) { buffer_add_id (buf, 0); } else { MonoError error; - m = mono_get_method_checked (VM_ASSEMBLY_GET_IMAGE(ass), token, NULL, NULL, &error); + m = mono_get_method_checked (ass->image, token, NULL, NULL, &error); if (!m) mono_error_cleanup (&error); /* FIXME don't swallow the error */ buffer_add_methodid (buf, domain, m); @@ -9231,7 +9229,7 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) break; } case CMD_ASSEMBLY_GET_MANIFEST_MODULE: { - buffer_add_moduleid (buf, domain, VM_ASSEMBLY_GET_IMAGE(ass)); + buffer_add_moduleid (buf, domain, ass->image); break; } case CMD_ASSEMBLY_GET_OBJECT: { @@ -9263,7 +9261,7 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) } else { if (info.assembly.name) NOT_IMPLEMENTED; - t = mono_reflection_get_type_checked (VM_ASSEMBLY_GET_IMAGE(ass), VM_ASSEMBLY_GET_IMAGE(ass), &info, ignorecase, &type_resolve, &error); + t = mono_reflection_get_type_checked (ass->image, ass->image, &info, ignorecase, &type_resolve, &error); if (!is_ok (&error)) { mono_error_cleanup (&error); /* FIXME don't swallow the error */ mono_reflection_free_type_info (&info); @@ -9282,9 +9280,6 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) case CMD_ASSEMBLY_GET_NAME: { gchar *name; MonoAssembly *mass = ass; -#ifdef IL2CPP_MONO_DEBUGGER - name = VM_ASSEMBLY_GET_NAME(mass); -#else name = g_strdup_printf ( "%s, Version=%d.%d.%d.%d, Culture=%s, PublicKeyToken=%s%s", mass->aname.name, @@ -9292,7 +9287,6 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) mass->aname.culture && *mass->aname.culture ? mass->aname.culture : "neutral", mass->aname.public_key_token[0] ? (char *)mass->aname.public_key_token : "null", (mass->aname.flags & ASSEMBLYREF_RETARGETABLE_FLAG) ? ", Retargetable=Yes" : ""); -#endif buffer_add_string (buf, name); g_free (name); diff --git a/mono/mini/il2cpp-c-types.h b/mono/mini/il2cpp-c-types.h index 7e57f2595c25..9c6c25131903 100644 --- a/mono/mini/il2cpp-c-types.h +++ b/mono/mini/il2cpp-c-types.h @@ -27,10 +27,10 @@ #define MonoInternalThread Il2CppInternalThread #define MonoReflectionType Il2CppReflectionType #define MonoProfiler Il2CppProfiler +#define MonoAssembly Il2CppAssembly //still stubs everywhere typedef struct _Il2CppMonoAssemblyName Il2CppMonoAssemblyNameReplacement; -typedef struct _Il2CppMonoAssembly Il2CppMonoAssembly; typedef struct _Il2CppMonoDomain Il2CppMonoDomain; typedef struct _Il2CppMonoMethodSignature Il2CppMonoMethodSignature; typedef struct _Il2CppMonoMethodHeader Il2CppMonoMethodHeader; @@ -168,12 +168,6 @@ struct _Il2CppMonoAssemblyName uint16_t major, minor, build, revision; }; -struct _Il2CppMonoAssembly -{ - Il2CppMonoAssemblyNameReplacement aname; - MonoImage *image; -}; - struct _Il2CppMonoDomain { gpointer runtime_info; @@ -181,7 +175,7 @@ struct _Il2CppMonoDomain char *friendly_name; mono_mutex_t assemblies_lock; GSList *domain_assemblies; - Il2CppMonoAssembly *entry_assembly; + MonoAssembly *entry_assembly; Il2CppMonoAppDomain *domain; }; @@ -272,9 +266,9 @@ MonoDebugOptions il2cpp_mono_debug_options; typedef void (*Il2CppMonoProfileFunc) (MonoProfiler *prof); typedef void (*Il2CppMonoProfileAppDomainFunc) (MonoProfiler *prof, Il2CppMonoDomain *domain); typedef void (*Il2CppMonoProfileAppDomainResult) (MonoProfiler *prof, Il2CppMonoDomain *domain, int result); -typedef void (*Il2CppMonoProfileAssemblyFunc) (MonoProfiler *prof, Il2CppMonoAssembly *assembly); +typedef void (*Il2CppMonoProfileAssemblyFunc) (MonoProfiler *prof, MonoAssembly *assembly); typedef void (*Il2CppMonoProfileJitResult) (MonoProfiler *prof, MonoMethod *method, MonoJitInfo* jinfo, int result); -typedef void (*Il2CppMonoProfileAssemblyResult) (MonoProfiler *prof, Il2CppMonoAssembly *assembly, int result); +typedef void (*Il2CppMonoProfileAssemblyResult) (MonoProfiler *prof, MonoAssembly *assembly, int result); typedef void (*Il2CppMonoProfileThreadFunc) (MonoProfiler *prof, uintptr_t tid); typedef gboolean (*Il2CppMonoJitStackWalk) (Il2CppMonoStackFrameInfo *frame, MonoContext *ctx, gpointer data); typedef void (*Il2CppMonoDomainFunc) (Il2CppMonoDomain *domain, void* user_data); @@ -288,7 +282,6 @@ void il2cpp_domain_set_agent_info(Il2CppMonoAppDomain* domain, void* agentInfo); void il2cpp_start_debugger_thread(); void* il2cpp_gc_alloc_fixed(size_t size); void il2cpp_gc_free_fixed(void* address); -char* il2cpp_assembly_get_name(Il2CppMonoAssembly* assembly); const char* il2cpp_domain_get_name(Il2CppMonoDomain* domain); #endif \ No newline at end of file diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index 66b3d68e76f3..55c36b1f247a 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -17,19 +17,6 @@ #define VM_DOMAIN_SET_AGENT_INFO(domain, value) il2cpp_domain_set_agent_info(domain, value) #define VM_DOMAIN_GET_NAME(domain) il2cpp_domain_get_name(domain) #define VM_DOMAIN_GET_CORLIB(domain) il2cpp_image_get_assembly(il2cpp_get_corlib()) -#define VM_ASSEMBLY_GET_NAME(assembly) il2cpp_assembly_get_name(assembly) -#define VM_ASSEMBLY_FREE_NAME(name) g_free(name) -#define VM_ASSEMBLY_IS_DYNAMIC(assembly) FALSE -#define VM_ASSEMBLY_GET_IMAGE(assembly) il2cpp_mono_assembly_get_image(assembly) -#define VM_ASSEMBLY_NAME_GET_NAME(assembly) il2cpp_assembly_name_name(assembly) -#define VM_ASSEMBLY_NAME_GET_MAJOR(assembly) il2cpp_assembly_name_major(assembly) -#define VM_ASSEMBLY_NAME_GET_MINOR(assembly) il2cpp_assembly_name_minor(assembly) -#define VM_ASSEMBLY_NAME_GET_BUILD(assembly) il2cpp_assembly_name_build(assembly) -#define VM_ASSEMBLY_NAME_GET_REVISION(assembly) il2cpp_assembly_name_revision(assembly) -#define VM_ASSEMBLY_NAME_GET_CULTURE(assembly) il2cpp_assembly_name_culture(assembly) -#define VM_ASSEMBLY_NAME_GET_PUBLIC_KEY_TOKEN(assembly, i) il2cpp_assembly_name_public_key_token(assembly, i) -#define VM_ASSEMBLY_NAME_GET_PUBLIC_KEY_TOKEN_STRING(assembly) il2cpp_assembly_name_public_key_token_string(assembly) -#define VM_ASSEMBLY_NAME_GET_FLAGS(assembly) il2cpp_assembly_name_flags(assembly) #define VM_METHOD_IS_STRING_CTOR(method) il2cpp_method_is_string_ctor(method) #define VM_INFLATED_METHOD_GET_DECLARING(imethod) il2cpp_method_get_generic_definition(imethod) #define VM_INFLATED_METHOD_GET_CLASS_INST(imethod) il2cpp_method_get_generic_class_inst(imethod) @@ -49,19 +36,6 @@ #define VM_DOMAIN_SET_AGENT_INFO(domain, value) domain_jit_info (domain)->agent_info = value #define VM_DOMAIN_GET_NAME(domain) domain->friendly_name #define VM_DOMAIN_GET_CORLIB(domain) domain->domain->mbr.obj.vtable->klass->image->assembly -#define VM_ASSEMBLY_GET_NAME(assembly) assembly->aname.name -#define VM_ASSEMBLY_FREE_NAME(name) -#define VM_ASSEMBLY_IS_DYNAMIC(assembly) assembly->image->dynamic -#define VM_ASSEMBLY_GET_IMAGE(assembly) assembly->image -#define VM_ASSEMBLY_NAME_GET_NAME(assembly) (assembly)->aname.name -#define VM_ASSEMBLY_NAME_GET_MAJOR(assembly) (assembly)->aname.major -#define VM_ASSEMBLY_NAME_GET_MINOR(assembly) (assembly)->aname.minor -#define VM_ASSEMBLY_NAME_GET_BUILD(assembly) (assembly)->aname.build -#define VM_ASSEMBLY_NAME_GET_REVISION(assembly) (assembly)->aname.revision -#define VM_ASSEMBLY_NAME_GET_CULTURE(assembly) (assembly)->aname.culture -#define VM_ASSEMBLY_NAME_GET_PUBLIC_KEY_TOKEN(assembly, i) (assembly)->aname.public_key_token[i] -#define VM_ASSEMBLY_NAME_GET_PUBLIC_KEY_TOKEN_STRING(assembly) (char*)(assembly)->aname.public_key_token -#define VM_ASSEMBLY_NAME_GET_FLAGS(assembly) (assembly)->aname.flags #define VM_METHOD_IS_STRING_CTOR(method) method->string_ctor #define VM_INFLATED_METHOD_GET_DECLARING(imethod) (imethod)->declaring #define VM_INFLATED_METHOD_GET_CLASS_INST(imethod) (imethod)->context.class_inst @@ -81,7 +55,6 @@ #define MonoMethodHeader Il2CppMonoMethodHeader #define MonoVTable Il2CppMonoVTable -#define MonoAssembly Il2CppMonoAssembly #define MonoAppDomain Il2CppMonoAppDomain #define MonoDomain Il2CppMonoDomain #define MonoMethodSignature Il2CppMonoMethodSignature @@ -453,7 +426,6 @@ gint32 il2cpp_mono_environment_exitcode_get(); void il2cpp_mono_environment_exitcode_set(gint32 value); void il2cpp_mono_threadpool_suspend(); void il2cpp_mono_threadpool_resume(); -MonoImage* il2cpp_mono_assembly_get_image(Il2CppMonoAssembly* assembly); gboolean il2cpp_mono_runtime_try_shutdown(); gboolean il2cpp_mono_verifier_is_method_valid_generic_instantiation(MonoMethod* method); MonoType* il2cpp_mono_reflection_get_type_checked(MonoImage* rootimage, MonoImage* image, Il2CppMonoTypeNameParse* info, gboolean ignorecase, gboolean* type_resolve, MonoError* error); @@ -461,7 +433,7 @@ Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_method_checked(MonoMetho Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_class_checked(MonoClass* klass, MonoError* error); Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_property_checked(MonoClass* klass, MonoProperty* property, MonoError* error); Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_field_checked(MonoClass* klass, MonoClassField* field, MonoError* error); -Il2CppMonoReflectionAssemblyHandle il2cpp_mono_assembly_get_object_handle(Il2CppMonoDomain* domain, Il2CppMonoAssembly* assembly, MonoError* error); +Il2CppMonoReflectionAssemblyHandle il2cpp_mono_assembly_get_object_handle(Il2CppMonoDomain* domain, MonoAssembly* assembly, MonoError* error); MonoReflectionType* il2cpp_mono_type_get_object_checked(Il2CppMonoDomain* domain, MonoType* type, MonoError* error); void il2cpp_mono_network_init(); gint il2cpp_mono_w32socket_set_blocking(SOCKET sock, gboolean blocking); @@ -513,15 +485,6 @@ Il2CppSequencePointC* il2cpp_get_method_sequence_points(MonoMethod* method, void MonoClass* il2cpp_class_get_nested_types_accepts_generic(MonoClass *monoClass, void* *iter); MonoClass* il2cpp_defaults_object_class(); guint8 il2cpp_array_rank(MonoArray *monoArr); -const char* il2cpp_assembly_name_name(Il2CppMonoAssembly *monoAssembly); -uint16_t il2cpp_assembly_name_major(Il2CppMonoAssembly *monoAssembly); -uint16_t il2cpp_assembly_name_minor(Il2CppMonoAssembly *monoAssembly); -uint16_t il2cpp_assembly_name_build(Il2CppMonoAssembly *monoAssembly); -uint16_t il2cpp_assembly_name_revision(Il2CppMonoAssembly *monoAssembly); -const char* il2cpp_assembly_name_culture(Il2CppMonoAssembly *monoAssembly); -mono_byte il2cpp_assembly_name_public_key_token(Il2CppMonoAssembly *monoAssembly, int i); -const char* il2cpp_assembly_name_public_key_token_string(Il2CppMonoAssembly *monoAssembly); -uint32_t il2cpp_assembly_name_flags(Il2CppMonoAssembly *monoAssembly); const char* il2cpp_image_name(MonoImage *monoImage); guint8* il2cpp_field_get_address(Il2CppMonoObject *obj, MonoClassField *monoField); MonoType* il2cpp_mono_object_get_type(Il2CppMonoObject* object); @@ -533,7 +496,7 @@ void il2cpp_set_var(guint8* newValue, void *value, MonoType *localVariableTypeMo MonoMethod* il2cpp_get_interface_method(MonoClass* klass, MonoClass* itf, int slot); gboolean il2cpp_field_is_deleted(MonoClassField *field); MonoClass* il2cpp_iterate_loaded_classes(void* *iter); -Il2CppMonoAssembly* il2cpp_domain_get_assemblies_iter(Il2CppMonoAppDomain *domain, void* *iter); +MonoAssembly* il2cpp_domain_get_assemblies_iter(Il2CppMonoAppDomain *domain, void* *iter); const char** il2cpp_get_source_files_for_type(MonoClass *klass, int *count); MonoMethod* il2cpp_method_get_generic_definition(Il2CppMonoMethodInflated *imethod); MonoGenericInst* il2cpp_method_get_generic_class_inst(Il2CppMonoMethodInflated *imethod); diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index 379759cd2134..bb2d072dc4c1 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -965,7 +965,7 @@ void il2cpp_mono_threadpool_resume() #endif // NET_4_0 } -MonoImage* il2cpp_mono_assembly_get_image(Il2CppMonoAssembly* assembly) +MonoImage* il2cpp_mono_assembly_get_image(MonoAssembly* assembly) { return (MonoImage*)il2cpp::vm::Assembly::GetImage((Il2CppAssembly*)assembly); } @@ -1022,7 +1022,7 @@ Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_field_checked(MonoClass* return NULL; } -Il2CppMonoReflectionAssemblyHandle il2cpp_mono_assembly_get_object_handle(Il2CppMonoDomain* domain, Il2CppMonoAssembly* assembly, MonoError* error) +Il2CppMonoReflectionAssemblyHandle il2cpp_mono_assembly_get_object_handle(Il2CppMonoDomain* domain, MonoAssembly* assembly, MonoError* error) { return (Il2CppMonoReflectionAssemblyHandle)il2cpp::vm::Reflection::GetAssemblyObject((const Il2CppAssembly *)assembly); } @@ -1310,7 +1310,7 @@ void il2cpp_domain_set_agent_info(Il2CppMonoAppDomain* domain, void* agentInfo) ((Il2CppDomain*)domain)->agent_info = agentInfo; } -Il2CppMonoAssembly* il2cpp_domain_get_assemblies_iter(Il2CppMonoAppDomain *domain, void* *iter) +MonoAssembly* il2cpp_domain_get_assemblies_iter(Il2CppMonoAppDomain *domain, void* *iter) { if (!iter) return NULL; @@ -1322,14 +1322,14 @@ Il2CppMonoAssembly* il2cpp_domain_get_assemblies_iter(Il2CppMonoAppDomain *domai il2cpp::vm::AssemblyVector::iterator *pIter = new il2cpp::vm::AssemblyVector::iterator(); *pIter = assemblies->begin(); *iter = pIter; - return (Il2CppMonoAssembly*)**pIter; + return (MonoAssembly*)**pIter; } il2cpp::vm::AssemblyVector::iterator *pIter = (il2cpp::vm::AssemblyVector::iterator*)*iter; (*pIter)++; if (*pIter != assemblies->end()) { - return (Il2CppMonoAssembly*)(**pIter); + return (MonoAssembly*)(**pIter); } else { @@ -1355,12 +1355,6 @@ void il2cpp_gc_free_fixed(void* address) il2cpp::gc::GarbageCollector::FreeFixed(address); } -char* il2cpp_assembly_get_name(Il2CppMonoAssembly* assembly) -{ - std::string name = il2cpp::vm::AssemblyName::AssemblyNameToString(((Il2CppAssembly*)assembly)->aname); - return g_strdup(name.c_str()); -} - const char* il2cpp_domain_get_name(Il2CppMonoDomain* domain) { return ((Il2CppDomain*)domain)->friendly_name; @@ -1431,60 +1425,6 @@ guint8 il2cpp_array_rank(MonoArray *monoArr) return arr->klass->rank; } -const char* il2cpp_assembly_name_name(Il2CppMonoAssembly *monoAssembly) -{ - Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; - return il2cpp::vm::MetadataCache::GetStringFromIndex(assembly->aname.nameIndex); -} - -uint16_t il2cpp_assembly_name_major(Il2CppMonoAssembly *monoAssembly) -{ - Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; - return assembly->aname.major; -} - -uint16_t il2cpp_assembly_name_minor(Il2CppMonoAssembly *monoAssembly) -{ - Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; - return assembly->aname.minor; -} - -uint16_t il2cpp_assembly_name_build(Il2CppMonoAssembly *monoAssembly) -{ - Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; - return assembly->aname.build; -} - -uint16_t il2cpp_assembly_name_revision(Il2CppMonoAssembly *monoAssembly) -{ - Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; - return assembly->aname.revision; -} - -const char* il2cpp_assembly_name_culture(Il2CppMonoAssembly *monoAssembly) -{ - Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; - return il2cpp::vm::MetadataCache::GetStringFromIndex(assembly->aname.cultureIndex); -} - -mono_byte il2cpp_assembly_name_public_key_token(Il2CppMonoAssembly *monoAssembly, int i) -{ - Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; - return assembly->aname.publicKeyToken[i]; -} - -const char* il2cpp_assembly_name_public_key_token_string(Il2CppMonoAssembly *monoAssembly) -{ - Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; - return il2cpp::vm::MetadataCache::GetStringFromIndex(assembly->aname.publicKeyIndex); -} - -uint32_t il2cpp_assembly_name_flags(Il2CppMonoAssembly *monoAssembly) -{ - Il2CppAssembly *assembly = (Il2CppAssembly*)monoAssembly; - return assembly->aname.flags; -} - const char* il2cpp_image_name(MonoImage *monoImage) { Il2CppImage *image = (Il2CppImage*)monoImage; From 2099330c0a0782d38930d4991059be67ed29b27f Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Tue, 12 Dec 2017 09:14:13 -0500 Subject: [PATCH 019/582] Debugger Remove "C" versions of structs and instead use included versions (#750) * remove more fake types * Remove Il2cppMonoDomain * remove more structs --- mono/mini/debugger-agent.c | 129 ++++++++++++++++++--------------- mono/mini/il2cpp-c-types.h | 141 +++++-------------------------------- mono/mini/il2cpp-compat.h | 74 +++++++++---------- mono/mini/il2cpp-stubs.cpp | 80 ++++++++++----------- 4 files changed, 165 insertions(+), 259 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index d24828f5b69f..203a5f10b72b 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -3383,7 +3383,7 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) } else if (tls->il2cpp_context.frameCount > 0) { for (int frame_index = tls->il2cpp_context.frameCount - 1; frame_index >= 0; --frame_index) { - Il2CppSequencePointC* seq_point = tls->il2cpp_context.sequencePoints[frame_index]; + Il2CppSequencePoint* seq_point = tls->il2cpp_context.sequencePoints[frame_index]; StackFrame* frame = g_new0(StackFrame, 1); frame->method = seq_point->method; frame->actual_method = seq_point->method; @@ -4382,7 +4382,7 @@ typedef struct { MonoJitInfo *ji; MonoDomain *domain; #ifdef IL2CPP_MONO_DEBUGGER - Il2CppSequencePointC* seq_point; + Il2CppSequencePoint* seq_point; #endif } BreakpointInstance; @@ -4724,7 +4724,7 @@ set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req, MonoError mono_loader_lock (); #ifdef IL2CPP_MONO_DEBUGGER void *seqPointIter = NULL; - Il2CppSequencePointC *seqPoint; + Il2CppSequencePoint *seqPoint; while(seqPoint = il2cpp_get_method_sequence_points(method, &seqPointIter)) { if (bp_matches_method(bp, seqPoint->method) && seqPoint->ilOffset == bp->il_offset) @@ -4783,7 +4783,7 @@ set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req, MonoError #ifdef IL2CPP_MONO_DEBUGGER -static MonoBreakpoint* set_breakpoint_fast(Il2CppSequencePointC *sp, EventRequest *req, MonoError *error) +static MonoBreakpoint* set_breakpoint_fast(Il2CppSequencePoint *sp, EventRequest *req, MonoError *error) { MonoBreakpoint *bp; GHashTableIter iter, iter2; @@ -5080,7 +5080,7 @@ ss_update (SingleStepReq *req, MonoJitInfo *ji, SeqPoint *sp, DebuggerTlsData *t * Return FALSE if single stepping needs to continue. */ static gboolean -ss_update_il2cpp(SingleStepReq *req, DebuggerTlsData *tls, MonoContext *ctx, Il2CppSequencePointC *sequencePoint) +ss_update_il2cpp(SingleStepReq *req, DebuggerTlsData *tls, MonoContext *ctx, Il2CppSequencePoint *sequencePoint) { gboolean hit = TRUE; @@ -5746,7 +5746,7 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, uint64_t #ifndef IL2CPP_MONO_DEBUGGER process_event (EVENT_KIND_STEP, jinfo_get_method (ji), il_offset, ctx, events, suspend_policy); #else - Il2CppSequencePointC* sequence_pt = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]; + Il2CppSequencePoint* sequence_pt = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]; /* * This could be in ss_update method, but mono_find_next_seq_point_for_native_offset is pretty expensive method, @@ -6023,7 +6023,7 @@ ss_bp_add_one (SingleStepReq *ss_req, int *ss_req_bp_count, GHashTable **ss_req_ #ifdef IL2CPP_MONO_DEBUGGER -static void ss_bp_add_one_il2cpp(SingleStepReq *ss_req, int *ss_req_bp_count, GHashTable **ss_req_bp_cache, Il2CppSequencePointC *sp) +static void ss_bp_add_one_il2cpp(SingleStepReq *ss_req, int *ss_req_bp_count, GHashTable **ss_req_bp_cache, Il2CppSequencePoint *sp) { // This list is getting too long, switch to using the hash table if (!*ss_req_bp_cache && *ss_req_bp_count > MAX_LINEAR_SCAN_BPS) @@ -6357,10 +6357,10 @@ ss_start_il2cpp(SingleStepReq *ss_req, DebuggerTlsData *tls) MonoMethod* currentMethod = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]->method; void *seqPointIter = NULL; - Il2CppSequencePointC *seqPoint; + Il2CppSequencePoint *seqPoint; while(seqPoint = il2cpp_get_method_sequence_points(currentMethod, &seqPointIter)) { - if (seqPoint->kind != kSequencePointKindC_Normal) + if (seqPoint->kind != kSequencePointKind_Normal) continue; if (il2cpp_mono_methods_match(seqPoint->method, currentMethod)) @@ -6370,8 +6370,8 @@ ss_start_il2cpp(SingleStepReq *ss_req, DebuggerTlsData *tls) if (tls->il2cpp_context.frameCount > 1) { - Il2CppSequencePointC* sequencePointForStepOut = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 2]; - g_assert(sequencePointForStepOut->kind == kSequencePointKindC_StepOut); + Il2CppSequencePoint* sequencePointForStepOut = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 2]; + g_assert(sequencePointForStepOut->kind == kSequencePointKind_StepOut); ss_bp_add_one_il2cpp(ss_req, &ss_req_bp_count, &ss_req_bp_cache, sequencePointForStepOut); } @@ -6463,7 +6463,7 @@ ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilte if (tls->il2cpp_context.frameCount > 0) { - Il2CppSequencePointC* seq_point = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]; + Il2CppSequencePoint* seq_point = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]; ss_req->start_method = seq_point->method; ss_req->last_method = seq_point->method; ss_req->last_line = seq_point->lineEnd; @@ -6671,7 +6671,7 @@ mono_debugger_agent_unhandled_exception (MonoException *exc) #ifdef IL2CPP_MONO_DEBUGGER void -unity_debugger_agent_handle_exception(MonoException *exc, Il2CppSequencePointC *sequencePoint) +unity_debugger_agent_handle_exception(MonoException *exc, Il2CppSequencePoint *sequencePoint) { int i, j, suspend_policy; GSList *events; @@ -9056,6 +9056,7 @@ domain_commands (int command, guint8 *p, guint8 *end, Buffer *buf) { ErrorCode err; MonoDomain *domain; + void *iter = NULL; switch (command) { case CMD_APPDOMAIN_GET_ROOT_DOMAIN: { @@ -9079,12 +9080,20 @@ domain_commands (int command, guint8 *p, guint8 *end, Buffer *buf) return err; mono_loader_lock (); count = 0; +#ifndef IL2CPP_MONO_DEBUGGER for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) { +#else + while(il2cpp_domain_get_assemblies_iter(domain, &iter)) { +#endif //IL2CPP_MONO_DEBUGGER count ++; } buffer_add_int (buf, count); +#ifndef IL2CPP_MONO_DEBUGGER for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) { ass = (MonoAssembly *)tmp->data; +#else + while(ass = il2cpp_domain_get_assemblies_iter(domain, &iter)) { +#endif //IL2CPP_MONO_DEBUGGER buffer_add_assemblyid (buf, domain, ass); } mono_loader_unlock (); @@ -9094,8 +9103,11 @@ domain_commands (int command, guint8 *p, guint8 *end, Buffer *buf) domain = decode_domainid (p, &p, end, NULL, &err); if (err != ERR_NONE) return err; - +#ifndef IL2CPP_MONO_DEBUGGER buffer_add_assemblyid (buf, domain, domain->entry_assembly); +#else + buffer_add_assemblyid (buf, domain, NULL); +#endif //IL2CPP_MONO_DEBUGGER break; } case CMD_APPDOMAIN_GET_CORLIB: { @@ -9969,8 +9981,8 @@ type_commands (int command, guint8 *p, guint8 *end, Buffer *buf) gint CompareSeqPointsByIlOffset(gconstpointer a, gconstpointer b) { - Il2CppSequencePointC *seqPointA = *(Il2CppSequencePointC**)a; - Il2CppSequencePointC *seqPointB = *(Il2CppSequencePointC**)b; + Il2CppSequencePoint *seqPointA = *(Il2CppSequencePoint**)a; + Il2CppSequencePoint *seqPointB = *(Il2CppSequencePoint**)b; if (seqPointA->ilOffset < seqPointB->ilOffset) return -1; @@ -9988,7 +10000,7 @@ static void GetSequencePointsAndSourceFilesUniqueSequencePoints(MonoMethod* meth *uniqueFileSequencePointIndices = g_array_new(FALSE, FALSE, sizeof(int)); void *seqPointIter = NULL; - Il2CppSequencePointC *seqPoint; + Il2CppSequencePoint *seqPoint; while (seqPoint = il2cpp_get_method_sequence_points(method, &seqPointIter)) { if(seqPoint->ilOffset == METHOD_ENTRY_IL_OFFSET || seqPoint->ilOffset == METHOD_EXIT_IL_OFFSET) @@ -10003,11 +10015,11 @@ static void GetSequencePointsAndSourceFilesUniqueSequencePoints(MonoMethod* meth for(i=0;i < (*sequencePoints)->len;++i) { int j; - seqPoint = (Il2CppSequencePointC*)(*sequencePoints)->pdata[i]; + seqPoint = (Il2CppSequencePoint*)(*sequencePoints)->pdata[i]; for (j = 0; j < (*uniqueFileSequencePoints)->len; j++) { - Il2CppSequencePointC* uniqueSequencePoint = g_ptr_array_index(*uniqueFileSequencePoints, j); + Il2CppSequencePoint* uniqueSequencePoint = g_ptr_array_index(*uniqueFileSequencePoints, j); if (strcmp(uniqueSequencePoint->sourceFile, seqPoint->sourceFile) == 0) break; } @@ -10020,10 +10032,10 @@ static void GetSequencePointsAndSourceFilesUniqueSequencePoints(MonoMethod* meth } } -static void GetExecutionContextAndHeaderInfo(MonoMethod* method, uint32_t* executionContextInfoCount, const Il2CppMethodExecutionContextInfoC **executionContextInfo, const Il2CppMethodHeaderInfoC **headerInfo) +static void GetExecutionContextAndHeaderInfo(MonoMethod* method, uint32_t* executionContextInfoCount, const Il2CppMethodExecutionContextInfo **executionContextInfo, const Il2CppMethodHeaderInfo **headerInfo) { void *seqPointIter = NULL; - Il2CppSequencePointC *seqPoint; + Il2CppSequencePoint *seqPoint; while (seqPoint = il2cpp_get_method_sequence_points(method, &seqPointIter)) { if (il2cpp_mono_methods_match(seqPoint->method, method)) @@ -10136,16 +10148,16 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g if (CHECK_PROTOCOL_VERSION(2, 13)) { buffer_add_int(buf, uniqueFileSequencePoints->len); for (i = 0; i < uniqueFileSequencePoints->len; ++i) { - Il2CppSequencePointC* sequencePoint = g_ptr_array_index(uniqueFileSequencePoints, i); + Il2CppSequencePoint* sequencePoint = g_ptr_array_index(uniqueFileSequencePoints, i); buffer_add_string(buf, sequencePoint->sourceFile); if (CHECK_PROTOCOL_VERSION(2, 14)) { - buffer_add_data(buf, sequencePoint->sourceFileHash, 16); + buffer_add_data(buf, sequencePoint->sourceFileHash.m_hash, 16); } } } else { if (uniqueFileSequencePoints->len > 0) { - buffer_add_string(buf, ((Il2CppSequencePointC*)g_ptr_array_index(uniqueFileSequencePoints, 0))->sourceFile); + buffer_add_string(buf, ((Il2CppSequencePoint*)g_ptr_array_index(uniqueFileSequencePoints, 0))->sourceFile); } else { buffer_add_string(buf, ""); } @@ -10153,7 +10165,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g buffer_add_int(buf, sequencePoints->len); DEBUG_PRINTF(10, "Line number table for method %s:\n", mono_method_full_name(method, TRUE)); for (i = 0; i < sequencePoints->len; ++i) { - Il2CppSequencePointC* sequencePoint = g_ptr_array_index(sequencePoints, i); + Il2CppSequencePoint* sequencePoint = g_ptr_array_index(sequencePoints, i); DEBUG_PRINTF(10, "IL%x -> %s:%d %d %d %d\n", sequencePoint->ilOffset, sequencePoint->sourceFile, sequencePoint->lineStart, sequencePoint->columnStart, sequencePoint->lineEnd, sequencePoint->columnEnd); buffer_add_int(buf, sequencePoint->ilOffset); @@ -10278,19 +10290,19 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g g_free (locals_map); #else uint32_t executionInfoCount, localVariableCount = 0, i; - const Il2CppMethodExecutionContextInfoC* executionContextInfo; - const Il2CppMethodHeaderInfoC* headerInfo; + const Il2CppMethodExecutionContextInfo* executionContextInfo; + const Il2CppMethodHeaderInfo* headerInfo; GetExecutionContextAndHeaderInfo(method, &executionInfoCount, &executionContextInfo, &headerInfo); if (CHECK_PROTOCOL_VERSION(2, 43)) { if (headerInfo) { - buffer_add_int(buf, headerInfo->numScopes); - for (i = 0; i < headerInfo->numScopes; ++i) + buffer_add_int(buf, headerInfo->m_numScopes); + for (i = 0; i < headerInfo->m_numScopes; ++i) { - buffer_add_int(buf, headerInfo->scopes[i].startOffset); - buffer_add_int(buf, headerInfo->scopes[i].endOffset); + buffer_add_int(buf, headerInfo->m_scopes[i].startOffset); + buffer_add_int(buf, headerInfo->m_scopes[i].endOffset); } } else @@ -10301,7 +10313,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g for (i = 0; i < executionInfoCount; i++) { - if (executionContextInfo[i].variableKind == kMethodVariableKindC_LocalVariable) + if (executionContextInfo[i].m_variableKind == kMethodVariableKind_LocalVariable) localVariableCount++; } @@ -10309,21 +10321,21 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g for (i = 0; i < executionInfoCount; i++) { - if (executionContextInfo[i].variableKind == kMethodVariableKindC_LocalVariable) - buffer_add_typeid(buf, domain, mono_class_from_mono_type(*executionContextInfo[i].type)); + if (executionContextInfo[i].m_variableKind == kMethodVariableKind_LocalVariable) + buffer_add_typeid(buf, domain, mono_class_from_mono_type(*executionContextInfo[i].m_type)); } for (i = 0; i < executionInfoCount; i++) { - if (executionContextInfo[i].variableKind == kMethodVariableKindC_LocalVariable) - buffer_add_string(buf, executionContextInfo[i].name); + if (executionContextInfo[i].m_variableKind == kMethodVariableKind_LocalVariable) + buffer_add_string(buf, executionContextInfo[i].m_name); } for (i = 0; i < executionInfoCount; i++) { - if (executionContextInfo[i].variableKind == kMethodVariableKindC_LocalVariable) { - buffer_add_int(buf, executionContextInfo[i].start); - buffer_add_int(buf, executionContextInfo[i].end); + if (executionContextInfo[i].m_variableKind == kMethodVariableKind_LocalVariable) { + buffer_add_int(buf, executionContextInfo[i].m_start); + buffer_add_int(buf, executionContextInfo[i].m_end); } } #endif // !IL2CPP_MONO_DEBUGGER @@ -10405,6 +10417,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g break; } case CMD_METHOD_GET_BODY: { +#ifndef IL2CPP_MONO_DEBUGGER MonoError error; int i; @@ -10439,8 +10452,10 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g mono_metadata_free_mh (header); } - break; +#else + return ERR_NOT_IMPLEMENTED; +#endif } case CMD_METHOD_RESOLVE_TOKEN: { guint32 token = decode_int (p, &p, end); @@ -10749,7 +10764,7 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf) #ifdef IL2CPP_MONO_DEBUGGER -static uint32_t GetExecutionContextIndex(const Il2CppSequencePointC* sequencePoint, MethodVariableKindC variableKind, uint32_t variablePosition) +static uint32_t GetExecutionContextIndex(const Il2CppSequencePoint* sequencePoint, MethodVariableKind variableKind, uint32_t variablePosition) { uint32_t executionContextPosition, variablesIterated = 0; @@ -10757,7 +10772,7 @@ static uint32_t GetExecutionContextIndex(const Il2CppSequencePointC* sequencePoi { g_assert(executionContextPosition < sequencePoint->executionContextInfoCount); - if (sequencePoint->executionContextInfos[executionContextPosition].variableKind == variableKind) + if (sequencePoint->executionContextInfos[executionContextPosition].m_variableKind == variableKind) { if (variablesIterated == variablePosition) return executionContextPosition; @@ -10767,22 +10782,22 @@ static uint32_t GetExecutionContextIndex(const Il2CppSequencePointC* sequencePoi } } -static void GetVariable(DebuggerTlsData* tls, StackFrame* frame, MethodVariableKindC variableKind, uint32_t variablePosition, MonoType** type, void** var) +static void GetVariable(DebuggerTlsData* tls, StackFrame* frame, MethodVariableKind variableKind, uint32_t variablePosition, MonoType** type, void** var) { for (int frame_index = 0; frame_index < tls->il2cpp_context.frameCount; ++frame_index) { if (tls->il2cpp_context.sequencePoints[frame_index]->method == frame->actual_method) { - Il2CppSequencePointC* sequencePoint = tls->il2cpp_context.sequencePoints[frame_index]; - Il2CppSequencePointExecutionContextC* executionContext = tls->il2cpp_context.executionContexts[frame_index]; + Il2CppSequencePoint* sequencePoint = tls->il2cpp_context.sequencePoints[frame_index]; + Il2CppSequencePointExecutionContext* executionContext = tls->il2cpp_context.executionContexts[frame_index]; uint32_t executionContextPosition = GetExecutionContextIndex(sequencePoint, variableKind, variablePosition); - *type = *sequencePoint->executionContextInfos[executionContextPosition].type; + *type = *sequencePoint->executionContextInfos[executionContextPosition].m_type; *var = executionContext->values[executionContextPosition]; } } } -static void SendVariableData(DebuggerTlsData* tls, StackFrame* frame, Buffer* buf, MethodVariableKindC variableKind, uint32_t variablePosition) +static void SendVariableData(DebuggerTlsData* tls, StackFrame* frame, Buffer* buf, MethodVariableKind variableKind, uint32_t variablePosition) { MonoType* localVariableType; void* localVariableValue; @@ -10890,7 +10905,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) add_var (buf, jit, sig->params [pos], &jit->params [pos], &frame->ctx, frame->domain, FALSE); } #else - SendVariableData (tls, frame, buf, kMethodVariableKindC_Parameter, pos); + SendVariableData (tls, frame, buf, kMethodVariableKind_Parameter, pos); #endif } else { #ifndef IL2CPP_MONO_DEBUGGER @@ -10917,7 +10932,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) add_var (buf, jit, header->locals [pos], &jit->locals [pos], &frame->ctx, frame->domain, FALSE); } #else - SendVariableData (tls, frame, buf, kMethodVariableKindC_LocalVariable, pos); + SendVariableData (tls, frame, buf, kMethodVariableKind_LocalVariable, pos); #endif } } @@ -10971,7 +10986,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) add_var (buf, jit, &frame->api_method->klass->byval_arg, jit->this_var, &frame->ctx, frame->domain, TRUE); } #else - SendVariableData (tls, frame, buf, kMethodVariableKindC_This, 0); + SendVariableData (tls, frame, buf, kMethodVariableKind_This, 0); #endif } } @@ -11006,7 +11021,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) t = sig->params [pos]; var = &jit->params [pos]; #else - GetVariable (tls, frame, kMethodVariableKindC_Parameter, pos, &t, &var); + GetVariable (tls, frame, kMethodVariableKind_Parameter, pos, &t, &var); #endif is_arg = TRUE; } else { @@ -11024,7 +11039,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) t = header->locals [pos]; var = &jit->locals [pos]; #else - GetVariable(tls, frame, kMethodVariableKindC_LocalVariable, pos, &t, &var); + GetVariable(tls, frame, kMethodVariableKind_LocalVariable, pos, &t, &var); #endif } @@ -11093,7 +11108,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) set_var (&frame->actual_method->klass->this_arg, var, &frame->ctx, frame->domain, val_buf, frame->reg_locations, &tls->restore_state.ctx); } #else - GetVariable (tls, frame, kMethodVariableKindC_This, 0, &t, &var); + GetVariable (tls, frame, kMethodVariableKind_This, 0, &t, &var); il2cpp_set_var(val_buf, var, &frame->actual_method->klass->this_arg); #endif break; @@ -11693,7 +11708,7 @@ debugger_thread (void *arg) process_profiler_event (EVENT_KIND_VM_START, mono_thread_get_main ()); #ifdef IL2CPP_MONO_DEBUGGER { - Il2CppMonoDomain* domain = il2cpp_mono_get_root_domain(); + MonoDomain* domain = il2cpp_mono_get_root_domain(); appdomain_load(NULL, domain); AgentDomainInfo *info = VM_DOMAIN_GET_AGENT_INFO(domain); void *iter = NULL; @@ -11858,7 +11873,7 @@ debugger_thread (void *arg) #ifdef IL2CPP_MONO_DEBUGGER static void -unity_process_breakpoint_inner(DebuggerTlsData *tls, gboolean from_signal, Il2CppSequencePointC* sequencePoint) +unity_process_breakpoint_inner(DebuggerTlsData *tls, gboolean from_signal, Il2CppSequencePoint* sequencePoint) { MonoJitInfo *ji = NULL; guint8 *ip; @@ -11991,7 +12006,7 @@ unity_process_breakpoint_inner(DebuggerTlsData *tls, gboolean from_signal, Il2Cp } void -unity_debugger_agent_breakpoint(Il2CppSequencePointC* sequencePoint) +unity_debugger_agent_breakpoint(Il2CppSequencePoint* sequencePoint) { DebuggerTlsData *tls; MonoThreadUnwindState orig_restore_state; @@ -12016,7 +12031,7 @@ gboolean unity_debugger_agent_is_global_breakpoint_active() return ss_req->global; } -gboolean unity_sequence_point_active(Il2CppSequencePointC *seqPoint) +gboolean unity_sequence_point_active(Il2CppSequencePoint *seqPoint) { gboolean global = unity_debugger_agent_is_global_breakpoint_active(); diff --git a/mono/mini/il2cpp-c-types.h b/mono/mini/il2cpp-c-types.h index 9c6c25131903..32c4eefeadfd 100644 --- a/mono/mini/il2cpp-c-types.h +++ b/mono/mini/il2cpp-c-types.h @@ -4,6 +4,7 @@ #if defined(RUNTIME_IL2CPP) #include "il2cpp-class-internals.h" #include "il2cpp-object-internals.h" +#include "vm-utils/Debugger.h" #endif // RUNTIME_IL2CPP #define IL2CPP_MONO_PUBLIC_KEY_TOKEN_LENGTH 17 @@ -28,18 +29,19 @@ #define MonoReflectionType Il2CppReflectionType #define MonoProfiler Il2CppProfiler #define MonoAssembly Il2CppAssembly +#define MonoAssembyName Il2CppAssemblyName +#define MonoMethodHeader Il2CppMethodHeaderInfo +#define MonoReflectionAssembly Il2CppReflectionAssembly +#define MonoAppDomain Il2CppAppDomain +#define MonoDomain Il2CppDomain +#define MonoDomainFunc Il2CppDomainFunc //still stubs everywhere -typedef struct _Il2CppMonoAssemblyName Il2CppMonoAssemblyNameReplacement; -typedef struct _Il2CppMonoDomain Il2CppMonoDomain; typedef struct _Il2CppMonoMethodSignature Il2CppMonoMethodSignature; -typedef struct _Il2CppMonoMethodHeader Il2CppMonoMethodHeader; typedef struct _Il2CppMonoVTable Il2CppMonoVTable; -typedef struct _Il2CppMonoAppDomain Il2CppMonoAppDomain; typedef struct _Il2CppMonoMarshalByRefObject Il2CppMonoMarshalByRefObject; typedef struct _Il2CppMonoObject Il2CppMonoObject; typedef struct _Il2CppMonoCustomAttrInfo Il2CppMonoCustomAttrInfo; -typedef struct Il2CppReflectionAssembly Il2CppMonoReflectionAssembly; typedef struct _Il2CppMonoJitTlsData Il2CppMonoJitTlsData; typedef struct _Il2CppMonoRuntimeExceptionHandlingCallbacks Il2CppMonoRuntimeExceptionHandlingCallbacks; typedef struct _Il2CppMonoCustomAttrEntry Il2CppMonoCustomAttrEntry; @@ -48,25 +50,11 @@ typedef struct Il2CppDefaults Il2CppMonoDefaults; typedef struct _Il2CppMonoMethodInflated Il2CppMonoMethodInflated; typedef struct _Il2CppMonoException Il2CppMonoException; typedef struct _Il2CppCattrNamedArg Il2CppCattrNamedArg; -typedef struct _Il2CppMonoExceptionClause Il2CppMonoExceptionClause; typedef struct _Il2CppMonoTypeNameParse Il2CppMonoTypeNameParse; struct _Il2CppMonoJitTlsData { void *dummy; }; -struct _Il2CppMonoExceptionClause -{ - uint32_t flags; - uint32_t try_offset; - uint32_t try_len; - uint32_t handler_offset; - uint32_t handler_len; - union { - uint32_t filter_offset; - MonoClass *catch_class; - } data; -}; - struct _Il2CppCattrNamedArg { MonoType *type; @@ -97,7 +85,7 @@ struct _Il2CppMonoStackFrameInfo MonoJitInfo *ji; MonoMethod *method; MonoMethod *actual_method; - Il2CppMonoDomain *domain; + MonoDomain *domain; gboolean managed; gboolean async_context; int native_offset; @@ -135,50 +123,15 @@ struct _Il2CppMonoMarshalByRefObject Il2CppMonoObject obj; }; -struct _Il2CppMonoMethodHeader -{ - const unsigned char *code; - guint32 code_size; - guint16 num_locals; - Il2CppMonoExceptionClause *clauses; - unsigned int num_clauses : 15; - MonoType *locals [MONO_ZERO_LEN_ARRAY]; -}; - struct _Il2CppMonoVTable { MonoClass *klass; - Il2CppMonoDomain *domain; + MonoDomain *domain; guint8 initialized; gpointer type; guint init_failed : 1; }; -struct _Il2CppMonoAppDomain -{ - Il2CppMonoMarshalByRefObject mbr; -}; - -struct _Il2CppMonoAssemblyName -{ - const char *name; - const char *culture; - mono_byte public_key_token [IL2CPP_MONO_PUBLIC_KEY_TOKEN_LENGTH]; - uint32_t flags; - uint16_t major, minor, build, revision; -}; - -struct _Il2CppMonoDomain -{ - gpointer runtime_info; - guint32 state; - char *friendly_name; - mono_mutex_t assemblies_lock; - GSList *domain_assemblies; - MonoAssembly *entry_assembly; - Il2CppMonoAppDomain *domain; -}; - struct _Il2CppMonoMethodSignature { MonoType *ret; @@ -191,97 +144,41 @@ struct _Il2CppMonoMethodSignature struct _Il2CppMonoTypeNameParse { - Il2CppMonoAssemblyNameReplacement assembly; + MonoAssemblyName assembly; void *il2cppTypeNameParseInfo; }; -typedef enum -{ - kMethodVariableKindC_This, - kMethodVariableKindC_Parameter, - kMethodVariableKindC_LocalVariable -} MethodVariableKindC; - -typedef enum -{ - kSequencePointKindC_Normal, - kSequencePointKindC_StepOut -} SequencePointKindC; - -typedef struct -{ - const MonoType* const* const type; - const char* const name; - const MethodVariableKindC variableKind; - const int start; - const int end; -} Il2CppMethodExecutionContextInfoC; - -typedef struct -{ - int startOffset; - int endOffset; -} Il2CppMethodScopeC; - -typedef struct -{ - int codeSize; - int numScopes; - Il2CppMethodScopeC *scopes; -} Il2CppMethodHeaderInfoC; - -typedef struct -{ - const Il2CppMethodExecutionContextInfoC* const executionContextInfos; - const uint32_t executionContextInfoCount; - const Il2CppMethodHeaderInfoC *header; - const MonoMethod* method; - const char* const sourceFile; - const uint8_t sourceFileHash[16]; - const int32_t lineStart, lineEnd; - const int32_t columnStart, columnEnd; - const int32_t ilOffset; - const SequencePointKindC kind; - uint8_t isActive; - uint64_t id; -} Il2CppSequencePointC; - -typedef struct -{ - void** values; -} Il2CppSequencePointExecutionContextC; - typedef struct Il2CppThreadUnwindState { - Il2CppSequencePointC** sequencePoints; - Il2CppSequencePointExecutionContextC** executionContexts; + Il2CppSequencePoint** sequencePoints; + Il2CppSequencePointExecutionContext** executionContexts; uint32_t frameCount; } Il2CppThreadUnwindState; TYPED_HANDLE_DECL (Il2CppMonoObject); -TYPED_HANDLE_DECL (Il2CppMonoReflectionAssembly); +TYPED_HANDLE_DECL (MonoReflectionAssembly); Il2CppMonoDefaults il2cpp_mono_defaults; MonoDebugOptions il2cpp_mono_debug_options; typedef void (*Il2CppMonoProfileFunc) (MonoProfiler *prof); -typedef void (*Il2CppMonoProfileAppDomainFunc) (MonoProfiler *prof, Il2CppMonoDomain *domain); -typedef void (*Il2CppMonoProfileAppDomainResult) (MonoProfiler *prof, Il2CppMonoDomain *domain, int result); +typedef void (*Il2CppMonoProfileAppDomainFunc) (MonoProfiler *prof, MonoDomain *domain); +typedef void (*Il2CppMonoProfileAppDomainResult) (MonoProfiler *prof, MonoDomain *domain, int result); typedef void (*Il2CppMonoProfileAssemblyFunc) (MonoProfiler *prof, MonoAssembly *assembly); typedef void (*Il2CppMonoProfileJitResult) (MonoProfiler *prof, MonoMethod *method, MonoJitInfo* jinfo, int result); typedef void (*Il2CppMonoProfileAssemblyResult) (MonoProfiler *prof, MonoAssembly *assembly, int result); typedef void (*Il2CppMonoProfileThreadFunc) (MonoProfiler *prof, uintptr_t tid); typedef gboolean (*Il2CppMonoJitStackWalk) (Il2CppMonoStackFrameInfo *frame, MonoContext *ctx, gpointer data); -typedef void (*Il2CppMonoDomainFunc) (Il2CppMonoDomain *domain, void* user_data); +typedef void (*Il2CppDomainFunc) (MonoDomain *domain, void* user_data); typedef void (*emit_assembly_load_callback)(void*, void*); typedef void(*emit_type_load_callback)(void*, void*, void*); void il2cpp_set_thread_state_background(MonoThread* thread); -void* il2cpp_domain_get_agent_info(Il2CppMonoAppDomain* domain); -void il2cpp_domain_set_agent_info(Il2CppMonoAppDomain* domain, void* agentInfo); +void* il2cpp_domain_get_agent_info(MonoAppDomain* domain); +void il2cpp_domain_set_agent_info(MonoAppDomain* domain, void* agentInfo); void il2cpp_start_debugger_thread(); void* il2cpp_gc_alloc_fixed(size_t size); void il2cpp_gc_free_fixed(void* address); -const char* il2cpp_domain_get_name(Il2CppMonoDomain* domain); +const char* il2cpp_domain_get_name(MonoDomain* domain); #endif \ No newline at end of file diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index 55c36b1f247a..b21ebdf3870c 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -53,16 +53,11 @@ #if defined(RUNTIME_IL2CPP) -#define MonoMethodHeader Il2CppMonoMethodHeader #define MonoVTable Il2CppMonoVTable -#define MonoAppDomain Il2CppMonoAppDomain -#define MonoDomain Il2CppMonoDomain #define MonoMethodSignature Il2CppMonoMethodSignature -#define MonoAssemblyName Il2CppMonoAssemblyNameReplacement #define MonoMarshalByRefObject Il2CppMonoMarshalByRefObject #define MonoObject Il2CppMonoObject #define MonoCustomAttrInfo Il2CppMonoCustomAttrInfo -#define MonoReflectionAssemblyHandle Il2CppMonoReflectionAssemblyHandle #define MonoJitTlsData Il2CppMonoJitTlsData #define MonoRuntimeExceptionHandlingCallbacks Il2CppMonoRuntimeExceptionHandlingCallbacks #define MonoCustomAttrEntry Il2CppMonoCustomAttrEntry @@ -70,7 +65,6 @@ #define MonoMethodInflated Il2CppMonoMethodInflated #define MonoException Il2CppMonoException #define CattrNamedArg Il2CppCattrNamedArg -#define MonoExceptionClause Il2CppMonoExceptionClause #define debug_options il2cpp_mono_debug_options #define MonoTypeNameParse Il2CppMonoTypeNameParse @@ -304,13 +298,13 @@ const char* il2cpp_mono_image_get_guid (MonoImage *image); MonoClass* il2cpp_mono_type_get_class (MonoType *type); mono_bool il2cpp_mono_type_is_struct (MonoType *type); mono_bool il2cpp_mono_type_is_reference (MonoType *type); -void il2cpp_mono_metadata_free_mh (Il2CppMonoMethodHeader *mh); +void il2cpp_mono_metadata_free_mh (MonoMethodHeader *mh); Il2CppMonoMethodSignature* il2cpp_mono_method_signature (MonoMethod *m); void il2cpp_mono_method_get_param_names (MonoMethod *method, const char **names); mono_bool il2cpp_mono_type_generic_inst_is_valuetype (MonoType *type); -Il2CppMonoMethodHeader* il2cpp_mono_method_get_header_checked (MonoMethod *method, MonoError *error); +MonoMethodHeader* il2cpp_mono_method_get_header_checked (MonoMethod *method, MonoError *error); gboolean il2cpp_mono_class_init (MonoClass *klass); -Il2CppMonoVTable* il2cpp_mono_class_vtable (Il2CppMonoDomain *domain, MonoClass *klass); +Il2CppMonoVTable* il2cpp_mono_class_vtable (MonoDomain *domain, MonoClass *klass); MonoClassField* il2cpp_mono_class_get_field_from_name (MonoClass *klass, const char *name); int32_t il2cpp_mono_array_element_size (MonoClass *ac); int32_t il2cpp_mono_class_instance_size (MonoClass *klass); @@ -328,9 +322,9 @@ mono_unichar2* il2cpp_mono_string_chars (MonoString *s); int il2cpp_mono_string_length (MonoString *s); char* il2cpp_mono_array_addr_with_size (MonoArray *array, int size, uintptr_t idx); uintptr_t il2cpp_mono_array_length (MonoArray *array); -MonoString* il2cpp_mono_string_new (Il2CppMonoDomain *domain, const char *text); -MonoString* il2cpp_mono_string_new (Il2CppMonoDomain *domain, const char *text); -MonoString* il2cpp_mono_string_new_checked (Il2CppMonoDomain *domain, const char *text, MonoError *merror); +MonoString* il2cpp_mono_string_new (MonoDomain *domain, const char *text); +MonoString* il2cpp_mono_string_new (MonoDomain *domain, const char *text); +MonoString* il2cpp_mono_string_new_checked (MonoDomain *domain, const char *text, MonoError *merror); char* il2cpp_mono_string_to_utf8_checked (MonoString *string_obj, MonoError *error); int il2cpp_mono_object_hash (Il2CppMonoObject* obj); void* il2cpp_mono_object_unbox (Il2CppMonoObject *obj); @@ -344,21 +338,21 @@ int il2cpp_mono_reflection_parse_type_checked (char *name, Il2CppMonoTypeNamePar void il2cpp_mono_reflection_free_type_info (Il2CppMonoTypeNameParse *info); mono_bool il2cpp_mono_custom_attrs_has_attr (Il2CppMonoCustomAttrInfo *ainfo, MonoClass *attr_klass); void il2cpp_mono_custom_attrs_free (Il2CppMonoCustomAttrInfo *ainfo); -Il2CppMonoDomain* il2cpp_mono_get_root_domain (void); +MonoDomain* il2cpp_mono_get_root_domain (void); void il2cpp_mono_runtime_quit (void); gboolean il2cpp_mono_runtime_is_shutting_down (void); -Il2CppMonoDomain* il2cpp_mono_domain_get (void); -gboolean il2cpp_mono_domain_set (Il2CppMonoDomain *domain, gboolean force); -void il2cpp_mono_domain_foreach(Il2CppMonoDomainFunc func, gpointer user_data); -MonoJitInfo* il2cpp_mono_jit_info_table_find(Il2CppMonoDomain* domain, char* addr); +MonoDomain* il2cpp_mono_domain_get (void); +gboolean il2cpp_mono_domain_set (MonoDomain *domain, gboolean force); +void il2cpp_mono_domain_foreach(MonoDomainFunc func, gpointer user_data); +MonoJitInfo* il2cpp_mono_jit_info_table_find(MonoDomain* domain, char* addr); MonoMethod* il2cpp_mono_jit_info_get_method(MonoJitInfo* ji); MonoDebugMethodInfo* il2cpp_mono_debug_lookup_method(MonoMethod* method); -MonoDebugMethodJitInfo* il2cpp_mono_debug_find_method(MonoMethod* method, Il2CppMonoDomain* domain); +MonoDebugMethodJitInfo* il2cpp_mono_debug_find_method(MonoMethod* method, MonoDomain* domain); void il2cpp_mono_debug_free_method_jit_info(MonoDebugMethodJitInfo* jit); MonoDebugLocalsInfo* il2cpp_mono_debug_lookup_locals(MonoMethod* method); MonoDebugMethodAsyncInfo* il2cpp_mono_debug_lookup_method_async_debug_info(MonoMethod* method); MonoDebugSourceLocation* il2cpp_mono_debug_method_lookup_location(MonoDebugMethodInfo* minfo, int il_offset); -gint32 il2cpp_mono_debug_il_offset_from_address(MonoMethod* method, Il2CppMonoDomain* domain, guint32 native_offset); +gint32 il2cpp_mono_debug_il_offset_from_address(MonoMethod* method, MonoDomain* domain, guint32 native_offset); void il2cpp_mono_debug_free_source_location(MonoDebugSourceLocation* location); void il2cpp_mono_set_is_debugger_attached(gboolean attached); char* il2cpp_mono_type_full_name(MonoType* type); @@ -368,10 +362,10 @@ void il2cpp_mono_debug_free_locals(MonoDebugLocalsInfo* info); void il2cpp_mono_debug_free_method_async_debug_info(MonoDebugMethodAsyncInfo* info); MonoThread* il2cpp_mono_thread_current(); MonoThread* il2cpp_mono_thread_get_main(); -MonoThread* il2cpp_mono_thread_attach(Il2CppMonoDomain* domain); -void il2cpp_mono_domain_lock(Il2CppMonoDomain* domain); -void il2cpp_mono_domain_unlock(Il2CppMonoDomain* domain); -MonoJitInfo* il2cpp_mono_jit_info_table_find_internal(Il2CppMonoDomain* domain, char* addr, gboolean try_aot, gboolean allow_trampolines); +MonoThread* il2cpp_mono_thread_attach(MonoDomain* domain); +void il2cpp_mono_domain_lock(MonoDomain* domain); +void il2cpp_mono_domain_unlock(MonoDomain* domain); +MonoJitInfo* il2cpp_mono_jit_info_table_find_internal(MonoDomain* domain, char* addr, gboolean try_aot, gboolean allow_trampolines); guint il2cpp_mono_aligned_addr_hash(gconstpointer ptr); MonoGenericInst* il2cpp_mono_metadata_get_generic_inst(int type_argc, MonoType** type_argv); MonoMethod* il2cpp_mono_get_method_checked(MonoImage* image, guint32 token, MonoClass* klass, MonoGenericContext* context, MonoError* error); @@ -411,12 +405,12 @@ void il2cpp_mono_stack_mark_record_size(MonoThreadInfo* info, HandleStackMark* s Il2CppMonoRuntimeExceptionHandlingCallbacks* il2cpp_mono_get_eh_callbacks(); void il2cpp_mono_reflection_create_custom_attr_data_args(MonoImage* image, MonoMethod* method, const guchar* data, guint32 len, MonoArray** typed_args, MonoArray** named_args, CattrNamedArg** named_arg_info, MonoError* error); void il2cpp_mono_nullable_init(guint8* buf, Il2CppMonoObject* value, MonoClass* klass); -Il2CppMonoObject* il2cpp_mono_value_box_checked(Il2CppMonoDomain* domain, MonoClass* klass, gpointer value, MonoError* error); +Il2CppMonoObject* il2cpp_mono_value_box_checked(MonoDomain* domain, MonoClass* klass, gpointer value, MonoError* error); void il2cpp_mono_field_static_get_value_checked(Il2CppMonoVTable* vt, MonoClassField* field, void* value, MonoError* error); void il2cpp_mono_field_static_get_value_for_thread(MonoInternalThread* thread, Il2CppMonoVTable* vt, MonoClassField* field, void* value, MonoError* error); -Il2CppMonoObject* il2cpp_mono_field_get_value_object_checked(Il2CppMonoDomain* domain, MonoClassField* field, Il2CppMonoObject* obj, MonoError* error); -Il2CppMonoObject* il2cpp_mono_object_new_checked(Il2CppMonoDomain* domain, MonoClass* klass, MonoError* error); -MonoString* il2cpp_mono_ldstr_checked(Il2CppMonoDomain* domain, MonoImage* image, guint32 idx, MonoError* error); +Il2CppMonoObject* il2cpp_mono_field_get_value_object_checked(MonoDomain* domain, MonoClassField* field, Il2CppMonoObject* obj, MonoError* error); +Il2CppMonoObject* il2cpp_mono_object_new_checked(MonoDomain* domain, MonoClass* klass, MonoError* error); +MonoString* il2cpp_mono_ldstr_checked(MonoDomain* domain, MonoImage* image, guint32 idx, MonoError* error); Il2CppMonoObject* il2cpp_mono_runtime_try_invoke(MonoMethod* method, void* obj, void** params, Il2CppMonoObject** exc, MonoError* error); Il2CppMonoObject* il2cpp_mono_runtime_invoke_checked(MonoMethod* method, void* obj, void** params, MonoError* error); void il2cpp_mono_gc_base_init(); @@ -433,18 +427,18 @@ Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_method_checked(MonoMetho Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_class_checked(MonoClass* klass, MonoError* error); Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_property_checked(MonoClass* klass, MonoProperty* property, MonoError* error); Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_field_checked(MonoClass* klass, MonoClassField* field, MonoError* error); -Il2CppMonoReflectionAssemblyHandle il2cpp_mono_assembly_get_object_handle(Il2CppMonoDomain* domain, MonoAssembly* assembly, MonoError* error); -MonoReflectionType* il2cpp_mono_type_get_object_checked(Il2CppMonoDomain* domain, MonoType* type, MonoError* error); +MonoReflectionAssemblyHandle il2cpp_mono_assembly_get_object_handle(MonoDomain* domain, MonoAssembly* assembly, MonoError* error); +MonoReflectionType* il2cpp_mono_type_get_object_checked(MonoDomain* domain, MonoType* type, MonoError* error); void il2cpp_mono_network_init(); gint il2cpp_mono_w32socket_set_blocking(SOCKET sock, gboolean blocking); char* il2cpp_mono_get_runtime_build_info(); MonoMethod* il2cpp_mono_marshal_method_from_wrapper(MonoMethod* wrapper); MonoDebugOptions* il2cpp_mini_get_debug_options(); -gpointer il2cpp_mono_jit_find_compiled_method_with_jit_info(Il2CppMonoDomain* domain, MonoMethod* method, MonoJitInfo** ji); +gpointer il2cpp_mono_jit_find_compiled_method_with_jit_info(MonoDomain* domain, MonoMethod* method, MonoJitInfo** ji); MonoLMF** il2cpp_mono_get_lmf_addr(); void il2cpp_mono_set_lmf(MonoLMF* lmf); -gpointer il2cpp_mono_aot_get_method_checked(Il2CppMonoDomain* domain, MonoMethod* method, MonoError* error); +gpointer il2cpp_mono_aot_get_method_checked(MonoDomain* domain, MonoMethod* method, MonoError* error); void il2cpp_mono_arch_setup_resume_sighandler_ctx(MonoContext* ctx, gpointer func); void il2cpp_mono_arch_set_breakpoint(MonoJitInfo* ji, guint8* ip); void il2cpp_mono_arch_clear_breakpoint(MonoJitInfo* ji, guint8* ip); @@ -459,29 +453,29 @@ void il2cpp_mono_walk_stack_with_ctx(Il2CppMonoJitStackWalk func, MonoContext* s void il2cpp_mono_walk_stack_with_state(Il2CppMonoJitStackWalk func, MonoThreadUnwindState* state, MonoUnwindOptions unwind_options, void* user_data); gboolean il2cpp_mono_thread_state_init_from_current(MonoThreadUnwindState* ctx); gboolean il2cpp_mono_thread_state_init_from_monoctx(MonoThreadUnwindState* ctx, MonoContext* mctx); -MonoJitInfo* il2cpp_mini_jit_info_table_find(Il2CppMonoDomain* domain, char* addr, Il2CppMonoDomain** out_domain); +MonoJitInfo* il2cpp_mini_jit_info_table_find(MonoDomain* domain, char* addr, MonoDomain** out_domain); void il2cpp_mono_restore_context(MonoContext* ctx); -gboolean il2cpp_mono_find_jit_info_ext(Il2CppMonoDomain* domain, Il2CppMonoJitTlsData* jit_tls, MonoJitInfo* prev_ji, MonoContext* ctx, MonoContext* new_ctx, char** trace, MonoLMF** lmf, mgreg_t** save_locations, StackFrameInfo* frame); +gboolean il2cpp_mono_find_jit_info_ext(MonoDomain* domain, Il2CppMonoJitTlsData* jit_tls, MonoJitInfo* prev_ji, MonoContext* ctx, MonoContext* new_ctx, char** trace, MonoLMF** lmf, mgreg_t** save_locations, StackFrameInfo* frame); MonoMethod* il2cpp_mono_method_get_declaring_generic_method(MonoMethod* method); MonoMethod* il2cpp_jinfo_get_method (MonoJitInfo *ji); -gboolean il2cpp_mono_find_prev_seq_point_for_native_offset (Il2CppMonoDomain *domain, MonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point); +gboolean il2cpp_mono_find_prev_seq_point_for_native_offset (MonoDomain *domain, MonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point); SOCKET il2cpp_mono_w32socket_accept_internal (SOCKET s, struct sockaddr *addr, socklen_t *addrlen, gboolean blocking); -gboolean il2cpp_mono_find_next_seq_point_for_native_offset (Il2CppMonoDomain *domain, MonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point); +gboolean il2cpp_mono_find_next_seq_point_for_native_offset (MonoDomain *domain, MonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point); gboolean il2cpp_mono_class_has_parent (MonoClass *klass, MonoClass *parent); MonoGenericParam* il2cpp_mono_generic_container_get_param (MonoGenericContainer *gc, int i); -gboolean il2cpp_mono_find_seq_point (Il2CppMonoDomain *domain, MonoMethod *method, gint32 il_offset, MonoSeqPointInfo **info, SeqPoint *seq_point); +gboolean il2cpp_mono_find_seq_point (MonoDomain *domain, MonoMethod *method, gint32 il_offset, MonoSeqPointInfo **info, SeqPoint *seq_point); void il2cpp_mono_seq_point_iterator_init (SeqPointIterator* it, MonoSeqPointInfo* info); gboolean il2cpp_mono_seq_point_iterator_next (SeqPointIterator* it); void il2cpp_mono_seq_point_init_next (MonoSeqPointInfo* info, SeqPoint sp, SeqPoint* next); -MonoSeqPointInfo* il2cpp_mono_get_seq_points (Il2CppMonoDomain *domain, MonoMethod *method); +MonoSeqPointInfo* il2cpp_mono_get_seq_points (MonoDomain *domain, MonoMethod *method); void IL2CPP_G_BREAKPOINT(); void il2cpp_mono_thread_info_safe_suspend_and_run (MonoNativeThreadId id, gboolean interrupt_kernel, MonoSuspendThreadCallback callback, gpointer user_data); void il2cpp_mono_error_cleanup (MonoError *oerror); Il2CppMonoException* il2cpp_mono_error_convert_to_exception (MonoError *target_error); const char* il2cpp_mono_error_get_message (MonoError *oerror); void il2cpp_mono_error_assert_ok_pos (MonoError *error, const char* filename, int lineno); -Il2CppSequencePointC* il2cpp_get_sequence_points(void* *iter); -Il2CppSequencePointC* il2cpp_get_method_sequence_points(MonoMethod* method, void* *iter); +Il2CppSequencePoint* il2cpp_get_sequence_points(void* *iter); +Il2CppSequencePoint* il2cpp_get_method_sequence_points(MonoMethod* method, void* *iter); MonoClass* il2cpp_class_get_nested_types_accepts_generic(MonoClass *monoClass, void* *iter); MonoClass* il2cpp_defaults_object_class(); guint8 il2cpp_array_rank(MonoArray *monoArr); @@ -496,7 +490,7 @@ void il2cpp_set_var(guint8* newValue, void *value, MonoType *localVariableTypeMo MonoMethod* il2cpp_get_interface_method(MonoClass* klass, MonoClass* itf, int slot); gboolean il2cpp_field_is_deleted(MonoClassField *field); MonoClass* il2cpp_iterate_loaded_classes(void* *iter); -MonoAssembly* il2cpp_domain_get_assemblies_iter(Il2CppMonoAppDomain *domain, void* *iter); +MonoAssembly* il2cpp_domain_get_assemblies_iter(MonoAppDomain *domain, void* *iter); const char** il2cpp_get_source_files_for_type(MonoClass *klass, int *count); MonoMethod* il2cpp_method_get_generic_definition(Il2CppMonoMethodInflated *imethod); MonoGenericInst* il2cpp_method_get_generic_class_inst(Il2CppMonoMethodInflated *imethod); diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index bb2d072dc4c1..7927ea5bbf6e 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -81,7 +81,7 @@ mono_bool il2cpp_mono_type_is_reference (MonoType *type) return il2cpp::vm::Type::IsReference((Il2CppType*)type); } -void il2cpp_mono_metadata_free_mh (Il2CppMonoMethodHeader *mh) +void il2cpp_mono_metadata_free_mh (MonoMethodHeader *mh) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); } @@ -160,7 +160,7 @@ mono_bool il2cpp_mono_type_generic_inst_is_valuetype (MonoType *monoType) return (typeDef->bitfield >> (kBitIsValueType - 1)) & 0x1; } -Il2CppMonoMethodHeader* il2cpp_mono_method_get_header_checked (MonoMethod *method, MonoError *error) +MonoMethodHeader* il2cpp_mono_method_get_header_checked (MonoMethod *method, MonoError *error) { return NULL; } @@ -171,7 +171,7 @@ gboolean il2cpp_mono_class_init (MonoClass *klass) return 0; } -Il2CppMonoVTable* il2cpp_mono_class_vtable (Il2CppMonoDomain *domain, MonoClass *klass) +Il2CppMonoVTable* il2cpp_mono_class_vtable (MonoDomain *domain, MonoClass *klass) { return (Il2CppMonoVTable*)((Il2CppClass*)klass)->vtable; } @@ -267,13 +267,13 @@ uintptr_t il2cpp_mono_array_length (MonoArray *array) return 0; } -MonoString* il2cpp_mono_string_new (Il2CppMonoDomain *domain, const char *text) +MonoString* il2cpp_mono_string_new (MonoDomain *domain, const char *text) { return (MonoString*)il2cpp::vm::String::New(text); } -MonoString* il2cpp_mono_string_new_checked (Il2CppMonoDomain *domain, const char *text, MonoError *merror) +MonoString* il2cpp_mono_string_new_checked (MonoDomain *domain, const char *text, MonoError *merror) { error_init(merror); return il2cpp_mono_string_new (domain, text); @@ -356,9 +356,9 @@ void il2cpp_mono_custom_attrs_free (Il2CppMonoCustomAttrInfo *ainfo) IL2CPP_ASSERT(0 && "This method is not yet implemented"); } -Il2CppMonoDomain* il2cpp_mono_get_root_domain (void) +MonoDomain* il2cpp_mono_get_root_domain (void) { - return (Il2CppMonoDomain*)il2cpp::vm::Domain::GetCurrent(); + return (MonoDomain*)il2cpp::vm::Domain::GetCurrent(); } void il2cpp_mono_runtime_quit (void) @@ -371,12 +371,12 @@ gboolean il2cpp_mono_runtime_is_shutting_down (void) return il2cpp::vm::Runtime::IsShuttingDown() ? TRUE : FALSE; } -Il2CppMonoDomain* il2cpp_mono_domain_get (void) +MonoDomain* il2cpp_mono_domain_get (void) { return il2cpp_mono_get_root_domain(); } -gboolean il2cpp_mono_domain_set (Il2CppMonoDomain *domain, gboolean force) +gboolean il2cpp_mono_domain_set (MonoDomain *domain, gboolean force) { IL2CPP_ASSERT(domain == il2cpp_mono_get_root_domain()); return TRUE; @@ -387,7 +387,7 @@ void il2cpp_mono_domain_foreach(MonoDomainFunc func, gpointer user_data) func((MonoDomain*)il2cpp_mono_get_root_domain(), user_data); } -MonoJitInfo* il2cpp_mono_jit_info_table_find(Il2CppMonoDomain* domain, char* addr) +MonoJitInfo* il2cpp_mono_jit_info_table_find(MonoDomain* domain, char* addr) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; @@ -404,7 +404,7 @@ MonoDebugMethodInfo* il2cpp_mono_debug_lookup_method(MonoMethod* method) return NULL; } -MonoDebugMethodJitInfo* il2cpp_mono_debug_find_method(MonoMethod* method, Il2CppMonoDomain* domain) +MonoDebugMethodJitInfo* il2cpp_mono_debug_find_method(MonoMethod* method, MonoDomain* domain) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; @@ -433,7 +433,7 @@ MonoDebugSourceLocation* il2cpp_mono_debug_method_lookup_location(MonoDebugMetho return NULL; } -gint32 il2cpp_mono_debug_il_offset_from_address(MonoMethod* method, Il2CppMonoDomain* domain, guint32 native_offset) +gint32 il2cpp_mono_debug_il_offset_from_address(MonoMethod* method, MonoDomain* domain, guint32 native_offset) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; @@ -485,7 +485,7 @@ MonoThread* il2cpp_mono_thread_get_main() return (MonoThread*)il2cpp::vm::Thread::Main(); } -MonoThread* il2cpp_mono_thread_attach(Il2CppMonoDomain* domain) +MonoThread* il2cpp_mono_thread_attach(MonoDomain* domain) { return (MonoThread*)il2cpp::vm::Thread::Attach((Il2CppDomain*)domain); } @@ -495,15 +495,15 @@ void il2cpp_mono_thread_detach(MonoThread* thread) il2cpp::vm::Thread::Detach((Il2CppThread*)thread); } -void il2cpp_mono_domain_lock(Il2CppMonoDomain* domain) +void il2cpp_mono_domain_lock(MonoDomain* domain) { } -void il2cpp_mono_domain_unlock(Il2CppMonoDomain* domain) +void il2cpp_mono_domain_unlock(MonoDomain* domain) { } -MonoJitInfo* il2cpp_mono_jit_info_table_find_internal(Il2CppMonoDomain* domain, char* addr, gboolean try_aot, gboolean allow_trampolines) +MonoJitInfo* il2cpp_mono_jit_info_table_find_internal(MonoDomain* domain, char* addr, gboolean try_aot, gboolean allow_trampolines) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; @@ -860,7 +860,7 @@ void il2cpp_mono_nullable_init(guint8* buf, Il2CppMonoObject* value, MonoClass* il2cpp::vm::Object::NullableInit(buf, (Il2CppObject*)value, (Il2CppClass*)klass); } -Il2CppMonoObject* il2cpp_mono_value_box_checked(Il2CppMonoDomain* domain, MonoClass* klass, gpointer value, MonoError* error) +Il2CppMonoObject* il2cpp_mono_value_box_checked(MonoDomain* domain, MonoClass* klass, gpointer value, MonoError* error) { error_init(error); return (Il2CppMonoObject*)il2cpp::vm::Object::Box((Il2CppClass*)klass, value); @@ -878,19 +878,19 @@ void il2cpp_mono_field_static_get_value_for_thread(MonoInternalThread* thread, I il2cpp::vm::Field::StaticGetValueForThread((FieldInfo*)field, value, (Il2CppInternalThread*)thread); } -Il2CppMonoObject* il2cpp_mono_field_get_value_object_checked(Il2CppMonoDomain* domain, MonoClassField* field, Il2CppMonoObject* obj, MonoError* error) +Il2CppMonoObject* il2cpp_mono_field_get_value_object_checked(MonoDomain* domain, MonoClassField* field, Il2CppMonoObject* obj, MonoError* error) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; } -Il2CppMonoObject* il2cpp_mono_object_new_checked(Il2CppMonoDomain* domain, MonoClass* klass, MonoError* error) +Il2CppMonoObject* il2cpp_mono_object_new_checked(MonoDomain* domain, MonoClass* klass, MonoError* error) { error_init(error); return (Il2CppMonoObject*)il2cpp::vm::Object::New((Il2CppClass*)klass); } -MonoString* il2cpp_mono_ldstr_checked(Il2CppMonoDomain* domain, MonoImage* image, guint32 idx, MonoError* error) +MonoString* il2cpp_mono_ldstr_checked(MonoDomain* domain, MonoImage* image, guint32 idx, MonoError* error) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; @@ -1022,12 +1022,12 @@ Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_field_checked(MonoClass* return NULL; } -Il2CppMonoReflectionAssemblyHandle il2cpp_mono_assembly_get_object_handle(Il2CppMonoDomain* domain, MonoAssembly* assembly, MonoError* error) +MonoReflectionAssemblyHandle il2cpp_mono_assembly_get_object_handle(MonoDomain* domain, MonoAssembly* assembly, MonoError* error) { - return (Il2CppMonoReflectionAssemblyHandle)il2cpp::vm::Reflection::GetAssemblyObject((const Il2CppAssembly *)assembly); + return (MonoReflectionAssemblyHandle)il2cpp::vm::Reflection::GetAssemblyObject((const Il2CppAssembly *)assembly); } -MonoReflectionType* il2cpp_mono_type_get_object_checked(Il2CppMonoDomain* domain, MonoType* type, MonoError* error) +MonoReflectionType* il2cpp_mono_type_get_object_checked(MonoDomain* domain, MonoType* type, MonoError* error) { error_init(error); return (MonoReflectionType*)il2cpp::vm::Reflection::GetTypeObject((const Il2CppType*)type); @@ -1060,7 +1060,7 @@ MonoDebugOptions* il2cpp_mini_get_debug_options() return NULL; } -gpointer il2cpp_mono_jit_find_compiled_method_with_jit_info(Il2CppMonoDomain* domain, MonoMethod* method, MonoJitInfo** ji) +gpointer il2cpp_mono_jit_find_compiled_method_with_jit_info(MonoDomain* domain, MonoMethod* method, MonoJitInfo** ji) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; @@ -1077,7 +1077,7 @@ void il2cpp_mono_set_lmf(MonoLMF* lmf) IL2CPP_ASSERT(0 && "This method is not yet implemented"); } -gpointer il2cpp_mono_aot_get_method_checked(Il2CppMonoDomain* domain, MonoMethod* method, MonoError* error) +gpointer il2cpp_mono_aot_get_method_checked(MonoDomain* domain, MonoMethod* method, MonoError* error) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; @@ -1156,7 +1156,7 @@ gboolean il2cpp_mono_thread_state_init_from_monoctx(MonoThreadUnwindState* ctx, return 0; } -MonoJitInfo* il2cpp_mini_jit_info_table_find(Il2CppMonoDomain* domain, char* addr, Il2CppMonoDomain** out_domain) +MonoJitInfo* il2cpp_mini_jit_info_table_find(MonoDomain* domain, char* addr, MonoDomain** out_domain) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; @@ -1167,7 +1167,7 @@ void il2cpp_mono_restore_context(MonoContext* ctx) IL2CPP_ASSERT(0 && "This method is not yet implemented"); } -gboolean il2cpp_mono_find_jit_info_ext(Il2CppMonoDomain* domain, MonoJitTlsData* jit_tls, MonoJitInfo* prev_ji, MonoContext* ctx, MonoContext* new_ctx, char** trace, MonoLMF** lmf, mgreg_t** save_locations, StackFrameInfo* frame) +gboolean il2cpp_mono_find_jit_info_ext(MonoDomain* domain, MonoJitTlsData* jit_tls, MonoJitInfo* prev_ji, MonoContext* ctx, MonoContext* new_ctx, char** trace, MonoLMF** lmf, mgreg_t** save_locations, StackFrameInfo* frame) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; @@ -1191,7 +1191,7 @@ MonoMethod* il2cpp_jinfo_get_method (MonoJitInfo *ji) return NULL; } -gboolean il2cpp_mono_find_prev_seq_point_for_native_offset (Il2CppMonoDomain *domain, MonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point) +gboolean il2cpp_mono_find_prev_seq_point_for_native_offset (MonoDomain *domain, MonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; @@ -1212,7 +1212,7 @@ void* il2cpp_mono_w32socket_accept_internal (void* s, struct sockaddr *addr, voi return 0; } -gboolean il2cpp_mono_find_next_seq_point_for_native_offset (Il2CppMonoDomain *domain, MonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point) +gboolean il2cpp_mono_find_next_seq_point_for_native_offset (MonoDomain *domain, MonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; @@ -1229,7 +1229,7 @@ MonoGenericParam* il2cpp_mono_generic_container_get_param (MonoGenericContainer return (MonoGenericParam*)il2cpp::vm::GenericContainer::GetGenericParameter((Il2CppGenericContainer*)gc, i); } -gboolean il2cpp_mono_find_seq_point (Il2CppMonoDomain *domain, MonoMethod *method, gint32 il_offset, MonoSeqPointInfo **info, SeqPoint *seq_point) +gboolean il2cpp_mono_find_seq_point (MonoDomain *domain, MonoMethod *method, gint32 il_offset, MonoSeqPointInfo **info, SeqPoint *seq_point) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; @@ -1251,7 +1251,7 @@ void il2cpp_mono_seq_point_init_next (MonoSeqPointInfo* info, SeqPoint sp, SeqPo IL2CPP_ASSERT(0 && "This method is not yet implemented"); } -MonoSeqPointInfo* il2cpp_mono_get_seq_points (Il2CppMonoDomain *domain, MonoMethod *method) +MonoSeqPointInfo* il2cpp_mono_get_seq_points (MonoDomain *domain, MonoMethod *method) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; @@ -1300,17 +1300,17 @@ void* il2cpp_mono_gc_invoke_with_gc_lock (Il2CppMonoGCLockedCallbackFunc func, v // These functions expose the IL2CPP VM C++ API to C -void* il2cpp_domain_get_agent_info(Il2CppMonoAppDomain* domain) +void* il2cpp_domain_get_agent_info(MonoAppDomain* domain) { return ((Il2CppDomain*)domain)->agent_info; } -void il2cpp_domain_set_agent_info(Il2CppMonoAppDomain* domain, void* agentInfo) +void il2cpp_domain_set_agent_info(MonoAppDomain* domain, void* agentInfo) { ((Il2CppDomain*)domain)->agent_info = agentInfo; } -MonoAssembly* il2cpp_domain_get_assemblies_iter(Il2CppMonoAppDomain *domain, void* *iter) +MonoAssembly* il2cpp_domain_get_assemblies_iter(MonoAppDomain *domain, void* *iter) { if (!iter) return NULL; @@ -1355,22 +1355,22 @@ void il2cpp_gc_free_fixed(void* address) il2cpp::gc::GarbageCollector::FreeFixed(address); } -const char* il2cpp_domain_get_name(Il2CppMonoDomain* domain) +const char* il2cpp_domain_get_name(MonoDomain* domain) { return ((Il2CppDomain*)domain)->friendly_name; } -Il2CppSequencePointC* il2cpp_get_sequence_points(void* *iter) +Il2CppSequencePoint* il2cpp_get_sequence_points(void* *iter) { - return (Il2CppSequencePointC*)il2cpp::utils::Debugger::GetSequencePoints(iter); + return (Il2CppSequencePoint*)il2cpp::utils::Debugger::GetSequencePoints(iter); } -Il2CppSequencePointC* il2cpp_get_method_sequence_points(MonoMethod* method, void* *iter) +Il2CppSequencePoint* il2cpp_get_method_sequence_points(MonoMethod* method, void* *iter) { if (!method) - return (Il2CppSequencePointC*)il2cpp::utils::Debugger::GetSequencePoints(iter); + return (Il2CppSequencePoint*)il2cpp::utils::Debugger::GetSequencePoints(iter); else - return (Il2CppSequencePointC*)il2cpp::utils::Debugger::GetSequencePoints((const MethodInfo*)method, iter); + return (Il2CppSequencePoint*)il2cpp::utils::Debugger::GetSequencePoints((const MethodInfo*)method, iter); } gboolean il2cpp_mono_methods_match(MonoMethod* left, MonoMethod* right) From e1d8189f1d0fa3d0d3726817b403cdceca581fea Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 12 Dec 2017 13:39:32 -0500 Subject: [PATCH 020/582] Implementing step-to-catch for il2cpp debugger --- mono/mini/debugger-agent.c | 151 ++++++++++++++++++++++++++++++------- 1 file changed, 125 insertions(+), 26 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 203a5f10b72b..1abae4ffb625 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -248,6 +248,9 @@ typedef struct { InvokeData *invoke; StackFrameInfo catch_frame; +#ifdef IL2CPP_MONO_DEBUGGER + MonoException *exception; +#endif gboolean has_catch_frame; /* @@ -806,7 +809,8 @@ static void suspend_init (void); static void ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint *sp, MonoSeqPointInfo *info, MonoContext *ctx, DebuggerTlsData *tls, gboolean step_to_catch, StackFrame **frames, int nframes); #ifdef IL2CPP_MONO_DEBUGGER -static void ss_start_il2cpp(SingleStepReq *ss_req, DebuggerTlsData *tls); +static Il2CppSequencePoint* il2cpp_find_catch_sequence_point(DebuggerTlsData *tls); +static void ss_start_il2cpp(SingleStepReq *ss_req, DebuggerTlsData *tls, Il2CppSequencePoint *catchFrameSp); static void GetSequencePointsAndSourceFilesUniqueSequencePoints(MonoMethod* method, GPtrArray** sequencePoints, GPtrArray** uniqueFileSequencePoints, GArray** uniqueFileSequencePointIndices); #endif static ErrorCode ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilter filter, EventRequest *req); @@ -4100,6 +4104,7 @@ thread_startup (MonoProfiler *prof, uintptr_t tid) } #ifdef IL2CPP_MONO_DEBUGGER tls = il2cpp_gc_alloc_fixed(sizeof(DebuggerTlsData)); + tls->exception = NULL; #else tls = g_new0 (DebuggerTlsData, 1); MONO_GC_REGISTER_ROOT_SINGLE (tls->thread, MONO_ROOT_SOURCE_DEBUGGER, "debugger thread reference"); @@ -6339,7 +6344,7 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI #ifdef IL2CPP_MONO_DEBUGGER static void -ss_start_il2cpp(SingleStepReq *ss_req, DebuggerTlsData *tls) +ss_start_il2cpp(SingleStepReq *ss_req, DebuggerTlsData *tls, Il2CppSequencePoint *catchFrameSp) { // When 8 or more entries are in bps, we build a hash table to serve as a set of breakpoints. // Recreating this on each pass is a little wasteful but at least keeps behavior linear. @@ -6352,39 +6357,42 @@ ss_start_il2cpp(SingleStepReq *ss_req, DebuggerTlsData *tls) DEBUG_PRINTF(0, "Step depth: %d\n", ss_req->depth); - if (ss_req->depth == STEP_DEPTH_OVER) - { - MonoMethod* currentMethod = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]->method; - - void *seqPointIter = NULL; - Il2CppSequencePoint *seqPoint; - while(seqPoint = il2cpp_get_method_sequence_points(currentMethod, &seqPointIter)) + if (catchFrameSp) { + ss_bp_add_one_il2cpp (ss_req, &ss_req_bp_count, &ss_req_bp_cache, catchFrameSp); + } else { + if (ss_req->depth == STEP_DEPTH_OVER) { + MonoMethod* currentMethod = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]->method; + + void *seqPointIter = NULL; + Il2CppSequencePoint *seqPoint; + while(seqPoint = il2cpp_get_method_sequence_points(currentMethod, &seqPointIter)) + { if (seqPoint->kind != kSequencePointKind_Normal) - continue; + continue; - if (il2cpp_mono_methods_match(seqPoint->method, currentMethod)) - ss_bp_add_one_il2cpp(ss_req, &ss_req_bp_count, &ss_req_bp_cache, seqPoint); + if (il2cpp_mono_methods_match(seqPoint->method, currentMethod)) + ss_bp_add_one_il2cpp(ss_req, &ss_req_bp_count, &ss_req_bp_cache, seqPoint); + } } - } - if (tls->il2cpp_context.frameCount > 1) - { + if (tls->il2cpp_context.frameCount > 1) + { Il2CppSequencePoint* sequencePointForStepOut = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 2]; g_assert(sequencePointForStepOut->kind == kSequencePointKind_StepOut); - ss_bp_add_one_il2cpp(ss_req, &ss_req_bp_count, &ss_req_bp_cache, sequencePointForStepOut); + ss_bp_add_one_il2cpp(ss_req, &ss_req_bp_count, &ss_req_bp_cache, sequencePointForStepOut); + } + + if (ss_req->depth == STEP_DEPTH_INTO) + { + /* Enable global stepping so we stop at method entry too */ + enable_global = TRUE; + } } if (ss_req_bp_cache) g_hash_table_destroy(ss_req_bp_cache); - - if (ss_req->depth == STEP_DEPTH_INTO) - { - /* Enable global stepping so we stop at method entry too */ - enable_global = TRUE; - } - if (enable_global) { DEBUG_PRINTF(1, "[dbg] Turning on global single stepping.\n"); @@ -6460,6 +6468,7 @@ ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilte #ifdef IL2CPP_MONO_DEBUGGER ss_req->nframes = tls->il2cpp_context.frameCount; + Il2CppSequencePoint *catchFrameSp = NULL; if (tls->il2cpp_context.frameCount > 0) { @@ -6467,9 +6476,12 @@ ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilte ss_req->start_method = seq_point->method; ss_req->last_method = seq_point->method; ss_req->last_line = seq_point->lineEnd; + + if (tls->exception) + catchFrameSp = il2cpp_find_catch_sequence_point(tls); } - ss_start_il2cpp(ss_req, tls); + ss_start_il2cpp(ss_req, tls, catchFrameSp); #else if (!tls->context.valid) { DEBUG_PRINTF (1, "Received a single step request on a thread with no managed frames."); @@ -6670,6 +6682,63 @@ mono_debugger_agent_unhandled_exception (MonoException *exc) #endif #ifdef IL2CPP_MONO_DEBUGGER + +static Il2CppSequencePoint* il2cpp_find_catch_sequence_point_in_method(Il2CppSequencePoint* callSp, MonoException *exc) +{ + uint8_t tryDepth = callSp->tryDepth; + MonoMethod *method = callSp->method; + int32_t ilOffset = callSp->ilOffset; + Il2CppSequencePoint *sp; + + void *seqPointIter = NULL; + while (sp = il2cpp_get_method_sequence_points(method, &seqPointIter)) + { + if (sp->tryDepth == tryDepth && sp->ilOffset > ilOffset && sp->catchType != NULL && mono_class_is_assignable_from(sp->catchType, VM_OBJECT_GET_CLASS(exc))) + return sp; + } + + return NULL; +} + +static Il2CppSequencePoint* il2cpp_find_catch_sequence_point(DebuggerTlsData *tls) +{ + int frameIndex = tls->il2cpp_context.frameCount - 1; + while (frameIndex >= 0) + { + Il2CppSequencePoint* sp = il2cpp_find_catch_sequence_point_in_method(tls->il2cpp_context.sequencePoints[frameIndex], tls->exception); + if (sp) + return sp; + + --frameIndex; + } + + return NULL; +} + +static Il2CppSequencePoint* il2cpp_find_catch_sequence_point_from_exeption(DebuggerTlsData *tls, MonoException *exc, Il2CppSequencePoint *firstSp) +{ + Il2CppSequencePoint* sp; + + if (firstSp) + { + sp = il2cpp_find_catch_sequence_point_in_method(firstSp, exc); + if (sp) + return sp; + } + + int frameIndex = tls->il2cpp_context.frameCount - 1; + while (frameIndex >= 0) + { + sp = il2cpp_find_catch_sequence_point_in_method(tls->il2cpp_context.sequencePoints[frameIndex], exc); + if (sp) + return sp; + + --frameIndex; + } + + return NULL; +} + void unity_debugger_agent_handle_exception(MonoException *exc, Il2CppSequencePoint *sequencePoint) { @@ -6695,7 +6764,15 @@ unity_debugger_agent_handle_exception(MonoException *exc, Il2CppSequencePoint *s memset(&ei, 0, sizeof(DebuggerEventInfo)); ei.exc = (MonoObject*)exc; - ei.caught = TRUE; + ei.caught = FALSE; + Il2CppSequencePoint *catchSp = NULL; + + if (tls) + { + catchSp = il2cpp_find_catch_sequence_point_from_exeption(tls, exc, sequencePoint); + if (catchSp) + ei.caught = TRUE; + } mono_loader_lock(); @@ -6731,7 +6808,25 @@ unity_debugger_agent_handle_exception(MonoException *exc, Il2CppSequencePoint *s events = create_event_list(EVENT_KIND_EXCEPTION, NULL, NULL, &ei, &suspend_policy); mono_loader_unlock(); + if (tls && ei.caught) + { + if (!ss_req || !ss_req->bps) { + tls->exception = exc; + } else if (ss_req->bps && catchSp) { + int ss_req_bp_count = g_slist_length(ss_req->bps); + GHashTable *ss_req_bp_cache = NULL; + + ss_bp_add_one_il2cpp(ss_req, &ss_req_bp_count, &ss_req_bp_cache, catchSp); + + if (ss_req_bp_cache) + g_hash_table_destroy(ss_req_bp_cache); + } + } + process_event(EVENT_KIND_EXCEPTION, &ei, 0, NULL, events, suspend_policy, sequencePoint ? sequencePoint->id : 0); + + if (tls) + tls->exception = NULL; } #endif @@ -11977,7 +12072,11 @@ unity_process_breakpoint_inner(DebuggerTlsData *tls, gboolean from_signal, Il2Cp if (hit) { g_ptr_array_add(ss_reqs, req); - ss_start_il2cpp(ss_req, tls); + Il2CppSequencePoint *catchFrameSp = NULL; + if (tls->exception) + catchFrameSp = il2cpp_find_catch_sequence_point(tls); + + ss_start_il2cpp(ss_req, tls, catchFrameSp); } } From 9655708ab7ed8907ad463c2e7bcf99ddd0b6100e Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 12 Dec 2017 13:53:52 -0500 Subject: [PATCH 021/582] Not setting tls->exception pointer to zero because gc alloc will do this. --- mono/mini/debugger-agent.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 1abae4ffb625..08860fc7541b 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -4104,7 +4104,6 @@ thread_startup (MonoProfiler *prof, uintptr_t tid) } #ifdef IL2CPP_MONO_DEBUGGER tls = il2cpp_gc_alloc_fixed(sizeof(DebuggerTlsData)); - tls->exception = NULL; #else tls = g_new0 (DebuggerTlsData, 1); MONO_GC_REGISTER_ROOT_SINGLE (tls->thread, MONO_ROOT_SOURCE_DEBUGGER, "debugger thread reference"); From a682954ea7c13c7dcfa5275488347add6c25a81f Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Thu, 14 Dec 2017 11:27:14 -0500 Subject: [PATCH 022/582] Avoid using BSTR for conversion of a SecureString There is no need to use BSTR marshaling to convert a SecureString to a string. On some platforms, BSTR marshaling is not implemented, but we still want to be able to convert a SecureString to a string on those platforms. So instead, use Unicode string marshaling. --- .../System/ReferenceSources/SecureStringHelper.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mcs/class/System/ReferenceSources/SecureStringHelper.cs b/mcs/class/System/ReferenceSources/SecureStringHelper.cs index 31372e2cc6cc..de5ac5809fa1 100644 --- a/mcs/class/System/ReferenceSources/SecureStringHelper.cs +++ b/mcs/class/System/ReferenceSources/SecureStringHelper.cs @@ -14,7 +14,18 @@ internal static string CreateString(SecureString secureString) if (secureString == null || secureString.Length == 0) return String.Empty; - +#if MONO + try + { + bstr = Marshal.SecureStringToGlobalAllocUnicode(secureString); + plainString = Marshal.PtrToStringUni(bstr); + } + finally + { + if (bstr != IntPtr.Zero) + Marshal.ZeroFreeGlobalAllocUnicode(bstr); + } +#else try { bstr = Marshal.SecureStringToBSTR(secureString); @@ -25,6 +36,7 @@ internal static string CreateString(SecureString secureString) if (bstr != IntPtr.Zero) Marshal.ZeroFreeBSTR(bstr); } +#endif return plainString; } From d773c76817f8bdb0590adb0bf3523be0ffa3af06 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Tue, 12 Dec 2017 18:28:02 +0100 Subject: [PATCH 023/582] [unitytls] Added UnityTLS interface defintion --- mcs/class/System/Mono.UnityTLS/UnityTLS.cs | 276 ++++++++++++++ .../Mono.UnityTLS/UnityTLSCiphersuites.cs | 350 ++++++++++++++++++ mcs/class/System/common.sources | 3 + 3 files changed, 629 insertions(+) create mode 100644 mcs/class/System/Mono.UnityTLS/UnityTLS.cs create mode 100644 mcs/class/System/Mono.UnityTLS/UnityTLSCiphersuites.cs diff --git a/mcs/class/System/Mono.UnityTLS/UnityTLS.cs b/mcs/class/System/Mono.UnityTLS/UnityTLS.cs new file mode 100644 index 000000000000..45196c0731e0 --- /dev/null +++ b/mcs/class/System/Mono.UnityTLS/UnityTLS.cs @@ -0,0 +1,276 @@ +using System; +using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; + +namespace Mono.UnityTLS +{ + using size_t = UIntPtr; + using UInt8 = Byte; + + unsafe internal static partial class UnityTLS + { + private const string DLLNAME = "MacStandalonePlayer_TLSModule_Dynamic.dylib"; + private const CallingConvention CALLCONV = CallingConvention.Cdecl; + + // TODO + //extern const UInt64 UNITYTLS_INVALID_HANDLE; + + // ------------------------------------ + // Error Handling + // ------------------------------------ + public enum unitytls_error_code : UInt32 + { + UNITYTLS_SUCCESS = 0, + UNITYTLS_INVALID_ARGUMENT, // One of the arguments has an invalid value (e.g. null where not allowed) + UNITYTLS_INVALID_FORMAT, // The passed data does not have a valid format. + UNITYTLS_INVALID_STATE, // The object operating being operated on is not in a state that allows this function call. + UNITYTLS_BUFFER_OVERFLOW, // A passed buffer was not large enough. + UNITYTLS_OUT_OF_MEMORY, // Out of memory error + UNITYTLS_INTERNAL_ERROR, // public implementation error. + UNITYTLS_NOT_SUPPORTED, // The requested action is not supported on the current platform/implementation. + UNITYTLS_ENTROPY_SOURCE_FAILED, // Failed to generate requested amount of entropy data. + + UNITYTLS_USER_WOULD_BLOCK, // Can be set by the user to signal that a call (e.g. read/write callback) would block and needs to be called again. + // Some implementations may set this if not all bytes have been read/written. + UNITYTLS_USER_STREAM_CLOSED, // Can be set by the user to cancel a read/write operation. + UNITYTLS_USER_READ_FAILED, // Can be set by the user to indicate a failed read operation. + UNITYTLS_USER_WRITE_FAILED, // Can be set by the user to indicate a failed write operation. + UNITYTLS_USER_UNKNOWN_ERROR, // Can be set by the user to indicate a generic error. + } + + [StructLayout (LayoutKind.Sequential)] + public struct unitytls_errorstate + { + UInt32 magic; + unitytls_error_code code; + UInt64 reserved; // Implementation specific error code/handle. + } + + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_errorstate unitytls_errorstate_create(); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static void unitytls_errorstate_raise_error(unitytls_errorstate* errorState, unitytls_error_code errorCode); + + + public struct unitytls_pubkey {} + [StructLayout (LayoutKind.Sequential)] + public struct unitytls_pubkey_ref { UInt64 handle; } + + // ------------------------------------ + // public Key + // ------------------------------------ + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_pubkey_ref unitytls_pubkey_get_ref(unitytls_pubkey* key, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_pubkey* unitytls_pubkey_parse_der(UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_pubkey* unitytls_pubkey_parse_pem(char* buffer, size_t bufferLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static size_t unitytls_pubkey_export_der(unitytls_pubkey_ref key, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static size_t unitytls_pubkey_export_pem(unitytls_pubkey_ref key, char* buffer, size_t bufferLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static void unitytls_pubkey_free(unitytls_pubkey* key); + + // ------------------------------------ + // Private Key + // ------------------------------------ + public enum unitytls_key_type : UInt32 + { + UNITYTLS_KEY_TYPE_INVALID, + UNITYTLS_KEY_TYPE_RSA, + // UNITYTLS_KEY_TYPE_EC, // Not supported yet. + } + + public struct unitytls_key {} + [StructLayout (LayoutKind.Sequential)] + public struct unitytls_key_ref { UInt64 handle; } + + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_key_ref unitytls_key_get_ref(unitytls_key* key, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_key* unitytls_key_parse_der(UInt8* buffer, size_t bufferLen, UInt8* password, size_t passwordLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_key* unitytls_key_parse_pem(char* buffer, size_t bufferLen, UInt8* password, size_t passwordLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static size_t unitytls_key_export_der(unitytls_key_ref key, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static size_t unitytls_key_export_pem(unitytls_key_ref key, char* buffer, size_t bufferLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_pubkey_ref unitytls_key_get_pubkey(unitytls_key_ref key, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_key_type unitytls_key_get_type(unitytls_key_ref key, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static void unitytls_key_free(unitytls_key* key); + + // ------------------------------------ + // X.509 Certificate + // ----------------------------------- + public struct unitytls_x509 {} + [StructLayout (LayoutKind.Sequential)] + public struct unitytls_x509_ref { UInt64 handle; } + + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_x509_ref unitytls_x509_get_ref(unitytls_x509* cert, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_x509* unitytls_x509_parse_der(UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_x509* unitytls_x509_parse_pem(char* buffer, size_t bufferLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static size_t unitytls_x509_export_der(unitytls_x509_ref cert, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static size_t unitytls_x509_export_pem(unitytls_x509_ref cert, char* buffer, size_t bufferLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_pubkey_ref unitytls_x509_get_pubkey(unitytls_x509_ref cert, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static void unitytls_x509_free(unitytls_x509* cert); + + // ------------------------------------ + // X.509 Certificate List + // ------------------------------------ + public struct unitytls_x509list {} + [StructLayout (LayoutKind.Sequential)] + public struct unitytls_x509list_ref { UInt64 handle; } + + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_x509list_ref unitytls_x509list_get_ref(unitytls_x509list* list, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_x509list* unitytls_x509list_parse_pem(char* buffer, size_t bufferLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static size_t unitytls_x509list_export_pem(unitytls_x509list_ref list, char* buffer, size_t bufferLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static size_t unitytls_x509list_get_size(unitytls_x509list_ref list, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_x509_ref unitytls_x509list_get_x509(unitytls_x509list_ref list, size_t index, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_x509list* unitytls_x509list_create(unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static void unitytls_x509list_append(unitytls_x509list* list, unitytls_x509_ref cert, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static void unitytls_x509list_append_der(unitytls_x509list* list, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static size_t unitytls_x509list_append_pem(unitytls_x509list* list, char* buffer, size_t bufferLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static void unitytls_x509list_free(unitytls_x509list* list); + + // ------------------------------------ + // X.509 Certificate Verification + // ------------------------------------ + public enum unitytls_x509verify_result : UInt32 + { + UNITYTLS_X509VERIFY_SUCCESS = 0x00000000, + UNITYTLS_X509VERIFY_NOT_DONE = 0x80000000, + UNITYTLS_X509VERIFY_FATAL_ERROR = 0xFFFFFFFF, + + UNITYTLS_X509VERIFY_FLAG_EXPIRED = 0x00000001, + UNITYTLS_X509VERIFY_FLAG_REVOKED = 0x00000002, // requires CRL backend + UNITYTLS_X509VERIFY_FLAG_CN_MISMATCH = 0x00000004, + UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED = 0x00000008, + + UNITYTLS_X509VERIFY_FLAG_USER_ERROR1 = 0x00010000, + UNITYTLS_X509VERIFY_FLAG_USER_ERROR2 = 0x00020000, + UNITYTLS_X509VERIFY_FLAG_USER_ERROR3 = 0x00040000, + UNITYTLS_X509VERIFY_FLAG_USER_ERROR4 = 0x00080000, + UNITYTLS_X509VERIFY_FLAG_USER_ERROR5 = 0x00100000, + UNITYTLS_X509VERIFY_FLAG_USER_ERROR6 = 0x00200000, + UNITYTLS_X509VERIFY_FLAG_USER_ERROR7 = 0x00400000, + UNITYTLS_X509VERIFY_FLAG_USER_ERROR8 = 0x00800000, + + UNITYTLS_X509VERIFY_FLAG_UNKNOWN_ERROR = 0x08000000, + } + + public delegate unitytls_x509verify_result unitytls_x509verify_callback(void* userData, unitytls_x509_ref cert, unitytls_x509verify_result result, unitytls_errorstate* errorState); + + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_x509verify_result unitytls_x509verify_default_ca(unitytls_x509list_ref chain, char* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_x509verify_result unitytls_x509verify_explicit_ca(unitytls_x509list_ref chain, unitytls_x509list_ref trustCA, char* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); + + + // ------------------------------------ + // TLS Context + // ------------------------------------ + public struct unitytls_tlsctx {} + [StructLayout (LayoutKind.Sequential)] + public struct unitytls_tlsctx_ref { UInt64 handle; } + + public enum unitytls_protocol : UInt32 + { + UNITYTLS_PROTOCOL_TLS_1_0, + UNITYTLS_PROTOCOL_TLS_1_1, + UNITYTLS_PROTOCOL_TLS_1_2, + + UNITYTLS_PROTOCOL_INVALID, + } + [StructLayout (LayoutKind.Sequential)] + public struct unitytls_tlsctx_protocolrange + { + unitytls_protocol min; + unitytls_protocol max; + }; + // TODO + //[DllImport (DLLNAME, CallingConvention=CALLCONV)] + //extern public static unitytls_tlsctx_protocolrange UNITYTLS_TLSCTX_PROTOCOLRANGE_DEFAULT; + + public enum unitytls_tlsctx_handshakestate : UInt32 + { + UNITYTLS_HANDSHAKESTATE_BEGIN, // Called right before a handshake is performed. + UNITYTLS_HANDSHAKESTATE_DONE, // Called after a handshake was successfully performed. + + UNITYTLS_HANDSHAKESTATE_PEER_X509_CERT_VERIFY, // Server certificate needs to be verified. Set error state if verification failed. + UNITYTLS_HANDSHAKESTATE_PEER_X509_CERT_REQUEST, // A certificate is requested. + } + + public delegate size_t unitytls_tlsctx_callback_write(void* userData, UInt8* data, size_t bufferLen, unitytls_errorstate* errorState); + public delegate size_t unitytls_tlsctx_callback_read(void* userData, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + public delegate void unitytls_tlsctx_callback_handshake(void* userData, unitytls_tlsctx* ctx, unitytls_tlsctx_handshakestate currentState, unitytls_errorstate* errorState); + public delegate unitytls_x509verify_result unitytls_tlsctx_x509verify_callback(void* userData, unitytls_x509list_ref chain, unitytls_errorstate* errorState); + + [StructLayout (LayoutKind.Sequential)] + public struct unitytls_tlsctx_callbacks + { + unitytls_tlsctx_callback_read read; + unitytls_tlsctx_callback_write write; + void* data; + }; + + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_tlsctx* unitytls_tlsctx_create_server(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, unitytls_x509list_ref certChain, unitytls_key_ref leafCertificateKey, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_tlsctx* unitytls_tlsctx_create_client(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, char* cn, size_t cnLen, unitytls_errorstate* errorState); + + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static void unitytls_tlsctx_set_x509verify_callback(unitytls_tlsctx* ctx, unitytls_tlsctx_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static void unitytls_tlsctx_set_handshake_callback(unitytls_tlsctx* ctx, unitytls_tlsctx_callback_handshake cb, void* userData, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static void unitytls_tlsctx_set_supported_ciphersuites(unitytls_tlsctx* ctx, unitytls_ciphersuite* supportedCiphersuites, size_t supportedCiphersuitesLen, unitytls_errorstate* errorState); + + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_ciphersuite unitytls_tlsctx_get_ciphersuite(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_protocol unitytls_tlsctx_get_protocol(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_x509list_ref unitytls_tlsctx_get_peer_x509list(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_x509verify_result unitytls_tlsctx_get_verify_result(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); + + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static unitytls_x509verify_result unitytls_tlsctx_process_handshake(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static size_t unitytls_tlsctx_read(unitytls_tlsctx* ctx, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static size_t unitytls_tlsctx_write(unitytls_tlsctx* ctx, UInt8* data, size_t bufferLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static void unitytls_tlsctx_free(unitytls_tlsctx* ctx); + + + // ------------------------------------ + // Encoding / Decoding + // ------------------------------------ + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static size_t unitytls_base64_encode(char* outputBuffer, size_t outputBufferLen, UInt8* inputBuffer, size_t inputBufferLen, size_t lineMaxLength, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static size_t unitytls_base64_decode(UInt8* outputBuffer, size_t outputBufferLen, char* inputBuffer, size_t inputBufferLen, unitytls_errorstate* errorState); + } +} \ No newline at end of file diff --git a/mcs/class/System/Mono.UnityTLS/UnityTLSCiphersuites.cs b/mcs/class/System/Mono.UnityTLS/UnityTLSCiphersuites.cs new file mode 100644 index 000000000000..be22c0b84064 --- /dev/null +++ b/mcs/class/System/Mono.UnityTLS/UnityTLSCiphersuites.cs @@ -0,0 +1,350 @@ +using System; + +namespace Mono.UnityTLS +{ + unsafe internal static partial class UnityTLS + { + public enum unitytls_ciphersuite : UInt32 + { + UNITYTLS_CIPHERSUITE_TLS_NULL_WITH_NULL_NULL = 0x00, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_NULL_MD5 = 0x01, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_NULL_SHA = 0x02, + UNITYTLS_CIPHERSUITE_TLS_RSA_EXPORT_WITH_RC4_40_MD5 = 0x03, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_RC4_128_MD5 = 0x04, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_RC4_128_SHA = 0x05, + UNITYTLS_CIPHERSUITE_TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 = 0x06, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_IDEA_CBC_SHA = 0x07, + UNITYTLS_CIPHERSUITE_TLS_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x08, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_DES_CBC_SHA = 0x09, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_3DES_EDE_CBC_SHA = 0x0a, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA = 0x0b, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_DES_CBC_SHA = 0x0c, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA = 0x0d, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x0e, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_DES_CBC_SHA = 0x0f, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA = 0x10, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA = 0x11, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_DES_CBC_SHA = 0x12, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA = 0x13, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x14, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_DES_CBC_SHA = 0x15, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA = 0x16, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 = 0x17, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_RC4_128_MD5 = 0x18, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA = 0x19, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_DES_CBC_SHA = 0x1a, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_3DES_EDE_CBC_SHA = 0x1b, + UNITYTLS_CIPHERSUITE_SSL_FORTEZZA_KEA_WITH_NULL_SHA = 0x1c, + UNITYTLS_CIPHERSUITE_SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA = 0x1d, + //UNITYTLS_CIPHERSUITE_SSL_FORTEZZA_KEA_WITH_RC4_128_SHA = 0x1e, + UNITYTLS_CIPHERSUITE_TLS_KRB5_WITH_DES_CBC_SHA = 0x1e, + UNITYTLS_CIPHERSUITE_TLS_KRB5_WITH_3DES_EDE_CBC_SHA = 0x1f, + UNITYTLS_CIPHERSUITE_TLS_KRB5_WITH_RC4_128_SHA = 0x20, + UNITYTLS_CIPHERSUITE_TLS_KRB5_WITH_IDEA_CBC_SHA = 0x21, + UNITYTLS_CIPHERSUITE_TLS_KRB5_WITH_DES_CBC_MD5 = 0x22, + UNITYTLS_CIPHERSUITE_TLS_KRB5_WITH_3DES_EDE_CBC_MD5 = 0x23, + UNITYTLS_CIPHERSUITE_TLS_KRB5_WITH_RC4_128_MD5 = 0x24, + UNITYTLS_CIPHERSUITE_TLS_KRB5_WITH_IDEA_CBC_MD5 = 0x25, + UNITYTLS_CIPHERSUITE_TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA = 0x26, + UNITYTLS_CIPHERSUITE_TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA = 0x27, + UNITYTLS_CIPHERSUITE_TLS_KRB5_EXPORT_WITH_RC4_40_SHA = 0x28, + UNITYTLS_CIPHERSUITE_TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5 = 0x29, + UNITYTLS_CIPHERSUITE_TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5 = 0x2a, + UNITYTLS_CIPHERSUITE_TLS_KRB5_EXPORT_WITH_RC4_40_MD5 = 0x2b, + UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_NULL_SHA = 0x2c, + UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_NULL_SHA = 0x2d, + UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_NULL_SHA = 0x2e, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_128_CBC_SHA = 0x2f, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_AES_128_CBC_SHA = 0x30, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_AES_128_CBC_SHA = 0x31, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_AES_128_CBC_SHA = 0x32, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_128_CBC_SHA = 0x33, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_AES_128_CBC_SHA = 0x34, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_256_CBC_SHA = 0x35, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_AES_256_CBC_SHA = 0x36, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_AES_256_CBC_SHA = 0x37, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_AES_256_CBC_SHA = 0x38, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_256_CBC_SHA = 0x39, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_AES_256_CBC_SHA = 0x3a, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_NULL_SHA256 = 0x3b, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_128_CBC_SHA256 = 0x3c, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_256_CBC_SHA256 = 0x3d, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_AES_128_CBC_SHA256 = 0x3e, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_AES_128_CBC_SHA256 = 0x3f, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 = 0x40, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA = 0x41, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA = 0x42, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA = 0x43, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA = 0x44, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA = 0x45, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA = 0x46, + + UNITYTLS_CIPHERSUITE_TLS_RSA_EXPORT1024_WITH_RC4_56_MD5 = 0x60, + UNITYTLS_CIPHERSUITE_TLS_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 = 0x61, + UNITYTLS_CIPHERSUITE_TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA = 0x62, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA = 0x63, + UNITYTLS_CIPHERSUITE_TLS_RSA_EXPORT1024_WITH_RC4_56_SHA = 0x64, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA = 0x65, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_RC4_128_SHA = 0x66, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 = 0x67, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_AES_256_CBC_SHA256 = 0x68, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_AES_256_CBC_SHA256 = 0x69, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 = 0x6a, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 = 0x6b, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_AES_128_CBC_SHA256 = 0x6c, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_AES_256_CBC_SHA256 = 0x6d, + + UNITYTLS_CIPHERSUITE_TLS_GOSTR341094_WITH_28147_CNT_IMIT = 0x80, + UNITYTLS_CIPHERSUITE_TLS_GOSTR341001_WITH_28147_CNT_IMIT = 0x81, + UNITYTLS_CIPHERSUITE_TLS_GOSTR341001_WITH_NULL_GOSTR3411 = 0x82, + UNITYTLS_CIPHERSUITE_TLS_GOSTR341094_WITH_NULL_GOSTR3411 = 0x83, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA = 0x84, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA = 0x85, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA = 0x86, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA = 0x87, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA = 0x88, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA = 0x89, + UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_RC4_128_SHA = 0x8a, + UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_3DES_EDE_CBC_SHA = 0x8b, + UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_AES_128_CBC_SHA = 0x8c, + UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_AES_256_CBC_SHA = 0x8d, + UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_RC4_128_SHA = 0x8e, + UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA = 0x8f, + UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_AES_128_CBC_SHA = 0x90, + UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_AES_256_CBC_SHA = 0x91, + UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_RC4_128_SHA = 0x92, + UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA = 0x93, + UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_AES_128_CBC_SHA = 0x94, + UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_AES_256_CBC_SHA = 0x95, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_SEED_CBC_SHA = 0x96, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_SEED_CBC_SHA = 0x97, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_SEED_CBC_SHA = 0x98, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_SEED_CBC_SHA = 0x99, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_SEED_CBC_SHA = 0x9a, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_SEED_CBC_SHA = 0x9b, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_128_GCM_SHA256 = 0x9c, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_256_GCM_SHA384 = 0x9d, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 = 0x9e, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 = 0x9f, + + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_AES_128_GCM_SHA256 = 0xa0, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_AES_256_GCM_SHA384 = 0xa1, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 = 0xa2, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 = 0xa3, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_AES_128_GCM_SHA256 = 0xa4, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_AES_256_GCM_SHA384 = 0xa5, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_AES_128_GCM_SHA256 = 0xa6, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_AES_256_GCM_SHA384 = 0xa7, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 = 0xba, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 = 0xbb, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 = 0xbc, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 = 0xbd, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 = 0xbe, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256 = 0xbf, + + UNITYTLS_CIPHERSUITE_TLS_EMPTY_RENEGOTIATION_INFO_SCSV = 0x5600, + + UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_NULL_SHA = 0xc001, + UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_RC4_128_SHA = 0xc002, + UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA = 0xc003, + UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA = 0xc004, + UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA = 0xc005, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_NULL_SHA = 0xc006, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA = 0xc007, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA = 0xc008, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA = 0xc009, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA = 0xc00a, + UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_NULL_SHA = 0xc00b, + UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_RC4_128_SHA = 0xc00c, + UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA = 0xc00d, + UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA = 0xc00e, + UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA = 0xc00f, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_NULL_SHA = 0xc010, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_RC4_128_SHA = 0xc011, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA = 0xc012, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA = 0xc013, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA = 0xc014, + UNITYTLS_CIPHERSUITE_TLS_ECDH_anon_WITH_NULL_SHA = 0xc015, + UNITYTLS_CIPHERSUITE_TLS_ECDH_anon_WITH_RC4_128_SHA = 0xc016, + UNITYTLS_CIPHERSUITE_TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA = 0xc017, + UNITYTLS_CIPHERSUITE_TLS_ECDH_anon_WITH_AES_128_CBC_SHA = 0xc018, + UNITYTLS_CIPHERSUITE_TLS_ECDH_anon_WITH_AES_256_CBC_SHA = 0xc019, + UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA = 0xc01a, + UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA = 0xc01b, + UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA = 0xc01c, + UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_WITH_AES_128_CBC_SHA = 0xc01d, + UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA = 0xc01e, + UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA = 0xc01f, + UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_WITH_AES_256_CBC_SHA = 0xc020, + UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA = 0xc021, + UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA = 0xc022, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 = 0xc023, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 = 0xc024, + UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 = 0xc025, + UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 = 0xc026, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 = 0xc027, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 = 0xc028, + UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 = 0xc029, + UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 = 0xc02a, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 = 0xc02b, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 = 0xc02c, + UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 = 0xc02d, + UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 = 0xc02e, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 = 0xc02f, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 = 0xc030, + UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 = 0xc031, + UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 = 0xc032, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_RC4_128_SHA = 0xc033, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA = 0xc034, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA = 0xc035, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA = 0xc036, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 = 0xc037, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 = 0xc038, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_NULL_SHA = 0xc039, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_NULL_SHA256 = 0xc03A, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_NULL_SHA384 = 0xc03B, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_ARIA_128_CBC_SHA256 = 0xc03C, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_ARIA_256_CBC_SHA384 = 0xc03D, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256 = 0xc03E, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384 = 0xc03F, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256 = 0xc040, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384 = 0xc041, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256 = 0xc042, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384 = 0xc043, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256 = 0xc044, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384 = 0xc045, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_ARIA_128_CBC_SHA256 = 0xc046, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_ARIA_256_CBC_SHA384 = 0xc047, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256 = 0xc048, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384 = 0xc049, + UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256 = 0xc04A, + UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384 = 0xc04B, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256 = 0xc04C, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384 = 0xc04D, + UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256 = 0xc04E, + UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384 = 0xc04F, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_ARIA_128_GCM_SHA256 = 0xc050, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_ARIA_256_GCM_SHA384 = 0xc051, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256 = 0xc052, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384 = 0xc053, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256 = 0xc054, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384 = 0xc055, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256 = 0xc056, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384 = 0xc057, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256 = 0xc058, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384 = 0xc059, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_ARIA_128_GCM_SHA256 = 0xc05A, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_ARIA_256_GCM_SHA384 = 0xc05B, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 = 0xc05C, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 = 0xc05D, + UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 = 0xc05E, + UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 = 0xc05F, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 = 0xc060, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 = 0xc061, + UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 = 0xc062, + UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 = 0xc063, + UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_ARIA_128_CBC_SHA256 = 0xc064, + UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_ARIA_256_CBC_SHA384 = 0xc065, + UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256 = 0xc066, + UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384 = 0xc067, + UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256 = 0xc068, + UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384 = 0xc069, + UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_ARIA_128_GCM_SHA256 = 0xc06A, + UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_ARIA_256_GCM_SHA384 = 0xc06B, + UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256 = 0xc06C, + UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384 = 0xc06D, + UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256 = 0xc06E, + UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384 = 0xc06F, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256 = 0xc070, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384 = 0xc071, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 = 0xc072, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 = 0xc073, + UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 = 0xc074, + UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 = 0xc075, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 = 0xc076, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 = 0xc077, + UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 = 0xc078, + UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 = 0xc079, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 = 0xc07A, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 = 0xc07B, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 = 0xc07C, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 = 0xc07D, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256 = 0xc07E, + UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384 = 0xc07F, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256 = 0xc080, + UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384 = 0xc081, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256 = 0xc082, + UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384 = 0xc083, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256 = 0xc084, + UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384 = 0xc085, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 = 0xc086, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 = 0xc087, + UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 = 0xc088, + UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 = 0xc089, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 = 0xc08A, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 = 0xc08B, + UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 = 0xc08C, + UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 = 0xc08D, + UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 = 0xc08E, + UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 = 0xc08F, + UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 = 0xc090, + UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 = 0xc091, + UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 = 0xc092, + UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 = 0xc093, + UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 = 0xc094, + UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 = 0xc095, + UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 = 0xc096, + UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 = 0xc097, + UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 = 0xc098, + UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 = 0xc099, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 = 0xc09A, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 = 0xc09B, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_128_CCM = 0xc09c, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_256_CCM = 0xc09d, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_128_CCM = 0xc09e, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_256_CCM = 0xc09f, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_128_CCM_8 = 0xc0a0, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_256_CCM_8 = 0xc0a1, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_128_CCM_8 = 0xc0a2, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_256_CCM_8 = 0xc0a3, + UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_AES_128_CCM = 0xc0a4, + UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_AES_256_CCM = 0xc0a5, + UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_AES_128_CCM = 0xc0a6, + UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_AES_256_CCM = 0xc0a7, + UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_AES_128_CCM_8 = 0xc0a8, + UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_AES_256_CCM_8 = 0xc0a9, + UNITYTLS_CIPHERSUITE_TLS_PSK_DHE_WITH_AES_128_CCM_8 = 0xc0aa, + UNITYTLS_CIPHERSUITE_TLS_PSK_DHE_WITH_AES_256_CCM_8 = 0xc0ab, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_128_CCM = 0xc0ac, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_256_CCM = 0xc0ad, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 = 0xc0ae, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 = 0xc0af, + + UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256_OLD = 0xcc13, + UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256_OLD = 0xcc14, + UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256_OLD = 0xcc15, + + // GOST + UNITYTLS_CIPHERSUITE_TLS_GOSTR341094_RSA_WITH_28147_CNT_MD5 = 0xff00, + UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_28147_CNT_GOST94 = 0xff01, + UNITYTLS_CIPHERSUITE_GOST_89MAC = 0xff02, + UNITYTLS_CIPHERSUITE_GOST_89STREAM = 0xff03, + + UNITYTLS_CIPHERSUITE_SSL_RSA_FIPS_WITH_DES_CBC_SHA = 0xfefe, + UNITYTLS_CIPHERSUITE_SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA = 0xfeff, + //UNITYTLS_CIPHERSUITE_SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA = 0xfee0, + //UNITYTLS_CIPHERSUITE_SSL_RSA_FIPS_WITH_DES_CBC_SHA = 0xfee1, + + UNITYTLS_CIPHERSUITE_SSL_CK_RC4_128_WITH_MD5 = 0x010080, + UNITYTLS_CIPHERSUITE_SSL_CK_RC4_128_EXPORT40_WITH_MD5 = 0x020080, + UNITYTLS_CIPHERSUITE_SSL_CK_RC2_128_CBC_WITH_MD5 = 0x030080, + UNITYTLS_CIPHERSUITE_SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5 = 0x040080, + UNITYTLS_CIPHERSUITE_SSL_CK_IDEA_128_CBC_WITH_MD5 = 0x050080, + UNITYTLS_CIPHERSUITE_SSL_CK_DES_64_CBC_WITH_MD5 = 0x060040, + UNITYTLS_CIPHERSUITE_SSL_CK_DES_192_EDE3_CBC_WITH_MD5 = 0x0700c0, + UNITYTLS_CIPHERSUITE_SSL_CK_RC4_64_WITH_MD5 = 0x080080, + + UNITYTLS_CIPHERSUITE_INVALID = 0xFFFFFF + } + } +} \ No newline at end of file diff --git a/mcs/class/System/common.sources b/mcs/class/System/common.sources index 418336ceef91..190a83c85e74 100644 --- a/mcs/class/System/common.sources +++ b/mcs/class/System/common.sources @@ -258,6 +258,9 @@ Mono.AppleTls/Trust.cs Mono.AppleTls/SslConnection.cs Mono.AppleTls/Items.cs +Mono.UnityTLS/UnityTLS.cs +Mono.UnityTLS/UnityTLSCiphersuites.cs + Mono.Util/MonoPInvokeCallbackAttribute.cs MonoTouch/Dummy.cs From 90d29d75f5dd2d8dd42a73a7878218118a276238 Mon Sep 17 00:00:00 2001 From: andreasr Date: Wed, 13 Dec 2017 11:42:45 +0100 Subject: [PATCH 024/582] [unitytls] Added UnityTlsProvider stub + registration. Changed namespaces from UnityTls to Unity, change casing from 'TLS' to 'Tls' --- .../MonoTlsProviderFactory.cs | 6 +- .../UnityTLS.cs => Mono.UnityTls/UnityTls.cs} | 4 +- .../UnityTlsCiphersuites.cs} | 4 +- .../System/Mono.UnityTls/UnityTlsProvider.cs | 64 +++++++++++++++++++ mcs/class/System/common.sources | 5 +- 5 files changed, 76 insertions(+), 7 deletions(-) rename mcs/class/System/{Mono.UnityTLS/UnityTLS.cs => Mono.UnityTls/UnityTls.cs} (99%) rename mcs/class/System/{Mono.UnityTLS/UnityTLSCiphersuites.cs => Mono.UnityTls/UnityTlsCiphersuites.cs} (99%) create mode 100644 mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs diff --git a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs index dcc640ad30fe..0e28099180d8 100644 --- a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs +++ b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs @@ -226,6 +226,10 @@ static void InitializeProviderRegistration () providerRegistration = new Dictionary> (); providerCache = new Dictionary (); +#if UNITY + providerRegistration.Add ("unitytls", "Mono.Unity.UnityTlsProvider"); +#else + var appleTlsEntry = new Tuple (AppleTlsId, "Mono.AppleTls.AppleTlsProvider"); #if ONLY_APPLETLS || MONOTOUCH || XAMMAC @@ -242,7 +246,7 @@ static void InitializeProviderRegistration () providerRegistration.Add ("btls", btlsEntry); } #endif - +#endif if (Platform.IsMacOS) providerRegistration.Add ("default", appleTlsEntry); else if (btlsEntry != null) diff --git a/mcs/class/System/Mono.UnityTLS/UnityTLS.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs similarity index 99% rename from mcs/class/System/Mono.UnityTLS/UnityTLS.cs rename to mcs/class/System/Mono.UnityTls/UnityTls.cs index 45196c0731e0..af27ebb3638d 100644 --- a/mcs/class/System/Mono.UnityTLS/UnityTLS.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -2,12 +2,12 @@ using System.Runtime.InteropServices; using System.Runtime.CompilerServices; -namespace Mono.UnityTLS +namespace Mono.Unity { using size_t = UIntPtr; using UInt8 = Byte; - unsafe internal static partial class UnityTLS + unsafe internal static partial class UnityTls { private const string DLLNAME = "MacStandalonePlayer_TLSModule_Dynamic.dylib"; private const CallingConvention CALLCONV = CallingConvention.Cdecl; diff --git a/mcs/class/System/Mono.UnityTLS/UnityTLSCiphersuites.cs b/mcs/class/System/Mono.UnityTls/UnityTlsCiphersuites.cs similarity index 99% rename from mcs/class/System/Mono.UnityTLS/UnityTLSCiphersuites.cs rename to mcs/class/System/Mono.UnityTls/UnityTlsCiphersuites.cs index be22c0b84064..41e35d095577 100644 --- a/mcs/class/System/Mono.UnityTLS/UnityTLSCiphersuites.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsCiphersuites.cs @@ -1,8 +1,8 @@ using System; -namespace Mono.UnityTLS +namespace Mono.Unity { - unsafe internal static partial class UnityTLS + unsafe internal static partial class UnityTls { public enum unitytls_ciphersuite : UInt32 { diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs new file mode 100644 index 000000000000..d0dab87cadf8 --- /dev/null +++ b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs @@ -0,0 +1,64 @@ +#if SECURITY_DEP +#if MONO_SECURITY_ALIAS +extern alias MonoSecurity; +#endif + +using System; +using System.IO; +using System.Security.Cryptography.X509Certificates; +using System.Security.Authentication; + +#if MONO_SECURITY_ALIAS +using MonoSecurity::Mono.Security.Interface; +#else +using Mono.Security.Interface; +#endif + +using MNS = Mono.Net.Security; + +namespace Mono.Unity +{ + unsafe class UnityTlsProvider : MonoTlsProvider + { + static readonly Guid id = new Guid("06414A97-74F6-488F-877B-A6CA9BBEB82E"); + + public override Guid ID { + get { return id; } + } + public override string Name { + get { return "unitytls"; } + } + + public override bool SupportsSslStream { + get { return true; } + } + + public override bool SupportsMonoExtensions { + get { return true; } + } + + public override bool SupportsConnectionInfo { + get { return true; } + } + + public override SslProtocols SupportedProtocols { + get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; } + } + + public override IMonoSslStream CreateSslStream ( + Stream innerStream, bool leaveInnerStreamOpen, + MonoTlsSettings settings = null) + { + return null; // TODO + } + + internal override bool ValidateCertificate ( + ICertificateValidator2 validator, string targetHost, bool serverMode, + X509CertificateCollection certificates, bool wantsChain, ref X509Chain chain, + ref MonoSslPolicyErrors errors, ref int status11) + { + return false; // TODO + } + } +} +#endif diff --git a/mcs/class/System/common.sources b/mcs/class/System/common.sources index 190a83c85e74..dbb892a4e70e 100644 --- a/mcs/class/System/common.sources +++ b/mcs/class/System/common.sources @@ -258,8 +258,9 @@ Mono.AppleTls/Trust.cs Mono.AppleTls/SslConnection.cs Mono.AppleTls/Items.cs -Mono.UnityTLS/UnityTLS.cs -Mono.UnityTLS/UnityTLSCiphersuites.cs +Mono.UnityTls/UnityTls.cs +Mono.UnityTls/UnityTlsCiphersuites.cs +Mono.UnityTls/UnityTlsProvider.cs Mono.Util/MonoPInvokeCallbackAttribute.cs From 5ce647ea662eedf8b3ba03e3de5da51d09b80faf Mon Sep 17 00:00:00 2001 From: andreasr Date: Wed, 13 Dec 2017 14:48:07 +0100 Subject: [PATCH 025/582] [unitytls] Added stubs for UnityTlsContext/Stream --- .../System/Mono.UnityTls/UnityTlsContext.cs | 142 ++++++++++++++++++ .../System/Mono.UnityTls/UnityTlsProvider.cs | 2 +- .../System/Mono.UnityTls/UnityTlsStream.cs | 39 +++++ mcs/class/System/common.sources | 2 + 4 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 mcs/class/System/Mono.UnityTls/UnityTlsContext.cs create mode 100644 mcs/class/System/Mono.UnityTls/UnityTlsStream.cs diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs new file mode 100644 index 000000000000..e9707630d6ea --- /dev/null +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -0,0 +1,142 @@ +#if SECURITY_DEP +#if MONO_SECURITY_ALIAS +extern alias MonoSecurity; +#endif + +using System; +using System.IO; +using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Security.Cryptography.X509Certificates; +using System.Security.Authentication; + +#if MONO_SECURITY_ALIAS +using MonoSecurity::Mono.Security.Interface; +#else +using Mono.Security.Interface; +#endif + +using Mono.Net.Security; +using Mono.Util; + +namespace Mono.Unity +{ + unsafe internal class UnityTlsContext : MobileTlsContext + { + private const int MaxIOBufferSize = 16384; + + // States and certificates + X509Certificate m_LocalClientCertificate; + X509Certificate2 m_RemoteCertificate; + MonoTlsConnectionInfo m_Connectioninfo; + bool m_IsAuthenticated = false; + + public UnityTlsContext ( + MobileAuthenticatedStream parent, + bool serverMode, string targetHost, + SslProtocols enabledProtocols, X509Certificate serverCertificate, + X509CertificateCollection clientCertificates, bool askForClientCert) + : base (parent, serverMode, targetHost, enabledProtocols, serverCertificate, clientCertificates, askForClientCert) + { + // TODO + } + + public override bool HasContext { + get { return true; } + } + + public override bool IsAuthenticated { + get { return m_IsAuthenticated; } + } + + public override MonoTlsConnectionInfo ConnectionInfo { + get { return m_Connectioninfo; } + } + internal override bool IsRemoteCertificateAvailable { + get { return m_RemoteCertificate != null; } + } + internal override X509Certificate LocalClientCertificate { + get { return m_LocalClientCertificate; } + } + public override X509Certificate RemoteCertificate { + get { return m_RemoteCertificate; } + } + public override TlsProtocols NegotiatedProtocol { + get { return ConnectionInfo.ProtocolVersion; } + } + + void SetPrivateCertificate (X509Certificate cert) + { + X509Certificate2 privateKeyCert = cert as X509Certificate2; + if (privateKeyCert == null) + return; + } + + public override void Flush () + { + // NO-OP + } + + public override int Read (byte [] buffer, int offset, int count, out bool wouldBlock) + { + wouldBlock = false; + + int bufferSize = System.Math.Min(MaxIOBufferSize, count); + // TODO + return 0; + } + + public override int Write (byte [] buffer, int offset, int count, out bool wouldBlock) + { + wouldBlock = false; + + int bufferSize = System.Math.Min(MaxIOBufferSize, count); + // TODO + return 0; + } + + public override void Close () + { + } + + protected override void Dispose (bool disposing) + { + try { + if (disposing) + { + // reset states + m_LocalClientCertificate = null; + m_RemoteCertificate = null; + m_Connectioninfo = null; + m_IsAuthenticated = false; + } + + } finally { + base.Dispose (disposing); + } + } + + public override void StartHandshake () + { + // TODO + } + + public override bool ProcessHandshake () + { + // TODO + return false; + } + + public override void FinishHandshake () + { + m_Connectioninfo = new MonoTlsConnectionInfo () { + // TODO + //CipherSuiteCode = , + //ProtocolVersion = , + PeerDomainName = ServerName + }; + m_IsAuthenticated = true; + } + } +} +#endif \ No newline at end of file diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs index d0dab87cadf8..de939e60f8b7 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs @@ -49,7 +49,7 @@ public override IMonoSslStream CreateSslStream ( Stream innerStream, bool leaveInnerStreamOpen, MonoTlsSettings settings = null) { - return null; // TODO + return new UnityTlsStream (innerStream, leaveInnerStreamOpen, settings, this); } internal override bool ValidateCertificate ( diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsStream.cs b/mcs/class/System/Mono.UnityTls/UnityTlsStream.cs new file mode 100644 index 000000000000..575675f20715 --- /dev/null +++ b/mcs/class/System/Mono.UnityTls/UnityTlsStream.cs @@ -0,0 +1,39 @@ +#if SECURITY_DEP +#if MONO_SECURITY_ALIAS +extern alias MonoSecurity; +#endif + +using System.IO; +using System.Security.Cryptography.X509Certificates; +using System.Security.Authentication; + +#if MONO_SECURITY_ALIAS +using MonoSecurity::Mono.Security.Interface; +#else +using Mono.Security.Interface; +#endif + +using MNS = Mono.Net.Security; + +namespace Mono.Unity +{ + class UnityTlsStream : MNS.MobileAuthenticatedStream + { + public UnityTlsStream (Stream innerStream, bool leaveInnerStreamOpen, + MonoTlsSettings settings, MonoTlsProvider provider) + : base (innerStream, leaveInnerStreamOpen, settings, provider) + { + } + + protected override MNS.MobileTlsContext CreateContext ( + MNS.MobileAuthenticatedStream parent, bool serverMode, string targetHost, + SslProtocols enabledProtocols, X509Certificate serverCertificate, + X509CertificateCollection clientCertificates, bool askForClientCert) + { + return new UnityTlsContext (parent, serverMode, targetHost, + enabledProtocols, serverCertificate, clientCertificates, + askForClientCert); + } + } +} +#endif \ No newline at end of file diff --git a/mcs/class/System/common.sources b/mcs/class/System/common.sources index dbb892a4e70e..46c571ebb584 100644 --- a/mcs/class/System/common.sources +++ b/mcs/class/System/common.sources @@ -261,6 +261,8 @@ Mono.AppleTls/Items.cs Mono.UnityTls/UnityTls.cs Mono.UnityTls/UnityTlsCiphersuites.cs Mono.UnityTls/UnityTlsProvider.cs +Mono.UnityTls/UnityTlsStream.cs +Mono.UnityTls/UnityTlsContext.cs Mono.Util/MonoPInvokeCallbackAttribute.cs From b1e0d685b4dc93abc6979eb8ce5658038728da19 Mon Sep 17 00:00:00 2001 From: andreasr Date: Wed, 13 Dec 2017 14:48:53 +0100 Subject: [PATCH 026/582] [unitytls] Activate SslStreamTest on Mac if we're building for unity --- mcs/class/System/Test/System.Net.Security/SslStreamTest.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs b/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs index be4e5ad98315..d821a9dbd92f 100644 --- a/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs +++ b/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs @@ -59,7 +59,9 @@ public void GetReady () { } [Test] //bug https://bugzilla.novell.com/show_bug.cgi?id=457120 +#if !UNITY [Category ("MacNotWorking")] // Works but launches a prompt on 10.12 that will fail if you don't click in a few seconds +#endif #if FEATURE_NO_BSD_SOCKETS [ExpectedException (typeof (PlatformNotSupportedException))] #endif From 4d49d8b01c2f5067705b7063755b2452bdab5491 Mon Sep 17 00:00:00 2001 From: andreasr Date: Wed, 13 Dec 2017 16:00:12 +0100 Subject: [PATCH 027/582] [unitytls] size_t is now a struct instead of an alias. Change char* ptr to Int8=byte ptr since char has a different meaning in C# than in C --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 49 ++++++++++++++-------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index af27ebb3638d..e9fb6ece80b4 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -4,8 +4,21 @@ namespace Mono.Unity { - using size_t = UIntPtr; using UInt8 = Byte; + using Int8 = Byte; + + [StructLayout (LayoutKind.Sequential)] + internal struct size_t + { + public size_t(uint i) { + value = new UIntPtr(i); + } + + public static implicit operator size_t(int d) { + return new size_t((uint)d); + } + public UIntPtr value; + } unsafe internal static partial class UnityTls { @@ -41,9 +54,9 @@ public enum unitytls_error_code : UInt32 [StructLayout (LayoutKind.Sequential)] public struct unitytls_errorstate { - UInt32 magic; - unitytls_error_code code; - UInt64 reserved; // Implementation specific error code/handle. + private UInt32 magic; + public unitytls_error_code code; + private UInt64 reserved; // Implementation specific error code/handle. } [DllImport (DLLNAME, CallingConvention=CALLCONV)] @@ -64,11 +77,11 @@ public struct unitytls_pubkey_ref { UInt64 handle; } [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static unitytls_pubkey* unitytls_pubkey_parse_der(UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_pubkey* unitytls_pubkey_parse_pem(char* buffer, size_t bufferLen, unitytls_errorstate* errorState); + extern public static unitytls_pubkey* unitytls_pubkey_parse_pem(Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static size_t unitytls_pubkey_export_der(unitytls_pubkey_ref key, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_pubkey_export_pem(unitytls_pubkey_ref key, char* buffer, size_t bufferLen, unitytls_errorstate* errorState); + extern public static size_t unitytls_pubkey_export_pem(unitytls_pubkey_ref key, Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static void unitytls_pubkey_free(unitytls_pubkey* key); @@ -91,11 +104,11 @@ public struct unitytls_key_ref { UInt64 handle; } [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static unitytls_key* unitytls_key_parse_der(UInt8* buffer, size_t bufferLen, UInt8* password, size_t passwordLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_key* unitytls_key_parse_pem(char* buffer, size_t bufferLen, UInt8* password, size_t passwordLen, unitytls_errorstate* errorState); + extern public static unitytls_key* unitytls_key_parse_pem(Int8* buffer, size_t bufferLen, UInt8* password, size_t passwordLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static size_t unitytls_key_export_der(unitytls_key_ref key, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_key_export_pem(unitytls_key_ref key, char* buffer, size_t bufferLen, unitytls_errorstate* errorState); + extern public static size_t unitytls_key_export_pem(unitytls_key_ref key, Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static unitytls_pubkey_ref unitytls_key_get_pubkey(unitytls_key_ref key, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] @@ -115,11 +128,11 @@ public struct unitytls_x509_ref { UInt64 handle; } [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static unitytls_x509* unitytls_x509_parse_der(UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_x509* unitytls_x509_parse_pem(char* buffer, size_t bufferLen, unitytls_errorstate* errorState); + extern public static unitytls_x509* unitytls_x509_parse_pem(Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static size_t unitytls_x509_export_der(unitytls_x509_ref cert, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_x509_export_pem(unitytls_x509_ref cert, char* buffer, size_t bufferLen, unitytls_errorstate* errorState); + extern public static size_t unitytls_x509_export_pem(unitytls_x509_ref cert, Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static unitytls_pubkey_ref unitytls_x509_get_pubkey(unitytls_x509_ref cert, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] @@ -135,9 +148,9 @@ public struct unitytls_x509list_ref { UInt64 handle; } [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static unitytls_x509list_ref unitytls_x509list_get_ref(unitytls_x509list* list, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_x509list* unitytls_x509list_parse_pem(char* buffer, size_t bufferLen, unitytls_errorstate* errorState); + extern public static unitytls_x509list* unitytls_x509list_parse_pem(Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_x509list_export_pem(unitytls_x509list_ref list, char* buffer, size_t bufferLen, unitytls_errorstate* errorState); + extern public static size_t unitytls_x509list_export_pem(unitytls_x509list_ref list, Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static size_t unitytls_x509list_get_size(unitytls_x509list_ref list, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] @@ -149,7 +162,7 @@ public struct unitytls_x509list_ref { UInt64 handle; } [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static void unitytls_x509list_append_der(unitytls_x509list* list, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_x509list_append_pem(unitytls_x509list* list, char* buffer, size_t bufferLen, unitytls_errorstate* errorState); + extern public static size_t unitytls_x509list_append_pem(unitytls_x509list* list, Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static void unitytls_x509list_free(unitytls_x509list* list); @@ -182,9 +195,9 @@ public enum unitytls_x509verify_result : UInt32 public delegate unitytls_x509verify_result unitytls_x509verify_callback(void* userData, unitytls_x509_ref cert, unitytls_x509verify_result result, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_x509verify_result unitytls_x509verify_default_ca(unitytls_x509list_ref chain, char* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); + extern public static unitytls_x509verify_result unitytls_x509verify_default_ca(unitytls_x509list_ref chain, Int8* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_x509verify_result unitytls_x509verify_explicit_ca(unitytls_x509list_ref chain, unitytls_x509list_ref trustCA, char* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); + extern public static unitytls_x509verify_result unitytls_x509verify_explicit_ca(unitytls_x509list_ref chain, unitytls_x509list_ref trustCA, Int8* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); // ------------------------------------ @@ -237,7 +250,7 @@ public struct unitytls_tlsctx_callbacks [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static unitytls_tlsctx* unitytls_tlsctx_create_server(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, unitytls_x509list_ref certChain, unitytls_key_ref leafCertificateKey, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_tlsctx* unitytls_tlsctx_create_client(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, char* cn, size_t cnLen, unitytls_errorstate* errorState); + extern public static unitytls_tlsctx* unitytls_tlsctx_create_client(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, Int8* cn, size_t cnLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static void unitytls_tlsctx_set_x509verify_callback(unitytls_tlsctx* ctx, unitytls_tlsctx_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); @@ -269,8 +282,8 @@ public struct unitytls_tlsctx_callbacks // Encoding / Decoding // ------------------------------------ [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_base64_encode(char* outputBuffer, size_t outputBufferLen, UInt8* inputBuffer, size_t inputBufferLen, size_t lineMaxLength, unitytls_errorstate* errorState); + extern public static size_t unitytls_base64_encode(Int8* outputBuffer, size_t outputBufferLen, UInt8* inputBuffer, size_t inputBufferLen, size_t lineMaxLength, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_base64_decode(UInt8* outputBuffer, size_t outputBufferLen, char* inputBuffer, size_t inputBufferLen, unitytls_errorstate* errorState); + extern public static size_t unitytls_base64_decode(UInt8* outputBuffer, size_t outputBufferLen, Int8* inputBuffer, size_t inputBufferLen, unitytls_errorstate* errorState); } } \ No newline at end of file From 8f1c80bf05deed6df9feee17ad956497b6055ffb Mon Sep 17 00:00:00 2001 From: andreasr Date: Wed, 13 Dec 2017 16:00:48 +0100 Subject: [PATCH 028/582] [unitytls] Implemented UnityTlsProvider.ValidateCertificate --- .../System/Mono.UnityTls/UnityTlsProvider.cs | 47 ++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs index de939e60f8b7..f6ae4f9464f5 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs @@ -5,6 +5,7 @@ using System; using System.IO; +using System.Text; using System.Security.Cryptography.X509Certificates; using System.Security.Authentication; @@ -18,7 +19,7 @@ namespace Mono.Unity { - unsafe class UnityTlsProvider : MonoTlsProvider + unsafe internal class UnityTlsProvider : MonoTlsProvider { static readonly Guid id = new Guid("06414A97-74F6-488F-877B-A6CA9BBEB82E"); @@ -57,7 +58,49 @@ internal override bool ValidateCertificate ( X509CertificateCollection certificates, bool wantsChain, ref X509Chain chain, ref MonoSslPolicyErrors errors, ref int status11) { - return false; // TODO + if (wantsChain) + chain = MNS.SystemCertificateValidator.CreateX509Chain (certificates); + + if (certificates == null || certificates.Count == 0) { + errors |= MonoSslPolicyErrors.RemoteCertificateNotAvailable; + return false; + } + + // fixup targetHost name by removing port + if (!string.IsNullOrEmpty (targetHost)) { + var pos = targetHost.IndexOf (':'); + if (pos > 0) + targetHost = targetHost.Substring (0, pos); + } + + // convert cert to native + UnityTls.unitytls_errorstate errorState = UnityTls.unitytls_errorstate_create(); + UnityTls.unitytls_x509verify_result result; + + UnityTls.unitytls_x509list* certificatesNative = UnityTls.unitytls_x509list_create(&errorState); + try + { + foreach (X509Certificate certificate in certificates) { + byte[] certDer = certificate.GetRawCertData(); + fixed(byte* certDerPtr = certDer) { + UnityTls.unitytls_x509list_append_der(certificatesNative, certDerPtr, certDer.Length, &errorState); + } + } + + // validate + UnityTls.unitytls_x509list_ref certificatesNativeRef = UnityTls.unitytls_x509list_get_ref(certificatesNative, &errorState); + byte[] targetHostUtf8 = Encoding.UTF8.GetBytes(targetHost); + fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { + result = UnityTls.unitytls_x509verify_default_ca(certificatesNativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); + } + } + finally + { + UnityTls.unitytls_x509list_free(certificatesNative); + } + + return result == UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_SUCCESS && + errorState.code == UnityTls.unitytls_error_code.UNITYTLS_SUCCESS; } } } From 5b0f3c477296128378e28d5567656848879a2e34 Mon Sep 17 00:00:00 2001 From: andreasr Date: Thu, 14 Dec 2017 12:36:05 +0100 Subject: [PATCH 029/582] [unitytls] fixed access modifies for some structs in UnityTls interface --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index e9fb6ece80b4..ac4282b351ec 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -218,8 +218,8 @@ public enum unitytls_protocol : UInt32 [StructLayout (LayoutKind.Sequential)] public struct unitytls_tlsctx_protocolrange { - unitytls_protocol min; - unitytls_protocol max; + public unitytls_protocol min; + public unitytls_protocol max; }; // TODO //[DllImport (DLLNAME, CallingConvention=CALLCONV)] @@ -242,9 +242,9 @@ public enum unitytls_tlsctx_handshakestate : UInt32 [StructLayout (LayoutKind.Sequential)] public struct unitytls_tlsctx_callbacks { - unitytls_tlsctx_callback_read read; - unitytls_tlsctx_callback_write write; - void* data; + public unitytls_tlsctx_callback_read read; + public unitytls_tlsctx_callback_write write; + public void* data; }; [DllImport (DLLNAME, CallingConvention=CALLCONV)] From 1b25fe8b28a8ccf394a3ac783c45d207598da989 Mon Sep 17 00:00:00 2001 From: andreasr Date: Thu, 14 Dec 2017 12:37:17 +0100 Subject: [PATCH 030/582] [unitytls] Added debug helper for handling unitytls_errorstate --- mcs/class/System/Mono.UnityTLS/Debug.cs | 25 +++++++++++++++++++++++++ mcs/class/System/common.sources | 1 + 2 files changed, 26 insertions(+) create mode 100644 mcs/class/System/Mono.UnityTLS/Debug.cs diff --git a/mcs/class/System/Mono.UnityTLS/Debug.cs b/mcs/class/System/Mono.UnityTLS/Debug.cs new file mode 100644 index 000000000000..1d2607f14dd8 --- /dev/null +++ b/mcs/class/System/Mono.UnityTLS/Debug.cs @@ -0,0 +1,25 @@ +#if SECURITY_DEP +#if MONO_SECURITY_ALIAS +extern alias MonoSecurity; +#endif + +#if MONO_SECURITY_ALIAS +using MonoSecurity::Mono.Security.Interface; +#else +using Mono.Security.Interface; +#endif + +namespace Mono.Unity +{ + internal static class Debug + { + public static void CheckAndThrow(UnityTls.unitytls_errorstate errorState, string context) + { + if (errorState.code != UnityTls.unitytls_error_code.UNITYTLS_SUCCESS) { + string message = string.Format("{0} - error code {1}", context, errorState.code); + throw new TlsException(AlertDescription.InternalError, message); + } + } + } +} +#endif \ No newline at end of file diff --git a/mcs/class/System/common.sources b/mcs/class/System/common.sources index 46c571ebb584..12153ec06880 100644 --- a/mcs/class/System/common.sources +++ b/mcs/class/System/common.sources @@ -263,6 +263,7 @@ Mono.UnityTls/UnityTlsCiphersuites.cs Mono.UnityTls/UnityTlsProvider.cs Mono.UnityTls/UnityTlsStream.cs Mono.UnityTls/UnityTlsContext.cs +Mono.UnityTls/Debug.cs Mono.Util/MonoPInvokeCallbackAttribute.cs From 598e0d4fbaaff18f36e037a82d09627e575ca00a Mon Sep 17 00:00:00 2001 From: andreasr Date: Thu, 14 Dec 2017 12:37:35 +0100 Subject: [PATCH 031/582] [unitytls] Implemented UnityTlsContext init --- .../System/Mono.UnityTls/UnityTlsContext.cs | 110 ++++++++++++++++-- 1 file changed, 101 insertions(+), 9 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index e9707630d6ea..218e1b26ac71 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -5,6 +5,7 @@ using System; using System.IO; +using System.Text; using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; @@ -12,8 +13,10 @@ #if MONO_SECURITY_ALIAS using MonoSecurity::Mono.Security.Interface; +using MonoSecurity::Mono.Security.Cryptography; #else using Mono.Security.Interface; +using Mono.Security.Cryptography; #endif using Mono.Net.Security; @@ -25,11 +28,17 @@ unsafe internal class UnityTlsContext : MobileTlsContext { private const int MaxIOBufferSize = 16384; + // Native UnityTls objects + private UnityTls.unitytls_tlsctx* m_TlsContext = null; + private UnityTls.unitytls_x509list* m_ServerCerts = null; + private UnityTls.unitytls_key* m_ServerPrivateKey = null; + // States and certificates X509Certificate m_LocalClientCertificate; X509Certificate2 m_RemoteCertificate; MonoTlsConnectionInfo m_Connectioninfo; bool m_IsAuthenticated = false; + bool m_HasContext = false; public UnityTlsContext ( MobileAuthenticatedStream parent, @@ -38,11 +47,80 @@ public UnityTlsContext ( X509CertificateCollection clientCertificates, bool askForClientCert) : base (parent, serverMode, targetHost, enabledProtocols, serverCertificate, clientCertificates, askForClientCert) { - // TODO + UnityTls.unitytls_errorstate errorState = UnityTls.unitytls_errorstate_create(); + + // Map selected protocols as best as we can. + UnityTls.unitytls_tlsctx_protocolrange protocolRange = new UnityTls.unitytls_tlsctx_protocolrange { + min = GetMinProtocol(enabledProtocols), + max = GetMaxProtocol(enabledProtocols), + }; + + UnityTls.unitytls_tlsctx_callbacks callbacks = new UnityTls.unitytls_tlsctx_callbacks { + write = WriteCallback, + read = ReadCallback, + data = null, + }; + + if (serverMode) { + if (serverCertificate == null) + throw new ArgumentNullException ("serverCertificate"); + X509Certificate2 privateKeyCert = serverCertificate as X509Certificate2; + if (privateKeyCert == null || privateKeyCert.PrivateKey == null) + throw new ArgumentException ("serverCertificate does not have a private key", "serverCertificate"); + + m_ServerCerts = UnityTls.unitytls_x509list_create(&errorState); + byte[] certDer = serverCertificate.GetRawCertData(); + fixed(byte* certDerPtr = certDer) { + UnityTls.unitytls_x509list_append_der(m_ServerCerts, certDerPtr, certDer.Length, &errorState); + } + + byte[] privateKeyDer = PKCS8.PrivateKeyInfo.Encode(privateKeyCert.PrivateKey); + fixed(byte* privateKeyDerPtr = privateKeyDer) { + m_ServerPrivateKey = UnityTls.unitytls_key_parse_der(privateKeyDerPtr, privateKeyDer.Length, null, 0, &errorState); + } + + Mono.Unity.Debug.CheckAndThrow(errorState, "Failed to parse server key/certificate"); + + UnityTls.unitytls_x509list_ref serverCertsRef = UnityTls.unitytls_x509list_get_ref(m_ServerCerts, &errorState); + UnityTls.unitytls_key_ref serverKeyRef = UnityTls.unitytls_key_get_ref(m_ServerPrivateKey, &errorState); + m_TlsContext = UnityTls.unitytls_tlsctx_create_server(protocolRange, callbacks, serverCertsRef, serverKeyRef, &errorState); + } + else { + byte[] targetHostUtf8 = Encoding.UTF8.GetBytes(targetHost); + fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { + m_TlsContext = UnityTls.unitytls_tlsctx_create_client(protocolRange, callbacks, targetHostUtf8Ptr, targetHostUtf8.Length, &errorState); + } + } + + Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to create UnityTls context"); + m_HasContext = true; + } + + static private UnityTls.unitytls_protocol GetMinProtocol(SslProtocols protocols) + { + if (protocols.HasFlag(SslProtocols.Tls)) + return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_0; + if (protocols.HasFlag(SslProtocols.Tls11)) + return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_1; + if (protocols.HasFlag(SslProtocols.Tls12)) + return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_2; + return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_2; // Behavior as in AppleTlsContext } + static private UnityTls.unitytls_protocol GetMaxProtocol(SslProtocols protocols) + { + if (protocols.HasFlag(SslProtocols.Tls12)) + return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_2; + if (protocols.HasFlag(SslProtocols.Tls11)) + return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_1; + if (protocols.HasFlag(SslProtocols.Tls)) + return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_0; + return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_0; // Behavior as in AppleTlsContext + } + + public override bool HasContext { - get { return true; } + get { return m_HasContext; } } public override bool IsAuthenticated { @@ -65,13 +143,6 @@ public override TlsProtocols NegotiatedProtocol { get { return ConnectionInfo.ProtocolVersion; } } - void SetPrivateCertificate (X509Certificate cert) - { - X509Certificate2 privateKeyCert = cert as X509Certificate2; - if (privateKeyCert == null) - return; - } - public override void Flush () { // NO-OP @@ -104,11 +175,20 @@ protected override void Dispose (bool disposing) try { if (disposing) { + // Destroy native UnityTls objects + UnityTls.unitytls_tlsctx_free(m_TlsContext); + m_TlsContext = null; + UnityTls.unitytls_x509list_free(m_ServerCerts); + m_ServerCerts = null; + UnityTls.unitytls_key_free(m_ServerPrivateKey); + m_ServerPrivateKey = null; + // reset states m_LocalClientCertificate = null; m_RemoteCertificate = null; m_Connectioninfo = null; m_IsAuthenticated = false; + m_HasContext = false; } } finally { @@ -137,6 +217,18 @@ public override void FinishHandshake () }; m_IsAuthenticated = true; } + + private size_t WriteCallback(void* userData, byte* data, size_t bufferLen, UnityTls.unitytls_errorstate* errorState) + { + // TODO + return 0; + } + + private size_t ReadCallback(void* userData, byte* buffer, size_t bufferLen, UnityTls.unitytls_errorstate* errorState) + { + // TODO + return 0; + } } } #endif \ No newline at end of file From 98e940dd409782d01626c22c0e4af60ecaf80706 Mon Sep 17 00:00:00 2001 From: andreasr Date: Thu, 14 Dec 2017 16:36:45 +0100 Subject: [PATCH 032/582] [unitytls] added checking method that evaluates unitytls_x509verify_result as well --- mcs/class/System/Mono.UnityTLS/Debug.cs | 44 ++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/mcs/class/System/Mono.UnityTLS/Debug.cs b/mcs/class/System/Mono.UnityTLS/Debug.cs index 1d2607f14dd8..fcdb980c54aa 100644 --- a/mcs/class/System/Mono.UnityTLS/Debug.cs +++ b/mcs/class/System/Mono.UnityTLS/Debug.cs @@ -16,10 +16,52 @@ internal static class Debug public static void CheckAndThrow(UnityTls.unitytls_errorstate errorState, string context) { if (errorState.code != UnityTls.unitytls_error_code.UNITYTLS_SUCCESS) { - string message = string.Format("{0} - error code {1}", context, errorState.code); + string message = string.Format("{0} - error code: {1}", context, errorState.code); throw new TlsException(AlertDescription.InternalError, message); } } + + public static AlertDescription VerifyResultToAlertDescription(UnityTls.unitytls_x509verify_result verifyResult, AlertDescription defaultAlert = AlertDescription.InternalError) + { + if (verifyResult.HasFlag(UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_EXPIRED)) + return AlertDescription.CertificateExpired; + else if (verifyResult.HasFlag(UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_REVOKED)) + return AlertDescription.CertificateRevoked; + else if (verifyResult.HasFlag(UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_CN_MISMATCH)) + return AlertDescription.UnknownCA; + else if (verifyResult.HasFlag(UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED)) + return AlertDescription.CertificateUnknown; + + else if (verifyResult.HasFlag(UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR1)) + return AlertDescription.UserCancelled; + else if (verifyResult.HasFlag(UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR2)) + return AlertDescription.UserCancelled; + else if (verifyResult.HasFlag(UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR2)) + return AlertDescription.UserCancelled; + else if (verifyResult.HasFlag(UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR3)) + return AlertDescription.UserCancelled; + else if (verifyResult.HasFlag(UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR4)) + return AlertDescription.UserCancelled; + else if (verifyResult.HasFlag(UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR5)) + return AlertDescription.UserCancelled; + else if (verifyResult.HasFlag(UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR6)) + return AlertDescription.UserCancelled; + else if (verifyResult.HasFlag(UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR7)) + return AlertDescription.UserCancelled; + else if (verifyResult.HasFlag(UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR8)) + return AlertDescription.UserCancelled; + + return defaultAlert; + } + + public static void CheckAndThrow(UnityTls.unitytls_errorstate errorState, UnityTls.unitytls_x509verify_result verifyResult, string context, AlertDescription defaultAlert = AlertDescription.InternalError) + { + if (verifyResult != UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_SUCCESS) { + AlertDescription alert = VerifyResultToAlertDescription(verifyResult, defaultAlert); + string message = string.Format("{0} - error code: {1}, verify result: {2}", context, errorState.code, verifyResult); + throw new TlsException(alert, message); + } + } } } #endif \ No newline at end of file From 0b84cf20f9e4b970849a9135e528082591a54282 Mon Sep 17 00:00:00 2001 From: andreasr Date: Thu, 14 Dec 2017 16:37:37 +0100 Subject: [PATCH 033/582] [unitytls] size_t is now IntPtr and can convert to int implicitely. Updated UnityTls interface with trace methods --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index ac4282b351ec..8349b5b9b0b8 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -11,13 +11,17 @@ namespace Mono.Unity internal struct size_t { public size_t(uint i) { - value = new UIntPtr(i); + value = new IntPtr(i); } public static implicit operator size_t(int d) { return new size_t((uint)d); } - public UIntPtr value; + public static implicit operator int(size_t s) { + return s.value.ToInt32(); + } + + public IntPtr value; } unsafe internal static partial class UnityTls @@ -169,6 +173,7 @@ public struct unitytls_x509list_ref { UInt64 handle; } // ------------------------------------ // X.509 Certificate Verification // ------------------------------------ + [Flags] public enum unitytls_x509verify_result : UInt32 { UNITYTLS_X509VERIFY_SUCCESS = 0x00000000, @@ -236,6 +241,7 @@ public enum unitytls_tlsctx_handshakestate : UInt32 public delegate size_t unitytls_tlsctx_callback_write(void* userData, UInt8* data, size_t bufferLen, unitytls_errorstate* errorState); public delegate size_t unitytls_tlsctx_callback_read(void* userData, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + public delegate void unitytls_tlsctx_callback_trace(void* userData, unitytls_tlsctx* ctx, Int8* traceMessage, size_t traceMessageLen); public delegate void unitytls_tlsctx_callback_handshake(void* userData, unitytls_tlsctx* ctx, unitytls_tlsctx_handshakestate currentState, unitytls_errorstate* errorState); public delegate unitytls_x509verify_result unitytls_tlsctx_x509verify_callback(void* userData, unitytls_x509list_ref chain, unitytls_errorstate* errorState); @@ -252,6 +258,8 @@ public struct unitytls_tlsctx_callbacks [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static unitytls_tlsctx* unitytls_tlsctx_create_client(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, Int8* cn, size_t cnLen, unitytls_errorstate* errorState); + [DllImport (DLLNAME, CallingConvention=CALLCONV)] + extern public static void unitytls_tlsctx_set_trace_callback(unitytls_tlsctx* ctx, unitytls_tlsctx_callback_trace cb, void* userData, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static void unitytls_tlsctx_set_x509verify_callback(unitytls_tlsctx* ctx, unitytls_tlsctx_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] From 74d55926a89d8b08ef2d1e4567727d399abf6045 Mon Sep 17 00:00:00 2001 From: andreasr Date: Thu, 14 Dec 2017 16:38:22 +0100 Subject: [PATCH 034/582] [unitytls] Implemented tracing, basic handshake and read/write methods for UnityTlsContext --- .../System/Mono.UnityTls/UnityTlsContext.cs | 98 ++++++++++++++++--- 1 file changed, 87 insertions(+), 11 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index 218e1b26ac71..61fa1abf44ea 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -27,7 +27,8 @@ namespace Mono.Unity unsafe internal class UnityTlsContext : MobileTlsContext { private const int MaxIOBufferSize = 16384; - + private const bool ActivateTracing = false; + // Native UnityTls objects private UnityTls.unitytls_tlsctx* m_TlsContext = null; private UnityTls.unitytls_x509list* m_ServerCerts = null; @@ -40,6 +41,12 @@ unsafe internal class UnityTlsContext : MobileTlsContext bool m_IsAuthenticated = false; bool m_HasContext = false; + // Memory-buffer + byte[] m_WriteBuffer; + byte[] m_ReadBuffer; + + GCHandle m_handle; + public UnityTlsContext ( MobileAuthenticatedStream parent, bool serverMode, string targetHost, @@ -47,6 +54,10 @@ public UnityTlsContext ( X509CertificateCollection clientCertificates, bool askForClientCert) : base (parent, serverMode, targetHost, enabledProtocols, serverCertificate, clientCertificates, askForClientCert) { + // GCHandle allows to use managed class in native code. Stricly speaking we don't need this + // (there is no access on the native side and live time also doesn't depend on native code), but it makes a few things cleaner and more explicit. + m_handle = GCHandle.Alloc(this); + UnityTls.unitytls_errorstate errorState = UnityTls.unitytls_errorstate_create(); // Map selected protocols as best as we can. @@ -58,7 +69,7 @@ public UnityTlsContext ( UnityTls.unitytls_tlsctx_callbacks callbacks = new UnityTls.unitytls_tlsctx_callbacks { write = WriteCallback, read = ReadCallback, - data = null, + data = (void*)(IntPtr)m_handle, }; if (serverMode) { @@ -93,6 +104,12 @@ public UnityTlsContext ( } Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to create UnityTls context"); + + if (ActivateTracing) { + UnityTls.unitytls_tlsctx_set_trace_callback(m_TlsContext, TraceCallback, null, &errorState); + Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to set trace callback"); + } + m_HasContext = true; } @@ -191,6 +208,8 @@ protected override void Dispose (bool disposing) m_HasContext = false; } + m_handle.Free(); + } finally { base.Dispose (disposing); } @@ -198,13 +217,23 @@ protected override void Dispose (bool disposing) public override void StartHandshake () { - // TODO + // TODO: Check if we started a handshake already? + + // TODO, Not supported by UnityTls as of writing + if (IsServer && AskForClientCertificate) { + throw new NotImplementedException("No support for client certificate check yet."); + } } public override bool ProcessHandshake () { - // TODO - return false; + UnityTls.unitytls_errorstate errorState = UnityTls.unitytls_errorstate_create(); + UnityTls.unitytls_x509verify_result result = UnityTls.unitytls_tlsctx_process_handshake(m_TlsContext, &errorState); + if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) + return false; + Unity.Debug.CheckAndThrow(errorState, result, "Handshake failed", AlertDescription.HandshakeFailure); + + return true; } public override void FinishHandshake () @@ -218,16 +247,63 @@ public override void FinishHandshake () m_IsAuthenticated = true; } - private size_t WriteCallback(void* userData, byte* data, size_t bufferLen, UnityTls.unitytls_errorstate* errorState) + [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_callback_write))] + static private size_t WriteCallback(void* userData, byte* data, size_t bufferLen, UnityTls.unitytls_errorstate* errorState) { - // TODO - return 0; + var handle = (GCHandle)(IntPtr)userData; + var context = (UnityTlsContext)handle.Target; + return context.WriteCallback(data, bufferLen, errorState); } - private size_t ReadCallback(void* userData, byte* buffer, size_t bufferLen, UnityTls.unitytls_errorstate* errorState) + private size_t WriteCallback(byte* data, size_t bufferLen, UnityTls.unitytls_errorstate* errorState) { - // TODO - return 0; + if (m_WriteBuffer == null || m_WriteBuffer.Length < bufferLen) + m_WriteBuffer = new byte[bufferLen]; + Marshal.Copy((IntPtr)data, m_WriteBuffer, 0, bufferLen); + + if (!Parent.InternalWrite (m_WriteBuffer, 0, bufferLen)) + { + UnityTls.unitytls_errorstate_raise_error(errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WRITE_FAILED); + return 0; + } + + return bufferLen; + } + + [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_callback_read))] + static private size_t ReadCallback(void* userData, byte* buffer, size_t bufferLen, UnityTls.unitytls_errorstate* errorState) + { + var handle = (GCHandle)(IntPtr)userData; + var context = (UnityTlsContext)handle.Target; + return context.ReadCallback(buffer, bufferLen, errorState); + } + + private size_t ReadCallback(byte* buffer, size_t bufferLen, UnityTls.unitytls_errorstate* errorState) + { + if (m_ReadBuffer == null || m_ReadBuffer.Length < bufferLen) + m_ReadBuffer = new byte[bufferLen]; + + bool wouldBlock; + int numBytesRead = Parent.InternalRead (m_ReadBuffer, 0, bufferLen, out wouldBlock); + if (numBytesRead < 0) + { + UnityTls.unitytls_errorstate_raise_error(errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_READ_FAILED); + return 0; + } + if (wouldBlock) + { + UnityTls.unitytls_errorstate_raise_error(errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK); + } + + Marshal.Copy(m_ReadBuffer, 0, (IntPtr)buffer, bufferLen); + return numBytesRead; + } + + [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_callback_trace))] + static private void TraceCallback(void* userData, UnityTls.unitytls_tlsctx* ctx, byte* traceMessage, size_t traceMessageLen) + { + string message = Encoding.UTF8.GetString(traceMessage, traceMessageLen); + System.Console.Write(message); } } } From f7dac9eb0fd3be9c601f554bf8eaff06baaeeba0 Mon Sep 17 00:00:00 2001 From: andreasr Date: Thu, 14 Dec 2017 18:29:46 +0100 Subject: [PATCH 035/582] [unitytls] Cleaned up CheckAndThrow methods. CheckAndThrow for verify results forwards now to the one without verify result. --- mcs/class/System/Mono.UnityTLS/Debug.cs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/mcs/class/System/Mono.UnityTLS/Debug.cs b/mcs/class/System/Mono.UnityTLS/Debug.cs index fcdb980c54aa..847d8493c888 100644 --- a/mcs/class/System/Mono.UnityTLS/Debug.cs +++ b/mcs/class/System/Mono.UnityTLS/Debug.cs @@ -13,12 +13,13 @@ namespace Mono.Unity { internal static class Debug { - public static void CheckAndThrow(UnityTls.unitytls_errorstate errorState, string context) + public static void CheckAndThrow(UnityTls.unitytls_errorstate errorState, string context, AlertDescription defaultAlert = AlertDescription.InternalError) { - if (errorState.code != UnityTls.unitytls_error_code.UNITYTLS_SUCCESS) { - string message = string.Format("{0} - error code: {1}", context, errorState.code); - throw new TlsException(AlertDescription.InternalError, message); - } + if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_SUCCESS) + return; + + string message = string.Format("{0} - error code: {1}", context, errorState.code); + throw new TlsException(defaultAlert, message); } public static AlertDescription VerifyResultToAlertDescription(UnityTls.unitytls_x509verify_result verifyResult, AlertDescription defaultAlert = AlertDescription.InternalError) @@ -56,11 +57,15 @@ public static AlertDescription VerifyResultToAlertDescription(UnityTls.unitytls_ public static void CheckAndThrow(UnityTls.unitytls_errorstate errorState, UnityTls.unitytls_x509verify_result verifyResult, string context, AlertDescription defaultAlert = AlertDescription.InternalError) { - if (verifyResult != UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_SUCCESS) { - AlertDescription alert = VerifyResultToAlertDescription(verifyResult, defaultAlert); - string message = string.Format("{0} - error code: {1}, verify result: {2}", context, errorState.code, verifyResult); - throw new TlsException(alert, message); + // Ignore verify result if verification is not the issue. + if (verifyResult == UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_SUCCESS) { + CheckAndThrow (errorState, context, defaultAlert); + return; } + + AlertDescription alert = VerifyResultToAlertDescription (verifyResult, defaultAlert); + string message = string.Format ("{0} - error code: {1}, verify result: {2}", context, errorState.code, verifyResult); + throw new TlsException (alert, message); } } } From ad45770e320dbd5375ff1b7710021d8baebba366 Mon Sep 17 00:00:00 2001 From: andreasr Date: Thu, 14 Dec 2017 18:31:42 +0100 Subject: [PATCH 036/582] [unitytls] Implemented verify callback --- mcs/class/System/Mono.UnityTLS/CertHelper.cs | 55 +++++++++++++++++++ .../System/Mono.UnityTls/UnityTlsContext.cs | 37 ++++++++++--- mcs/class/System/common.sources | 1 + 3 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 mcs/class/System/Mono.UnityTLS/CertHelper.cs diff --git a/mcs/class/System/Mono.UnityTLS/CertHelper.cs b/mcs/class/System/Mono.UnityTLS/CertHelper.cs new file mode 100644 index 000000000000..42a037cd4b65 --- /dev/null +++ b/mcs/class/System/Mono.UnityTLS/CertHelper.cs @@ -0,0 +1,55 @@ +#if SECURITY_DEP +using System.Security.Cryptography.X509Certificates; + +namespace Mono.Unity +{ + internal unsafe static class CertHelper + { + public static void AddCertificatesToNativeChain(UnityTls.unitytls_x509list* nativeCertificateChain, X509CertificateCollection certificates, UnityTls.unitytls_errorstate* errorState) + { + foreach (var certificate in certificates) { + AddCertificateToNativeChain(nativeCertificateChain, certificate, errorState); + } + } + + public static void AddCertificateToNativeChain(UnityTls.unitytls_x509list* nativeCertificateChain, X509Certificate certificate, UnityTls.unitytls_errorstate* errorState) + { + byte[] certDer = certificate.GetRawCertData(); + fixed(byte* certDerPtr = certDer) { + UnityTls.unitytls_x509list_append_der(nativeCertificateChain, certDerPtr, certDer.Length, errorState); + } + + var certificateImpl2 = certificate.Impl as X509Certificate2Impl; + if (certificateImpl2 != null) { + var intermediates = certificateImpl2.IntermediateCertificates; + if (intermediates != null && intermediates.Count > 0) { + for (int i=0; i Date: Thu, 14 Dec 2017 18:32:30 +0100 Subject: [PATCH 037/582] [unitytls] Use of CertHelper in TlsProvider --- mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs index f6ae4f9464f5..b16044c23a9f 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs @@ -75,17 +75,11 @@ internal override bool ValidateCertificate ( // convert cert to native UnityTls.unitytls_errorstate errorState = UnityTls.unitytls_errorstate_create(); - UnityTls.unitytls_x509verify_result result; - UnityTls.unitytls_x509list* certificatesNative = UnityTls.unitytls_x509list_create(&errorState); + UnityTls.unitytls_x509verify_result result = UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_NOT_DONE; try { - foreach (X509Certificate certificate in certificates) { - byte[] certDer = certificate.GetRawCertData(); - fixed(byte* certDerPtr = certDer) { - UnityTls.unitytls_x509list_append_der(certificatesNative, certDerPtr, certDer.Length, &errorState); - } - } + CertHelper.AddCertificatesToNativeChain(certificatesNative, certificates, &errorState); // validate UnityTls.unitytls_x509list_ref certificatesNativeRef = UnityTls.unitytls_x509list_get_ref(certificatesNative, &errorState); From f6c2b7544b4849a94ed5548d51ceb9fb22d4910b Mon Sep 17 00:00:00 2001 From: andreasr Date: Thu, 14 Dec 2017 18:40:04 +0100 Subject: [PATCH 038/582] [unitytls] Mono coding style compliance fixes --- mcs/class/System/Mono.UnityTLS/CertHelper.cs | 16 +-- mcs/class/System/Mono.UnityTLS/Debug.cs | 34 +++--- .../System/Mono.UnityTls/UnityTlsContext.cs | 106 +++++++++--------- .../System/Mono.UnityTls/UnityTlsProvider.cs | 14 +-- 4 files changed, 85 insertions(+), 85 deletions(-) diff --git a/mcs/class/System/Mono.UnityTLS/CertHelper.cs b/mcs/class/System/Mono.UnityTLS/CertHelper.cs index 42a037cd4b65..c21b12cb9d5b 100644 --- a/mcs/class/System/Mono.UnityTLS/CertHelper.cs +++ b/mcs/class/System/Mono.UnityTLS/CertHelper.cs @@ -5,18 +5,18 @@ namespace Mono.Unity { internal unsafe static class CertHelper { - public static void AddCertificatesToNativeChain(UnityTls.unitytls_x509list* nativeCertificateChain, X509CertificateCollection certificates, UnityTls.unitytls_errorstate* errorState) + public static void AddCertificatesToNativeChain (UnityTls.unitytls_x509list* nativeCertificateChain, X509CertificateCollection certificates, UnityTls.unitytls_errorstate* errorState) { foreach (var certificate in certificates) { - AddCertificateToNativeChain(nativeCertificateChain, certificate, errorState); + AddCertificateToNativeChain (nativeCertificateChain, certificate, errorState); } } - public static void AddCertificateToNativeChain(UnityTls.unitytls_x509list* nativeCertificateChain, X509Certificate certificate, UnityTls.unitytls_errorstate* errorState) + public static void AddCertificateToNativeChain (UnityTls.unitytls_x509list* nativeCertificateChain, X509Certificate certificate, UnityTls.unitytls_errorstate* errorState) { - byte[] certDer = certificate.GetRawCertData(); + byte[] certDer = certificate.GetRawCertData (); fixed(byte* certDerPtr = certDer) { - UnityTls.unitytls_x509list_append_der(nativeCertificateChain, certDerPtr, certDer.Length, errorState); + UnityTls.unitytls_x509list_append_der (nativeCertificateChain, certDerPtr, certDer.Length, errorState); } var certificateImpl2 = certificate.Impl as X509Certificate2Impl; @@ -24,19 +24,19 @@ public static void AddCertificateToNativeChain(UnityTls.unitytls_x509list* nativ var intermediates = certificateImpl2.IntermediateCertificates; if (intermediates != null && intermediates.Count > 0) { for (int i=0; i Date: Thu, 14 Dec 2017 18:43:07 +0100 Subject: [PATCH 039/582] [unitytls] Removed full mapping of ciphersuite enum since it is not needed. --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 6 + .../Mono.UnityTls/UnityTlsCiphersuites.cs | 350 ------------------ mcs/class/System/common.sources | 1 - 3 files changed, 6 insertions(+), 351 deletions(-) delete mode 100644 mcs/class/System/Mono.UnityTls/UnityTlsCiphersuites.cs diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index 8349b5b9b0b8..11cf0305aab3 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -212,6 +212,12 @@ public struct unitytls_tlsctx {} [StructLayout (LayoutKind.Sequential)] public struct unitytls_tlsctx_ref { UInt64 handle; } + public enum unitytls_ciphersuite : UInt32 + { + // With exception of the INVALID value, this enum represents an IANA cipher ID. + UNITYTLS_CIPHERSUITE_INVALID = 0xFFFFFF + } + public enum unitytls_protocol : UInt32 { UNITYTLS_PROTOCOL_TLS_1_0, diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsCiphersuites.cs b/mcs/class/System/Mono.UnityTls/UnityTlsCiphersuites.cs deleted file mode 100644 index 41e35d095577..000000000000 --- a/mcs/class/System/Mono.UnityTls/UnityTlsCiphersuites.cs +++ /dev/null @@ -1,350 +0,0 @@ -using System; - -namespace Mono.Unity -{ - unsafe internal static partial class UnityTls - { - public enum unitytls_ciphersuite : UInt32 - { - UNITYTLS_CIPHERSUITE_TLS_NULL_WITH_NULL_NULL = 0x00, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_NULL_MD5 = 0x01, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_NULL_SHA = 0x02, - UNITYTLS_CIPHERSUITE_TLS_RSA_EXPORT_WITH_RC4_40_MD5 = 0x03, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_RC4_128_MD5 = 0x04, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_RC4_128_SHA = 0x05, - UNITYTLS_CIPHERSUITE_TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 = 0x06, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_IDEA_CBC_SHA = 0x07, - UNITYTLS_CIPHERSUITE_TLS_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x08, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_DES_CBC_SHA = 0x09, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_3DES_EDE_CBC_SHA = 0x0a, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA = 0x0b, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_DES_CBC_SHA = 0x0c, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA = 0x0d, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x0e, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_DES_CBC_SHA = 0x0f, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA = 0x10, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA = 0x11, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_DES_CBC_SHA = 0x12, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA = 0x13, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA = 0x14, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_DES_CBC_SHA = 0x15, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA = 0x16, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 = 0x17, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_RC4_128_MD5 = 0x18, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA = 0x19, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_DES_CBC_SHA = 0x1a, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_3DES_EDE_CBC_SHA = 0x1b, - UNITYTLS_CIPHERSUITE_SSL_FORTEZZA_KEA_WITH_NULL_SHA = 0x1c, - UNITYTLS_CIPHERSUITE_SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA = 0x1d, - //UNITYTLS_CIPHERSUITE_SSL_FORTEZZA_KEA_WITH_RC4_128_SHA = 0x1e, - UNITYTLS_CIPHERSUITE_TLS_KRB5_WITH_DES_CBC_SHA = 0x1e, - UNITYTLS_CIPHERSUITE_TLS_KRB5_WITH_3DES_EDE_CBC_SHA = 0x1f, - UNITYTLS_CIPHERSUITE_TLS_KRB5_WITH_RC4_128_SHA = 0x20, - UNITYTLS_CIPHERSUITE_TLS_KRB5_WITH_IDEA_CBC_SHA = 0x21, - UNITYTLS_CIPHERSUITE_TLS_KRB5_WITH_DES_CBC_MD5 = 0x22, - UNITYTLS_CIPHERSUITE_TLS_KRB5_WITH_3DES_EDE_CBC_MD5 = 0x23, - UNITYTLS_CIPHERSUITE_TLS_KRB5_WITH_RC4_128_MD5 = 0x24, - UNITYTLS_CIPHERSUITE_TLS_KRB5_WITH_IDEA_CBC_MD5 = 0x25, - UNITYTLS_CIPHERSUITE_TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA = 0x26, - UNITYTLS_CIPHERSUITE_TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA = 0x27, - UNITYTLS_CIPHERSUITE_TLS_KRB5_EXPORT_WITH_RC4_40_SHA = 0x28, - UNITYTLS_CIPHERSUITE_TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5 = 0x29, - UNITYTLS_CIPHERSUITE_TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5 = 0x2a, - UNITYTLS_CIPHERSUITE_TLS_KRB5_EXPORT_WITH_RC4_40_MD5 = 0x2b, - UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_NULL_SHA = 0x2c, - UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_NULL_SHA = 0x2d, - UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_NULL_SHA = 0x2e, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_128_CBC_SHA = 0x2f, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_AES_128_CBC_SHA = 0x30, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_AES_128_CBC_SHA = 0x31, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_AES_128_CBC_SHA = 0x32, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_128_CBC_SHA = 0x33, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_AES_128_CBC_SHA = 0x34, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_256_CBC_SHA = 0x35, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_AES_256_CBC_SHA = 0x36, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_AES_256_CBC_SHA = 0x37, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_AES_256_CBC_SHA = 0x38, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_256_CBC_SHA = 0x39, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_AES_256_CBC_SHA = 0x3a, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_NULL_SHA256 = 0x3b, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_128_CBC_SHA256 = 0x3c, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_256_CBC_SHA256 = 0x3d, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_AES_128_CBC_SHA256 = 0x3e, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_AES_128_CBC_SHA256 = 0x3f, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 = 0x40, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA = 0x41, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA = 0x42, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA = 0x43, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA = 0x44, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA = 0x45, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA = 0x46, - - UNITYTLS_CIPHERSUITE_TLS_RSA_EXPORT1024_WITH_RC4_56_MD5 = 0x60, - UNITYTLS_CIPHERSUITE_TLS_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 = 0x61, - UNITYTLS_CIPHERSUITE_TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA = 0x62, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA = 0x63, - UNITYTLS_CIPHERSUITE_TLS_RSA_EXPORT1024_WITH_RC4_56_SHA = 0x64, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA = 0x65, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_RC4_128_SHA = 0x66, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 = 0x67, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_AES_256_CBC_SHA256 = 0x68, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_AES_256_CBC_SHA256 = 0x69, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 = 0x6a, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 = 0x6b, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_AES_128_CBC_SHA256 = 0x6c, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_AES_256_CBC_SHA256 = 0x6d, - - UNITYTLS_CIPHERSUITE_TLS_GOSTR341094_WITH_28147_CNT_IMIT = 0x80, - UNITYTLS_CIPHERSUITE_TLS_GOSTR341001_WITH_28147_CNT_IMIT = 0x81, - UNITYTLS_CIPHERSUITE_TLS_GOSTR341001_WITH_NULL_GOSTR3411 = 0x82, - UNITYTLS_CIPHERSUITE_TLS_GOSTR341094_WITH_NULL_GOSTR3411 = 0x83, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA = 0x84, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA = 0x85, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA = 0x86, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA = 0x87, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA = 0x88, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA = 0x89, - UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_RC4_128_SHA = 0x8a, - UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_3DES_EDE_CBC_SHA = 0x8b, - UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_AES_128_CBC_SHA = 0x8c, - UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_AES_256_CBC_SHA = 0x8d, - UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_RC4_128_SHA = 0x8e, - UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA = 0x8f, - UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_AES_128_CBC_SHA = 0x90, - UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_AES_256_CBC_SHA = 0x91, - UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_RC4_128_SHA = 0x92, - UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA = 0x93, - UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_AES_128_CBC_SHA = 0x94, - UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_AES_256_CBC_SHA = 0x95, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_SEED_CBC_SHA = 0x96, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_SEED_CBC_SHA = 0x97, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_SEED_CBC_SHA = 0x98, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_SEED_CBC_SHA = 0x99, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_SEED_CBC_SHA = 0x9a, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_SEED_CBC_SHA = 0x9b, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_128_GCM_SHA256 = 0x9c, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_256_GCM_SHA384 = 0x9d, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 = 0x9e, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 = 0x9f, - - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_AES_128_GCM_SHA256 = 0xa0, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_AES_256_GCM_SHA384 = 0xa1, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 = 0xa2, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 = 0xa3, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_AES_128_GCM_SHA256 = 0xa4, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_AES_256_GCM_SHA384 = 0xa5, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_AES_128_GCM_SHA256 = 0xa6, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_AES_256_GCM_SHA384 = 0xa7, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 = 0xba, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 = 0xbb, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 = 0xbc, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 = 0xbd, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 = 0xbe, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256 = 0xbf, - - UNITYTLS_CIPHERSUITE_TLS_EMPTY_RENEGOTIATION_INFO_SCSV = 0x5600, - - UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_NULL_SHA = 0xc001, - UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_RC4_128_SHA = 0xc002, - UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA = 0xc003, - UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA = 0xc004, - UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA = 0xc005, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_NULL_SHA = 0xc006, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA = 0xc007, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA = 0xc008, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA = 0xc009, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA = 0xc00a, - UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_NULL_SHA = 0xc00b, - UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_RC4_128_SHA = 0xc00c, - UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA = 0xc00d, - UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA = 0xc00e, - UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA = 0xc00f, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_NULL_SHA = 0xc010, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_RC4_128_SHA = 0xc011, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA = 0xc012, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA = 0xc013, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA = 0xc014, - UNITYTLS_CIPHERSUITE_TLS_ECDH_anon_WITH_NULL_SHA = 0xc015, - UNITYTLS_CIPHERSUITE_TLS_ECDH_anon_WITH_RC4_128_SHA = 0xc016, - UNITYTLS_CIPHERSUITE_TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA = 0xc017, - UNITYTLS_CIPHERSUITE_TLS_ECDH_anon_WITH_AES_128_CBC_SHA = 0xc018, - UNITYTLS_CIPHERSUITE_TLS_ECDH_anon_WITH_AES_256_CBC_SHA = 0xc019, - UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA = 0xc01a, - UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA = 0xc01b, - UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA = 0xc01c, - UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_WITH_AES_128_CBC_SHA = 0xc01d, - UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA = 0xc01e, - UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA = 0xc01f, - UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_WITH_AES_256_CBC_SHA = 0xc020, - UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA = 0xc021, - UNITYTLS_CIPHERSUITE_TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA = 0xc022, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 = 0xc023, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 = 0xc024, - UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 = 0xc025, - UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 = 0xc026, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 = 0xc027, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 = 0xc028, - UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 = 0xc029, - UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 = 0xc02a, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 = 0xc02b, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 = 0xc02c, - UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 = 0xc02d, - UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 = 0xc02e, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 = 0xc02f, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 = 0xc030, - UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 = 0xc031, - UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 = 0xc032, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_RC4_128_SHA = 0xc033, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA = 0xc034, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA = 0xc035, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA = 0xc036, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 = 0xc037, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 = 0xc038, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_NULL_SHA = 0xc039, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_NULL_SHA256 = 0xc03A, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_NULL_SHA384 = 0xc03B, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_ARIA_128_CBC_SHA256 = 0xc03C, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_ARIA_256_CBC_SHA384 = 0xc03D, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256 = 0xc03E, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384 = 0xc03F, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256 = 0xc040, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384 = 0xc041, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256 = 0xc042, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384 = 0xc043, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256 = 0xc044, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384 = 0xc045, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_ARIA_128_CBC_SHA256 = 0xc046, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_ARIA_256_CBC_SHA384 = 0xc047, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256 = 0xc048, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384 = 0xc049, - UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256 = 0xc04A, - UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384 = 0xc04B, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256 = 0xc04C, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384 = 0xc04D, - UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256 = 0xc04E, - UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384 = 0xc04F, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_ARIA_128_GCM_SHA256 = 0xc050, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_ARIA_256_GCM_SHA384 = 0xc051, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256 = 0xc052, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384 = 0xc053, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256 = 0xc054, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384 = 0xc055, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256 = 0xc056, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384 = 0xc057, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256 = 0xc058, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384 = 0xc059, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_ARIA_128_GCM_SHA256 = 0xc05A, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_ARIA_256_GCM_SHA384 = 0xc05B, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 = 0xc05C, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 = 0xc05D, - UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 = 0xc05E, - UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 = 0xc05F, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 = 0xc060, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 = 0xc061, - UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 = 0xc062, - UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 = 0xc063, - UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_ARIA_128_CBC_SHA256 = 0xc064, - UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_ARIA_256_CBC_SHA384 = 0xc065, - UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256 = 0xc066, - UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384 = 0xc067, - UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256 = 0xc068, - UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384 = 0xc069, - UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_ARIA_128_GCM_SHA256 = 0xc06A, - UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_ARIA_256_GCM_SHA384 = 0xc06B, - UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256 = 0xc06C, - UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384 = 0xc06D, - UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256 = 0xc06E, - UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384 = 0xc06F, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256 = 0xc070, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384 = 0xc071, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 = 0xc072, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 = 0xc073, - UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 = 0xc074, - UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 = 0xc075, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 = 0xc076, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 = 0xc077, - UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 = 0xc078, - UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 = 0xc079, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 = 0xc07A, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 = 0xc07B, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 = 0xc07C, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 = 0xc07D, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256 = 0xc07E, - UNITYTLS_CIPHERSUITE_TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384 = 0xc07F, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256 = 0xc080, - UNITYTLS_CIPHERSUITE_TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384 = 0xc081, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256 = 0xc082, - UNITYTLS_CIPHERSUITE_TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384 = 0xc083, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256 = 0xc084, - UNITYTLS_CIPHERSUITE_TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384 = 0xc085, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 = 0xc086, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 = 0xc087, - UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 = 0xc088, - UNITYTLS_CIPHERSUITE_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 = 0xc089, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 = 0xc08A, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 = 0xc08B, - UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 = 0xc08C, - UNITYTLS_CIPHERSUITE_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 = 0xc08D, - UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 = 0xc08E, - UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 = 0xc08F, - UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 = 0xc090, - UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 = 0xc091, - UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 = 0xc092, - UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 = 0xc093, - UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 = 0xc094, - UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 = 0xc095, - UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 = 0xc096, - UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 = 0xc097, - UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 = 0xc098, - UNITYTLS_CIPHERSUITE_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 = 0xc099, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 = 0xc09A, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 = 0xc09B, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_128_CCM = 0xc09c, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_256_CCM = 0xc09d, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_128_CCM = 0xc09e, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_256_CCM = 0xc09f, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_128_CCM_8 = 0xc0a0, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_AES_256_CCM_8 = 0xc0a1, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_128_CCM_8 = 0xc0a2, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_AES_256_CCM_8 = 0xc0a3, - UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_AES_128_CCM = 0xc0a4, - UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_AES_256_CCM = 0xc0a5, - UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_AES_128_CCM = 0xc0a6, - UNITYTLS_CIPHERSUITE_TLS_DHE_PSK_WITH_AES_256_CCM = 0xc0a7, - UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_AES_128_CCM_8 = 0xc0a8, - UNITYTLS_CIPHERSUITE_TLS_PSK_WITH_AES_256_CCM_8 = 0xc0a9, - UNITYTLS_CIPHERSUITE_TLS_PSK_DHE_WITH_AES_128_CCM_8 = 0xc0aa, - UNITYTLS_CIPHERSUITE_TLS_PSK_DHE_WITH_AES_256_CCM_8 = 0xc0ab, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_128_CCM = 0xc0ac, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_256_CCM = 0xc0ad, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 = 0xc0ae, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 = 0xc0af, - - UNITYTLS_CIPHERSUITE_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256_OLD = 0xcc13, - UNITYTLS_CIPHERSUITE_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256_OLD = 0xcc14, - UNITYTLS_CIPHERSUITE_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256_OLD = 0xcc15, - - // GOST - UNITYTLS_CIPHERSUITE_TLS_GOSTR341094_RSA_WITH_28147_CNT_MD5 = 0xff00, - UNITYTLS_CIPHERSUITE_TLS_RSA_WITH_28147_CNT_GOST94 = 0xff01, - UNITYTLS_CIPHERSUITE_GOST_89MAC = 0xff02, - UNITYTLS_CIPHERSUITE_GOST_89STREAM = 0xff03, - - UNITYTLS_CIPHERSUITE_SSL_RSA_FIPS_WITH_DES_CBC_SHA = 0xfefe, - UNITYTLS_CIPHERSUITE_SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA = 0xfeff, - //UNITYTLS_CIPHERSUITE_SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA = 0xfee0, - //UNITYTLS_CIPHERSUITE_SSL_RSA_FIPS_WITH_DES_CBC_SHA = 0xfee1, - - UNITYTLS_CIPHERSUITE_SSL_CK_RC4_128_WITH_MD5 = 0x010080, - UNITYTLS_CIPHERSUITE_SSL_CK_RC4_128_EXPORT40_WITH_MD5 = 0x020080, - UNITYTLS_CIPHERSUITE_SSL_CK_RC2_128_CBC_WITH_MD5 = 0x030080, - UNITYTLS_CIPHERSUITE_SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5 = 0x040080, - UNITYTLS_CIPHERSUITE_SSL_CK_IDEA_128_CBC_WITH_MD5 = 0x050080, - UNITYTLS_CIPHERSUITE_SSL_CK_DES_64_CBC_WITH_MD5 = 0x060040, - UNITYTLS_CIPHERSUITE_SSL_CK_DES_192_EDE3_CBC_WITH_MD5 = 0x0700c0, - UNITYTLS_CIPHERSUITE_SSL_CK_RC4_64_WITH_MD5 = 0x080080, - - UNITYTLS_CIPHERSUITE_INVALID = 0xFFFFFF - } - } -} \ No newline at end of file diff --git a/mcs/class/System/common.sources b/mcs/class/System/common.sources index c3c3c8fdb8ec..0e7e4bea647f 100644 --- a/mcs/class/System/common.sources +++ b/mcs/class/System/common.sources @@ -259,7 +259,6 @@ Mono.AppleTls/SslConnection.cs Mono.AppleTls/Items.cs Mono.UnityTls/UnityTls.cs -Mono.UnityTls/UnityTlsCiphersuites.cs Mono.UnityTls/UnityTlsProvider.cs Mono.UnityTls/UnityTlsStream.cs Mono.UnityTls/UnityTlsContext.cs From 445e584f1d8a25cc720ec6e42ca6eac0f915ff49 Mon Sep 17 00:00:00 2001 From: andreasr Date: Fri, 15 Dec 2017 10:41:22 +0100 Subject: [PATCH 040/582] [sslstreamtest] Added check for correct certificates and no policy errors --- .../Test/System.Net.Security/SslStreamTest.cs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs b/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs index d821a9dbd92f..cf30fac8e1b0 100644 --- a/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs +++ b/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs @@ -58,7 +58,7 @@ public void GetReady () { m_clientCert = new X509Certificate2 (m_clientCertRaw, "client"); } - [Test] //bug https://bugzilla.novell.com/show_bug.cgi?id=457120 + [Test] #if !UNITY [Category ("MacNotWorking")] // Works but launches a prompt on 10.12 that will fail if you don't click in a few seconds #endif @@ -107,7 +107,7 @@ private void StartClientAndAuthenticate (ClientServerState state, state.Client.Connect (endPoint.Address, endPoint.Port); NetworkStream s = state.Client.GetStream (); state.ClientStream = new SslStream (s, false, - (a1, a2, a3, a4) => true, + ClientRemoteCertificateValidationCallback, (a1, a2, a3, a4, a5) => m_clientCert); state.ClientStream.AuthenticateAsClient ("test_host"); state.ClientAuthenticated.Set (); @@ -123,7 +123,7 @@ private void StartServerAndAuthenticate (ClientServerState state) { state.ServerClient = state.Listener.AcceptTcpClient (); NetworkStream s = state.ServerClient.GetStream (); state.ServerStream = new SslStream (s, false, - (a1, a2, a3, a4) => true, + ServerRemoteCertificateValidationCallback, (a1, a2, a3, a4, a5) => m_serverCert); state.ServerStream.AuthenticateAsServer (m_serverCert); state.ServerAuthenticated.Set (); @@ -136,7 +136,21 @@ private void StartServerAndAuthenticate (ClientServerState state) { throw; } } - + + public bool ClientRemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) + { + Assert.AreEqual(m_serverCert.RawData, certificate.GetRawCertData(), "Client remote certification callback received a certificate that is not identical to the expected server cert."); + Assert.AreEqual(SslPolicyErrors.None, sslPolicyErrors); + return true; + } + + public bool ServerRemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) + { + Assert.AreEqual(m_clientCert.RawData, certificate.GetRawCertData(), "Server remote certification callback received a certificate that is not identical to the expected client cert."); + Assert.AreEqual(SslPolicyErrors.None, sslPolicyErrors); + return true; + } + private class ClientServerState { public TcpListener Listener { get; set; } public TcpClient Client { get; set; } From 594e2ac196152c67f17d643f210001034d33f2b3 Mon Sep 17 00:00:00 2001 From: andreasr Date: Fri, 15 Dec 2017 10:59:54 +0100 Subject: [PATCH 041/582] [sslstreamtest] a few renamings for clarification --- .../Test/System.Net.Security/SslStreamTest.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs b/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs index cf30fac8e1b0..978a472ad577 100644 --- a/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs +++ b/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs @@ -58,7 +58,7 @@ public void GetReady () { m_clientCert = new X509Certificate2 (m_clientCertRaw, "client"); } - [Test] + [TestCase()] #if !UNITY [Category ("MacNotWorking")] // Works but launches a prompt on 10.12 that will fail if you don't click in a few seconds #endif @@ -67,10 +67,10 @@ public void GetReady () { #endif public void AuthenticateClientAndServer_ClientSendsNoData () { - AuthenticateClientAndServer (true, true); + AuthenticateClientAndServer (serverAuthShouldSucceed: true, clientAuthShouldSucceed: true); } - void AuthenticateClientAndServer (bool server, bool client) + void AuthenticateClientAndServer (bool serverAuthShouldSucceed, bool clientAuthShouldSucceed) { IPEndPoint endPoint = new IPEndPoint (IPAddress.Parse ("127.0.0.1"), NetworkHelpers.FindFreePort ()); ClientServerState state = new ClientServerState (); @@ -79,15 +79,15 @@ void AuthenticateClientAndServer (bool server, bool client) state.Listener.Start (); state.ServerAuthenticated = new AutoResetEvent (false); state.ClientAuthenticated = new AutoResetEvent (false); - state.ServerIOException = !server; + state.AllowServerIOException = !serverAuthShouldSucceed; try { Thread serverThread = new Thread (() => StartServerAndAuthenticate (state)); serverThread.Start (); Thread clientThread = new Thread (() => StartClientAndAuthenticate (state, endPoint)); clientThread.Start (); - Assert.AreEqual (server, state.ServerAuthenticated.WaitOne (TimeSpan.FromSeconds (5)), + Assert.AreEqual (serverAuthShouldSucceed, state.ServerAuthenticated.WaitOne (TimeSpan.FromSeconds (5)), "server not authenticated"); - Assert.AreEqual (client, state.ClientAuthenticated.WaitOne (TimeSpan.FromSeconds (5)), + Assert.AreEqual (clientAuthShouldSucceed, state.ClientAuthenticated.WaitOne (TimeSpan.FromSeconds (5)), "client not authenticated"); } finally { if (state.ClientStream != null) @@ -113,7 +113,7 @@ private void StartClientAndAuthenticate (ClientServerState state, state.ClientAuthenticated.Set (); } catch (ObjectDisposedException) { /* this can happen when closing connection it's irrelevant for the test result*/ } catch (IOException) { - if (!state.ServerIOException) + if (!state.AllowServerIOException) throw; } } @@ -132,7 +132,7 @@ private void StartServerAndAuthenticate (ClientServerState state) { // The authentication or decryption has failed. // ---> Mono.Security.Protocol.Tls.TlsException: Insuficient Security // that's fine for MismatchedCipherSuites - if (!state.ServerIOException) + if (!state.AllowServerIOException) throw; } } @@ -159,7 +159,7 @@ private class ClientServerState { public SslStream ClientStream { get; set; } public AutoResetEvent ServerAuthenticated { get; set; } public AutoResetEvent ClientAuthenticated { get; set; } - public bool ServerIOException { get; set; } + public bool AllowServerIOException { get; set; } } } } From ca572383290ef354037d2388ffdc9cb303086564 Mon Sep 17 00:00:00 2001 From: andreasr Date: Fri, 15 Dec 2017 11:31:25 +0100 Subject: [PATCH 042/582] [unitytls] Added exception handling for native callbacks as a safety precaution --- .../System/Mono.UnityTls/UnityTlsContext.cs | 72 +++++++++++-------- 1 file changed, 43 insertions(+), 29 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index 90ebddf95105..e47b5fd7c518 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -260,17 +260,22 @@ static private size_t WriteCallback (void* userData, byte* data, size_t bufferLe private size_t WriteCallback (byte* data, size_t bufferLen, UnityTls.unitytls_errorstate* errorState) { - if (m_WriteBuffer == null || m_WriteBuffer.Length < bufferLen) - m_WriteBuffer = new byte[bufferLen]; - Marshal.Copy ((IntPtr)data, m_WriteBuffer, 0, bufferLen); + try { + if (m_WriteBuffer == null || m_WriteBuffer.Length < bufferLen) + m_WriteBuffer = new byte[bufferLen]; + Marshal.Copy ((IntPtr)data, m_WriteBuffer, 0, bufferLen); - if (!Parent.InternalWrite (m_WriteBuffer, 0, bufferLen)) - { - UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WRITE_FAILED); + if (!Parent.InternalWrite (m_WriteBuffer, 0, bufferLen)) + { + UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WRITE_FAILED); + return 0; + } + + return bufferLen; + } catch { // handle all exceptions since we don't want to let them go through native code. + UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); return 0; } - - return bufferLen; } [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_callback_read))] @@ -283,23 +288,28 @@ static private size_t ReadCallback (void* userData, byte* buffer, size_t bufferL private size_t ReadCallback (byte* buffer, size_t bufferLen, UnityTls.unitytls_errorstate* errorState) { - if (m_ReadBuffer == null || m_ReadBuffer.Length < bufferLen) - m_ReadBuffer = new byte [bufferLen]; - - bool wouldBlock; - int numBytesRead = Parent.InternalRead (m_ReadBuffer, 0, bufferLen, out wouldBlock); - if (numBytesRead < 0) - { - UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_READ_FAILED); + try { + if (m_ReadBuffer == null || m_ReadBuffer.Length < bufferLen) + m_ReadBuffer = new byte [bufferLen]; + + bool wouldBlock; + int numBytesRead = Parent.InternalRead (m_ReadBuffer, 0, bufferLen, out wouldBlock); + if (numBytesRead < 0) + { + UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_READ_FAILED); + return 0; + } + if (wouldBlock) + { + UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK); + } + + Marshal.Copy (m_ReadBuffer, 0, (IntPtr)buffer, bufferLen); + return numBytesRead; + } catch { // handle all exceptions since we don't want to let them go through native code. + UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); return 0; } - if (wouldBlock) - { - UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK); - } - - Marshal.Copy (m_ReadBuffer, 0, (IntPtr)buffer, bufferLen); - return numBytesRead; } [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_callback_read))] @@ -312,12 +322,16 @@ static private UnityTls.unitytls_x509verify_result VerifyCallback (void* userDat private UnityTls.unitytls_x509verify_result VerifyCallback (UnityTls.unitytls_x509list_ref chain, UnityTls.unitytls_errorstate* errorState) { - X509CertificateCollection certificates = CertHelper.NativeChainToManagedCollection (chain, errorState); - - if (ValidateCertificate (certificates)) - return UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_SUCCESS; - else - return UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED; + try { + X509CertificateCollection certificates = CertHelper.NativeChainToManagedCollection (chain, errorState); + + if (ValidateCertificate (certificates)) + return UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_SUCCESS; + else + return UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED; + } catch { // handle all exceptions since we don't want to let them go through native code. + return UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FATAL_ERROR; + } } [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_callback_trace))] From af91c353b2df247483fca4965a07ad9963c52a58 Mon Sep 17 00:00:00 2001 From: andreasr Date: Fri, 15 Dec 2017 12:00:43 +0100 Subject: [PATCH 043/582] [unitytls] implemented data read/write --- .../System/Mono.UnityTls/UnityTlsContext.cs | 59 ++++++++++++------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index e47b5fd7c518..9d11ae95dcf9 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -26,7 +26,6 @@ namespace Mono.Unity { unsafe internal class UnityTlsContext : MobileTlsContext { - private const int MaxIOBufferSize = 16384; private const bool ActivateTracing = false; // Native UnityTls objects @@ -167,23 +166,50 @@ public override void Flush () public override int Read (byte [] buffer, int offset, int count, out bool wouldBlock) { wouldBlock = false; + int numBytesRead = 0; - int bufferSize = System.Math.Min (MaxIOBufferSize, count); - // TODO - return 0; + UnityTls.unitytls_errorstate errorState = UnityTls.unitytls_errorstate_create (); + fixed (byte* bufferPtr = buffer) { + numBytesRead = UnityTls.unitytls_tlsctx_read (m_TlsContext, bufferPtr + offset, count, &errorState); + } + + if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) + wouldBlock = true; + else + Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to read data from TLS context"); + + return numBytesRead; } public override int Write (byte [] buffer, int offset, int count, out bool wouldBlock) { wouldBlock = false; + int numBytesWritten = 0; + + UnityTls.unitytls_errorstate errorState = UnityTls.unitytls_errorstate_create (); + fixed (byte* bufferPtr = buffer) { + numBytesWritten = UnityTls.unitytls_tlsctx_write (m_TlsContext, bufferPtr + offset, count, &errorState); + } - int bufferSize = System.Math.Min (MaxIOBufferSize, count); - // TODO - return 0; + if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) + wouldBlock = true; + else + Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to write data to TLS context"); + + return numBytesWritten; } public override void Close () { + // Destroy native UnityTls objects + UnityTls.unitytls_tlsctx_free (m_TlsContext); + m_TlsContext = null; + UnityTls.unitytls_x509list_free (m_ServerCerts); + m_ServerCerts = null; + UnityTls.unitytls_key_free (m_ServerPrivateKey); + m_ServerPrivateKey = null; + + m_HasContext = false; } protected override void Dispose (bool disposing) @@ -191,13 +217,7 @@ protected override void Dispose (bool disposing) try { if (disposing) { - // Destroy native UnityTls objects - UnityTls.unitytls_tlsctx_free (m_TlsContext); - m_TlsContext = null; - UnityTls.unitytls_x509list_free (m_ServerCerts); - m_ServerCerts = null; - UnityTls.unitytls_key_free (m_ServerPrivateKey); - m_ServerPrivateKey = null; + Close(); // reset states m_LocalClientCertificate = null; @@ -217,7 +237,6 @@ protected override void Dispose (bool disposing) public override void StartHandshake () { // TODO: Check if we started a handshake already? - // TODO, Not supported by UnityTls as of writing if (IsServer && AskForClientCertificate) { throw new NotImplementedException ("No support for client certificate check yet."); @@ -265,8 +284,7 @@ private size_t WriteCallback (byte* data, size_t bufferLen, UnityTls.unitytls_er m_WriteBuffer = new byte[bufferLen]; Marshal.Copy ((IntPtr)data, m_WriteBuffer, 0, bufferLen); - if (!Parent.InternalWrite (m_WriteBuffer, 0, bufferLen)) - { + if (!Parent.InternalWrite (m_WriteBuffer, 0, bufferLen)) { UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WRITE_FAILED); return 0; } @@ -294,15 +312,12 @@ private size_t ReadCallback (byte* buffer, size_t bufferLen, UnityTls.unitytls_e bool wouldBlock; int numBytesRead = Parent.InternalRead (m_ReadBuffer, 0, bufferLen, out wouldBlock); - if (numBytesRead < 0) - { + if (numBytesRead < 0) { UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_READ_FAILED); return 0; } - if (wouldBlock) - { + if (wouldBlock) UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK); - } Marshal.Copy (m_ReadBuffer, 0, (IntPtr)buffer, bufferLen); return numBytesRead; From 5bb3eb64dfb84dcaf4b586e1c286ae4807fb5faa Mon Sep 17 00:00:00 2001 From: andreasr Date: Fri, 15 Dec 2017 12:26:57 +0100 Subject: [PATCH 044/582] [unitytls] Filling out MonoTlsConnectionInfo now --- .../System/Mono.UnityTls/UnityTlsContext.cs | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index 9d11ae95dcf9..94091425703e 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -133,6 +133,21 @@ static private UnityTls.unitytls_protocol GetMaxProtocol (SslProtocols protocols return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_0; // Behavior as in AppleTlsContext } + static private TlsProtocols ConvertProtocolVersion(UnityTls.unitytls_protocol protocol) + { + switch (protocol) + { + case UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_0: + return TlsProtocols.Tls10; + case UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_1: + return TlsProtocols.Tls11; + case UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_2: + return TlsProtocols.Tls12; + case UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_INVALID: + return TlsProtocols.Zero; + } + return TlsProtocols.Zero; + } public override bool HasContext { get { return m_HasContext; } @@ -260,11 +275,22 @@ public override bool ProcessHandshake () public override void FinishHandshake () { + // Query some data. Ignore errors on the way since failure is not crucial. + UnityTls.unitytls_ciphersuite cipherSuite = UnityTls.unitytls_tlsctx_get_ciphersuite(m_TlsContext, null); + UnityTls.unitytls_protocol protocolVersion = UnityTls.unitytls_tlsctx_get_protocol(m_TlsContext, null); + m_Connectioninfo = new MonoTlsConnectionInfo () { - // TODO - //CipherSuiteCode = , - //ProtocolVersion = , + CipherSuiteCode = (CipherSuiteCode)cipherSuite, + ProtocolVersion = ConvertProtocolVersion(protocolVersion), PeerDomainName = ServerName + + // TODO: + // The following properties can be deducted from CipherSuiteCode. + // It looks though like as of writing no Mono implemention fills it out and there is also no mechanism that does that automatically + // + //CipherAlgorithmType + //HashAlgorithmType + //ExchangeAlgorithmType }; m_IsAuthenticated = true; } From 9ea74ae02c62b2a117b1dfb81325e30939f62845 Mon Sep 17 00:00:00 2001 From: andreasr Date: Fri, 15 Dec 2017 12:39:25 +0100 Subject: [PATCH 045/582] [unitytls] moved conversion functions into separate file --- mcs/class/System/Mono.UnityTLS/Debug.cs | 35 +------- .../Mono.UnityTLS/UnityTlsConversions.cs | 88 +++++++++++++++++++ .../System/Mono.UnityTls/UnityTlsContext.cs | 44 +--------- mcs/class/System/common.sources | 1 + 4 files changed, 93 insertions(+), 75 deletions(-) create mode 100644 mcs/class/System/Mono.UnityTLS/UnityTlsConversions.cs diff --git a/mcs/class/System/Mono.UnityTLS/Debug.cs b/mcs/class/System/Mono.UnityTLS/Debug.cs index cb5248d96463..74ab6941f28c 100644 --- a/mcs/class/System/Mono.UnityTLS/Debug.cs +++ b/mcs/class/System/Mono.UnityTLS/Debug.cs @@ -22,39 +22,6 @@ public static void CheckAndThrow (UnityTls.unitytls_errorstate errorState, strin throw new TlsException (defaultAlert, message); } - public static AlertDescription VerifyResultToAlertDescription (UnityTls.unitytls_x509verify_result verifyResult, AlertDescription defaultAlert = AlertDescription.InternalError) - { - if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_EXPIRED)) - return AlertDescription.CertificateExpired; - else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_REVOKED)) - return AlertDescription.CertificateRevoked; - else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_CN_MISMATCH)) - return AlertDescription.UnknownCA; - else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED)) - return AlertDescription.CertificateUnknown; - - else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR1)) - return AlertDescription.UserCancelled; - else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR2)) - return AlertDescription.UserCancelled; - else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR2)) - return AlertDescription.UserCancelled; - else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR3)) - return AlertDescription.UserCancelled; - else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR4)) - return AlertDescription.UserCancelled; - else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR5)) - return AlertDescription.UserCancelled; - else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR6)) - return AlertDescription.UserCancelled; - else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR7)) - return AlertDescription.UserCancelled; - else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR8)) - return AlertDescription.UserCancelled; - - return defaultAlert; - } - public static void CheckAndThrow(UnityTls.unitytls_errorstate errorState, UnityTls.unitytls_x509verify_result verifyResult, string context, AlertDescription defaultAlert = AlertDescription.InternalError) { // Ignore verify result if verification is not the issue. @@ -63,7 +30,7 @@ public static void CheckAndThrow(UnityTls.unitytls_errorstate errorState, UnityT return; } - AlertDescription alert = VerifyResultToAlertDescription (verifyResult, defaultAlert); + AlertDescription alert = UnityTlsConversions.VerifyResultToAlertDescription (verifyResult, defaultAlert); string message = string.Format ("{0} - error code: {1}, verify result: {2}", context, errorState.code, verifyResult); throw new TlsException (alert, message); } diff --git a/mcs/class/System/Mono.UnityTLS/UnityTlsConversions.cs b/mcs/class/System/Mono.UnityTLS/UnityTlsConversions.cs new file mode 100644 index 000000000000..fcb850c332f3 --- /dev/null +++ b/mcs/class/System/Mono.UnityTLS/UnityTlsConversions.cs @@ -0,0 +1,88 @@ +#if SECURITY_DEP + +#if MONO_SECURITY_ALIAS +extern alias MonoSecurity; +using MonoSecurity::Mono.Security.Interface; +#else +using Mono.Security.Interface; +#endif + +using System.Security.Authentication; + +namespace Mono.Unity +{ + internal static class UnityTlsConversions + { + public static UnityTls.unitytls_protocol GetMinProtocol (SslProtocols protocols) + { + if (protocols.HasFlag (SslProtocols.Tls)) + return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_0; + if (protocols.HasFlag (SslProtocols.Tls11)) + return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_1; + if (protocols.HasFlag (SslProtocols.Tls12)) + return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_2; + return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_2; // Behavior as in AppleTlsContext + } + + public static UnityTls.unitytls_protocol GetMaxProtocol (SslProtocols protocols) + { + if (protocols.HasFlag (SslProtocols.Tls12)) + return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_2; + if (protocols.HasFlag (SslProtocols.Tls11)) + return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_1; + if (protocols.HasFlag (SslProtocols.Tls)) + return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_0; + return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_0; // Behavior as in AppleTlsContext + } + + public static TlsProtocols ConvertProtocolVersion(UnityTls.unitytls_protocol protocol) + { + switch (protocol) + { + case UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_0: + return TlsProtocols.Tls10; + case UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_1: + return TlsProtocols.Tls11; + case UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_2: + return TlsProtocols.Tls12; + case UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_INVALID: + return TlsProtocols.Zero; + } + return TlsProtocols.Zero; + } + + public static AlertDescription VerifyResultToAlertDescription (UnityTls.unitytls_x509verify_result verifyResult, AlertDescription defaultAlert = AlertDescription.InternalError) + { + if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_EXPIRED)) + return AlertDescription.CertificateExpired; + else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_REVOKED)) + return AlertDescription.CertificateRevoked; + else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_CN_MISMATCH)) + return AlertDescription.UnknownCA; + else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED)) + return AlertDescription.CertificateUnknown; + + else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR1)) + return AlertDescription.UserCancelled; + else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR2)) + return AlertDescription.UserCancelled; + else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR2)) + return AlertDescription.UserCancelled; + else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR3)) + return AlertDescription.UserCancelled; + else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR4)) + return AlertDescription.UserCancelled; + else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR5)) + return AlertDescription.UserCancelled; + else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR6)) + return AlertDescription.UserCancelled; + else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR7)) + return AlertDescription.UserCancelled; + else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_USER_ERROR8)) + return AlertDescription.UserCancelled; + + return defaultAlert; + } + } +} +#endif \ No newline at end of file diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index 94091425703e..dda6b00ad3b8 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -61,8 +61,8 @@ public UnityTlsContext ( // Map selected protocols as best as we can. UnityTls.unitytls_tlsctx_protocolrange protocolRange = new UnityTls.unitytls_tlsctx_protocolrange { - min = GetMinProtocol (enabledProtocols), - max = GetMaxProtocol (enabledProtocols), + min = UnityTlsConversions.GetMinProtocol (enabledProtocols), + max = UnityTlsConversions.GetMaxProtocol (enabledProtocols), }; UnityTls.unitytls_tlsctx_callbacks callbacks = new UnityTls.unitytls_tlsctx_callbacks { @@ -111,44 +111,6 @@ public UnityTlsContext ( m_HasContext = true; } - static private UnityTls.unitytls_protocol GetMinProtocol (SslProtocols protocols) - { - if (protocols.HasFlag (SslProtocols.Tls)) - return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_0; - if (protocols.HasFlag (SslProtocols.Tls11)) - return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_1; - if (protocols.HasFlag (SslProtocols.Tls12)) - return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_2; - return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_2; // Behavior as in AppleTlsContext - } - - static private UnityTls.unitytls_protocol GetMaxProtocol (SslProtocols protocols) - { - if (protocols.HasFlag (SslProtocols.Tls12)) - return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_2; - if (protocols.HasFlag (SslProtocols.Tls11)) - return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_1; - if (protocols.HasFlag (SslProtocols.Tls)) - return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_0; - return UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_0; // Behavior as in AppleTlsContext - } - - static private TlsProtocols ConvertProtocolVersion(UnityTls.unitytls_protocol protocol) - { - switch (protocol) - { - case UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_0: - return TlsProtocols.Tls10; - case UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_1: - return TlsProtocols.Tls11; - case UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_TLS_1_2: - return TlsProtocols.Tls12; - case UnityTls.unitytls_protocol.UNITYTLS_PROTOCOL_INVALID: - return TlsProtocols.Zero; - } - return TlsProtocols.Zero; - } - public override bool HasContext { get { return m_HasContext; } } @@ -281,7 +243,7 @@ public override void FinishHandshake () m_Connectioninfo = new MonoTlsConnectionInfo () { CipherSuiteCode = (CipherSuiteCode)cipherSuite, - ProtocolVersion = ConvertProtocolVersion(protocolVersion), + ProtocolVersion = UnityTlsConversions.ConvertProtocolVersion(protocolVersion), PeerDomainName = ServerName // TODO: diff --git a/mcs/class/System/common.sources b/mcs/class/System/common.sources index 0e7e4bea647f..c3b0f8a1bf11 100644 --- a/mcs/class/System/common.sources +++ b/mcs/class/System/common.sources @@ -262,6 +262,7 @@ Mono.UnityTls/UnityTls.cs Mono.UnityTls/UnityTlsProvider.cs Mono.UnityTls/UnityTlsStream.cs Mono.UnityTls/UnityTlsContext.cs +Mono.UnityTls/UnityTlsConversions.cs Mono.UnityTls/Debug.cs Mono.UnityTls/CertHelper.cs From 22b6ae964ab49657a2b2bf56c185101e13b3e08f Mon Sep 17 00:00:00 2001 From: andreasr Date: Fri, 15 Dec 2017 17:08:49 +0100 Subject: [PATCH 046/582] [unitytls] Updated interfaces to newer mono version. Development up until this point happened on unity-2017-02-staging --- .../MonoTlsProviderFactory.cs | 5 +++- .../System/Mono.UnityTls/UnityTlsContext.cs | 16 +++++------ .../System/Mono.UnityTls/UnityTlsProvider.cs | 28 ++++++++++++------- .../System/Mono.UnityTls/UnityTlsStream.cs | 20 +++++++------ 4 files changed, 41 insertions(+), 28 deletions(-) diff --git a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs index 0e28099180d8..b78172fcb9e7 100644 --- a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs +++ b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs @@ -211,6 +211,7 @@ internal static void Debug (string message, params object[] args) #endregion + internal static readonly Guid UnityTlsId = new Guid("06414A97-74F6-488F-877B-A6CA9BBEB82E"); internal static readonly Guid AppleTlsId = new Guid ("981af8af-a3a3-419a-9f01-a518e3a17c1c"); internal static readonly Guid BtlsId = new Guid ("432d18c9-9348-4b90-bfbf-9f2a10e1f15b"); internal static readonly Guid LegacyId = new Guid ("809e77d5-56cc-4da8-b9f0-45e65ba9cceb"); @@ -227,7 +228,9 @@ static void InitializeProviderRegistration () providerCache = new Dictionary (); #if UNITY - providerRegistration.Add ("unitytls", "Mono.Unity.UnityTlsProvider"); + var unityTlsEntry = new Tuple (UnityTlsId, "Mono.Unity.UnityTlsProvider"); + providerRegistration.Add ("default", unityTlsEntry); + providerRegistration.Add ("unitytls", unityTlsEntry); #else var appleTlsEntry = new Tuple (AppleTlsId, "Mono.AppleTls.AppleTlsProvider"); diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index dda6b00ad3b8..2304ff10b891 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -140,9 +140,9 @@ public override void Flush () // NO-OP } - public override int Read (byte [] buffer, int offset, int count, out bool wouldBlock) + public override (int ret, bool wantMore) Read (byte[] buffer, int offset, int count) { - wouldBlock = false; + bool wouldBlock = false; int numBytesRead = 0; UnityTls.unitytls_errorstate errorState = UnityTls.unitytls_errorstate_create (); @@ -155,12 +155,12 @@ public override int Read (byte [] buffer, int offset, int count, out bool wouldB else Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to read data from TLS context"); - return numBytesRead; + return (numBytesRead, wouldBlock); } - public override int Write (byte [] buffer, int offset, int count, out bool wouldBlock) + public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int count) { - wouldBlock = false; + bool wouldBlock = false; int numBytesWritten = 0; UnityTls.unitytls_errorstate errorState = UnityTls.unitytls_errorstate_create (); @@ -173,10 +173,10 @@ public override int Write (byte [] buffer, int offset, int count, out bool would else Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to write data to TLS context"); - return numBytesWritten; + return (numBytesWritten, wouldBlock); } - public override void Close () + public override void Shutdown () { // Destroy native UnityTls objects UnityTls.unitytls_tlsctx_free (m_TlsContext); @@ -194,7 +194,7 @@ protected override void Dispose (bool disposing) try { if (disposing) { - Close(); + Shutdown(); // reset states m_LocalClientCertificate = null; diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs index 4705e479a873..7e9f10940d8c 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs @@ -4,32 +4,31 @@ #endif using System; -using System.IO; using System.Text; -using System.Security.Cryptography.X509Certificates; +using System.IO; +using System.Net.Security; using System.Security.Authentication; +using System.Security.Cryptography.X509Certificates; +using MNS = Mono.Net.Security; #if MONO_SECURITY_ALIAS using MonoSecurity::Mono.Security.Interface; #else using Mono.Security.Interface; #endif -using MNS = Mono.Net.Security; - namespace Mono.Unity { unsafe internal class UnityTlsProvider : MonoTlsProvider { - static readonly Guid id = new Guid("06414A97-74F6-488F-877B-A6CA9BBEB82E"); - - public override Guid ID { - get { return id; } - } public override string Name { get { return "unitytls"; } } + public override Guid ID { + get { return MNS.MonoTlsProviderFactory.UnityTlsId; } + } + public override bool SupportsSslStream { get { return true; } } @@ -42,6 +41,8 @@ public override bool SupportsConnectionInfo { get { return true; } } + internal override bool SupportsCleanShutdown => true; + public override SslProtocols SupportedProtocols { get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; } } @@ -50,7 +51,14 @@ public override IMonoSslStream CreateSslStream ( Stream innerStream, bool leaveInnerStreamOpen, MonoTlsSettings settings = null) { - return new UnityTlsStream (innerStream, leaveInnerStreamOpen, settings, this); + return SslStream.CreateMonoSslStream (innerStream, leaveInnerStreamOpen, this, settings); + } + + internal override IMonoSslStream CreateSslStreamInternal ( + SslStream sslStream, Stream innerStream, bool leaveInnerStreamOpen, + MonoTlsSettings settings) + { + return new UnityTlsStream (innerStream, leaveInnerStreamOpen, sslStream, settings, this); } internal override bool ValidateCertificate ( diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsStream.cs b/mcs/class/System/Mono.UnityTls/UnityTlsStream.cs index 575675f20715..9f99ae8e6a2d 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsStream.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsStream.cs @@ -4,6 +4,7 @@ #endif using System.IO; +using System.Net.Security; using System.Security.Cryptography.X509Certificates; using System.Security.Authentication; @@ -19,20 +20,21 @@ namespace Mono.Unity { class UnityTlsStream : MNS.MobileAuthenticatedStream { - public UnityTlsStream (Stream innerStream, bool leaveInnerStreamOpen, - MonoTlsSettings settings, MonoTlsProvider provider) - : base (innerStream, leaveInnerStreamOpen, settings, provider) + public UnityTlsStream (Stream innerStream, bool leaveInnerStreamOpen, SslStream owner, + MonoTlsSettings settings, MonoTlsProvider provider) + : base (innerStream, leaveInnerStreamOpen, owner, settings, provider) { } protected override MNS.MobileTlsContext CreateContext ( - MNS.MobileAuthenticatedStream parent, bool serverMode, string targetHost, - SslProtocols enabledProtocols, X509Certificate serverCertificate, - X509CertificateCollection clientCertificates, bool askForClientCert) + bool serverMode, string targetHost, SslProtocols enabledProtocols, + X509Certificate serverCertificate, X509CertificateCollection clientCertificates, + bool askForClientCert) { - return new UnityTlsContext (parent, serverMode, targetHost, - enabledProtocols, serverCertificate, clientCertificates, - askForClientCert); + return new UnityTlsContext ( + this, serverMode, targetHost, + enabledProtocols, serverCertificate, + clientCertificates, askForClientCert); } } } From 6ecb133eeda60feeb912c712d99ac7c128c20af5 Mon Sep 17 00:00:00 2001 From: andreasr Date: Fri, 15 Dec 2017 13:49:12 +0100 Subject: [PATCH 047/582] [sslstreamtest] Added separate test suite for BadSsl authentification test (only activated for unity) --- mcs/class/System/System_test.dll.sources | 1 + .../SslStreamBadSslTest.cs | 72 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 mcs/class/System/Test/System.Net.Security/SslStreamBadSslTest.cs diff --git a/mcs/class/System/System_test.dll.sources b/mcs/class/System/System_test.dll.sources index 6cd61c08477f..48b47f4df857 100644 --- a/mcs/class/System/System_test.dll.sources +++ b/mcs/class/System/System_test.dll.sources @@ -275,6 +275,7 @@ System.Net.NetworkInformation/NetworkInterfaceTest.cs System.Net.NetworkInformation/PhysicalAddressTest.cs System.Net.NetworkInformation/PingTest.cs System.Net.Security/SslStreamTest.cs +System.Net.Security/SslStreamBadSslTest.cs System.Runtime.Versioning/FrameworkNameTest.cs System.Security.AccessControl/SemaphoreSecurityTest.cs System.Security.Cryptography/AsnEncodedDataTest.cs diff --git a/mcs/class/System/Test/System.Net.Security/SslStreamBadSslTest.cs b/mcs/class/System/Test/System.Net.Security/SslStreamBadSslTest.cs new file mode 100644 index 000000000000..8616da77b3cd --- /dev/null +++ b/mcs/class/System/Test/System.Net.Security/SslStreamBadSslTest.cs @@ -0,0 +1,72 @@ +#if UNITY // Does this test work with Mono's default tls implementations? + +using NUnit.Framework; +using System.Net.Security; +using System.Net.Sockets; +using System.Security.Authentication; + +namespace MonoTests.System.Net.Security +{ + +[TestFixture] +public class SslStreamBadSslTest +{ + private SslStream sslStream; + private TcpClient client; + + [SetUp] + public void InitClient() + { + const string machineName = "badssl.com"; + client = new TcpClient(machineName, 443); + sslStream = new SslStream(client.GetStream()); + } + + [TestCase("www.badssl.com")] + [TestCase("sha256.badssl.com")] + [TestCase("sha384.badssl.com")] + [TestCase("sha512.badssl.com")] + //[TestCase("1000-sans.badssl.com")] // MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE + //[TestCase("10000-sans.badssl.com")] + [TestCase("ecc256.badssl.com")] + [TestCase("ecc384.badssl.com")] + [TestCase("rsa2048.badssl.com")] + [TestCase("rsa8192.badssl.com")] + [TestCase("dh2048.badssl.com")] + [TestCase("tls-v1-0.badssl.com")] + [TestCase("tls-v1-1.badssl.com")] + [TestCase("long-extended-subdomain-name-containing-many-letters-and-dashes.badssl.com")] + [TestCase("longextendedsubdomainnamewithoutdashesinordertotestwordwrapping.badssl.com")] + public void SuccessFullHostProvider(string targetHost) + { + sslStream.AuthenticateAsClient(targetHost); + } + + [ExpectedException(typeof(AuthenticationException))] + [TestCase("expired.badssl.com")] + [TestCase("wrong.host.badssl.com")] + [TestCase("self-signed.badssl.com")] + [TestCase("untrusted-root.badssl.com")] + //[TestCase("revoked.badssl.com")] // No support for revoking yet + [TestCase("sha1-intermediate.badssl.com")] + [TestCase("dh480.badssl.com")] + [TestCase("dh512.badssl.com")] + //[TestCase("dh1024.badssl.com")] + //[TestCase("dh-small-subgroup.badssl.com")] + //[TestCase("dh-composite.badssl.com")] + //[TestCase("invalid-expected-sct.badssl.com")] + [TestCase("superfish.badssl.com")] + [TestCase("edellroot.badssl.com")] + [TestCase("dsdtestprovider.badssl.com")] + [TestCase("preact-cli.badssl.com")] + [TestCase("webpack-dev-server.badssl.com")] + [TestCase("sha1-2016.badssl.com")] + [TestCase("sha1-2017.badssl.com")] + public void FailingHostsProvider(string targetHost) + { + sslStream.AuthenticateAsClient(targetHost); + } + } +} + +#endif \ No newline at end of file From 32ca0875f303a970a5b2fbb2cb5fb920ceabc05b Mon Sep 17 00:00:00 2001 From: andreasr Date: Fri, 15 Dec 2017 17:40:11 +0100 Subject: [PATCH 048/582] [sslstreamtest] SslStreamBadSslTest unpacks AggregateException now Note that previous versions of mono would directly pass on whatever exception the implementation throws. Now, not only is TlsException wrapped with the correct AuthentificationException but - since it is run form a task - it is passed on as an AggregateException --- .../System/Test/System.Net.Security/SslStreamBadSslTest.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mcs/class/System/Test/System.Net.Security/SslStreamBadSslTest.cs b/mcs/class/System/Test/System.Net.Security/SslStreamBadSslTest.cs index 8616da77b3cd..75470fb3cf67 100644 --- a/mcs/class/System/Test/System.Net.Security/SslStreamBadSslTest.cs +++ b/mcs/class/System/Test/System.Net.Security/SslStreamBadSslTest.cs @@ -64,7 +64,11 @@ public void SuccessFullHostProvider(string targetHost) [TestCase("sha1-2017.badssl.com")] public void FailingHostsProvider(string targetHost) { - sslStream.AuthenticateAsClient(targetHost); + try { + sslStream.AuthenticateAsClient(targetHost); + } catch (global::System.AggregateException e) { + throw e.InnerException; + } } } } From af58b51b8e2f3e7d5b849e87abdc1e5ba28f9e18 Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 18 Dec 2017 10:38:57 +0100 Subject: [PATCH 049/582] [unitytls] unitytls api update - changed callback names (non-breaking change) --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 18 +++++++++--------- .../System/Mono.UnityTls/UnityTlsContext.cs | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index 11cf0305aab3..cb85c4fc98ff 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -150,7 +150,7 @@ public struct unitytls_x509list {} public struct unitytls_x509list_ref { UInt64 handle; } [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_x509list_ref unitytls_x509list_get_ref(unitytls_x509list* list, unitytls_errorstate* errorState); + extern public static unitytls_x509list_ref unitytls_x509list_get_ref(unitytls_x509list* list, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static unitytls_x509list* unitytls_x509list_parse_pem(Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] @@ -245,17 +245,17 @@ public enum unitytls_tlsctx_handshakestate : UInt32 UNITYTLS_HANDSHAKESTATE_PEER_X509_CERT_REQUEST, // A certificate is requested. } - public delegate size_t unitytls_tlsctx_callback_write(void* userData, UInt8* data, size_t bufferLen, unitytls_errorstate* errorState); - public delegate size_t unitytls_tlsctx_callback_read(void* userData, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - public delegate void unitytls_tlsctx_callback_trace(void* userData, unitytls_tlsctx* ctx, Int8* traceMessage, size_t traceMessageLen); - public delegate void unitytls_tlsctx_callback_handshake(void* userData, unitytls_tlsctx* ctx, unitytls_tlsctx_handshakestate currentState, unitytls_errorstate* errorState); + public delegate size_t unitytls_tlsctx_write_callback(void* userData, UInt8* data, size_t bufferLen, unitytls_errorstate* errorState); + public delegate size_t unitytls_tlsctx_read_callback(void* userData, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + public delegate void unitytls_tlsctx_trace_callback(void* userData, unitytls_tlsctx* ctx, Int8* traceMessage, size_t traceMessageLen); + public delegate void unitytls_tlsctx_handshake_callback(void* userData, unitytls_tlsctx* ctx, unitytls_tlsctx_handshakestate currentState, unitytls_errorstate* errorState); public delegate unitytls_x509verify_result unitytls_tlsctx_x509verify_callback(void* userData, unitytls_x509list_ref chain, unitytls_errorstate* errorState); [StructLayout (LayoutKind.Sequential)] public struct unitytls_tlsctx_callbacks { - public unitytls_tlsctx_callback_read read; - public unitytls_tlsctx_callback_write write; + public unitytls_tlsctx_read_callback read; + public unitytls_tlsctx_write_callback write; public void* data; }; @@ -265,11 +265,11 @@ public struct unitytls_tlsctx_callbacks extern public static unitytls_tlsctx* unitytls_tlsctx_create_client(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, Int8* cn, size_t cnLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static void unitytls_tlsctx_set_trace_callback(unitytls_tlsctx* ctx, unitytls_tlsctx_callback_trace cb, void* userData, unitytls_errorstate* errorState); + extern public static void unitytls_tlsctx_set_trace_callback(unitytls_tlsctx* ctx, unitytls_tlsctx_trace_callback cb, void* userData, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static void unitytls_tlsctx_set_x509verify_callback(unitytls_tlsctx* ctx, unitytls_tlsctx_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static void unitytls_tlsctx_set_handshake_callback(unitytls_tlsctx* ctx, unitytls_tlsctx_callback_handshake cb, void* userData, unitytls_errorstate* errorState); + extern public static void unitytls_tlsctx_set_handshake_callback(unitytls_tlsctx* ctx, unitytls_tlsctx_handshake_callback cb, void* userData, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static void unitytls_tlsctx_set_supported_ciphersuites(unitytls_tlsctx* ctx, unitytls_ciphersuite* supportedCiphersuites, size_t supportedCiphersuitesLen, unitytls_errorstate* errorState); diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index 2304ff10b891..e822e9ee6cfc 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -257,7 +257,7 @@ public override void FinishHandshake () m_IsAuthenticated = true; } - [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_callback_write))] + [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_write_callback))] static private size_t WriteCallback (void* userData, byte* data, size_t bufferLen, UnityTls.unitytls_errorstate* errorState) { var handle = (GCHandle)(IntPtr)userData; @@ -284,7 +284,7 @@ private size_t WriteCallback (byte* data, size_t bufferLen, UnityTls.unitytls_er } } - [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_callback_read))] + [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_read_callback))] static private size_t ReadCallback (void* userData, byte* buffer, size_t bufferLen, UnityTls.unitytls_errorstate* errorState) { var handle = (GCHandle)(IntPtr)userData; @@ -315,7 +315,7 @@ private size_t ReadCallback (byte* buffer, size_t bufferLen, UnityTls.unitytls_e } } - [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_callback_read))] + [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_read_callback))] static private UnityTls.unitytls_x509verify_result VerifyCallback (void* userData, UnityTls.unitytls_x509list_ref chain, UnityTls.unitytls_errorstate* errorState) { var handle = (GCHandle)(IntPtr)userData; @@ -337,7 +337,7 @@ private UnityTls.unitytls_x509verify_result VerifyCallback (UnityTls.unitytls_x5 } } - [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_callback_trace))] + [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_trace_callback))] static private void TraceCallback (void* userData, UnityTls.unitytls_tlsctx* ctx, byte* traceMessage, size_t traceMessageLen) { string message = Encoding.UTF8.GetString (traceMessage, traceMessageLen); From 4a0611cc59181aea4ce19c9c55bad6db090ad499 Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 18 Dec 2017 10:52:29 +0100 Subject: [PATCH 050/582] [unitytls] removed unused & unnecessary handling of intermediate certificates --- mcs/class/System/Mono.UnityTLS/CertHelper.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/mcs/class/System/Mono.UnityTLS/CertHelper.cs b/mcs/class/System/Mono.UnityTLS/CertHelper.cs index c21b12cb9d5b..d3701afd1031 100644 --- a/mcs/class/System/Mono.UnityTLS/CertHelper.cs +++ b/mcs/class/System/Mono.UnityTLS/CertHelper.cs @@ -18,16 +18,6 @@ public static void AddCertificateToNativeChain (UnityTls.unitytls_x509list* nati fixed(byte* certDerPtr = certDer) { UnityTls.unitytls_x509list_append_der (nativeCertificateChain, certDerPtr, certDer.Length, errorState); } - - var certificateImpl2 = certificate.Impl as X509Certificate2Impl; - if (certificateImpl2 != null) { - var intermediates = certificateImpl2.IntermediateCertificates; - if (intermediates != null && intermediates.Count > 0) { - for (int i=0; i Date: Mon, 18 Dec 2017 11:08:33 +0100 Subject: [PATCH 051/582] [unitytls] Fixed path casing for a couple of files --- mcs/class/System/{Mono.UnityTLS => Mono.UnityTls}/CertHelper.cs | 0 mcs/class/System/{Mono.UnityTLS => Mono.UnityTls}/Debug.cs | 0 .../{Mono.UnityTLS => Mono.UnityTls}/UnityTlsConversions.cs | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename mcs/class/System/{Mono.UnityTLS => Mono.UnityTls}/CertHelper.cs (100%) rename mcs/class/System/{Mono.UnityTLS => Mono.UnityTls}/Debug.cs (100%) rename mcs/class/System/{Mono.UnityTLS => Mono.UnityTls}/UnityTlsConversions.cs (100%) diff --git a/mcs/class/System/Mono.UnityTLS/CertHelper.cs b/mcs/class/System/Mono.UnityTls/CertHelper.cs similarity index 100% rename from mcs/class/System/Mono.UnityTLS/CertHelper.cs rename to mcs/class/System/Mono.UnityTls/CertHelper.cs diff --git a/mcs/class/System/Mono.UnityTLS/Debug.cs b/mcs/class/System/Mono.UnityTls/Debug.cs similarity index 100% rename from mcs/class/System/Mono.UnityTLS/Debug.cs rename to mcs/class/System/Mono.UnityTls/Debug.cs diff --git a/mcs/class/System/Mono.UnityTLS/UnityTlsConversions.cs b/mcs/class/System/Mono.UnityTls/UnityTlsConversions.cs similarity index 100% rename from mcs/class/System/Mono.UnityTLS/UnityTlsConversions.cs rename to mcs/class/System/Mono.UnityTls/UnityTlsConversions.cs From 01d462a17d0d12c1a452201e62fd507fd934349c Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 18 Dec 2017 13:41:18 +0100 Subject: [PATCH 052/582] [unitytls] use der instead of pem in NativeChainToManagedCollection --- mcs/class/System/Mono.UnityTls/CertHelper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/CertHelper.cs b/mcs/class/System/Mono.UnityTls/CertHelper.cs index d3701afd1031..3566a2c217ff 100644 --- a/mcs/class/System/Mono.UnityTls/CertHelper.cs +++ b/mcs/class/System/Mono.UnityTls/CertHelper.cs @@ -28,11 +28,11 @@ public static X509CertificateCollection NativeChainToManagedCollection (UnityTls size_t numCerts = UnityTls.unitytls_x509list_get_size (nativeCertificateChain, errorState); for (int i = 0; i < numCerts; ++i) { UnityTls.unitytls_x509_ref cert = UnityTls.unitytls_x509list_get_x509 (nativeCertificateChain, i, errorState); - size_t certBufferSize = UnityTls.unitytls_x509_export_pem (cert, null, 0, errorState); + size_t certBufferSize = UnityTls.unitytls_x509_export_der (cert, null, 0, errorState); var certBuffer = new byte[certBufferSize]; // Need to reallocate every time since X509Certificate constructor takes no length but only a byte array. fixed(byte* certBufferPtr = certBuffer) { - UnityTls.unitytls_x509_export_pem (cert, certBufferPtr, certBufferSize, errorState); + UnityTls.unitytls_x509_export_der (cert, certBufferPtr, certBufferSize, errorState); } certificates.Add (new X509Certificate (certBuffer)); From 6492173773593932a41fcdda37e3c127e278e375 Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 18 Dec 2017 13:45:52 +0100 Subject: [PATCH 053/582] [unitytls] Improved wording of NotImplementedException for server-sided client certificate check, fixed comment on gchandle --- mcs/class/System/Mono.UnityTls/UnityTlsContext.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index e822e9ee6cfc..70fd2cbb29c4 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -53,8 +53,7 @@ public UnityTlsContext ( X509CertificateCollection clientCertificates, bool askForClientCert) : base (parent, serverMode, targetHost, enabledProtocols, serverCertificate, clientCertificates, askForClientCert) { - // GCHandle allows to use managed class in native code. Stricly speaking we don't need this - // (there is no access on the native side and live time also doesn't depend on native code), but it makes a few things cleaner and more explicit. + // Need GCHandle to get a consistent pointer to this instance m_handle = GCHandle.Alloc (this); UnityTls.unitytls_errorstate errorState = UnityTls.unitytls_errorstate_create (); @@ -216,7 +215,7 @@ public override void StartHandshake () // TODO: Check if we started a handshake already? // TODO, Not supported by UnityTls as of writing if (IsServer && AskForClientCertificate) { - throw new NotImplementedException ("No support for client certificate check yet."); + throw new NotImplementedException ("No support for server-sided client certificate check yet."); } } From a898096be8a8342c96448a87b537157926c98ff7 Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 18 Dec 2017 13:46:15 +0100 Subject: [PATCH 054/582] [unitytls] Brought back handling of intermediate certificates in AddCertificateToNativeChain This reverts commit 4a0611cc59181aea4ce19c9c55bad6db090ad499. --- mcs/class/System/Mono.UnityTls/CertHelper.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mcs/class/System/Mono.UnityTls/CertHelper.cs b/mcs/class/System/Mono.UnityTls/CertHelper.cs index 3566a2c217ff..3be07b9cf80c 100644 --- a/mcs/class/System/Mono.UnityTls/CertHelper.cs +++ b/mcs/class/System/Mono.UnityTls/CertHelper.cs @@ -18,6 +18,16 @@ public static void AddCertificateToNativeChain (UnityTls.unitytls_x509list* nati fixed(byte* certDerPtr = certDer) { UnityTls.unitytls_x509list_append_der (nativeCertificateChain, certDerPtr, certDer.Length, errorState); } + + var certificateImpl2 = certificate.Impl as X509Certificate2Impl; + if (certificateImpl2 != null) { + var intermediates = certificateImpl2.IntermediateCertificates; + if (intermediates != null && intermediates.Count > 0) { + for (int i=0; i Date: Mon, 18 Dec 2017 09:27:28 -0500 Subject: [PATCH 055/582] add editorconfig back, enable pmip via debug flag (#766) --- .editorconfig | 28 ++++++++++++++++++++++++++++ mono/mini/mini-runtime.c | 4 +++- mono/mini/mini.h | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000000..f06c382dcef0 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,28 @@ +# see http://editorconfig.org/ for docs on this file + +root = true + +[*] +end_of_line = lf +trim_trailing_whitespace = false +insert_final_newline = false +indent_style = tab +indent_size = 4 + +# this VS-specific stuff is based on experiments to see how VS will modify a file after it has been manually edited. +# the settings are meant to closely match what VS does to minimize unnecessary diffs. this duplicates some settings in * +# but let's be explicit here to be safe (in case someone wants to copy-paste this out to another .editorconfig). +[*.{vcxproj,vcxproj.filters,csproj,props,targets}] +indent_style = space +indent_size = 2 +end_of_line = crlf +charset = utf-8-bom +trim_trailing_whitespace = true +insert_final_newline = false +[*.{sln,sln.template}] +indent_style = tab +indent_size = 4 +end_of_line = crlf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = false diff --git a/mono/mini/mini-runtime.c b/mono/mini/mini-runtime.c index 33eb4c800dd4..8798c8341a15 100644 --- a/mono/mini/mini-runtime.c +++ b/mono/mini/mini-runtime.c @@ -3440,6 +3440,8 @@ mini_parse_debug_option (const char *option) debug_options.gdb = TRUE; else if (!strcmp (option, "lldb")) debug_options.lldb = TRUE; + else if (!strcmp (option, "unity-mixed-callstack")) + debug_options.unity_mixed_callstack = TRUE; else if (!strcmp (option, "explicit-null-checks")) debug_options.explicit_null_checks = TRUE; else if (!strcmp (option, "gen-seq-points")) @@ -3909,7 +3911,7 @@ mini_init (const char *filename, const char *runtime_version) mono_lldb_init (""); mono_dont_free_domains = TRUE; } - if (g_hasenv ("UNITY_MIXED_CALLSTACK")) { + if (mini_get_debug_options()->unity_mixed_callstack || g_hasenv ("UNITY_MIXED_CALLSTACK")) { mixed_callstack_plugin_init (""); } diff --git a/mono/mini/mini.h b/mono/mini/mini.h index bb3fdb77a838..00d041950828 100644 --- a/mono/mini/mini.h +++ b/mono/mini/mini.h @@ -2175,6 +2175,7 @@ typedef struct { gboolean dyn_runtime_invoke; gboolean gdb; gboolean lldb; + gboolean unity_mixed_callstack; gboolean use_fallback_tls; /* * Whenever data such as next sequence points and flags is required. From e8d0652e706ca2ff8ee414db4a698b3fc5ac9b22 Mon Sep 17 00:00:00 2001 From: Brian Raderman Date: Mon, 18 Dec 2017 10:21:25 -0500 Subject: [PATCH 056/582] Debugger suspend threads * Initial work to properly suspend threads running managed code when the debugger requests it. Enabling more thread related tests after the thread suspension fix. * Fixing some issues with step filters that were never working. Hijacking the jitinfo pointer and storing a Il2CppSequencePoint pointer in it for il2cpp. We can use the sequence point to access data we need for filtering, in much the same way mono uses the JitInfo pointer. * Fixing crashing issues that occur when you generate debug code but don't pass in the appropriate arguments to initialize the debugger. We need to check that the debugger has been initialized before performing various debugger-related operations. --- mono/mini/debugger-agent.c | 53 +++++++++++++++++++++++++++++--------- mono/mini/il2cpp-compat.h | 1 + mono/mini/il2cpp-stubs.cpp | 5 +++- 3 files changed, 46 insertions(+), 13 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 08860fc7541b..4e8d5cacb302 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -2879,13 +2879,14 @@ notify_thread (gpointer key, gpointer value, gpointer user_data) } } -#ifndef IL2CPP_MONO_DEBUGGER static void process_suspend (DebuggerTlsData *tls, MonoContext *ctx) { +#ifndef IL2CPP_MONO_DEBUGGER guint8 *ip = (guint8 *)MONO_CONTEXT_GET_IP (ctx); MonoJitInfo *ji; MonoMethod *method; +#endif if (mono_loader_lock_is_owned_by_self ()) { /* @@ -2915,18 +2916,19 @@ process_suspend (DebuggerTlsData *tls, MonoContext *ctx) return; } +#ifndef IL2CPP_MONO_DEBUGGER ji = get_top_method_ji (ip, NULL, NULL); g_assert (ji); /* Can't suspend in these methods */ method = jinfo_get_method (ji); if (method->klass == mono_defaults.string_class && (!strcmp (mono_method_get_name(method), "memset") || strstr (mono_method_get_name(method), "memcpy"))) return; +#endif save_thread_context (ctx); suspend_current (); } -#endif /* * suspend_vm: @@ -3622,6 +3624,9 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv { int i, j; GSList *events = NULL; +#if IL2CPP_MONO_DEBUGGER + Il2CppSequencePoint *sp = (Il2CppSequencePoint*)ji; +#endif *suspend_policy = SUSPEND_POLICY_NONE; @@ -3668,8 +3673,15 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv if (assemblies) { for (k = 0; assemblies [k]; ++k) +#ifdef IL2CPP_MONO_DEBUGGER + { + if (assemblies[k] == sp->method->klass->image->assembly) + found = TRUE; + } +#else if (assemblies [k] == jinfo_get_method (ji)->klass->image->assembly) found = TRUE; +#endif } if (!found) filtered = TRUE; @@ -3722,6 +3734,14 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv filtered = TRUE; g_free (s); } else if (mod->kind == MOD_KIND_STEP) { +#ifdef IL2CPP_MONO_DEBUGGER + Il2CppSequencePoint *sp = (Il2CppSequencePoint*)ji; + if ((mod->data.filter & STEP_FILTER_STATIC_CTOR) && sp && + (sp->method->flags & METHOD_ATTRIBUTE_SPECIAL_NAME) && + !strcmp (sp->method->name, ".cctor") && + (sp->method != ((SingleStepReq*)req->info)->start_method)) + filtered = TRUE; +#else if ((mod->data.filter & STEP_FILTER_STATIC_CTOR) && ji && (jinfo_get_method (ji)->flags & METHOD_ATTRIBUTE_SPECIAL_NAME) && !strcmp (jinfo_get_method (ji)->name, ".cctor") && @@ -3742,6 +3762,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv if (ji->dbg_non_user_code) filtered = TRUE; } +#endif } } @@ -5648,6 +5669,7 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, uint64_t mono_arch_skip_single_step (ctx); #else NOT_IMPLEMENTED; +#endif #endif if (suspend_count > 0) { @@ -5665,6 +5687,8 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, uint64_t if (mono_thread_internal_current () != ss_req->thread) return; +#ifndef IL2CPP_MONO_DEBUGGER + ip = (guint8 *)MONO_CONTEXT_GET_IP (ctx); ji = get_top_method_ji (ip, &domain, (gpointer*)&ip); @@ -5740,7 +5764,7 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, uint64_t #ifndef IL2CPP_MONO_DEBUGGER events = create_event_list (EVENT_KIND_STEP, reqs, ji, NULL, &suspend_policy); #else - events = create_event_list(EVENT_KIND_STEP, reqs, NULL, NULL, &suspend_policy); + events = create_event_list(EVENT_KIND_STEP, reqs, il2cpp_get_sequence_point(sequencePointId), NULL, &suspend_policy); #endif g_ptr_array_free (reqs, TRUE); @@ -5889,35 +5913,35 @@ debugger_agent_breakpoint_from_context (MonoContext *ctx) static void start_single_stepping (void) { -#ifndef IL2CPP_MONO_DEBUGGER #ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED int val = mono_atomic_inc_i32 (&ss_count); if (val == 1) { mono_arch_start_single_stepping (); +#ifndef IL2CPP_MONO_DEBUGGER mono_interp_start_single_stepping (); +#endif } #else g_assert_not_reached (); #endif -#endif } static void stop_single_stepping (void) { -#ifndef IL2CPP_MONO_DEBUGGER #ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED int val = mono_atomic_dec_i32 (&ss_count); if (val == 0) { mono_arch_stop_single_stepping (); +#ifndef IL2CPP_MONO_DEBUGGER mono_interp_stop_single_stepping (); +#endif } #else g_assert_not_reached (); #endif -#endif } /* @@ -12080,11 +12104,11 @@ unity_process_breakpoint_inner(DebuggerTlsData *tls, gboolean from_signal, Il2Cp } if (ss_reqs->len > 0) - ss_events = create_event_list(EVENT_KIND_STEP, ss_reqs, ji, NULL, &suspend_policy); + ss_events = create_event_list(EVENT_KIND_STEP, ss_reqs, sequencePoint, NULL, &suspend_policy); if (bp_reqs->len > 0) - bp_events = create_event_list(EVENT_KIND_BREAKPOINT, bp_reqs, ji, NULL, &suspend_policy); + bp_events = create_event_list(EVENT_KIND_BREAKPOINT, bp_reqs, sequencePoint, NULL, &suspend_policy); if (kind != EVENT_KIND_BREAKPOINT) - enter_leave_events = create_event_list(kind, NULL, ji, NULL, &suspend_policy); + enter_leave_events = create_event_list(kind, NULL, sequencePoint, NULL, &suspend_policy); mono_loader_unlock(); @@ -12129,12 +12153,17 @@ gboolean unity_debugger_agent_is_global_breakpoint_active() return ss_req->global; } +int32_t unity_debugger_agent_is_single_stepping () +{ + return ss_count; +} + gboolean unity_sequence_point_active(Il2CppSequencePoint *seqPoint) { gboolean global = unity_debugger_agent_is_global_breakpoint_active(); if ((seqPoint->ilOffset != METHOD_ENTRY_IL_OFFSET) && (seqPoint->ilOffset != METHOD_EXIT_IL_OFFSET)) - return seqPoint->isActive || global; + return seqPoint->isActive || global || unity_debugger_agent_is_single_stepping (); int i = 0; while (i < event_requests->len) @@ -12144,7 +12173,7 @@ gboolean unity_sequence_point_active(Il2CppSequencePoint *seqPoint) if ((req->event_kind == EVENT_KIND_METHOD_ENTRY && seqPoint->ilOffset == METHOD_ENTRY_IL_OFFSET) || (req->event_kind == EVENT_KIND_METHOD_EXIT && seqPoint->ilOffset == METHOD_EXIT_IL_OFFSET)) { - return seqPoint->isActive || global; + return seqPoint->isActive || global || unity_debugger_agent_is_single_stepping (); } ++i; diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index b21ebdf3870c..2f28d8994322 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -497,5 +497,6 @@ MonoGenericInst* il2cpp_method_get_generic_class_inst(Il2CppMonoMethodInflated * MonoClass* il2cpp_generic_class_get_container_class(MonoGenericClass *gclass); void il2cpp_mono_thread_detach(MonoThread* thread); MonoClass* il2cpp_mono_get_string_class (void); +Il2CppSequencePoint* il2cpp_get_sequence_point(size_t id); #endif // RUNTIME_IL2CPP diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index 7927ea5bbf6e..c4f576cf7259 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -1570,6 +1570,9 @@ MonoClass* il2cpp_mono_get_string_class (void) return (MonoClass*)il2cpp_defaults.string_class; } +Il2CppSequencePoint* il2cpp_get_sequence_point(size_t id) +{ + return il2cpp::utils::Debugger::GetSequencePoint(id); +} } - #endif // RUNTIME_IL2CPP From 048d08a546b175ca260bb8acdeaa2ac4aafc551d Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 18 Dec 2017 16:47:54 +0100 Subject: [PATCH 057/582] [unitytls] fixed internal read blocking handling previously would_block may have not been set correctly --- mcs/class/System/Mono.UnityTls/UnityTlsContext.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index 70fd2cbb29c4..371ea4969377 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -299,12 +299,14 @@ private size_t ReadCallback (byte* buffer, size_t bufferLen, UnityTls.unitytls_e bool wouldBlock; int numBytesRead = Parent.InternalRead (m_ReadBuffer, 0, bufferLen, out wouldBlock); + if (wouldBlock) { + UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK); + return 0; + } if (numBytesRead < 0) { UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_READ_FAILED); return 0; } - if (wouldBlock) - UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK); Marshal.Copy (m_ReadBuffer, 0, (IntPtr)buffer, bufferLen); return numBytesRead; From 7f657735c721f2d3c102988e69f3e471b245280a Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 18 Dec 2017 17:55:50 +0100 Subject: [PATCH 058/582] [unitytls] Fixed UNITYTLS_X509VERIFY_FATAL_ERROR being translated to CertificateExpired --- mcs/class/System/Mono.UnityTls/UnityTlsConversions.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsConversions.cs b/mcs/class/System/Mono.UnityTls/UnityTlsConversions.cs index fcb850c332f3..ba30e1993ec6 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsConversions.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsConversions.cs @@ -53,7 +53,9 @@ public static TlsProtocols ConvertProtocolVersion(UnityTls.unitytls_protocol pro public static AlertDescription VerifyResultToAlertDescription (UnityTls.unitytls_x509verify_result verifyResult, AlertDescription defaultAlert = AlertDescription.InternalError) { - if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_EXPIRED)) + if (verifyResult == UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FATAL_ERROR) + return AlertDescription.CertificateUnknown; + else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_EXPIRED)) return AlertDescription.CertificateExpired; else if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_REVOKED)) return AlertDescription.CertificateRevoked; From 86c910f4c729785dd17c92e77c0c3bfd81b4596e Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 18 Dec 2017 19:20:05 +0100 Subject: [PATCH 059/582] [unitytls] Fixed serversided handshake errors being ignored --- mcs/class/System/Mono.UnityTls/UnityTlsContext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index 371ea4969377..fd4af164a836 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -228,9 +228,10 @@ public override bool ProcessHandshake () // Not done is not an error if we are server and don't ask for ClientCertificate if (result == UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_NOT_DONE && IsServer && !AskForClientCertificate) - return true; + Unity.Debug.CheckAndThrow (errorState, "Handshake failed", AlertDescription.HandshakeFailure); + else + Unity.Debug.CheckAndThrow (errorState, result, "Handshake failed", AlertDescription.HandshakeFailure); - Unity.Debug.CheckAndThrow (errorState, result, "Handshake failed", AlertDescription.HandshakeFailure); return true; } From 7cf1799ad6ab1992629dfeb6aa4b4ed221a53cbe Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 18 Dec 2017 19:22:02 +0100 Subject: [PATCH 060/582] [unitytls] Fixed indentation of BadSslTest --- .../SslStreamBadSslTest.cs | 114 +++++++++--------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/mcs/class/System/Test/System.Net.Security/SslStreamBadSslTest.cs b/mcs/class/System/Test/System.Net.Security/SslStreamBadSslTest.cs index 75470fb3cf67..0f249ccaa31f 100644 --- a/mcs/class/System/Test/System.Net.Security/SslStreamBadSslTest.cs +++ b/mcs/class/System/Test/System.Net.Security/SslStreamBadSslTest.cs @@ -11,66 +11,66 @@ namespace MonoTests.System.Net.Security [TestFixture] public class SslStreamBadSslTest { - private SslStream sslStream; - private TcpClient client; + private SslStream sslStream; + private TcpClient client; - [SetUp] - public void InitClient() - { - const string machineName = "badssl.com"; - client = new TcpClient(machineName, 443); - sslStream = new SslStream(client.GetStream()); - } + [SetUp] + public void InitClient() + { + const string machineName = "badssl.com"; + client = new TcpClient(machineName, 443); + sslStream = new SslStream(client.GetStream()); + } - [TestCase("www.badssl.com")] - [TestCase("sha256.badssl.com")] - [TestCase("sha384.badssl.com")] - [TestCase("sha512.badssl.com")] - //[TestCase("1000-sans.badssl.com")] // MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE - //[TestCase("10000-sans.badssl.com")] - [TestCase("ecc256.badssl.com")] - [TestCase("ecc384.badssl.com")] - [TestCase("rsa2048.badssl.com")] - [TestCase("rsa8192.badssl.com")] - [TestCase("dh2048.badssl.com")] - [TestCase("tls-v1-0.badssl.com")] - [TestCase("tls-v1-1.badssl.com")] - [TestCase("long-extended-subdomain-name-containing-many-letters-and-dashes.badssl.com")] - [TestCase("longextendedsubdomainnamewithoutdashesinordertotestwordwrapping.badssl.com")] - public void SuccessFullHostProvider(string targetHost) - { - sslStream.AuthenticateAsClient(targetHost); - } + [TestCase("www.badssl.com")] + [TestCase("sha256.badssl.com")] + [TestCase("sha384.badssl.com")] + [TestCase("sha512.badssl.com")] + //[TestCase("1000-sans.badssl.com")] // MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE + //[TestCase("10000-sans.badssl.com")] + [TestCase("ecc256.badssl.com")] + [TestCase("ecc384.badssl.com")] + [TestCase("rsa2048.badssl.com")] + [TestCase("rsa8192.badssl.com")] + [TestCase("dh2048.badssl.com")] + [TestCase("tls-v1-0.badssl.com")] + [TestCase("tls-v1-1.badssl.com")] + [TestCase("long-extended-subdomain-name-containing-many-letters-and-dashes.badssl.com")] + [TestCase("longextendedsubdomainnamewithoutdashesinordertotestwordwrapping.badssl.com")] + public void SuccessFullHostProvider(string targetHost) + { + sslStream.AuthenticateAsClient(targetHost); + } - [ExpectedException(typeof(AuthenticationException))] - [TestCase("expired.badssl.com")] - [TestCase("wrong.host.badssl.com")] - [TestCase("self-signed.badssl.com")] - [TestCase("untrusted-root.badssl.com")] - //[TestCase("revoked.badssl.com")] // No support for revoking yet - [TestCase("sha1-intermediate.badssl.com")] - [TestCase("dh480.badssl.com")] - [TestCase("dh512.badssl.com")] - //[TestCase("dh1024.badssl.com")] - //[TestCase("dh-small-subgroup.badssl.com")] - //[TestCase("dh-composite.badssl.com")] - //[TestCase("invalid-expected-sct.badssl.com")] - [TestCase("superfish.badssl.com")] - [TestCase("edellroot.badssl.com")] - [TestCase("dsdtestprovider.badssl.com")] - [TestCase("preact-cli.badssl.com")] - [TestCase("webpack-dev-server.badssl.com")] - [TestCase("sha1-2016.badssl.com")] - [TestCase("sha1-2017.badssl.com")] - public void FailingHostsProvider(string targetHost) - { - try { - sslStream.AuthenticateAsClient(targetHost); - } catch (global::System.AggregateException e) { - throw e.InnerException; - } - } - } + [ExpectedException(typeof(AuthenticationException))] + [TestCase("expired.badssl.com")] + [TestCase("wrong.host.badssl.com")] + [TestCase("self-signed.badssl.com")] + [TestCase("untrusted-root.badssl.com")] + //[TestCase("revoked.badssl.com")] // No support for revoking yet + [TestCase("sha1-intermediate.badssl.com")] + [TestCase("dh480.badssl.com")] + [TestCase("dh512.badssl.com")] + //[TestCase("dh1024.badssl.com")] + //[TestCase("dh-small-subgroup.badssl.com")] + //[TestCase("dh-composite.badssl.com")] + //[TestCase("invalid-expected-sct.badssl.com")] + [TestCase("superfish.badssl.com")] + [TestCase("edellroot.badssl.com")] + [TestCase("dsdtestprovider.badssl.com")] + [TestCase("preact-cli.badssl.com")] + [TestCase("webpack-dev-server.badssl.com")] + [TestCase("sha1-2016.badssl.com")] + [TestCase("sha1-2017.badssl.com")] + public void FailingHostsProvider(string targetHost) + { + try { + sslStream.AuthenticateAsClient(targetHost); + } catch (global::System.AggregateException e) { + throw e.InnerException; + } + } +} } #endif \ No newline at end of file From 3e5828250f051bbcc3576f27c6a59121c674cf13 Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 18 Dec 2017 19:22:34 +0100 Subject: [PATCH 061/582] [unitytls] Added new (so far) unity specific test suite for ssl tests. Has only handshake verification failure test so far --- mcs/class/System/System_test.dll.sources | 1 + .../System.Net.Security/SslStreamTest2.cs | 138 ++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs diff --git a/mcs/class/System/System_test.dll.sources b/mcs/class/System/System_test.dll.sources index 48b47f4df857..dae376afcb16 100644 --- a/mcs/class/System/System_test.dll.sources +++ b/mcs/class/System/System_test.dll.sources @@ -275,6 +275,7 @@ System.Net.NetworkInformation/NetworkInterfaceTest.cs System.Net.NetworkInformation/PhysicalAddressTest.cs System.Net.NetworkInformation/PingTest.cs System.Net.Security/SslStreamTest.cs +System.Net.Security/SslStreamTest2.cs System.Net.Security/SslStreamBadSslTest.cs System.Runtime.Versioning/FrameworkNameTest.cs System.Security.AccessControl/SemaphoreSecurityTest.cs diff --git a/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs b/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs new file mode 100644 index 000000000000..a235c68513ed --- /dev/null +++ b/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs @@ -0,0 +1,138 @@ +#if UNITY // Does this test work with Mono's default tls implementations? + +using NUnit.Framework; +using System; +using System.IO; +using System.Net; +using System.Net.Security; +using System.Net.Sockets; +using System.Security.Authentication; +using System.Security.Cryptography.X509Certificates; +using System.Threading; +using System.Threading.Tasks; +using MonoTests.Helpers; + +namespace MonoTests.System.Net.Security +{ + [TestFixture] + public class SslStreamTest2 + { + byte[] m_serverCertRaw = { 48, 130, 5, 165, 2, 1, 3, 48, 130, 5, 95, 6, 9, 42, 134, 72, 134, 247, 13, 1, 7, 1, 160, 130, 5, 80, 4, 130, 5, 76, 48, 130, 5, 72, 48, 130, 2, 87, 6, 9, 42, 134, 72, 134, 247, 13, 1, 7, 6, 160, 130, 2, 72, 48, 130, 2, 68, 2, 1, 0, 48, 130, 2, 61, 6, 9, 42, 134, 72, 134, 247, 13, 1, 7, 1, 48, 28, 6, 10, 42, 134, 72, 134, 247, 13, 1, 12, 1, 3, 48, 14, 4, 8, 211, 176, 234, 3, 252, 26, 32, 15, 2, 2, 7, 208, 128, 130, 2, 16, 183, 149, 35, 180, 127, 95, 163, 122, 138, 244, 29, 177, 220, 173, 46, 73, 208, 217, 211, 190, 164, 183, 21, 110, 33, 122, 98, 163, 251, 16, 23, 106, 154, 14, 52, 177, 3, 12, 248, 226, 48, 123, 211, 6, 216, 6, 192, 175, 203, 142, 141, 143, 252, 178, 7, 162, 81, 232, 159, 42, 56, 177, 191, 53, 7, 146, 189, 236, 75, 140, 210, 143, 11, 103, 64, 58, 10, 73, 123, 39, 97, 119, 166, 114, 123, 65, 68, 214, 42, 17, 156, 122, 8, 58, 184, 134, 255, 48, 64, 20, 229, 247, 196, 12, 130, 56, 176, 69, 179, 254, 216, 45, 25, 244, 240, 116, 88, 137, 66, 13, 18, 202, 199, 59, 200, 245, 19, 175, 232, 217, 211, 12, 191, 222, 26, 162, 253, 73, 201, 48, 61, 3, 248, 117, 16, 71, 233, 183, 90, 110, 91, 116, 56, 133, 223, 148, 19, 78, 140, 123, 159, 203, 78, 15, 172, 39, 190, 39, 71, 180, 155, 48, 156, 116, 212, 52, 1, 231, 201, 196, 73, 87, 68, 104, 208, 40, 104, 32, 218, 235, 245, 84, 136, 168, 51, 9, 93, 126, 46, 80, 180, 240, 144, 79, 88, 87, 159, 24, 108, 186, 9, 20, 48, 100, 148, 250, 4, 163, 115, 131, 44, 13, 38, 222, 117, 196, 196, 128, 114, 149, 97, 93, 37, 191, 3, 192, 231, 88, 80, 218, 147, 8, 192, 165, 27, 206, 56, 42, 157, 230, 223, 130, 253, 169, 182, 245, 192, 181, 18, 212, 133, 168, 73, 92, 66, 197, 117, 245, 107, 127, 23, 146, 249, 41, 66, 219, 210, 207, 221, 205, 205, 15, 110, 92, 12, 207, 76, 239, 4, 13, 129, 127, 170, 205, 253, 148, 208, 24, 129, 24, 210, 220, 85, 45, 179, 137, 66, 134, 142, 22, 112, 48, 160, 236, 232, 38, 83, 101, 55, 51, 18, 110, 99, 69, 41, 173, 107, 233, 11, 199, 23, 61, 135, 222, 94, 74, 29, 219, 80, 128, 167, 186, 254, 235, 42, 96, 134, 5, 13, 90, 59, 231, 137, 195, 207, 28, 165, 12, 218, 5, 72, 102, 61, 135, 198, 73, 250, 97, 89, 214, 179, 244, 194, 23, 142, 157, 4, 243, 90, 69, 54, 10, 139, 76, 95, 40, 225, 219, 59, 15, 54, 182, 206, 142, 228, 248, 79, 156, 129, 246, 63, 6, 6, 236, 44, 67, 116, 213, 170, 47, 193, 186, 139, 25, 80, 166, 57, 99, 231, 156, 191, 117, 65, 76, 7, 243, 244, 127, 225, 210, 190, 164, 141, 46, 36, 99, 111, 203, 133, 127, 80, 28, 61, 160, 36, 132, 182, 16, 41, 39, 185, 232, 123, 32, 57, 189, 100, 152, 38, 205, 5, 189, 240, 65, 3, 191, 73, 85, 12, 209, 180, 1, 194, 70, 124, 57, 71, 48, 230, 235, 122, 175, 157, 35, 233, 83, 40, 20, 169, 224, 14, 11, 216, 48, 194, 105, 25, 187, 210, 182, 6, 184, 73, 95, 85, 210, 227, 113, 58, 10, 186, 175, 254, 25, 102, 39, 3, 2, 200, 194, 197, 200, 224, 77, 164, 8, 36, 114, 48, 130, 2, 233, 6, 9, 42, 134, 72, 134, 247, 13, 1, 7, 1, 160, 130, 2, 218, 4, 130, 2, 214, 48, 130, 2, 210, 48, 130, 2, 206, 6, 11, 42, 134, 72, 134, 247, 13, 1, 12, 10, 1, 2, 160, 130, 2, 166, 48, 130, 2, 162, 48, 28, 6, 10, 42, 134, 72, 134, 247, 13, 1, 12, 1, 3, 48, 14, 4, 8, 178, 13, 52, 135, 85, 49, 79, 105, 2, 2, 7, 208, 4, 130, 2, 128, 21, 84, 227, 109, 230, 144, 140, 170, 117, 250, 179, 207, 129, 100, 126, 126, 29, 231, 94, 140, 45, 26, 168, 45, 240, 4, 170, 73, 98, 115, 109, 96, 177, 206, 6, 80, 170, 22, 237, 144, 58, 95, 59, 26, 85, 135, 178, 69, 184, 44, 122, 81, 213, 135, 149, 198, 246, 83, 68, 129, 2, 186, 118, 33, 44, 214, 227, 240, 220, 51, 175, 220, 220, 180, 113, 216, 101, 138, 81, 54, 38, 0, 216, 30, 29, 187, 213, 230, 12, 181, 130, 21, 241, 98, 120, 41, 150, 176, 69, 37, 169, 249, 123, 212, 254, 135, 154, 214, 127, 39, 105, 149, 180, 218, 41, 207, 75, 70, 105, 169, 185, 169, 132, 173, 188, 82, 251, 71, 234, 136, 5, 254, 110, 223, 34, 4, 145, 7, 19, 51, 123, 140, 75, 226, 0, 21, 220, 228, 223, 218, 8, 169, 210, 194, 139, 93, 218, 55, 40, 174, 50, 238, 38, 166, 222, 103, 0, 209, 88, 131, 51, 222, 154, 217, 18, 172, 73, 17, 133, 54, 173, 208, 118, 104, 167, 113, 153, 223, 251, 154, 120, 176, 18, 127, 51, 206, 164, 77, 86, 9, 82, 212, 86, 162, 206, 230, 79, 217, 178, 42, 217, 162, 152, 188, 217, 59, 212, 117, 200, 135, 75, 74, 43, 1, 42, 79, 180, 164, 250, 122, 103, 103, 157, 11, 14, 33, 48, 8, 108, 155, 46, 124, 223, 204, 169, 124, 104, 11, 246, 213, 226, 16, 125, 17, 228, 15, 178, 141, 79, 78, 115, 76, 131, 122, 166, 124, 154, 1, 174, 178, 176, 213, 208, 188, 71, 118, 220, 168, 64, 218, 176, 134, 38, 229, 14, 109, 162, 125, 16, 57, 249, 201, 180, 17, 182, 143, 184, 12, 248, 113, 65, 70, 109, 79, 249, 34, 170, 35, 228, 219, 121, 202, 228, 121, 127, 255, 22, 173, 202, 171, 33, 232, 4, 240, 142, 216, 80, 56, 177, 83, 93, 123, 217, 213, 157, 99, 34, 194, 61, 228, 239, 194, 20, 27, 9, 53, 132, 79, 19, 97, 107, 31, 51, 39, 176, 223, 90, 88, 67, 138, 194, 169, 176, 144, 202, 119, 146, 74, 27, 118, 63, 129, 230, 101, 104, 75, 116, 49, 223, 254, 225, 70, 206, 183, 11, 134, 148, 10, 55, 57, 50, 178, 144, 164, 139, 233, 169, 109, 186, 211, 95, 123, 75, 111, 192, 187, 127, 240, 45, 226, 194, 240, 128, 10, 79, 178, 192, 66, 21, 197, 24, 171, 141, 255, 185, 230, 84, 206, 151, 9, 93, 115, 162, 12, 115, 129, 218, 103, 219, 183, 142, 123, 3, 110, 139, 208, 4, 146, 76, 99, 246, 240, 32, 169, 148, 16, 146, 172, 230, 36, 56, 145, 23, 94, 209, 92, 38, 244, 127, 70, 121, 253, 66, 55, 36, 140, 98, 105, 233, 112, 24, 23, 230, 112, 62, 244, 12, 48, 30, 51, 0, 18, 244, 139, 66, 245, 234, 203, 195, 52, 119, 255, 84, 82, 204, 100, 176, 167, 24, 224, 8, 127, 214, 148, 115, 242, 56, 190, 72, 221, 68, 252, 36, 74, 254, 57, 52, 96, 20, 173, 32, 236, 87, 15, 16, 76, 9, 48, 3, 61, 2, 137, 137, 9, 68, 213, 99, 163, 63, 201, 83, 241, 98, 7, 117, 108, 4, 123, 170, 18, 10, 19, 198, 31, 170, 15, 247, 216, 145, 172, 239, 137, 181, 80, 160, 24, 11, 35, 131, 58, 218, 22, 250, 215, 52, 160, 246, 197, 183, 92, 137, 0, 245, 63, 49, 183, 246, 195, 58, 63, 4, 75, 10, 92, 131, 181, 59, 78, 247, 44, 150, 49, 49, 107, 211, 62, 71, 62, 222, 159, 161, 118, 236, 55, 219, 49, 0, 3, 82, 236, 96, 20, 83, 39, 245, 208, 240, 245, 174, 218, 49, 21, 48, 19, 6, 9, 42, 134, 72, 134, 247, 13, 1, 9, 21, 49, 6, 4, 4, 1, 0, 0, 0, 48, 61, 48, 33, 48, 9, 6, 5, 43, 14, 3, 2, 26, 5, 0, 4, 20, 30, 154, 48, 126, 198, 239, 114, 62, 12, 58, 129, 172, 67, 156, 76, 214, 62, 205, 89, 28, 4, 20, 135, 177, 105, 83, 79, 93, 181, 149, 169, 49, 112, 201, 70, 212, 153, 79, 198, 163, 137, 90, 2, 2, 7, 208 }; + + private X509Certificate2 m_serverCert; + private IPEndPoint m_ipEndPoint; + private TcpClient m_tcpClient; + private TcpClient m_tcpServer; + private MemoryStream m_stream; + + + class TestException : Exception + { + } + + [SetUp()] + public void GetReady() + { + m_serverCert = new X509Certificate2(m_serverCertRaw, "server"); + m_ipEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), NetworkHelpers.FindFreePort ()); + } + + private void SetupClientServerConnection() + { + m_tcpClient = new TcpClient(); + var tcpListener = new TcpListener(m_ipEndPoint); + tcpListener.Start(); + Task.Run(() => m_tcpClient.Connect(m_ipEndPoint.Address, m_ipEndPoint.Port)); + m_tcpServer = tcpListener.AcceptTcpClient(); + tcpListener.Stop(); + } + + [TestCase] + [ExpectedException(typeof(AuthenticationException))] + public void HandshakeVerificationFailure_client() + { + SetupClientServerConnection(); + var clientStream = new SslStream(m_tcpClient.GetStream(), true, RemoteCertificateValidationCallback_AlwaysFail); + var serverStream = new SslStream(m_tcpServer.GetStream(), true, RemoteCertificateValidationCallback_AlwaysSucceed); + DoHandshake(clientStream, serverStream); + } + +// We don't support client authentification, so we can't fail the handshake on the server side +// Note that in contrast to .Net we don't call the verification callback (with a null certificate) if verification is disabled. + + // [TestCase] + // [ExpectedException(typeof(AuthenticationException))] + // public void HandshakeVerificationFailure_server() + // { + // SetupClientServerConnection(); + // var clientStream = new SslStream(m_tcpClient.GetStream(), true, RemoteCertificateValidationCallback_AlwaysSucceed); + // var serverStream = new SslStream(m_tcpServer.GetStream(), true, RemoteCertificateValidationCallback_AlwaysFail); + // DoHandshake(clientStream, serverStream); + // } +Ø +// TODO: Can we support passing on the exception? + + // [TestCase] + // [ExpectedException(typeof(TestException))] + // public void HandshakeVerificationFailure_clientException() + // { + // SetupClientServerConnection(); + // var clientStream = new SslStream(m_tcpClient.GetStream(), true, RemoteCertificateValidationCallback_ThrowException); + // var serverStream = new SslStream(m_tcpServer.GetStream(), true, RemoteCertificateValidationCallback_AlwaysSucceed); + // DoHandshake(clientStream, serverStream); + // } + + + private void DoHandshake(SslStream clientStream, SslStream serverStream) + { + try + { + Task.WaitAll( + Task.Run(() => { + try { + if (clientStream != null) + clientStream.AuthenticateAsClient("test_host"); + } + catch { + m_tcpServer.Close(); + throw; + }}), + Task.Run(() => { + try { + if (serverStream != null) + serverStream.AuthenticateAsServer(m_serverCert); + } + catch { + m_tcpClient.Close(); + throw; + }}) + ); + } + // We're intersted in the "first" exception. + catch (AggregateException e) + { + if (e.InnerException is AggregateException) + throw e.InnerException.InnerException; + else + throw e.InnerException; + } + } + + private bool RemoteCertificateValidationCallback_AlwaysSucceed(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) + { + return true; + } + + private bool RemoteCertificateValidationCallback_AlwaysFail(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) + { + return false; + } + + private bool RemoteCertificateValidationCallback_ThrowException(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) + { + throw new TestException(); + } + } +} + +#endif \ No newline at end of file From bc25f6294cb562355cb560d4570b7bab78498355 Mon Sep 17 00:00:00 2001 From: andreasr Date: Tue, 19 Dec 2017 11:22:58 +0100 Subject: [PATCH 062/582] [unitytls] Fixed incorrect type in MonoPInvokeCallback attribute --- mcs/class/System/Mono.UnityTls/UnityTlsContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index fd4af164a836..63f422dbbcd0 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -317,7 +317,7 @@ private size_t ReadCallback (byte* buffer, size_t bufferLen, UnityTls.unitytls_e } } - [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_read_callback))] + [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_x509verify_callback))] static private UnityTls.unitytls_x509verify_result VerifyCallback (void* userData, UnityTls.unitytls_x509list_ref chain, UnityTls.unitytls_errorstate* errorState) { var handle = (GCHandle)(IntPtr)userData; From afc9bb2e9a2b0616a41dcb4da071c3d5b1ea9bb5 Mon Sep 17 00:00:00 2001 From: andreasr Date: Tue, 19 Dec 2017 11:59:54 +0100 Subject: [PATCH 063/582] [unitytls] Cleanup of properties in UntyTlsProvider. Comment notes on use of validator.Settings --- .../System/Mono.UnityTls/UnityTlsProvider.cs | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs index 7e9f10940d8c..3a216bb41f1d 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs @@ -25,27 +25,12 @@ public override string Name { get { return "unitytls"; } } - public override Guid ID { - get { return MNS.MonoTlsProviderFactory.UnityTlsId; } - } - - public override bool SupportsSslStream { - get { return true; } - } - - public override bool SupportsMonoExtensions { - get { return true; } - } - - public override bool SupportsConnectionInfo { - get { return true; } - } - + public override Guid ID => MNS.MonoTlsProviderFactory.UnityTlsId; + public override bool SupportsSslStream => true; + public override bool SupportsMonoExtensions => true; + public override bool SupportsConnectionInfo => true; internal override bool SupportsCleanShutdown => true; - - public override SslProtocols SupportedProtocols { - get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; } - } + public override SslProtocols SupportedProtocols => SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; public override IMonoSslStream CreateSslStream ( Stream innerStream, bool leaveInnerStreamOpen, @@ -89,6 +74,14 @@ internal override bool ValidateCertificate ( { CertHelper.AddCertificatesToNativeChain (certificatesNative, certificates, &errorState); + // Things the validator provides that we might want to make use of here: + //validator.Settings.CheckCertificateName // not used by mono? + //validator.Settings.CheckCertificateRevocationStatus // not used by mono? + //validator.Settings.CertificateValidationTime + //validator.Settings.TrustAnchors + //validator.Settings.CertificateSearchPaths // currently only used by MonoBtlsProvider + //validator.Settings.SendCloseNotify // UnityTls always sends a close notify if the underlying impl supports it. Currently only used by MonoBtlsProvider + // validate UnityTls.unitytls_x509list_ref certificatesNativeRef = UnityTls.unitytls_x509list_get_ref (certificatesNative, &errorState); byte[] targetHostUtf8 = Encoding.UTF8.GetBytes (targetHost); From d303e41050320529bf3575bfe9aca3851a322313 Mon Sep 17 00:00:00 2001 From: andreasr Date: Tue, 19 Dec 2017 12:47:09 +0100 Subject: [PATCH 064/582] [unitytls] UnityTlsProvider no longer ignores validator.Settings.TrustAnchors --- .../System/Mono.UnityTls/UnityTlsProvider.cs | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs index 3a216bb41f1d..0a0fdc813b7b 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs @@ -72,21 +72,32 @@ internal override bool ValidateCertificate ( UnityTls.unitytls_x509verify_result result = UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_NOT_DONE; try { - CertHelper.AddCertificatesToNativeChain (certificatesNative, certificates, &errorState); // Things the validator provides that we might want to make use of here: //validator.Settings.CheckCertificateName // not used by mono? //validator.Settings.CheckCertificateRevocationStatus // not used by mono? //validator.Settings.CertificateValidationTime - //validator.Settings.TrustAnchors //validator.Settings.CertificateSearchPaths // currently only used by MonoBtlsProvider //validator.Settings.SendCloseNotify // UnityTls always sends a close notify if the underlying impl supports it. Currently only used by MonoBtlsProvider - // validate + CertHelper.AddCertificatesToNativeChain (certificatesNative, certificates, &errorState); UnityTls.unitytls_x509list_ref certificatesNativeRef = UnityTls.unitytls_x509list_get_ref (certificatesNative, &errorState); byte[] targetHostUtf8 = Encoding.UTF8.GetBytes (targetHost); - fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { - result = UnityTls.unitytls_x509verify_default_ca (certificatesNativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); + + if (validator.Settings.TrustAnchors != null) { + UnityTls.unitytls_x509list* trustCAnative = UnityTls.unitytls_x509list_create (&errorState); + CertHelper.AddCertificatesToNativeChain (trustCAnative, validator.Settings.TrustAnchors, &errorState); + UnityTls.unitytls_x509list_ref trustCAnativeRef = UnityTls.unitytls_x509list_get_ref (certificatesNative, &errorState); + + fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { + result = UnityTls.unitytls_x509verify_explicit_ca (certificatesNativeRef, trustCAnativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); + } + + UnityTls.unitytls_x509list_free (trustCAnative); + } else { + fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { + result = UnityTls.unitytls_x509verify_default_ca (certificatesNativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); + } } } finally From 2cb0c4c5a1bd45b9fc574c9cefa18ed3618ad849 Mon Sep 17 00:00:00 2001 From: andreasr Date: Tue, 19 Dec 2017 15:07:12 +0100 Subject: [PATCH 065/582] [unitytls] Reverted mono's orginal SslStreamTest --- .../Test/System.Net.Security/SslStreamTest.cs | 39 ++++++------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs b/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs index 978a472ad577..f95a9af066c3 100644 --- a/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs +++ b/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs @@ -58,7 +58,7 @@ public void GetReady () { m_clientCert = new X509Certificate2 (m_clientCertRaw, "client"); } - [TestCase()] + [Test] //bug https://bugzilla.novell.com/show_bug.cgi?id=457120 #if !UNITY [Category ("MacNotWorking")] // Works but launches a prompt on 10.12 that will fail if you don't click in a few seconds #endif @@ -67,10 +67,10 @@ public void GetReady () { #endif public void AuthenticateClientAndServer_ClientSendsNoData () { - AuthenticateClientAndServer (serverAuthShouldSucceed: true, clientAuthShouldSucceed: true); + AuthenticateClientAndServer (true, true); } - void AuthenticateClientAndServer (bool serverAuthShouldSucceed, bool clientAuthShouldSucceed) + void AuthenticateClientAndServer (bool server, bool client) { IPEndPoint endPoint = new IPEndPoint (IPAddress.Parse ("127.0.0.1"), NetworkHelpers.FindFreePort ()); ClientServerState state = new ClientServerState (); @@ -79,15 +79,15 @@ void AuthenticateClientAndServer (bool serverAuthShouldSucceed, bool clientAuthS state.Listener.Start (); state.ServerAuthenticated = new AutoResetEvent (false); state.ClientAuthenticated = new AutoResetEvent (false); - state.AllowServerIOException = !serverAuthShouldSucceed; + state.ServerIOException = !server; try { Thread serverThread = new Thread (() => StartServerAndAuthenticate (state)); serverThread.Start (); Thread clientThread = new Thread (() => StartClientAndAuthenticate (state, endPoint)); clientThread.Start (); - Assert.AreEqual (serverAuthShouldSucceed, state.ServerAuthenticated.WaitOne (TimeSpan.FromSeconds (5)), + Assert.AreEqual (server, state.ServerAuthenticated.WaitOne (TimeSpan.FromSeconds (5)), "server not authenticated"); - Assert.AreEqual (clientAuthShouldSucceed, state.ClientAuthenticated.WaitOne (TimeSpan.FromSeconds (5)), + Assert.AreEqual (client, state.ClientAuthenticated.WaitOne (TimeSpan.FromSeconds (5)), "client not authenticated"); } finally { if (state.ClientStream != null) @@ -107,13 +107,13 @@ private void StartClientAndAuthenticate (ClientServerState state, state.Client.Connect (endPoint.Address, endPoint.Port); NetworkStream s = state.Client.GetStream (); state.ClientStream = new SslStream (s, false, - ClientRemoteCertificateValidationCallback, + (a1, a2, a3, a4) => true, (a1, a2, a3, a4, a5) => m_clientCert); state.ClientStream.AuthenticateAsClient ("test_host"); state.ClientAuthenticated.Set (); } catch (ObjectDisposedException) { /* this can happen when closing connection it's irrelevant for the test result*/ } catch (IOException) { - if (!state.AllowServerIOException) + if (!state.ServerIOException) throw; } } @@ -123,7 +123,7 @@ private void StartServerAndAuthenticate (ClientServerState state) { state.ServerClient = state.Listener.AcceptTcpClient (); NetworkStream s = state.ServerClient.GetStream (); state.ServerStream = new SslStream (s, false, - ServerRemoteCertificateValidationCallback, + (a1, a2, a3, a4) => true, (a1, a2, a3, a4, a5) => m_serverCert); state.ServerStream.AuthenticateAsServer (m_serverCert); state.ServerAuthenticated.Set (); @@ -132,25 +132,11 @@ private void StartServerAndAuthenticate (ClientServerState state) { // The authentication or decryption has failed. // ---> Mono.Security.Protocol.Tls.TlsException: Insuficient Security // that's fine for MismatchedCipherSuites - if (!state.AllowServerIOException) + if (!state.ServerIOException) throw; } } - - public bool ClientRemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) - { - Assert.AreEqual(m_serverCert.RawData, certificate.GetRawCertData(), "Client remote certification callback received a certificate that is not identical to the expected server cert."); - Assert.AreEqual(SslPolicyErrors.None, sslPolicyErrors); - return true; - } - - public bool ServerRemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) - { - Assert.AreEqual(m_clientCert.RawData, certificate.GetRawCertData(), "Server remote certification callback received a certificate that is not identical to the expected client cert."); - Assert.AreEqual(SslPolicyErrors.None, sslPolicyErrors); - return true; - } - + private class ClientServerState { public TcpListener Listener { get; set; } public TcpClient Client { get; set; } @@ -159,8 +145,7 @@ private class ClientServerState { public SslStream ClientStream { get; set; } public AutoResetEvent ServerAuthenticated { get; set; } public AutoResetEvent ClientAuthenticated { get; set; } - public bool AllowServerIOException { get; set; } + public bool ServerIOException { get; set; } } } } - From 9bd3b1aed67c5004c2b60fdab7aece11e0bbd6ca Mon Sep 17 00:00:00 2001 From: andreasr Date: Tue, 19 Dec 2017 15:16:28 +0100 Subject: [PATCH 066/582] [unitytls] TlsProvider validation fills out policy errors now --- .../System/Mono.UnityTls/UnityTlsConversions.cs | 17 +++++++++++++++++ .../System/Mono.UnityTls/UnityTlsProvider.cs | 7 ++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsConversions.cs b/mcs/class/System/Mono.UnityTls/UnityTlsConversions.cs index ba30e1993ec6..e72f8e623c29 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsConversions.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsConversions.cs @@ -85,6 +85,23 @@ public static AlertDescription VerifyResultToAlertDescription (UnityTls.unitytls return defaultAlert; } + + public static MonoSslPolicyErrors VerifyResultToPolicyErrror (UnityTls.unitytls_x509verify_result verifyResult) + { + // First, check "non-flags" + if (verifyResult == UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_SUCCESS) + return MonoSslPolicyErrors.None; + else if (verifyResult == UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FATAL_ERROR) + return MonoSslPolicyErrors.RemoteCertificateChainErrors; + + MonoSslPolicyErrors error = MonoSslPolicyErrors.None; + if (verifyResult.HasFlag (UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_CN_MISMATCH)) + error |= MonoSslPolicyErrors.RemoteCertificateNameMismatch; + // Anything else translates to MonoSslPolicyErrors.RemoteCertificateChainErrors. So if it is not the only flag, add it. + if (verifyResult != UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_CN_MISMATCH) + error |= MonoSslPolicyErrors.RemoteCertificateChainErrors; + return error; + } } } #endif \ No newline at end of file diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs index 0a0fdc813b7b..843fbdf91d30 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs @@ -51,6 +51,11 @@ internal override bool ValidateCertificate ( X509CertificateCollection certificates, bool wantsChain, ref X509Chain chain, ref MonoSslPolicyErrors errors, ref int status11) { + if (certificates == null) { + errors |= MonoSslPolicyErrors.RemoteCertificateNotAvailable; + return false; + } + if (wantsChain) chain = MNS.SystemCertificateValidator.CreateX509Chain (certificates); @@ -72,7 +77,6 @@ internal override bool ValidateCertificate ( UnityTls.unitytls_x509verify_result result = UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_NOT_DONE; try { - // Things the validator provides that we might want to make use of here: //validator.Settings.CheckCertificateName // not used by mono? //validator.Settings.CheckCertificateRevocationStatus // not used by mono? @@ -105,6 +109,7 @@ internal override bool ValidateCertificate ( UnityTls.unitytls_x509list_free (certificatesNative); } + errors = UnityTlsConversions.VerifyResultToPolicyErrror(result); return result == UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_SUCCESS && errorState.code == UnityTls.unitytls_error_code.UNITYTLS_SUCCESS; } From 9dfe4d8348c78b05576ae87cf1e3e39dd9f3d87c Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Tue, 19 Dec 2017 09:16:32 -0500 Subject: [PATCH 067/582] add embedding api lost in mono master merge (#769) * add embedding api lost in mono master * Add MMAP overrides --- mono/utils/mono-filemap.c | 24 ++++++++++++++++++++++++ mono/utils/mono-mmap.c | 15 ++++++++++++++- mono/utils/mono-mmap.h | 11 +++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/mono/utils/mono-filemap.c b/mono/utils/mono-filemap.c index 416ca2625d37..f03a0c263f0d 100644 --- a/mono/utils/mono-filemap.c +++ b/mono/utils/mono-filemap.c @@ -24,9 +24,30 @@ #include "mono-mmap.h" +static MonoFileMapOpen file_open_func = 0; +static MonoFileMapSize file_size_func = 0; +static MonoFileMapFd file_fd_func = 0; +static MonoFileMapClose file_close_func = 0; + MonoFileMapMap file_map_func = 0; + MonoFileMapUnmap file_unmap_func = 0; + +#if defined(ANDROID) +void mono_file_map_override(MonoFileMapOpen open_func, MonoFileMapSize size_func, MonoFileMapFd fd_func, MonoFileMapClose close_func, MonoFileMapMap map_func, MonoFileMapUnmap unmap_func) +{ + file_open_func = open_func; + file_size_func = size_func; + file_fd_func = fd_func; + file_close_func = close_func; + file_map_func = map_func; + file_unmap_func = unmap_func; +} +#endif + + MonoFileMap * mono_file_map_open (const char* name) { + if (file_open_func) return file_open_func(name); #ifdef WIN32 gunichar2 *wname = g_utf8_to_utf16 (name, -1, 0, 0, 0); MonoFileMap *result; @@ -47,6 +68,7 @@ mono_file_map_open (const char* name) guint64 mono_file_map_size (MonoFileMap *fmap) { + if (file_size_func) return file_size_func(fmap); struct stat stat_buf; if (fstat (mono_file_map_fd (fmap), &stat_buf) < 0) return 0; @@ -56,6 +78,7 @@ mono_file_map_size (MonoFileMap *fmap) int mono_file_map_fd (MonoFileMap *fmap) { + if (file_fd_func) return file_fd_func(fmap); #ifdef WIN32 return fileno ((FILE*)fmap); #else @@ -66,6 +89,7 @@ mono_file_map_fd (MonoFileMap *fmap) int mono_file_map_close (MonoFileMap *fmap) { + if (file_close_func) return file_close_func(fmap); #ifdef WIN32 return fclose ((FILE*)fmap); #else diff --git a/mono/utils/mono-mmap.c b/mono/utils/mono-mmap.c index cc2750825b19..b040751ff1dc 100644 --- a/mono/utils/mono-mmap.c +++ b/mono/utils/mono-mmap.c @@ -281,10 +281,20 @@ mono_vfree (void *addr, size_t length, MonoMemAccountType type) * \p ret_handle must point to a void*: this value must be used when unmapping * the memory area using \c mono_file_unmap(). */ +extern MonoFileMapMap file_map_func; +extern MonoFileMapUnmap file_unmap_func; + void* mono_file_map (size_t length, int flags, int fd, guint64 offset, void **ret_handle) { void *ptr; + if (file_map_func) + { + BEGIN_CRITICAL_SECTION; + ptr = file_map_func(length, flags, fd, offset, ret_handle); + END_CRITICAL_SECTION; + return ptr; + } int mflags = 0; int prot = prot_from_flags (flags); /* translate the flags */ @@ -320,7 +330,10 @@ mono_file_unmap (void *addr, void *handle) int res; BEGIN_CRITICAL_SECTION; - res = munmap (addr, (size_t)handle); + if (file_unmap_func) + res = file_unmap_func(addr, handle); + else + res = munmap(addr, (size_t)handle); END_CRITICAL_SECTION; return res; diff --git a/mono/utils/mono-mmap.h b/mono/utils/mono-mmap.h index 2e2c7cdf0367..e1568a8ff88d 100644 --- a/mono/utils/mono-mmap.h +++ b/mono/utils/mono-mmap.h @@ -84,5 +84,16 @@ typedef void (*mono_file_map_release_fn) (void *addr); MONO_API void mono_file_map_set_allocator (mono_file_map_alloc_fn alloc, mono_file_map_release_fn release); +typedef MonoFileMap* (*MonoFileMapOpen) (const char* name); +typedef guint64 (*MonoFileMapSize) (MonoFileMap *fmap); +typedef int (*MonoFileMapFd) (MonoFileMap *fmap); +typedef int (*MonoFileMapClose) (MonoFileMap *fmap); +typedef void * (*MonoFileMapMap) (size_t length, int flags, int fd, guint64 offset, void **ret_handle); +typedef int (*MonoFileMapUnmap) (void *addr, void *handle); + +#if defined(ANDROID) +MONO_API void mono_file_map_override(MonoFileMapOpen open_func, MonoFileMapSize size_func, MonoFileMapFd fd_func, MonoFileMapClose close_func, MonoFileMapMap map_func, MonoFileMapUnmap unmap_func); +#endif + #endif /* __MONO_UTILS_MMAP_H__ */ From dbe0ae820f10455793159487cc619db4833e03fc Mon Sep 17 00:00:00 2001 From: andreasr Date: Tue, 19 Dec 2017 15:17:10 +0100 Subject: [PATCH 068/582] [unitytls] Added tests for correct policy errors --- .../System.Net.Security/SslStreamTest2.cs | 86 ++++++++++++------- 1 file changed, 56 insertions(+), 30 deletions(-) diff --git a/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs b/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs index a235c68513ed..1c9fdba2a0a9 100644 --- a/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs +++ b/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs @@ -18,6 +18,7 @@ namespace MonoTests.System.Net.Security public class SslStreamTest2 { byte[] m_serverCertRaw = { 48, 130, 5, 165, 2, 1, 3, 48, 130, 5, 95, 6, 9, 42, 134, 72, 134, 247, 13, 1, 7, 1, 160, 130, 5, 80, 4, 130, 5, 76, 48, 130, 5, 72, 48, 130, 2, 87, 6, 9, 42, 134, 72, 134, 247, 13, 1, 7, 6, 160, 130, 2, 72, 48, 130, 2, 68, 2, 1, 0, 48, 130, 2, 61, 6, 9, 42, 134, 72, 134, 247, 13, 1, 7, 1, 48, 28, 6, 10, 42, 134, 72, 134, 247, 13, 1, 12, 1, 3, 48, 14, 4, 8, 211, 176, 234, 3, 252, 26, 32, 15, 2, 2, 7, 208, 128, 130, 2, 16, 183, 149, 35, 180, 127, 95, 163, 122, 138, 244, 29, 177, 220, 173, 46, 73, 208, 217, 211, 190, 164, 183, 21, 110, 33, 122, 98, 163, 251, 16, 23, 106, 154, 14, 52, 177, 3, 12, 248, 226, 48, 123, 211, 6, 216, 6, 192, 175, 203, 142, 141, 143, 252, 178, 7, 162, 81, 232, 159, 42, 56, 177, 191, 53, 7, 146, 189, 236, 75, 140, 210, 143, 11, 103, 64, 58, 10, 73, 123, 39, 97, 119, 166, 114, 123, 65, 68, 214, 42, 17, 156, 122, 8, 58, 184, 134, 255, 48, 64, 20, 229, 247, 196, 12, 130, 56, 176, 69, 179, 254, 216, 45, 25, 244, 240, 116, 88, 137, 66, 13, 18, 202, 199, 59, 200, 245, 19, 175, 232, 217, 211, 12, 191, 222, 26, 162, 253, 73, 201, 48, 61, 3, 248, 117, 16, 71, 233, 183, 90, 110, 91, 116, 56, 133, 223, 148, 19, 78, 140, 123, 159, 203, 78, 15, 172, 39, 190, 39, 71, 180, 155, 48, 156, 116, 212, 52, 1, 231, 201, 196, 73, 87, 68, 104, 208, 40, 104, 32, 218, 235, 245, 84, 136, 168, 51, 9, 93, 126, 46, 80, 180, 240, 144, 79, 88, 87, 159, 24, 108, 186, 9, 20, 48, 100, 148, 250, 4, 163, 115, 131, 44, 13, 38, 222, 117, 196, 196, 128, 114, 149, 97, 93, 37, 191, 3, 192, 231, 88, 80, 218, 147, 8, 192, 165, 27, 206, 56, 42, 157, 230, 223, 130, 253, 169, 182, 245, 192, 181, 18, 212, 133, 168, 73, 92, 66, 197, 117, 245, 107, 127, 23, 146, 249, 41, 66, 219, 210, 207, 221, 205, 205, 15, 110, 92, 12, 207, 76, 239, 4, 13, 129, 127, 170, 205, 253, 148, 208, 24, 129, 24, 210, 220, 85, 45, 179, 137, 66, 134, 142, 22, 112, 48, 160, 236, 232, 38, 83, 101, 55, 51, 18, 110, 99, 69, 41, 173, 107, 233, 11, 199, 23, 61, 135, 222, 94, 74, 29, 219, 80, 128, 167, 186, 254, 235, 42, 96, 134, 5, 13, 90, 59, 231, 137, 195, 207, 28, 165, 12, 218, 5, 72, 102, 61, 135, 198, 73, 250, 97, 89, 214, 179, 244, 194, 23, 142, 157, 4, 243, 90, 69, 54, 10, 139, 76, 95, 40, 225, 219, 59, 15, 54, 182, 206, 142, 228, 248, 79, 156, 129, 246, 63, 6, 6, 236, 44, 67, 116, 213, 170, 47, 193, 186, 139, 25, 80, 166, 57, 99, 231, 156, 191, 117, 65, 76, 7, 243, 244, 127, 225, 210, 190, 164, 141, 46, 36, 99, 111, 203, 133, 127, 80, 28, 61, 160, 36, 132, 182, 16, 41, 39, 185, 232, 123, 32, 57, 189, 100, 152, 38, 205, 5, 189, 240, 65, 3, 191, 73, 85, 12, 209, 180, 1, 194, 70, 124, 57, 71, 48, 230, 235, 122, 175, 157, 35, 233, 83, 40, 20, 169, 224, 14, 11, 216, 48, 194, 105, 25, 187, 210, 182, 6, 184, 73, 95, 85, 210, 227, 113, 58, 10, 186, 175, 254, 25, 102, 39, 3, 2, 200, 194, 197, 200, 224, 77, 164, 8, 36, 114, 48, 130, 2, 233, 6, 9, 42, 134, 72, 134, 247, 13, 1, 7, 1, 160, 130, 2, 218, 4, 130, 2, 214, 48, 130, 2, 210, 48, 130, 2, 206, 6, 11, 42, 134, 72, 134, 247, 13, 1, 12, 10, 1, 2, 160, 130, 2, 166, 48, 130, 2, 162, 48, 28, 6, 10, 42, 134, 72, 134, 247, 13, 1, 12, 1, 3, 48, 14, 4, 8, 178, 13, 52, 135, 85, 49, 79, 105, 2, 2, 7, 208, 4, 130, 2, 128, 21, 84, 227, 109, 230, 144, 140, 170, 117, 250, 179, 207, 129, 100, 126, 126, 29, 231, 94, 140, 45, 26, 168, 45, 240, 4, 170, 73, 98, 115, 109, 96, 177, 206, 6, 80, 170, 22, 237, 144, 58, 95, 59, 26, 85, 135, 178, 69, 184, 44, 122, 81, 213, 135, 149, 198, 246, 83, 68, 129, 2, 186, 118, 33, 44, 214, 227, 240, 220, 51, 175, 220, 220, 180, 113, 216, 101, 138, 81, 54, 38, 0, 216, 30, 29, 187, 213, 230, 12, 181, 130, 21, 241, 98, 120, 41, 150, 176, 69, 37, 169, 249, 123, 212, 254, 135, 154, 214, 127, 39, 105, 149, 180, 218, 41, 207, 75, 70, 105, 169, 185, 169, 132, 173, 188, 82, 251, 71, 234, 136, 5, 254, 110, 223, 34, 4, 145, 7, 19, 51, 123, 140, 75, 226, 0, 21, 220, 228, 223, 218, 8, 169, 210, 194, 139, 93, 218, 55, 40, 174, 50, 238, 38, 166, 222, 103, 0, 209, 88, 131, 51, 222, 154, 217, 18, 172, 73, 17, 133, 54, 173, 208, 118, 104, 167, 113, 153, 223, 251, 154, 120, 176, 18, 127, 51, 206, 164, 77, 86, 9, 82, 212, 86, 162, 206, 230, 79, 217, 178, 42, 217, 162, 152, 188, 217, 59, 212, 117, 200, 135, 75, 74, 43, 1, 42, 79, 180, 164, 250, 122, 103, 103, 157, 11, 14, 33, 48, 8, 108, 155, 46, 124, 223, 204, 169, 124, 104, 11, 246, 213, 226, 16, 125, 17, 228, 15, 178, 141, 79, 78, 115, 76, 131, 122, 166, 124, 154, 1, 174, 178, 176, 213, 208, 188, 71, 118, 220, 168, 64, 218, 176, 134, 38, 229, 14, 109, 162, 125, 16, 57, 249, 201, 180, 17, 182, 143, 184, 12, 248, 113, 65, 70, 109, 79, 249, 34, 170, 35, 228, 219, 121, 202, 228, 121, 127, 255, 22, 173, 202, 171, 33, 232, 4, 240, 142, 216, 80, 56, 177, 83, 93, 123, 217, 213, 157, 99, 34, 194, 61, 228, 239, 194, 20, 27, 9, 53, 132, 79, 19, 97, 107, 31, 51, 39, 176, 223, 90, 88, 67, 138, 194, 169, 176, 144, 202, 119, 146, 74, 27, 118, 63, 129, 230, 101, 104, 75, 116, 49, 223, 254, 225, 70, 206, 183, 11, 134, 148, 10, 55, 57, 50, 178, 144, 164, 139, 233, 169, 109, 186, 211, 95, 123, 75, 111, 192, 187, 127, 240, 45, 226, 194, 240, 128, 10, 79, 178, 192, 66, 21, 197, 24, 171, 141, 255, 185, 230, 84, 206, 151, 9, 93, 115, 162, 12, 115, 129, 218, 103, 219, 183, 142, 123, 3, 110, 139, 208, 4, 146, 76, 99, 246, 240, 32, 169, 148, 16, 146, 172, 230, 36, 56, 145, 23, 94, 209, 92, 38, 244, 127, 70, 121, 253, 66, 55, 36, 140, 98, 105, 233, 112, 24, 23, 230, 112, 62, 244, 12, 48, 30, 51, 0, 18, 244, 139, 66, 245, 234, 203, 195, 52, 119, 255, 84, 82, 204, 100, 176, 167, 24, 224, 8, 127, 214, 148, 115, 242, 56, 190, 72, 221, 68, 252, 36, 74, 254, 57, 52, 96, 20, 173, 32, 236, 87, 15, 16, 76, 9, 48, 3, 61, 2, 137, 137, 9, 68, 213, 99, 163, 63, 201, 83, 241, 98, 7, 117, 108, 4, 123, 170, 18, 10, 19, 198, 31, 170, 15, 247, 216, 145, 172, 239, 137, 181, 80, 160, 24, 11, 35, 131, 58, 218, 22, 250, 215, 52, 160, 246, 197, 183, 92, 137, 0, 245, 63, 49, 183, 246, 195, 58, 63, 4, 75, 10, 92, 131, 181, 59, 78, 247, 44, 150, 49, 49, 107, 211, 62, 71, 62, 222, 159, 161, 118, 236, 55, 219, 49, 0, 3, 82, 236, 96, 20, 83, 39, 245, 208, 240, 245, 174, 218, 49, 21, 48, 19, 6, 9, 42, 134, 72, 134, 247, 13, 1, 9, 21, 49, 6, 4, 4, 1, 0, 0, 0, 48, 61, 48, 33, 48, 9, 6, 5, 43, 14, 3, 2, 26, 5, 0, 4, 20, 30, 154, 48, 126, 198, 239, 114, 62, 12, 58, 129, 172, 67, 156, 76, 214, 62, 205, 89, 28, 4, 20, 135, 177, 105, 83, 79, 93, 181, 149, 169, 49, 112, 201, 70, 212, 153, 79, 198, 163, 137, 90, 2, 2, 7, 208 }; + const string m_serverHostName = "server"; private X509Certificate2 m_serverCert; private IPEndPoint m_ipEndPoint; @@ -25,7 +26,6 @@ public class SslStreamTest2 private TcpClient m_tcpServer; private MemoryStream m_stream; - class TestException : Exception { } @@ -33,7 +33,7 @@ class TestException : Exception [SetUp()] public void GetReady() { - m_serverCert = new X509Certificate2(m_serverCertRaw, "server"); + m_serverCert = new X509Certificate2(m_serverCertRaw, m_serverHostName); m_ipEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), NetworkHelpers.FindFreePort ()); } @@ -47,13 +47,39 @@ private void SetupClientServerConnection() tcpListener.Stop(); } + [TestCase] + public void HandshakeVerification_CorrectPolicyError_ForSelfSignedCertificate() + { + SetupClientServerConnection(); + var clientStream = new SslStream(m_tcpClient.GetStream(), false, (sender, certificate, chain, sslPolicyErrors) => + { + Assert.AreEqual (SslPolicyErrors.RemoteCertificateChainErrors, sslPolicyErrors); + return true; + }); + var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); + DoHandshake(clientStream, serverStream); + } + + [TestCase] + public void HandshakeVerification_CorrectPolicyError_ForSelfSignedCertificateWithWrongCN() + { + SetupClientServerConnection(); + var clientStream = new SslStream(m_tcpClient.GetStream(), false, (sender, certificate, chain, sslPolicyErrors) => + { + Assert.AreEqual (SslPolicyErrors.RemoteCertificateChainErrors | SslPolicyErrors.RemoteCertificateNameMismatch, sslPolicyErrors); + return true; + }); + var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); + DoHandshake(clientStream, serverStream, "test"); + } + [TestCase] [ExpectedException(typeof(AuthenticationException))] - public void HandshakeVerificationFailure_client() + public void HandshakeVerification_FailureClient_ByCallback() { SetupClientServerConnection(); - var clientStream = new SslStream(m_tcpClient.GetStream(), true, RemoteCertificateValidationCallback_AlwaysFail); - var serverStream = new SslStream(m_tcpServer.GetStream(), true, RemoteCertificateValidationCallback_AlwaysSucceed); + var clientStream = new SslStream(m_tcpClient.GetStream(), false, RemoteCertificateValidationCallback_AlwaysFail); + var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); DoHandshake(clientStream, serverStream); } @@ -62,50 +88,50 @@ public void HandshakeVerificationFailure_client() // [TestCase] // [ExpectedException(typeof(AuthenticationException))] - // public void HandshakeVerificationFailure_server() + // public void HandshakeVerification_FailureServer_ByCallback() // { // SetupClientServerConnection(); - // var clientStream = new SslStream(m_tcpClient.GetStream(), true, RemoteCertificateValidationCallback_AlwaysSucceed); - // var serverStream = new SslStream(m_tcpServer.GetStream(), true, RemoteCertificateValidationCallback_AlwaysFail); + // var clientStream = new SslStream(m_tcpClient.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); + // var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysFail); // DoHandshake(clientStream, serverStream); // } -Ø + // TODO: Can we support passing on the exception? // [TestCase] // [ExpectedException(typeof(TestException))] - // public void HandshakeVerificationFailure_clientException() + // public void HandshakeVerification_FailureClient_ByException() // { // SetupClientServerConnection(); - // var clientStream = new SslStream(m_tcpClient.GetStream(), true, RemoteCertificateValidationCallback_ThrowException); - // var serverStream = new SslStream(m_tcpServer.GetStream(), true, RemoteCertificateValidationCallback_AlwaysSucceed); + // var clientStream = new SslStream(m_tcpClient.GetStream(), false, RemoteCertificateValidationCallback_ThrowException); + // var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); // DoHandshake(clientStream, serverStream); // } - private void DoHandshake(SslStream clientStream, SslStream serverStream) + private void DoHandshake(SslStream clientStream, SslStream serverStream, string expectedCN = m_serverHostName) { try { - Task.WaitAll( - Task.Run(() => { - try { + Task.WaitAll( + Task.Run(() => { + try { if (clientStream != null) - clientStream.AuthenticateAsClient("test_host"); - } - catch { - m_tcpServer.Close(); - throw; - }}), - Task.Run(() => { - try { + clientStream.AuthenticateAsClient(expectedCN); + } + catch { + m_tcpServer.Close(); + throw; + }}), + Task.Run(() => { + try { if (serverStream != null) - serverStream.AuthenticateAsServer(m_serverCert); - } - catch { - m_tcpClient.Close(); - throw; - }}) + serverStream.AuthenticateAsServer(m_serverCert); + } + catch { + m_tcpClient.Close(); + throw; + }}) ); } // We're intersted in the "first" exception. From 936a9258bd4fd273465b4762f6f6a010cf77fcd4 Mon Sep 17 00:00:00 2001 From: andreasr Date: Tue, 19 Dec 2017 15:49:48 +0100 Subject: [PATCH 069/582] [unitytls] No longer keeping server certs and private key alive. (possible due to a recent update in UnityTls) --- .../System/Mono.UnityTls/UnityTlsContext.cs | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index 63f422dbbcd0..e8c69b4d6911 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -30,8 +30,6 @@ unsafe internal class UnityTlsContext : MobileTlsContext // Native UnityTls objects private UnityTls.unitytls_tlsctx* m_TlsContext = null; - private UnityTls.unitytls_x509list* m_ServerCerts = null; - private UnityTls.unitytls_key* m_ServerPrivateKey = null; // States and certificates X509Certificate m_LocalClientCertificate; @@ -77,19 +75,26 @@ public UnityTlsContext ( if (serverCertificate2 == null || serverCertificate2.PrivateKey == null) throw new ArgumentException ("serverCertificate does not have a private key", "serverCertificate"); - m_ServerCerts = UnityTls.unitytls_x509list_create (&errorState); - CertHelper.AddCertificateToNativeChain (m_ServerCerts, serverCertificate, &errorState); - - byte[] privateKeyDer = PKCS8.PrivateKeyInfo.Encode (serverCertificate2.PrivateKey); - fixed(byte* privateKeyDerPtr = privateKeyDer) { - m_ServerPrivateKey = UnityTls.unitytls_key_parse_der (privateKeyDerPtr, privateKeyDer.Length, null, 0, &errorState); + UnityTls.unitytls_x509list* serverCerts = null; + UnityTls.unitytls_key* serverPrivateKey = null; + try { + serverCerts = UnityTls.unitytls_x509list_create (&errorState); + CertHelper.AddCertificateToNativeChain (serverCerts, serverCertificate, &errorState); + UnityTls.unitytls_x509list_ref serverCertsRef = UnityTls.unitytls_x509list_get_ref (serverCerts, &errorState); + + byte[] privateKeyDer = PKCS8.PrivateKeyInfo.Encode (serverCertificate2.PrivateKey); + fixed(byte* privateKeyDerPtr = privateKeyDer) { + serverPrivateKey = UnityTls.unitytls_key_parse_der (privateKeyDerPtr, privateKeyDer.Length, null, 0, &errorState); + } + UnityTls.unitytls_key_ref serverKeyRef = UnityTls.unitytls_key_get_ref (serverPrivateKey, &errorState); + + Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to parse server key/certificate"); + + m_TlsContext = UnityTls.unitytls_tlsctx_create_server (protocolRange, callbacks, serverCertsRef, serverKeyRef, &errorState); + } finally { + UnityTls.unitytls_x509list_free (serverCerts); + UnityTls.unitytls_key_free (serverPrivateKey); } - - Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to parse server key/certificate"); - - UnityTls.unitytls_x509list_ref serverCertsRef = UnityTls.unitytls_x509list_get_ref (m_ServerCerts, &errorState); - UnityTls.unitytls_key_ref serverKeyRef = UnityTls.unitytls_key_get_ref (m_ServerPrivateKey, &errorState); - m_TlsContext = UnityTls.unitytls_tlsctx_create_server (protocolRange, callbacks, serverCertsRef, serverKeyRef, &errorState); } else { byte [] targetHostUtf8 = Encoding.UTF8.GetBytes (targetHost); @@ -180,10 +185,6 @@ public override void Shutdown () // Destroy native UnityTls objects UnityTls.unitytls_tlsctx_free (m_TlsContext); m_TlsContext = null; - UnityTls.unitytls_x509list_free (m_ServerCerts); - m_ServerCerts = null; - UnityTls.unitytls_key_free (m_ServerPrivateKey); - m_ServerPrivateKey = null; m_HasContext = false; } @@ -217,6 +218,8 @@ public override void StartHandshake () if (IsServer && AskForClientCertificate) { throw new NotImplementedException ("No support for server-sided client certificate check yet."); } + + // TODO: Set ciphers from Settings.EnabledCiphers } public override bool ProcessHandshake () From 5778842d0fc998575ddafdb8d36605fb1362a720 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Wed, 20 Dec 2017 16:05:24 -0500 Subject: [PATCH 070/582] Fix TimeZoneInfo local time on platforms that do not have tzdata CreateLocal works by checking the platform. If it is windows, it uses the windows API or registry depending on api version, UWP, etc. otherwise it checks for the $TZ environment variable. If thats not found. it looks for /etc/localtime.....more obscure platforms like WebGL have no means of obtaining tzdata this way. This means that CreateLocal falls back to setting the TimeZoneInfo.Local time to UTC....this causes functions like DateTime.Now and DateTime.ToLocalTime to convert to UTC, instead of the user's local time. By using Mono's old icall, we won't be able to convert between arbitrary timezones, but basic time conversion, such as UTC to Local will work. --- mcs/class/corlib/System/TimeZone.cs | 13 + mcs/class/corlib/System/TimeZoneInfo.Unity.cs | 136 +++++++++ mcs/class/corlib/System/TimeZoneInfo.cs | 26 +- mcs/class/corlib/corlib.dll.sources | 1 + mono/metadata/Makefile.am | 3 +- mono/metadata/icall-def.h | 3 + mono/metadata/icall-internals.h | 4 + mono/metadata/unity-icall.c | 259 ++++++++++++++++++ msvc/libmonoruntime-unity.targets | 1 + msvc/libmonoruntime-unity.targets.filters | 4 + 10 files changed, 447 insertions(+), 3 deletions(-) create mode 100644 mcs/class/corlib/System/TimeZoneInfo.Unity.cs create mode 100644 mono/metadata/unity-icall.c diff --git a/mcs/class/corlib/System/TimeZone.cs b/mcs/class/corlib/System/TimeZone.cs index 1cfa2ee9bcc3..ba24b44788fa 100644 --- a/mcs/class/corlib/System/TimeZone.cs +++ b/mcs/class/corlib/System/TimeZone.cs @@ -210,5 +210,18 @@ public override bool IsDaylightSavingTime (DateTime dateTime) return LocalTimeZone.IsDaylightSavingTime (dateTime); } + + + // Internal method to get timezone data. + // data[0]: start of daylight saving time (in DateTime ticks). + // data[1]: end of daylight saving time (in DateTime ticks). + // data[2]: utcoffset (in TimeSpan ticks). + // data[3]: additional offset when daylight saving (in TimeSpan ticks). + // name[0]: name of this timezone when not daylight saving. + // name[1]: name of this timezone when daylight saving. +#if UNITY + [MethodImplAttribute(MethodImplOptions.InternalCall)] + public static extern bool GetTimeZoneData (int year, out Int64[] data, out string[] names); +#endif } } diff --git a/mcs/class/corlib/System/TimeZoneInfo.Unity.cs b/mcs/class/corlib/System/TimeZoneInfo.Unity.cs new file mode 100644 index 000000000000..934dde9490b3 --- /dev/null +++ b/mcs/class/corlib/System/TimeZoneInfo.Unity.cs @@ -0,0 +1,136 @@ +// +// System.TimeZoneInfo helper for MonoTouch +// because the devices cannot access the file system to read the data +// +// Authors: +// Sebastien Pouliot +// +// Copyright 2011-2013 Xamarin Inc. +// +// The class can be either constructed from a string (from user code) +// or from a handle (from iphone-sharp.dll internal calls). This +// delays the creation of the actual managed string until actually +// required +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +#if UNITY + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; +using System.IO; + +namespace System { + + public partial class TimeZoneInfo { + enum TimeZoneData + { + DaylightSavingStartIdx, + DaylightSavingEndIdx, + UtcOffsetIdx, + AdditionalDaylightOffsetIdx + }; + + enum TimeZoneNames + { + StandardNameIdx, + DaylightNameIdx + }; + static TimeZoneInfo CreateLocalUnity () + { + Int64[] data; + string[] names; + if (!System.CurrentSystemTimeZone.GetTimeZoneData (1973, out data, out names)) + throw new NotSupportedException ("Can't get timezone name."); + + TimeSpan utcOffsetTS = TimeSpan.FromTicks(data[(int)TimeZoneData.UtcOffsetIdx]); + char utcOffsetSign = (utcOffsetTS >= TimeSpan.Zero) ? '+' : '-'; + string displayName = "(GMT" + utcOffsetSign + utcOffsetTS.ToString(@"hh\:mm") + ") Local Time"; + string standardDisplayName = names[(int)TimeZoneNames.StandardNameIdx]; + string daylightDisplayName = names[(int)TimeZoneNames.DaylightNameIdx]; + + //Create The Adjustment Rules For This TimeZoneInfo. + var adjustmentList = new List(); + for(int year = 1973; year <= 2037; year++) + { + if (!System.CurrentSystemTimeZone.GetTimeZoneData (year, out data, out names)) + continue; + + DaylightTime dlt = new DaylightTime (new DateTime (data[(int)TimeZoneData.DaylightSavingStartIdx]), + new DateTime (data[(int)TimeZoneData.DaylightSavingEndIdx]), + new TimeSpan (data[(int)TimeZoneData.AdditionalDaylightOffsetIdx])); + + DateTime dltStartTime = new DateTime(1, 1, 1).Add(dlt.Start.TimeOfDay); + DateTime dltEndTime = new DateTime(1, 1, 1).Add(dlt.End.TimeOfDay); + + if (dlt.Start == dlt.End) + continue; + + TimeZoneInfo.TransitionTime startTime = TimeZoneInfo.TransitionTime.CreateFixedDateRule(dltStartTime, dlt.Start.Month, dlt.Start.Day); + TimeZoneInfo.TransitionTime endTime = TimeZoneInfo.TransitionTime.CreateFixedDateRule(dltEndTime, dlt.End.Month, dlt.End.Day); + + + //mktime only supports dates starting in 1973, so create an adjustment rule for years before 1973 following 1973s rules + if (year == 1973) + { + TimeZoneInfo.AdjustmentRule firstRule = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(DateTime.MinValue, + new DateTime(1969, 12, 31), + dlt.Delta, + startTime, + endTime); + adjustmentList.Add(firstRule); + } + + TimeZoneInfo.AdjustmentRule rule = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(new DateTime(year, 1, 1), + new DateTime(year, 12, 31), + dlt.Delta, + startTime, + endTime); + adjustmentList.Add(rule); + + //mktime only supports dates up to 2037, so create an adjustment rule for years after 2037 following 2037s rules + if (year == 2037) + { + // create a max date that does not include any time of day offset to make CreateAdjustmentRule happy + var maxDate = new DateTime(DateTime.MaxValue.Year, DateTime.MaxValue.Month, DateTime.MaxValue.Day); + TimeZoneInfo.AdjustmentRule lastRule = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(new DateTime(2038, 1, 1), + maxDate, + dlt.Delta, + startTime, + endTime); + adjustmentList.Add(lastRule); + } + } + + return TimeZoneInfo.CreateCustomTimeZone("local", + utcOffsetTS, + displayName, + standardDisplayName, + daylightDisplayName, + adjustmentList.ToArray(), + false); + } + } +} + +#endif diff --git a/mcs/class/corlib/System/TimeZoneInfo.cs b/mcs/class/corlib/System/TimeZoneInfo.cs index a1eaf2a7cf37..b69139680789 100644 --- a/mcs/class/corlib/System/TimeZoneInfo.cs +++ b/mcs/class/corlib/System/TimeZoneInfo.cs @@ -1,5 +1,4 @@ - -/* + /* * System.TimeZoneInfo * * Author(s) @@ -122,6 +121,11 @@ private static string readlink (string path) private static bool TryGetNameFromPath (string path, out string name) { name = null; +#if UNITY + //Avoids calling readlink on webgl, which causes abort due to dlopen + if(!File.Exists(path)) + return false; +#endif var linkPath = readlink (path); if (linkPath != null) { if (Path.IsPathRooted(linkPath)) @@ -165,14 +169,28 @@ static TimeZoneInfo CreateLocal () } #endif +#if UNITY + var localTimeZoneFallback = CreateLocalUnity(); + if(localTimeZoneFallback == null) + localTimeZoneFallback = Utc; +#endif + var tz = Environment.GetEnvironmentVariable ("TZ"); if (tz != null) { if (tz == String.Empty) +#if UNITY + return localTimeZoneFallback; +#else return Utc; +#endif try { return FindSystemTimeZoneByFileName (tz, Path.Combine (TimeZoneDirectory, tz)); } catch { +#if UNITY + return localTimeZoneFallback; +#else return Utc; +#endif } } @@ -191,7 +209,11 @@ static TimeZoneInfo CreateLocal () } } +#if UNITY + return localTimeZoneFallback; +#else return Utc; +#endif } static TimeZoneInfo FindSystemTimeZoneByIdCore (string id) diff --git a/mcs/class/corlib/corlib.dll.sources b/mcs/class/corlib/corlib.dll.sources index abfe4d1537d8..accfb9c2cf2d 100644 --- a/mcs/class/corlib/corlib.dll.sources +++ b/mcs/class/corlib/corlib.dll.sources @@ -142,6 +142,7 @@ System/TimeZoneInfo.cs System/TimeZoneInfo.Android.cs System/TimeZoneInfo.MonoTouch.cs System/TimeZoneInfo.Serialization.cs +System/TimeZoneInfo.Unity.cs System/TimeZoneInfo.WinRT.cs ../../build/common/MonoTODOAttribute.cs System/TypeIdentifier.cs diff --git a/mono/metadata/Makefile.am b/mono/metadata/Makefile.am index 056188e53400..748713e178b7 100644 --- a/mono/metadata/Makefile.am +++ b/mono/metadata/Makefile.am @@ -140,7 +140,8 @@ unity_sources = \ unity-memory-info.c \ unity-memory-info.h \ unity-utils.c \ - unity-utils.h + unity-utils.h \ + unity-icall.c common_sources = \ $(platform_sources) \ diff --git a/mono/metadata/icall-def.h b/mono/metadata/icall-def.h index 6bc2d9b2a27d..f1ac3faf3eb7 100644 --- a/mono/metadata/icall-def.h +++ b/mono/metadata/icall-def.h @@ -186,6 +186,9 @@ ICALL(CONSOLE_3, "SetBreak", ves_icall_System_ConsoleDriver_SetBreak ) ICALL(CONSOLE_4, "SetEcho", ves_icall_System_ConsoleDriver_SetEcho ) ICALL(CONSOLE_5, "TtySetup", ves_icall_System_ConsoleDriver_TtySetup ) +ICALL_TYPE(TZONE, "System.CurrentSystemTimeZone", TZONE_1) +ICALL(TZONE_1, "GetTimeZoneData", ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData) + ICALL_TYPE(DTIME, "System.DateTime", DTIME_1) ICALL(DTIME_1, "GetSystemTimeAsFileTime", mono_100ns_datetime) diff --git a/mono/metadata/icall-internals.h b/mono/metadata/icall-internals.h index c172b8404bcb..c3ee79d03999 100644 --- a/mono/metadata/icall-internals.h +++ b/mono/metadata/icall-internals.h @@ -10,6 +10,10 @@ #include #include +// UNITY +guint32 +ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData (guint32 year, MonoArray **data, MonoArray **names); + // On Windows platform implementation of bellow methods are hosted in separate source file // icall-windows.c or icall-windows-*.c. On other platforms the implementation is still keept // in icall.c still declared as static and in some places even inlined. diff --git a/mono/metadata/unity-icall.c b/mono/metadata/unity-icall.c new file mode 100644 index 000000000000..1de9b6be406d --- /dev/null +++ b/mono/metadata/unity-icall.c @@ -0,0 +1,259 @@ +/** + * \file + * Unity icall support for Mono. + * + * Copyright 2016 Unity + * Licensed under the MIT license. See LICENSE file in the project root for full license information. +*/ +#include +#include +#include "mono/utils/mono-compiler.h" +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_SYS_TIME_H +#include +#endif + +/* + * Magic number to convert a time which is relative to + * Jan 1, 1970 into a value which is relative to Jan 1, 0001. + */ +#define EPOCH_ADJUST ((guint64)62135596800LL) + +/* + * Magic number to convert FILETIME base Jan 1, 1601 to DateTime - base Jan, 1, 0001 + */ +#define FILETIME_ADJUST ((guint64)504911232000000000LL) + +#ifdef PLATFORM_WIN32 +/* convert a SYSTEMTIME which is of the form "last thursday in october" to a real date */ +static void +convert_to_absolute_date(SYSTEMTIME *date) +{ +#define IS_LEAP(y) ((y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0)) + static int days_in_month[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + static int leap_days_in_month[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + /* from the calendar FAQ */ + int a = (14 - date->wMonth) / 12; + int y = date->wYear - a; + int m = date->wMonth + 12 * a - 2; + int d = (1 + y + y/4 - y/100 + y/400 + (31*m)/12) % 7; + + /* d is now the day of the week for the first of the month (0 == Sunday) */ + + int day_of_week = date->wDayOfWeek; + + /* set day_in_month to the first day in the month which falls on day_of_week */ + int day_in_month = 1 + (day_of_week - d); + if (day_in_month <= 0) + day_in_month += 7; + + /* wDay is 1 for first weekday in month, 2 for 2nd ... 5 means last - so work that out allowing for days in the month */ + date->wDay = day_in_month + (date->wDay - 1) * 7; + if (date->wDay > (IS_LEAP(date->wYear) ? leap_days_in_month[date->wMonth - 1] : days_in_month[date->wMonth - 1])) + date->wDay -= 7; +} +#endif + +#ifndef PLATFORM_WIN32 +/* + * Return's the offset from GMT of a local time. + * + * tm is a local time + * t is the same local time as seconds. + */ +static int +gmt_offset(struct tm *tm, time_t t) +{ +#if defined (HAVE_TM_GMTOFF) + return tm->tm_gmtoff; +#else + struct tm g; + time_t t2; + g = *gmtime(&t); + g.tm_isdst = tm->tm_isdst; + t2 = mktime(&g); + return (int)difftime(t, t2); +#endif +} +#endif +/* + * This is heavily based on zdump.c from glibc 2.2. + * + * * data[0]: start of daylight saving time (in DateTime ticks). + * * data[1]: end of daylight saving time (in DateTime ticks). + * * data[2]: utcoffset (in TimeSpan ticks). + * * data[3]: additional offset when daylight saving (in TimeSpan ticks). + * * name[0]: name of this timezone when not daylight saving. + * * name[1]: name of this timezone when daylight saving. + * + * FIXME: This only works with "standard" Unix dates (years between 1900 and 2100) while + * the class library allows years between 1 and 9999. + * + * Returns true on success and zero on failure. + */ +guint32 +ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData (guint32 year, MonoArray **data, MonoArray **names) +{ + MonoError error; +#ifndef PLATFORM_WIN32 + MonoDomain *domain = mono_domain_get (); + struct tm start, tt; + time_t t; + + long int gmtoff; + int is_daylight = 0, day; + char tzone [64]; + + MONO_CHECK_ARG_NULL (data, FALSE); + MONO_CHECK_ARG_NULL (names, FALSE); + + mono_gc_wbarrier_generic_store (data, (MonoObject*) mono_array_new_checked (domain, mono_defaults.int64_class, 4, &error)); + mono_gc_wbarrier_generic_store (names, (MonoObject*) mono_array_new_checked (domain, mono_defaults.string_class, 2, &error)); + + /* + * no info is better than crashing: we'll need our own tz data + * to make this work properly, anyway. The range is probably + * reduced to 1970 .. 2037 because that is what mktime is + * guaranteed to support (we get into an infinite loop + * otherwise). + */ + + memset (&start, 0, sizeof (start)); + + start.tm_mday = 1; + start.tm_year = year-1900; + + t = mktime (&start); + + if ((year < 1970) || (year > 2037) || (t == -1)) { + t = time (NULL); + tt = *localtime (&t); + strftime (tzone, sizeof (tzone), "%Z", &tt); + mono_array_setref ((*names), 0, mono_string_new_checked (domain, tzone, &error)); + mono_array_setref ((*names), 1, mono_string_new_checked (domain, tzone, &error)); + return 1; + } + + gmtoff = gmt_offset (&start, t); + + /* For each day of the year, calculate the tm_gmtoff. */ + for (day = 0; day < 365; day++) { + + t += 3600*24; + tt = *localtime (&t); + + /* Daylight saving starts or ends here. */ + if (gmt_offset (&tt, t) != gmtoff) { + struct tm tt1; + time_t t1; + + /* Try to find the exact hour when daylight saving starts/ends. */ + t1 = t; + do { + t1 -= 3600; + tt1 = *localtime (&t1); + } while (gmt_offset (&tt1, t1) != gmtoff); + + /* Try to find the exact minute when daylight saving starts/ends. */ + do { + t1 += 60; + tt1 = *localtime (&t1); + } while (gmt_offset (&tt1, t1) == gmtoff); + t1+=gmtoff; + strftime (tzone, sizeof (tzone), "%Z", &tt); + + /* Write data, if we're already in daylight saving, we're done. */ + if (is_daylight) { + mono_array_setref ((*names), 0, mono_string_new_checked (domain, tzone, &error)); + mono_array_set ((*data), gint64, 1, ((gint64)t1 + EPOCH_ADJUST) * 10000000L); + return 1; + } else { + mono_array_setref ((*names), 1, mono_string_new_checked (domain, tzone, &error)); + mono_array_set ((*data), gint64, 0, ((gint64)t1 + EPOCH_ADJUST) * 10000000L); + is_daylight = 1; + } + + /* This is only set once when we enter daylight saving. */ + mono_array_set ((*data), gint64, 2, (gint64)gmtoff * 10000000L); + mono_array_set ((*data), gint64, 3, (gint64)(gmt_offset (&tt, t) - gmtoff) * 10000000L); + + gmtoff = gmt_offset (&tt, t); + } + } + + if (!is_daylight) { + strftime (tzone, sizeof (tzone), "%Z", &tt); + mono_array_setref ((*names), 0, mono_string_new_checked (domain, tzone, &error)); + mono_array_setref ((*names), 1, mono_string_new_checked (domain, tzone, &error)); + mono_array_set ((*data), gint64, 0, 0); + mono_array_set ((*data), gint64, 1, 0); + mono_array_set ((*data), gint64, 2, (gint64) gmtoff * 10000000L); + mono_array_set ((*data), gint64, 3, 0); + } + + return 1; +#else + MonoDomain *domain = mono_domain_get (); + TIME_ZONE_INFORMATION tz_info; + FILETIME ft; + int i; + int err, tz_id; + + tz_id = GetTimeZoneInformation (&tz_info); + if (tz_id == TIME_ZONE_ID_INVALID) + return 0; + + MONO_CHECK_ARG_NULL (data); + MONO_CHECK_ARG_NULL (names); + + mono_gc_wbarrier_generic_store (data, mono_array_new (domain, mono_defaults.int64_class, 4)); + mono_gc_wbarrier_generic_store (names, mono_array_new (domain, mono_defaults.string_class, 2)); + + for (i = 0; i < 32; ++i) + if (!tz_info.DaylightName [i]) + break; + mono_array_setref ((*names), 1, mono_string_new_utf16 (domain, tz_info.DaylightName, i)); + for (i = 0; i < 32; ++i) + if (!tz_info.StandardName [i]) + break; + mono_array_setref ((*names), 0, mono_string_new_utf16 (domain, tz_info.StandardName, i)); + + if ((year <= 1601) || (year > 30827)) { + /* + * According to MSDN, the MS time functions can't handle dates outside + * this interval. + */ + return 1; + } + + /* even if the timezone has no daylight savings it may have Bias (e.g. GMT+13 it seems) */ + if (tz_id != TIME_ZONE_ID_UNKNOWN) { + tz_info.StandardDate.wYear = year; + convert_to_absolute_date(&tz_info.StandardDate); + err = SystemTimeToFileTime (&tz_info.StandardDate, &ft); + //g_assert(err); + if (err == 0) + return 0; + + mono_array_set ((*data), gint64, 1, FILETIME_ADJUST + (((guint64)ft.dwHighDateTime<<32) | ft.dwLowDateTime)); + tz_info.DaylightDate.wYear = year; + convert_to_absolute_date(&tz_info.DaylightDate); + err = SystemTimeToFileTime (&tz_info.DaylightDate, &ft); + //g_assert(err); + if (err == 0) + return 0; + + mono_array_set ((*data), gint64, 0, FILETIME_ADJUST + (((guint64)ft.dwHighDateTime<<32) | ft.dwLowDateTime)); + } + mono_array_set ((*data), gint64, 2, (tz_info.Bias + tz_info.StandardBias) * -600000000LL); + mono_array_set ((*data), gint64, 3, (tz_info.DaylightBias - tz_info.StandardBias) * -600000000LL); + + return 1; +#endif +} diff --git a/msvc/libmonoruntime-unity.targets b/msvc/libmonoruntime-unity.targets index 1537b0610a30..4a7c19738af5 100644 --- a/msvc/libmonoruntime-unity.targets +++ b/msvc/libmonoruntime-unity.targets @@ -6,5 +6,6 @@ + diff --git a/msvc/libmonoruntime-unity.targets.filters b/msvc/libmonoruntime-unity.targets.filters index ebfb58fe7014..46ccf1069f0d 100644 --- a/msvc/libmonoruntime-unity.targets.filters +++ b/msvc/libmonoruntime-unity.targets.filters @@ -16,6 +16,10 @@ Header Files$(MonoRuntimeFilterSubFolder)\unity + + Source Files$(MonoRuntimeFilterSubFolder)\unity + + From f9389419d962e899dd3c0c71d57a09a4a8b17f4c Mon Sep 17 00:00:00 2001 From: andreasr Date: Thu, 21 Dec 2017 12:12:31 +0100 Subject: [PATCH 071/582] [unitytls] Emulating .net's behavior to call authentification even if server client authentification is disabled --- mcs/class/System/Mono.UnityTls/UnityTlsContext.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index e8c69b4d6911..7a359e030752 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -235,6 +235,13 @@ public override bool ProcessHandshake () else Unity.Debug.CheckAndThrow (errorState, result, "Handshake failed", AlertDescription.HandshakeFailure); + // .Net implementation gives the server a verification callback (with null cert) even if AskForClientCertificate is false. + // We stick to this behavior here. + if (IsServer && !AskForClientCertificate) { + if (!ValidateCertificate (null, null)) + throw new TlsException (AlertDescription.HandshakeFailure, "Verification failure during handshake"); + } + return true; } From 39be2ef06a976e0cf1d223c36b43212b603bc289 Mon Sep 17 00:00:00 2001 From: andreasr Date: Thu, 21 Dec 2017 12:13:14 +0100 Subject: [PATCH 072/582] [unitytls] Added tests for server client auth callback and getting correct certificates in callbacks --- .../System.Net.Security/SslStreamTest2.cs | 91 ++++++++++++------- 1 file changed, 58 insertions(+), 33 deletions(-) diff --git a/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs b/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs index 1c9fdba2a0a9..9f7b1795dbd2 100644 --- a/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs +++ b/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs @@ -83,18 +83,32 @@ public void HandshakeVerification_FailureClient_ByCallback() DoHandshake(clientStream, serverStream); } -// We don't support client authentification, so we can't fail the handshake on the server side -// Note that in contrast to .Net we don't call the verification callback (with a null certificate) if verification is disabled. + [TestCase] + [ExpectedException(typeof(AuthenticationException))] + public void HandshakeVerification_FailureServer_ByCallback_WithoutClientAuth() + { + SetupClientServerConnection(); + var clientStream = new SslStream(m_tcpClient.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); + var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysFail); + DoHandshake(clientStream, serverStream); + } - // [TestCase] - // [ExpectedException(typeof(AuthenticationException))] - // public void HandshakeVerification_FailureServer_ByCallback() - // { - // SetupClientServerConnection(); - // var clientStream = new SslStream(m_tcpClient.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); - // var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysFail); - // DoHandshake(clientStream, serverStream); - // } + [TestCase] + public void HandshakeVerification_CorrectCertificates_WithoutClientAuth() + { + SetupClientServerConnection(); + var clientStream = new SslStream(m_tcpClient.GetStream(), false, (sender, certificate, chain, sslPolicyErrors) => + { + Assert.AreEqual (m_serverCert.GetRawCertData(), certificate.GetRawCertData()); + return true; + }); + var serverStream = new SslStream(m_tcpServer.GetStream(), false, (sender, certificate, chain, sslPolicyErrors) => + { + Assert.IsNull (certificate); + return true; + }); + DoHandshake(clientStream, serverStream, "test"); + } // TODO: Can we support passing on the exception? @@ -113,34 +127,45 @@ private void DoHandshake(SslStream clientStream, SslStream serverStream, string { try { - Task.WaitAll( - Task.Run(() => { - try { + Task.WaitAll( + Task.Run(() => { + try { if (clientStream != null) - clientStream.AuthenticateAsClient(expectedCN); - } - catch { - m_tcpServer.Close(); - throw; - }}), - Task.Run(() => { - try { + clientStream.AuthenticateAsClient(expectedCN); + } + catch (global::System.IO.IOException) {} // Failure on server side will close client connection. + catch { + m_tcpServer.Close(); + throw; + }}), + Task.Run(() => { + try { if (serverStream != null) - serverStream.AuthenticateAsServer(m_serverCert); - } - catch { - m_tcpClient.Close(); - throw; - }}) + serverStream.AuthenticateAsServer(m_serverCert); + } + catch (global::System.IO.IOException) {} // Failure on client side will close server connection. + catch { + m_tcpClient.Close(); + throw; + }}) ); } - // We're intersted in the "first" exception. + // Filter for AuthentificationException catch (AggregateException e) { - if (e.InnerException is AggregateException) - throw e.InnerException.InnerException; - else - throw e.InnerException; + FilterForAuthExceptionAndRethrow(e); + throw e; + } + } + + private void FilterForAuthExceptionAndRethrow(Exception e) + { + if (e is AuthenticationException) + throw e; + else if (e is AggregateException) + { + foreach (var inner in ((AggregateException)e).InnerExceptions) + FilterForAuthExceptionAndRethrow(inner); } } From bf391b2f958b946a8b1366c4005159ab8a332de7 Mon Sep 17 00:00:00 2001 From: andreasr Date: Thu, 21 Dec 2017 12:19:58 +0100 Subject: [PATCH 073/582] [unitytls] Added test for failing handshake via user exception --- .../System.Net.Security/SslStreamTest2.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs b/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs index 9f7b1795dbd2..a4ccb6b6fde7 100644 --- a/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs +++ b/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs @@ -110,17 +110,16 @@ public void HandshakeVerification_CorrectCertificates_WithoutClientAuth() DoHandshake(clientStream, serverStream, "test"); } -// TODO: Can we support passing on the exception? - // [TestCase] - // [ExpectedException(typeof(TestException))] - // public void HandshakeVerification_FailureClient_ByException() - // { - // SetupClientServerConnection(); - // var clientStream = new SslStream(m_tcpClient.GetStream(), false, RemoteCertificateValidationCallback_ThrowException); - // var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); - // DoHandshake(clientStream, serverStream); - // } + [TestCase] + [ExpectedException(typeof(AuthenticationException))]//typeof(TestException))] // TODO: Can we support passing on the exception like .Net does? + public void HandshakeVerification_FailureClient_ByException() + { + SetupClientServerConnection(); + var clientStream = new SslStream(m_tcpClient.GetStream(), false, RemoteCertificateValidationCallback_ThrowException); + var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); + DoHandshake(clientStream, serverStream); + } private void DoHandshake(SslStream clientStream, SslStream serverStream, string expectedCN = m_serverHostName) From e7671c19fd4e87370dfcdedfeb92a114cde23fbc Mon Sep 17 00:00:00 2001 From: andreasr Date: Thu, 21 Dec 2017 12:30:46 +0100 Subject: [PATCH 074/582] [unitytls] Added simple read write test --- .../System.Net.Security/SslStreamTest2.cs | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs b/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs index a4ccb6b6fde7..d1fd5d3f38fe 100644 --- a/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs +++ b/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs @@ -2,6 +2,7 @@ using NUnit.Framework; using System; +using System.Text; using System.IO; using System.Net; using System.Net.Security; @@ -110,7 +111,6 @@ public void HandshakeVerification_CorrectCertificates_WithoutClientAuth() DoHandshake(clientStream, serverStream, "test"); } - [TestCase] [ExpectedException(typeof(AuthenticationException))]//typeof(TestException))] // TODO: Can we support passing on the exception like .Net does? public void HandshakeVerification_FailureClient_ByException() @@ -121,6 +121,28 @@ public void HandshakeVerification_FailureClient_ByException() DoHandshake(clientStream, serverStream); } + [TestCase] + public void ReadWriteData() + { + SetupClientServerConnection(); + var clientStream = new SslStream(m_tcpClient.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); + var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); + DoHandshake(clientStream, serverStream); + + // Send client to server. + byte[] message = Encoding.UTF8.GetBytes("Hello Mono!"); + byte[] receiveBuffer = new byte[message.Length]; + clientStream.Write(message); + serverStream.Read(receiveBuffer, 0, receiveBuffer.Length); + Assert.AreEqual(message, receiveBuffer); + + // Send server to client. + receiveBuffer = new byte[message.Length]; + serverStream.Write(message); + clientStream.Read(receiveBuffer, 0, receiveBuffer.Length); + Assert.AreEqual(message, receiveBuffer); + } + private void DoHandshake(SslStream clientStream, SslStream serverStream, string expectedCN = m_serverHostName) { From 3b9f52dd3b530737dc76007811ad7a2d167fa643 Mon Sep 17 00:00:00 2001 From: andreasr Date: Thu, 21 Dec 2017 14:59:26 +0100 Subject: [PATCH 075/582] [unitytls] Added test to verify properties of encryption after handshake --- .../Test/System.Net.Security/SslStreamTest2.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs b/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs index d1fd5d3f38fe..766e441f3ace 100644 --- a/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs +++ b/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs @@ -121,6 +121,24 @@ public void HandshakeVerification_FailureClient_ByException() DoHandshake(clientStream, serverStream); } + [TestCase] + public void HandshakeVerification_CorrectEncryptionProperties() + { + SetupClientServerConnection(); + var clientStream = new SslStream(m_tcpClient.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); + var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); + DoHandshake(clientStream, serverStream); + + Assert.AreEqual(SslProtocols.Tls12, clientStream.SslProtocol); + Assert.AreEqual(SslProtocols.Tls12, serverStream.SslProtocol); + + // Expected cipher is TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA + //Assert.AreEqual(CipherAlgorithmType.Aes256, clientStream.CipherAlgorithm); // Not filled out by UnityTls binding + //Assert.AreEqual(256, clientStream.CipherStrength); // Not implemented by Mono.Net.Security.MobileAuthenticatedStream. + //Assert.AreEqual(HashAlgorithmType.Sha1, clientStream.HashAlgorithm); // Not filled out by UnityTls binding + //Assert.AreEqual(ExchangeAlgorithmType.DiffieHellman, clientStream.KeyExchangeAlgorithm); // Not filled out by UnityTls binding + } + [TestCase] public void ReadWriteData() { From 37431ded5d42fb7f2adda9597d43a1276fea57b4 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Thu, 21 Dec 2017 10:51:32 -0500 Subject: [PATCH 076/582] Ensure mono_gc_dllmain always returns a value. --- mono/metadata/boehm-gc.c | 2 ++ msvc/libmono-dynamic.vcxproj | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index f312607de343..24dcfaa934c9 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -1522,6 +1522,8 @@ BOOL APIENTRY mono_gc_dllmain (HMODULE module_handle, DWORD reason, LPVOID reser { #ifdef GC_INSIDE_DLL return GC_DllMain (module_handle, reason, reserved); +#else + return TRUE; #endif } #endif diff --git a/msvc/libmono-dynamic.vcxproj b/msvc/libmono-dynamic.vcxproj index 3743f43468ed..59d695e6ffaf 100644 --- a/msvc/libmono-dynamic.vcxproj +++ b/msvc/libmono-dynamic.vcxproj @@ -95,7 +95,7 @@ - /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) + /we4716 /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) Disabled $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);%(AdditionalIncludeDirectories) WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;_DEBUG;%(PreprocessorDefinitions) @@ -134,7 +134,7 @@ X64 - /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) + /we4716 /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) Disabled $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);%(AdditionalIncludeDirectories) WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;WIN64;_DEBUG;%(PreprocessorDefinitions) @@ -168,7 +168,7 @@ - /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) + /we4716 /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) true $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);%(AdditionalIncludeDirectories) WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;NDEBUG;%(PreprocessorDefinitions) @@ -207,7 +207,7 @@ X64 - /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) + /we4716 /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) true $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);%(AdditionalIncludeDirectories) WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;WIN64;NDEBUG;%(PreprocessorDefinitions) From b7052c03210846c3e0aabfeab7a5b24749720bda Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Thu, 21 Dec 2017 11:12:48 -0500 Subject: [PATCH 077/582] Disable incremental link for release builds. This causes native stack traces to be incorrect for exported mono symbols. Also, move warning as error for 4716 from additional command line args to explicit setting in vcxproj. --- msvc/libmono-dynamic.vcxproj | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/msvc/libmono-dynamic.vcxproj b/msvc/libmono-dynamic.vcxproj index 59d695e6ffaf..d63cc408b1e6 100644 --- a/msvc/libmono-dynamic.vcxproj +++ b/msvc/libmono-dynamic.vcxproj @@ -89,13 +89,19 @@ true + + false + + + false + - /we4716 /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) + /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) Disabled $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);%(AdditionalIncludeDirectories) WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;_DEBUG;%(PreprocessorDefinitions) @@ -104,6 +110,7 @@ 4996;4018;4244;%(DisableSpecificWarnings) Level3 true + 4716 _DEBUG;%(PreprocessorDefinitions) @@ -134,7 +141,7 @@ X64 - /we4716 /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) + /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) Disabled $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);%(AdditionalIncludeDirectories) WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;WIN64;_DEBUG;%(PreprocessorDefinitions) @@ -143,6 +150,7 @@ 4996;4018;4244;%(DisableSpecificWarnings) Level3 true + 4716 _DEBUG;%(PreprocessorDefinitions) @@ -168,7 +176,7 @@ - /we4716 /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) + /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) true $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);%(AdditionalIncludeDirectories) WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;NDEBUG;%(PreprocessorDefinitions) @@ -176,6 +184,7 @@ Level3 + 4716 NDEBUG;%(PreprocessorDefinitions) @@ -207,7 +216,7 @@ X64 - /we4716 /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) + /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) true $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);%(AdditionalIncludeDirectories) WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;WIN64;NDEBUG;%(PreprocessorDefinitions) @@ -215,6 +224,7 @@ Level3 + 4716 NDEBUG;%(PreprocessorDefinitions) From 37ff3f568d33ac4b2c0897f31a41963d21fa7b83 Mon Sep 17 00:00:00 2001 From: brianradunity Date: Tue, 2 Jan 2018 11:52:21 -0500 Subject: [PATCH 078/582] IL2CPP debugger fixes for working with Unity players (#772) * IL2CPP debugger fixes for working with Unity players * Ignoring setp_out sequence points when searching for sequence points that don't correspond to step_out requests. * Not returning step_out sequence points when retrieving method debug info. The step out sequence points have the same offset as other sequence points, but different line numbers. * Hardened the il2cpp_mono_free_method_signatures() function against multiple calls by setting the method_signatures hash table to null after it is cleared. * The isActive field in Il2CppSequencePoint should be a uint8_t, not a bool, as it gets incremented. I think this change was made in the previous C-only type for this struct but not propagated to the C++ version, which is the only version we use now. * Fixed missed issue with duplicate inner loop variable --- mono/mini/debugger-agent.c | 33 +++++++++++++++++++++++++++++---- mono/mini/il2cpp-stubs.cpp | 1 + 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 818de301ee41..5cade0588401 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -4756,6 +4756,16 @@ set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req, MonoError { if (bp_matches_method(bp, seqPoint->method) && seqPoint->ilOffset == bp->il_offset) { + if (req->event_kind == EVENT_KIND_BREAKPOINT && seqPoint->kind == kSequencePointKind_StepOut) + continue; + + if (req->event_kind == EVENT_KIND_STEP) + { + SingleStepReq *ssreq = (SingleStepReq*)req->info; + if (ssreq->depth == STEP_DEPTH_OUT && seqPoint->kind != kSequencePointKind_StepOut) + continue; + } + BreakpointInstance* inst = g_new0(BreakpointInstance, 1); inst->il_offset = bp->il_offset;// it.seq_point.il_offset; inst->native_offset = 0;// it.seq_point.native_offset; @@ -10282,10 +10292,25 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g buffer_add_string(buf, ""); } } - buffer_add_int(buf, sequencePoints->len); + + int numSeqPoints = 0; + + for (i = 0; i < sequencePoints->len; ++i) { + Il2CppSequencePoint* sequencePoint = g_ptr_array_index(sequencePoints, i); + if (sequencePoint->kind == kSequencePointKind_StepOut) + continue; + else + ++numSeqPoints; + } + + buffer_add_int(buf, numSeqPoints); DEBUG_PRINTF(10, "Line number table for method %s:\n", mono_method_full_name(method, TRUE)); for (i = 0; i < sequencePoints->len; ++i) { Il2CppSequencePoint* sequencePoint = g_ptr_array_index(sequencePoints, i); + + if (sequencePoint->kind == kSequencePointKind_StepOut) + continue; + DEBUG_PRINTF(10, "IL%x -> %s:%d %d %d %d\n", sequencePoint->ilOffset, sequencePoint->sourceFile, sequencePoint->lineStart, sequencePoint->columnStart, sequencePoint->lineEnd, sequencePoint->columnEnd); buffer_add_int(buf, sequencePoint->ilOffset); @@ -12048,10 +12073,10 @@ unity_process_breakpoint_inner(DebuggerTlsData *tls, gboolean from_signal, Il2Cp inst = (BreakpointInstance *)g_ptr_array_index(bp->children, j); if (inst->il_offset == sequencePoint->ilOffset) { if (bp->req->event_kind == EVENT_KIND_STEP) { - for (int j = 0; j < bp->children->len; ++j) + for (int k = 0; k < bp->children->len; ++k) { - BreakpointInstance *inst = (BreakpointInstance *)g_ptr_array_index(bp->children, j); - if (inst->seq_point == sequencePoint) + BreakpointInstance *inst1 = (BreakpointInstance *)g_ptr_array_index(bp->children, k); + if (inst1->seq_point == sequencePoint) { g_ptr_array_add(ss_reqs_orig, bp->req); break; diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index c4f576cf7259..bbd5c4c4c7a4 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -141,6 +141,7 @@ void il2cpp_mono_free_method_signatures() { mono_g_hash_table_foreach(method_signatures, il2cpp_mono_free_method_signature, NULL); mono_g_hash_table_destroy(method_signatures); + method_signatures = NULL; } } From f9c524ff8816781532eca50a395508462f1e135a Mon Sep 17 00:00:00 2001 From: andreasr Date: Wed, 3 Jan 2018 14:27:30 +0100 Subject: [PATCH 079/582] [unitytls] Reduced UnityTls interface to used functions --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 84 +--------------------- 1 file changed, 1 insertion(+), 83 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index cb85c4fc98ff..33f6616eceda 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -68,36 +68,10 @@ public struct unitytls_errorstate [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static void unitytls_errorstate_raise_error(unitytls_errorstate* errorState, unitytls_error_code errorCode); - - public struct unitytls_pubkey {} - [StructLayout (LayoutKind.Sequential)] - public struct unitytls_pubkey_ref { UInt64 handle; } - - // ------------------------------------ - // public Key - // ------------------------------------ - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_pubkey_ref unitytls_pubkey_get_ref(unitytls_pubkey* key, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_pubkey* unitytls_pubkey_parse_der(UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_pubkey* unitytls_pubkey_parse_pem(Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_pubkey_export_der(unitytls_pubkey_ref key, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_pubkey_export_pem(unitytls_pubkey_ref key, Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static void unitytls_pubkey_free(unitytls_pubkey* key); - + // ------------------------------------ // Private Key // ------------------------------------ - public enum unitytls_key_type : UInt32 - { - UNITYTLS_KEY_TYPE_INVALID, - UNITYTLS_KEY_TYPE_RSA, - // UNITYTLS_KEY_TYPE_EC, // Not supported yet. - } public struct unitytls_key {} [StructLayout (LayoutKind.Sequential)] @@ -108,16 +82,6 @@ public struct unitytls_key_ref { UInt64 handle; } [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static unitytls_key* unitytls_key_parse_der(UInt8* buffer, size_t bufferLen, UInt8* password, size_t passwordLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_key* unitytls_key_parse_pem(Int8* buffer, size_t bufferLen, UInt8* password, size_t passwordLen, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_key_export_der(unitytls_key_ref key, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_key_export_pem(unitytls_key_ref key, Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_pubkey_ref unitytls_key_get_pubkey(unitytls_key_ref key, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_key_type unitytls_key_get_type(unitytls_key_ref key, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static void unitytls_key_free(unitytls_key* key); // ------------------------------------ @@ -127,20 +91,8 @@ public struct unitytls_x509 {} [StructLayout (LayoutKind.Sequential)] public struct unitytls_x509_ref { UInt64 handle; } - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_x509_ref unitytls_x509_get_ref(unitytls_x509* cert, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_x509* unitytls_x509_parse_der(UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_x509* unitytls_x509_parse_pem(Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static size_t unitytls_x509_export_der(unitytls_x509_ref cert, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_x509_export_pem(unitytls_x509_ref cert, Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_pubkey_ref unitytls_x509_get_pubkey(unitytls_x509_ref cert, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static void unitytls_x509_free(unitytls_x509* cert); // ------------------------------------ // X.509 Certificate List @@ -152,10 +104,6 @@ public struct unitytls_x509list_ref { UInt64 handle; } [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static unitytls_x509list_ref unitytls_x509list_get_ref(unitytls_x509list* list, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_x509list* unitytls_x509list_parse_pem(Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_x509list_export_pem(unitytls_x509list_ref list, Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static size_t unitytls_x509list_get_size(unitytls_x509list_ref list, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static unitytls_x509_ref unitytls_x509list_get_x509(unitytls_x509list_ref list, size_t index, unitytls_errorstate* errorState); @@ -166,8 +114,6 @@ public struct unitytls_x509list_ref { UInt64 handle; } [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static void unitytls_x509list_append_der(unitytls_x509list* list, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_x509list_append_pem(unitytls_x509list* list, Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static void unitytls_x509list_free(unitytls_x509list* list); // ------------------------------------ @@ -232,23 +178,10 @@ public struct unitytls_tlsctx_protocolrange public unitytls_protocol min; public unitytls_protocol max; }; - // TODO - //[DllImport (DLLNAME, CallingConvention=CALLCONV)] - //extern public static unitytls_tlsctx_protocolrange UNITYTLS_TLSCTX_PROTOCOLRANGE_DEFAULT; - - public enum unitytls_tlsctx_handshakestate : UInt32 - { - UNITYTLS_HANDSHAKESTATE_BEGIN, // Called right before a handshake is performed. - UNITYTLS_HANDSHAKESTATE_DONE, // Called after a handshake was successfully performed. - - UNITYTLS_HANDSHAKESTATE_PEER_X509_CERT_VERIFY, // Server certificate needs to be verified. Set error state if verification failed. - UNITYTLS_HANDSHAKESTATE_PEER_X509_CERT_REQUEST, // A certificate is requested. - } public delegate size_t unitytls_tlsctx_write_callback(void* userData, UInt8* data, size_t bufferLen, unitytls_errorstate* errorState); public delegate size_t unitytls_tlsctx_read_callback(void* userData, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); public delegate void unitytls_tlsctx_trace_callback(void* userData, unitytls_tlsctx* ctx, Int8* traceMessage, size_t traceMessageLen); - public delegate void unitytls_tlsctx_handshake_callback(void* userData, unitytls_tlsctx* ctx, unitytls_tlsctx_handshakestate currentState, unitytls_errorstate* errorState); public delegate unitytls_x509verify_result unitytls_tlsctx_x509verify_callback(void* userData, unitytls_x509list_ref chain, unitytls_errorstate* errorState); [StructLayout (LayoutKind.Sequential)] @@ -269,18 +202,12 @@ public struct unitytls_tlsctx_callbacks [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static void unitytls_tlsctx_set_x509verify_callback(unitytls_tlsctx* ctx, unitytls_tlsctx_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static void unitytls_tlsctx_set_handshake_callback(unitytls_tlsctx* ctx, unitytls_tlsctx_handshake_callback cb, void* userData, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static void unitytls_tlsctx_set_supported_ciphersuites(unitytls_tlsctx* ctx, unitytls_ciphersuite* supportedCiphersuites, size_t supportedCiphersuitesLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static unitytls_ciphersuite unitytls_tlsctx_get_ciphersuite(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static unitytls_protocol unitytls_tlsctx_get_protocol(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_x509list_ref unitytls_tlsctx_get_peer_x509list(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_x509verify_result unitytls_tlsctx_get_verify_result(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static unitytls_x509verify_result unitytls_tlsctx_process_handshake(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); @@ -290,14 +217,5 @@ public struct unitytls_tlsctx_callbacks extern public static size_t unitytls_tlsctx_write(unitytls_tlsctx* ctx, UInt8* data, size_t bufferLen, unitytls_errorstate* errorState); [DllImport (DLLNAME, CallingConvention=CALLCONV)] extern public static void unitytls_tlsctx_free(unitytls_tlsctx* ctx); - - - // ------------------------------------ - // Encoding / Decoding - // ------------------------------------ - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_base64_encode(Int8* outputBuffer, size_t outputBufferLen, UInt8* inputBuffer, size_t inputBufferLen, size_t lineMaxLength, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_base64_decode(UInt8* outputBuffer, size_t outputBufferLen, Int8* inputBuffer, size_t inputBufferLen, unitytls_errorstate* errorState); } } \ No newline at end of file From 9d07185d2a6c1c0edd7dbe5a0da7dd6354fede49 Mon Sep 17 00:00:00 2001 From: andreasr Date: Wed, 3 Jan 2018 16:06:41 +0100 Subject: [PATCH 080/582] [unitytls] UnityTls interface is now installed over a struct of callbacks --- .../MonoTlsProviderFactory.cs | 18 ++- mcs/class/System/Mono.UnityTls/CertHelper.cs | 10 +- mcs/class/System/Mono.UnityTls/UnityTls.cs | 151 ++++++++++-------- .../System/Mono.UnityTls/UnityTlsContext.cs | 50 +++--- .../System/Mono.UnityTls/UnityTlsProvider.cs | 22 +-- mono/metadata/unity-utils.c | 15 ++ mono/metadata/unity-utils.h | 4 + 7 files changed, 162 insertions(+), 108 deletions(-) diff --git a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs index b78172fcb9e7..b6379ad0a5a8 100644 --- a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs +++ b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs @@ -228,10 +228,18 @@ static void InitializeProviderRegistration () providerCache = new Dictionary (); #if UNITY - var unityTlsEntry = new Tuple (UnityTlsId, "Mono.Unity.UnityTlsProvider"); - providerRegistration.Add ("default", unityTlsEntry); - providerRegistration.Add ("unitytls", unityTlsEntry); -#else + if (Mono.Unity.UnityTls.IsSupported()) + { + var unityTlsEntry = new Tuple (UnityTlsId, "Mono.Unity.UnityTlsProvider"); + providerRegistration.Add ("default", unityTlsEntry); + providerRegistration.Add ("unitytls", unityTlsEntry); + + //Console.Out.WriteLine("UnityTls activated"); + } + else + { + //Console.Out.WriteLine("UnityTls not available, using Mono's default implementations"); +#endif var appleTlsEntry = new Tuple (AppleTlsId, "Mono.AppleTls.AppleTlsProvider"); @@ -258,6 +266,8 @@ static void InitializeProviderRegistration () providerRegistration.Add ("default", legacyEntry); providerRegistration.Add ("apple", appleTlsEntry); +#if UNITY + } #endif } } diff --git a/mcs/class/System/Mono.UnityTls/CertHelper.cs b/mcs/class/System/Mono.UnityTls/CertHelper.cs index 3be07b9cf80c..f5d357af1dcc 100644 --- a/mcs/class/System/Mono.UnityTls/CertHelper.cs +++ b/mcs/class/System/Mono.UnityTls/CertHelper.cs @@ -16,7 +16,7 @@ public static void AddCertificateToNativeChain (UnityTls.unitytls_x509list* nati { byte[] certDer = certificate.GetRawCertData (); fixed(byte* certDerPtr = certDer) { - UnityTls.unitytls_x509list_append_der (nativeCertificateChain, certDerPtr, certDer.Length, errorState); + UnityTls.GetInterface().unitytls_x509list_append_der (nativeCertificateChain, certDerPtr, certDer.Length, errorState); } var certificateImpl2 = certificate.Impl as X509Certificate2Impl; @@ -35,14 +35,14 @@ public static X509CertificateCollection NativeChainToManagedCollection (UnityTls X509CertificateCollection certificates = new X509CertificateCollection (); // TODO: Should iterate until we get an invalid handle instead. Can't acces INVALID_HANDLE yet though due to limitations of UnityTls interface - size_t numCerts = UnityTls.unitytls_x509list_get_size (nativeCertificateChain, errorState); + size_t numCerts = UnityTls.GetInterface().unitytls_x509list_get_size (nativeCertificateChain, errorState); for (int i = 0; i < numCerts; ++i) { - UnityTls.unitytls_x509_ref cert = UnityTls.unitytls_x509list_get_x509 (nativeCertificateChain, i, errorState); - size_t certBufferSize = UnityTls.unitytls_x509_export_der (cert, null, 0, errorState); + UnityTls.unitytls_x509_ref cert = UnityTls.GetInterface().unitytls_x509list_get_x509 (nativeCertificateChain, i, errorState); + size_t certBufferSize = UnityTls.GetInterface().unitytls_x509_export_der (cert, null, 0, errorState); var certBuffer = new byte[certBufferSize]; // Need to reallocate every time since X509Certificate constructor takes no length but only a byte array. fixed(byte* certBufferPtr = certBuffer) { - UnityTls.unitytls_x509_export_der (cert, certBufferPtr, certBufferSize, errorState); + UnityTls.GetInterface().unitytls_x509_export_der (cert, certBufferPtr, certBufferSize, errorState); } certificates.Add (new X509Certificate (certBuffer)); diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index 33f6616eceda..63a774619c98 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -63,12 +63,6 @@ public struct unitytls_errorstate private UInt64 reserved; // Implementation specific error code/handle. } - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_errorstate unitytls_errorstate_create(); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static void unitytls_errorstate_raise_error(unitytls_errorstate* errorState, unitytls_error_code errorCode); - - // ------------------------------------ // Private Key // ------------------------------------ @@ -77,13 +71,6 @@ public struct unitytls_key {} [StructLayout (LayoutKind.Sequential)] public struct unitytls_key_ref { UInt64 handle; } - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_key_ref unitytls_key_get_ref(unitytls_key* key, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_key* unitytls_key_parse_der(UInt8* buffer, size_t bufferLen, UInt8* password, size_t passwordLen, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static void unitytls_key_free(unitytls_key* key); - // ------------------------------------ // X.509 Certificate // ----------------------------------- @@ -91,9 +78,6 @@ public struct unitytls_x509 {} [StructLayout (LayoutKind.Sequential)] public struct unitytls_x509_ref { UInt64 handle; } - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_x509_export_der(unitytls_x509_ref cert, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - // ------------------------------------ // X.509 Certificate List // ------------------------------------ @@ -101,21 +85,6 @@ public struct unitytls_x509list {} [StructLayout (LayoutKind.Sequential)] public struct unitytls_x509list_ref { UInt64 handle; } - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_x509list_ref unitytls_x509list_get_ref(unitytls_x509list* list, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_x509list_get_size(unitytls_x509list_ref list, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_x509_ref unitytls_x509list_get_x509(unitytls_x509list_ref list, size_t index, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_x509list* unitytls_x509list_create(unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static void unitytls_x509list_append(unitytls_x509list* list, unitytls_x509_ref cert, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static void unitytls_x509list_append_der(unitytls_x509list* list, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static void unitytls_x509list_free(unitytls_x509list* list); - // ------------------------------------ // X.509 Certificate Verification // ------------------------------------ @@ -127,7 +96,7 @@ public enum unitytls_x509verify_result : UInt32 UNITYTLS_X509VERIFY_FATAL_ERROR = 0xFFFFFFFF, UNITYTLS_X509VERIFY_FLAG_EXPIRED = 0x00000001, - UNITYTLS_X509VERIFY_FLAG_REVOKED = 0x00000002, // requires CRL backend + UNITYTLS_X509VERIFY_FLAG_REVOKED = 0x00000002, UNITYTLS_X509VERIFY_FLAG_CN_MISMATCH = 0x00000004, UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED = 0x00000008, @@ -145,12 +114,6 @@ public enum unitytls_x509verify_result : UInt32 public delegate unitytls_x509verify_result unitytls_x509verify_callback(void* userData, unitytls_x509_ref cert, unitytls_x509verify_result result, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_x509verify_result unitytls_x509verify_default_ca(unitytls_x509list_ref chain, Int8* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_x509verify_result unitytls_x509verify_explicit_ca(unitytls_x509list_ref chain, unitytls_x509list_ref trustCA, Int8* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); - - // ------------------------------------ // TLS Context // ------------------------------------ @@ -192,30 +155,92 @@ public struct unitytls_tlsctx_callbacks public void* data; }; - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_tlsctx* unitytls_tlsctx_create_server(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, unitytls_x509list_ref certChain, unitytls_key_ref leafCertificateKey, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_tlsctx* unitytls_tlsctx_create_client(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, Int8* cn, size_t cnLen, unitytls_errorstate* errorState); - - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static void unitytls_tlsctx_set_trace_callback(unitytls_tlsctx* ctx, unitytls_tlsctx_trace_callback cb, void* userData, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static void unitytls_tlsctx_set_x509verify_callback(unitytls_tlsctx* ctx, unitytls_tlsctx_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static void unitytls_tlsctx_set_supported_ciphersuites(unitytls_tlsctx* ctx, unitytls_ciphersuite* supportedCiphersuites, size_t supportedCiphersuitesLen, unitytls_errorstate* errorState); - - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_ciphersuite unitytls_tlsctx_get_ciphersuite(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_protocol unitytls_tlsctx_get_protocol(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); - - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static unitytls_x509verify_result unitytls_tlsctx_process_handshake(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_tlsctx_read(unitytls_tlsctx* ctx, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static size_t unitytls_tlsctx_write(unitytls_tlsctx* ctx, UInt8* data, size_t bufferLen, unitytls_errorstate* errorState); - [DllImport (DLLNAME, CallingConvention=CALLCONV)] - extern public static void unitytls_tlsctx_free(unitytls_tlsctx* ctx); + + + // ------------------------------------------------------------------------ + // unitytls interface defintion + // ------------------------------------------------------------------------ + [StructLayout (LayoutKind.Sequential)] + public class mono_unity_unitytls_interface + { + public delegate unitytls_errorstate unitytls_errorstate_create_t(); + public unitytls_errorstate_create_t unitytls_errorstate_create; + public delegate void unitytls_errorstate_raise_error_t(unitytls_errorstate* errorState, unitytls_error_code errorCode); + public unitytls_errorstate_raise_error_t unitytls_errorstate_raise_error; + + public delegate unitytls_key_ref unitytls_key_get_ref_t(unitytls_key* key, unitytls_errorstate* errorState); + public unitytls_key_get_ref_t unitytls_key_get_ref; + public delegate unitytls_key* unitytls_key_parse_der_t(UInt8* buffer, size_t bufferLen, UInt8* password, size_t passwordLen, unitytls_errorstate* errorState); + public unitytls_key_parse_der_t unitytls_key_parse_der; + public delegate void unitytls_key_free_t(unitytls_key* key); + public unitytls_key_free_t unitytls_key_free; + + public delegate size_t unitytls_x509_export_der_t(unitytls_x509_ref cert, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + public unitytls_x509_export_der_t unitytls_x509_export_der; + + public delegate unitytls_x509list_ref unitytls_x509list_get_ref_t(unitytls_x509list* list, unitytls_errorstate* errorState); + public unitytls_x509list_get_ref_t unitytls_x509list_get_ref; + public delegate size_t unitytls_x509list_get_size_t(unitytls_x509list_ref list, unitytls_errorstate* errorState); + public unitytls_x509list_get_size_t unitytls_x509list_get_size; + public delegate unitytls_x509_ref unitytls_x509list_get_x509_t(unitytls_x509list_ref list, size_t index, unitytls_errorstate* errorState); + public unitytls_x509list_get_x509_t unitytls_x509list_get_x509; + public delegate unitytls_x509list* unitytls_x509list_create_t(unitytls_errorstate* errorState); + public unitytls_x509list_create_t unitytls_x509list_create; + public delegate void unitytls_x509list_append_t(unitytls_x509list* list, unitytls_x509_ref cert, unitytls_errorstate* errorState); + public unitytls_x509list_append_t unitytls_x509list_append; + public delegate void unitytls_x509list_append_der_t(unitytls_x509list* list, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + public unitytls_x509list_append_der_t unitytls_x509list_append_der; + public delegate void unitytls_x509list_free_t(unitytls_x509list* list); + public unitytls_x509list_free_t unitytls_x509list_free; + + public delegate unitytls_x509verify_result unitytls_x509verify_default_ca_t(unitytls_x509list_ref chain, Int8* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); + public unitytls_x509verify_default_ca_t unitytls_x509verify_default_ca; + public delegate unitytls_x509verify_result unitytls_x509verify_explicit_ca_t(unitytls_x509list_ref chain, unitytls_x509list_ref trustCA, Int8* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); + public unitytls_x509verify_explicit_ca_t unitytls_x509verify_explicit_ca; + + public delegate unitytls_tlsctx* unitytls_tlsctx_create_server_t(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, unitytls_x509list_ref certChain, unitytls_key_ref leafCertificateKey, unitytls_errorstate* errorState); + public unitytls_tlsctx_create_server_t unitytls_tlsctx_create_server; + public delegate unitytls_tlsctx* unitytls_tlsctx_create_client_t(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, Int8* cn, size_t cnLen, unitytls_errorstate* errorState); + public unitytls_tlsctx_create_client_t unitytls_tlsctx_create_client; + public delegate void unitytls_tlsctx_set_trace_callback_t(unitytls_tlsctx* ctx, unitytls_tlsctx_trace_callback cb, void* userData, unitytls_errorstate* errorState); + public unitytls_tlsctx_set_trace_callback_t unitytls_tlsctx_set_trace_callback; + public delegate void unitytls_tlsctx_set_x509verify_callback_t(unitytls_tlsctx* ctx, unitytls_tlsctx_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); + public unitytls_tlsctx_set_x509verify_callback_t unitytls_tlsctx_set_x509verify_callback; + public delegate void unitytls_tlsctx_set_supported_ciphersuites_t(unitytls_tlsctx* ctx, unitytls_ciphersuite* supportedCiphersuites, size_t supportedCiphersuitesLen, unitytls_errorstate* errorState); + public unitytls_tlsctx_set_supported_ciphersuites_t unitytls_tlsctx_set_supported_ciphersuites; + public delegate unitytls_ciphersuite unitytls_tlsctx_get_ciphersuite_t(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); + public unitytls_tlsctx_get_ciphersuite_t unitytls_tlsctx_get_ciphersuite; + public delegate unitytls_protocol unitytls_tlsctx_get_protocol_t(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); + public unitytls_tlsctx_get_protocol_t unitytls_tlsctx_get_protocol; + public delegate unitytls_x509verify_result unitytls_tlsctx_process_handshake_t(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); + public unitytls_tlsctx_process_handshake_t unitytls_tlsctx_process_handshake; + public delegate size_t unitytls_tlsctx_read_t(unitytls_tlsctx* ctx, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + public unitytls_tlsctx_read_t unitytls_tlsctx_read; + public delegate size_t unitytls_tlsctx_write_t(unitytls_tlsctx* ctx, UInt8* data, size_t bufferLen, unitytls_errorstate* errorState); + public unitytls_tlsctx_write_t unitytls_tlsctx_write; + public delegate void unitytls_tlsctx_free_t(unitytls_tlsctx* ctx); + public unitytls_tlsctx_free_t unitytls_tlsctx_free; + } + + [DllImport("__Internal")] + private static extern IntPtr mono_unity_get_unitytls_interface(); + + private static mono_unity_unitytls_interface marshalledInterface = null; + + public static bool IsSupported() + { + try { + return GetInterface() != null; + } catch (System.Exception) { + return false; + } + } + + public static mono_unity_unitytls_interface GetInterface() + { + if (marshalledInterface == null) + marshalledInterface = Marshal.PtrToStructure(mono_unity_get_unitytls_interface()); + return marshalledInterface; + } } } \ No newline at end of file diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index 7a359e030752..ba57cae9bb92 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -54,7 +54,7 @@ public UnityTlsContext ( // Need GCHandle to get a consistent pointer to this instance m_handle = GCHandle.Alloc (this); - UnityTls.unitytls_errorstate errorState = UnityTls.unitytls_errorstate_create (); + var errorState = UnityTls.GetInterface().unitytls_errorstate_create (); // Map selected protocols as best as we can. UnityTls.unitytls_tlsctx_protocolrange protocolRange = new UnityTls.unitytls_tlsctx_protocolrange { @@ -78,37 +78,37 @@ public UnityTlsContext ( UnityTls.unitytls_x509list* serverCerts = null; UnityTls.unitytls_key* serverPrivateKey = null; try { - serverCerts = UnityTls.unitytls_x509list_create (&errorState); + serverCerts = UnityTls.GetInterface().unitytls_x509list_create (&errorState); CertHelper.AddCertificateToNativeChain (serverCerts, serverCertificate, &errorState); - UnityTls.unitytls_x509list_ref serverCertsRef = UnityTls.unitytls_x509list_get_ref (serverCerts, &errorState); + var serverCertsRef = UnityTls.GetInterface().unitytls_x509list_get_ref (serverCerts, &errorState); byte[] privateKeyDer = PKCS8.PrivateKeyInfo.Encode (serverCertificate2.PrivateKey); fixed(byte* privateKeyDerPtr = privateKeyDer) { - serverPrivateKey = UnityTls.unitytls_key_parse_der (privateKeyDerPtr, privateKeyDer.Length, null, 0, &errorState); + serverPrivateKey = UnityTls.GetInterface().unitytls_key_parse_der (privateKeyDerPtr, privateKeyDer.Length, null, 0, &errorState); } - UnityTls.unitytls_key_ref serverKeyRef = UnityTls.unitytls_key_get_ref (serverPrivateKey, &errorState); + var serverKeyRef = UnityTls.GetInterface().unitytls_key_get_ref (serverPrivateKey, &errorState); Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to parse server key/certificate"); - m_TlsContext = UnityTls.unitytls_tlsctx_create_server (protocolRange, callbacks, serverCertsRef, serverKeyRef, &errorState); + m_TlsContext = UnityTls.GetInterface().unitytls_tlsctx_create_server (protocolRange, callbacks, serverCertsRef, serverKeyRef, &errorState); } finally { - UnityTls.unitytls_x509list_free (serverCerts); - UnityTls.unitytls_key_free (serverPrivateKey); + UnityTls.GetInterface().unitytls_x509list_free (serverCerts); + UnityTls.GetInterface().unitytls_key_free (serverPrivateKey); } } else { byte [] targetHostUtf8 = Encoding.UTF8.GetBytes (targetHost); fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { - m_TlsContext = UnityTls.unitytls_tlsctx_create_client (protocolRange, callbacks, targetHostUtf8Ptr, targetHostUtf8.Length, &errorState); + m_TlsContext = UnityTls.GetInterface().unitytls_tlsctx_create_client (protocolRange, callbacks, targetHostUtf8Ptr, targetHostUtf8.Length, &errorState); } } - UnityTls.unitytls_tlsctx_set_x509verify_callback (m_TlsContext, VerifyCallback, (void*)(IntPtr)m_handle, &errorState); + UnityTls.GetInterface().unitytls_tlsctx_set_x509verify_callback (m_TlsContext, VerifyCallback, (void*)(IntPtr)m_handle, &errorState); Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to create UnityTls context"); if (ActivateTracing) { - UnityTls.unitytls_tlsctx_set_trace_callback (m_TlsContext, TraceCallback, null, &errorState); + UnityTls.GetInterface().unitytls_tlsctx_set_trace_callback (m_TlsContext, TraceCallback, null, &errorState); Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to set trace callback"); } @@ -149,9 +149,9 @@ public override (int ret, bool wantMore) Read (byte[] buffer, int offset, int co bool wouldBlock = false; int numBytesRead = 0; - UnityTls.unitytls_errorstate errorState = UnityTls.unitytls_errorstate_create (); + var errorState = UnityTls.GetInterface().unitytls_errorstate_create (); fixed (byte* bufferPtr = buffer) { - numBytesRead = UnityTls.unitytls_tlsctx_read (m_TlsContext, bufferPtr + offset, count, &errorState); + numBytesRead = UnityTls.GetInterface().unitytls_tlsctx_read (m_TlsContext, bufferPtr + offset, count, &errorState); } if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) @@ -167,9 +167,9 @@ public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int c bool wouldBlock = false; int numBytesWritten = 0; - UnityTls.unitytls_errorstate errorState = UnityTls.unitytls_errorstate_create (); + var errorState = UnityTls.GetInterface().unitytls_errorstate_create (); fixed (byte* bufferPtr = buffer) { - numBytesWritten = UnityTls.unitytls_tlsctx_write (m_TlsContext, bufferPtr + offset, count, &errorState); + numBytesWritten = UnityTls.GetInterface().unitytls_tlsctx_write (m_TlsContext, bufferPtr + offset, count, &errorState); } if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) @@ -183,7 +183,7 @@ public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int c public override void Shutdown () { // Destroy native UnityTls objects - UnityTls.unitytls_tlsctx_free (m_TlsContext); + UnityTls.GetInterface().unitytls_tlsctx_free (m_TlsContext); m_TlsContext = null; m_HasContext = false; @@ -224,8 +224,8 @@ public override void StartHandshake () public override bool ProcessHandshake () { - UnityTls.unitytls_errorstate errorState = UnityTls.unitytls_errorstate_create (); - UnityTls.unitytls_x509verify_result result = UnityTls.unitytls_tlsctx_process_handshake (m_TlsContext, &errorState); + var errorState = UnityTls.GetInterface().unitytls_errorstate_create (); + var result = UnityTls.GetInterface().unitytls_tlsctx_process_handshake (m_TlsContext, &errorState); if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) return false; @@ -248,8 +248,8 @@ public override bool ProcessHandshake () public override void FinishHandshake () { // Query some data. Ignore errors on the way since failure is not crucial. - UnityTls.unitytls_ciphersuite cipherSuite = UnityTls.unitytls_tlsctx_get_ciphersuite(m_TlsContext, null); - UnityTls.unitytls_protocol protocolVersion = UnityTls.unitytls_tlsctx_get_protocol(m_TlsContext, null); + var cipherSuite = UnityTls.GetInterface().unitytls_tlsctx_get_ciphersuite(m_TlsContext, null); + var protocolVersion = UnityTls.GetInterface().unitytls_tlsctx_get_protocol(m_TlsContext, null); m_Connectioninfo = new MonoTlsConnectionInfo () { CipherSuiteCode = (CipherSuiteCode)cipherSuite, @@ -283,13 +283,13 @@ private size_t WriteCallback (byte* data, size_t bufferLen, UnityTls.unitytls_er Marshal.Copy ((IntPtr)data, m_WriteBuffer, 0, bufferLen); if (!Parent.InternalWrite (m_WriteBuffer, 0, bufferLen)) { - UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WRITE_FAILED); + UnityTls.GetInterface().unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WRITE_FAILED); return 0; } return bufferLen; } catch { // handle all exceptions since we don't want to let them go through native code. - UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); + UnityTls.GetInterface().unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); return 0; } } @@ -311,18 +311,18 @@ private size_t ReadCallback (byte* buffer, size_t bufferLen, UnityTls.unitytls_e bool wouldBlock; int numBytesRead = Parent.InternalRead (m_ReadBuffer, 0, bufferLen, out wouldBlock); if (wouldBlock) { - UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK); + UnityTls.GetInterface().unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK); return 0; } if (numBytesRead < 0) { - UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_READ_FAILED); + UnityTls.GetInterface().unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_READ_FAILED); return 0; } Marshal.Copy (m_ReadBuffer, 0, (IntPtr)buffer, bufferLen); return numBytesRead; } catch { // handle all exceptions since we don't want to let them go through native code. - UnityTls.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); + UnityTls.GetInterface().unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); return 0; } } diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs index 843fbdf91d30..582faa094da4 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs @@ -72,9 +72,9 @@ internal override bool ValidateCertificate ( } // convert cert to native - UnityTls.unitytls_errorstate errorState = UnityTls.unitytls_errorstate_create (); - UnityTls.unitytls_x509list* certificatesNative = UnityTls.unitytls_x509list_create (&errorState); - UnityTls.unitytls_x509verify_result result = UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_NOT_DONE; + var errorState = UnityTls.GetInterface().unitytls_errorstate_create (); + var certificatesNative = UnityTls.GetInterface().unitytls_x509list_create (&errorState); + var result = UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_NOT_DONE; try { // Things the validator provides that we might want to make use of here: @@ -85,28 +85,28 @@ internal override bool ValidateCertificate ( //validator.Settings.SendCloseNotify // UnityTls always sends a close notify if the underlying impl supports it. Currently only used by MonoBtlsProvider CertHelper.AddCertificatesToNativeChain (certificatesNative, certificates, &errorState); - UnityTls.unitytls_x509list_ref certificatesNativeRef = UnityTls.unitytls_x509list_get_ref (certificatesNative, &errorState); - byte[] targetHostUtf8 = Encoding.UTF8.GetBytes (targetHost); + var certificatesNativeRef = UnityTls.GetInterface().unitytls_x509list_get_ref (certificatesNative, &errorState); + var targetHostUtf8 = Encoding.UTF8.GetBytes (targetHost); if (validator.Settings.TrustAnchors != null) { - UnityTls.unitytls_x509list* trustCAnative = UnityTls.unitytls_x509list_create (&errorState); + var trustCAnative = UnityTls.GetInterface().unitytls_x509list_create (&errorState); CertHelper.AddCertificatesToNativeChain (trustCAnative, validator.Settings.TrustAnchors, &errorState); - UnityTls.unitytls_x509list_ref trustCAnativeRef = UnityTls.unitytls_x509list_get_ref (certificatesNative, &errorState); + var trustCAnativeRef = UnityTls.GetInterface().unitytls_x509list_get_ref (certificatesNative, &errorState); fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { - result = UnityTls.unitytls_x509verify_explicit_ca (certificatesNativeRef, trustCAnativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); + result = UnityTls.GetInterface().unitytls_x509verify_explicit_ca (certificatesNativeRef, trustCAnativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); } - UnityTls.unitytls_x509list_free (trustCAnative); + UnityTls.GetInterface().unitytls_x509list_free (trustCAnative); } else { fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { - result = UnityTls.unitytls_x509verify_default_ca (certificatesNativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); + result = UnityTls.GetInterface().unitytls_x509verify_default_ca (certificatesNativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); } } } finally { - UnityTls.unitytls_x509list_free (certificatesNative); + UnityTls.GetInterface().unitytls_x509list_free (certificatesNative); } errors = UnityTlsConversions.VerifyResultToPolicyErrror(result); diff --git a/mono/metadata/unity-utils.c b/mono/metadata/unity-utils.c index 4fbfdb1781f4..bec7eabd9918 100644 --- a/mono/metadata/unity-utils.c +++ b/mono/metadata/unity-utils.c @@ -885,6 +885,21 @@ MonoClass* mono_unity_defaults_get_byte_class() return mono_defaults.byte_class; } +//unitytls + +static mono_unity_unitytls_interface* gUnitytlsInterface = NULL; + +mono_unity_unitytls_interface* mono_unity_get_unitytls_interface() +{ + return gUnitytlsInterface; +} + +MONO_API void +mono_unity_install_unitytls_interface(mono_unity_unitytls_interface* callbacks) +{ + gUnitytlsInterface = callbacks; +} + //misc MonoAssembly* mono_unity_assembly_get_mscorlib() diff --git a/mono/metadata/unity-utils.h b/mono/metadata/unity-utils.h index 7b32452fd68c..c1ef1131c0fb 100644 --- a/mono/metadata/unity-utils.h +++ b/mono/metadata/unity-utils.h @@ -144,6 +144,10 @@ MonoClass* mono_unity_defaults_get_char_class(); MonoClass* mono_unity_defaults_get_delegate_class(); MonoClass* mono_unity_defaults_get_byte_class(); +//unitytls +typedef struct mono_unity_unitytls_interface mono_unity_unitytls_interface; +mono_unity_unitytls_interface* mono_unity_get_unitytls_interface(); + //misc MonoAssembly* mono_unity_assembly_get_mscorlib(); MonoImage* mono_unity_image_get_mscorlib(); From 4ebbe9a7b690061fb41f7821afd4fa15069ab1ee Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Wed, 3 Jan 2018 13:53:53 -0500 Subject: [PATCH 081/582] Update README.md with simpler branching scheme --- README.md | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7dacb42632b3..736badcadd55 100644 --- a/README.md +++ b/README.md @@ -13,33 +13,23 @@ Branches for released Unity versions are of the form unity-\\[-mbe\][- ### Branches #### Trunk -* [unity-staging (PR to this branch for Mono)](https://github.com/Unity-Technologies/mono/tree/unity-staging) -* [unity-trunk](https://github.com/Unity-Technologies/mono/tree/unity-trunk) -* [unity-master-staging (PR to this branch for MonoBleedingEdge)](https://github.com/Unity-Technologies/mono/tree/unity-master-staging) -* [unity-master](https://github.com/Unity-Technologies/mono/tree/unity-master) +* [unity-trunk (PR to this branch for Mono)](https://github.com/Unity-Technologies/mono/tree/unity-trunk +* [unity-master (PR to this branch for MonoBleedingEdge)](https://github.com/Unity-Technologies/mono/tree/unity-master) #### 2017.3 -* [unity-2017.3-staging](https://github.com/Unity-Technologies/mono/tree/unity-2017.3-staging) * [unity-2017.3](https://github.com/Unity-Technologies/mono/tree/unity-2017.3) -* [unity-2017.3-mbe-staging](https://github.com/Unity-Technologies/mono/tree/unity-2017.3-mbe-staging) * [unity-2017.3-mbe](https://github.com/Unity-Technologies/mono/tree/unity-2017.3-mbe) #### 2017.2 -* [unity-2017.2-staging](https://github.com/Unity-Technologies/mono/tree/unity-2017.2-staging) * [unity-2017.2](https://github.com/Unity-Technologies/mono/tree/unity-2017.2) -* [unity-2017.2-mbe-staging](https://github.com/Unity-Technologies/mono/tree/unity-2017.2-mbe-staging) * [unity-2017.2-mbe](https://github.com/Unity-Technologies/mono/tree/unity-2017.2-mbe) #### 2017.1 -* [unity-2017.1-staging](https://github.com/Unity-Technologies/mono/tree/unity-2017.1-staging) * [unity-2017.1](https://github.com/Unity-Technologies/mono/tree/unity-2017.1) -* [unity-2017.1-mbe-staging](https://github.com/Unity-Technologies/mono/tree/unity-2017.1-mbe-staging) * [unity-2017.1-mbe](https://github.com/Unity-Technologies/mono/tree/unity-2017.1-mbe) #### 5.6 -* [unity-5.6-staging](https://github.com/Unity-Technologies/mono/tree/unity-5.6-staging) * [unity-5.6](https://github.com/Unity-Technologies/mono/tree/unity-5.6) -* [unity-5.6-mbe-staging](https://github.com/Unity-Technologies/mono/tree/unity-5.6-mbe-staging) * [unity-5.6-mbe](https://github.com/Unity-Technologies/mono/tree/unity-5.6-mbe) From 008d8625ff411378f9dd68f99da59915e73f325d Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Wed, 3 Jan 2018 13:54:53 -0500 Subject: [PATCH 082/582] Fix link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 736badcadd55..440e4c4026f4 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Branches for released Unity versions are of the form unity-\\[-mbe\][- ### Branches #### Trunk -* [unity-trunk (PR to this branch for Mono)](https://github.com/Unity-Technologies/mono/tree/unity-trunk +* [unity-trunk (PR to this branch for Mono)](https://github.com/Unity-Technologies/mono/tree/unity-trunk) * [unity-master (PR to this branch for MonoBleedingEdge)](https://github.com/Unity-Technologies/mono/tree/unity-master) #### 2017.3 From bec1156d50fcfd26358bb53ceb264f62b662023a Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 2 Jan 2018 14:32:39 -0500 Subject: [PATCH 083/582] Remove unneeded *mono_arch_init_lmf_ext stub and fix call to mono_g_hash_table_new_type. --- mono/mini/il2cpp-compat.h | 2 -- mono/mini/il2cpp-stubs.cpp | 7 +------ 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index 2f28d8994322..7a9759699ec5 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -229,7 +229,6 @@ #define mono_arch_stop_single_stepping il2cpp_mono_arch_stop_single_stepping #define mono_arch_skip_breakpoint il2cpp_mono_arch_skip_breakpoint #define mono_arch_skip_single_step il2cpp_mono_arch_skip_single_step -#define mono_arch_init_lmf_ext il2cpp_mono_arch_init_lmf_ext #define mono_arch_context_get_int_reg il2cpp_mono_arch_context_get_int_reg #define mono_arch_context_set_int_reg il2cpp_mono_arch_context_set_int_reg #define mono_walk_stack_with_ctx il2cpp_mono_walk_stack_with_ctx @@ -446,7 +445,6 @@ void il2cpp_mono_arch_start_single_stepping(); void il2cpp_mono_arch_stop_single_stepping(); void il2cpp_mono_arch_skip_breakpoint(MonoContext* ctx, MonoJitInfo* ji); void il2cpp_mono_arch_skip_single_step(MonoContext* ctx); -void il2cpp_mono_arch_init_lmf_ext(MonoLMFExt* ext, gpointer prev_lmf); mgreg_t il2cpp_mono_arch_context_get_int_reg(MonoContext* ctx, int reg); void il2cpp_mono_arch_context_set_int_reg(MonoContext* ctx, int reg, mgreg_t val); void il2cpp_mono_walk_stack_with_ctx(Il2CppMonoJitStackWalk func, MonoContext* start_ctx, MonoUnwindOptions unwind_options, void* user_data); diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index bbd5c4c4c7a4..a45a6b157703 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -91,7 +91,7 @@ Il2CppMonoMethodSignature* il2cpp_mono_method_signature (MonoMethod *m) MethodInfo* method = (MethodInfo*)m; if (method_signatures == NULL) - method_signatures = mono_g_hash_table_new_type(NULL, NULL, MONO_HASH_KEY_GC, MONO_ROOT_SOURCE_DEBUGGER, "method-to-signature for il2cpp table"); + method_signatures = mono_g_hash_table_new_type(NULL, NULL, MONO_HASH_KEY_GC, MONO_ROOT_SOURCE_DEBUGGER, NULL, "method-to-signature for il2cpp table"); Il2CppMonoMethodSignature* existing_signature = (Il2CppMonoMethodSignature*)mono_g_hash_table_lookup(method_signatures, method); if (existing_signature != NULL) @@ -1119,11 +1119,6 @@ void il2cpp_mono_arch_skip_single_step(MonoContext* ctx) IL2CPP_ASSERT(0 && "This method is not yet implemented"); } -void il2cpp_mono_arch_init_lmf_ext(MonoLMFExt* ext, gpointer prev_lmf) -{ - IL2CPP_ASSERT(0 && "This method is not yet implemented"); -} - mgreg_t il2cpp_mono_arch_context_get_int_reg(MonoContext* ctx, int reg) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); From 033f565dc2b8334128afeca8edbc1c96977de2fa Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Wed, 3 Jan 2018 15:34:30 -0500 Subject: [PATCH 084/582] Fix error when DEBUG is enabled --- mono/metadata/w32handle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mono/metadata/w32handle.c b/mono/metadata/w32handle.c index 5ba22cab55c4..7ba74ef23fce 100644 --- a/mono/metadata/w32handle.c +++ b/mono/metadata/w32handle.c @@ -68,7 +68,7 @@ mono_w32handle_set_signal_state (MonoW32Handle *handle_data, gboolean state, gbo { #ifdef DEBUG g_message ("%s: setting state of %p to %s (broadcast %s)", __func__, - handle, state?"TRUE":"FALSE", broadcast?"TRUE":"FALSE"); + handle_data, state?"TRUE":"FALSE", broadcast?"TRUE":"FALSE"); #endif if (state) { From 3492bb2d19ae48f6b3ea137bfefefdd735d67e32 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Wed, 3 Jan 2018 16:20:44 -0500 Subject: [PATCH 085/582] Sync more API changes from Mono --- mono/metadata/il2cpp-compat-metadata.h | 4 ++-- mono/mini/il2cpp-compat.h | 2 +- mono/mini/il2cpp-stubs.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mono/metadata/il2cpp-compat-metadata.h b/mono/metadata/il2cpp-compat-metadata.h index ef369959ef9d..8e8cc6aaf19c 100644 --- a/mono/metadata/il2cpp-compat-metadata.h +++ b/mono/metadata/il2cpp-compat-metadata.h @@ -20,10 +20,10 @@ #define mono_gc_make_vector_descr il2cpp_mono_gc_make_vector_descr #define mono_gc_deregister_root il2cpp_mono_gc_deregister_root -int il2cpp_mono_gc_register_root_wbarrier (char *start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, const char *msg); +int il2cpp_mono_gc_register_root_wbarrier (char *start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, void *key, const char *msg); SgenDescriptor il2cpp_mono_gc_make_root_descr_all_refs(int numbits); MonoGCDescriptor il2cpp_mono_gc_make_vector_descr (void); -void* il2cpp_mono_gc_alloc_fixed (size_t size, void* descr, MonoGCRootSource source, const char *msg); +void* il2cpp_mono_gc_alloc_fixed (size_t size, void* descr, MonoGCRootSource source, void *key, const char *msg); gboolean il2cpp_mono_gc_is_moving(); typedef void* (*MonoGCLockedCallbackFunc) (void *data); diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index 7a9759699ec5..c1e00efae761 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -413,7 +413,7 @@ MonoString* il2cpp_mono_ldstr_checked(MonoDomain* domain, MonoImage* image, guin Il2CppMonoObject* il2cpp_mono_runtime_try_invoke(MonoMethod* method, void* obj, void** params, Il2CppMonoObject** exc, MonoError* error); Il2CppMonoObject* il2cpp_mono_runtime_invoke_checked(MonoMethod* method, void* obj, void** params, MonoError* error); void il2cpp_mono_gc_base_init(); -int il2cpp_mono_gc_register_root(char* start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, const char* msg); +int il2cpp_mono_gc_register_root(char* start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, void *key, const char* msg); void il2cpp_mono_gc_deregister_root(char* addr); gint32 il2cpp_mono_environment_exitcode_get(); void il2cpp_mono_environment_exitcode_set(gint32 value); diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index a45a6b157703..4bb03e76b8f4 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -531,7 +531,7 @@ SgenDescriptor il2cpp_mono_gc_make_root_descr_all_refs(int numbits) return NULL; } -int il2cpp_mono_gc_register_root_wbarrier (char *start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, const char *msg) +int il2cpp_mono_gc_register_root_wbarrier (char *start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, void *key, const char *msg) { il2cpp::gc::GarbageCollector::RegisterRoot(start, size); return 1; @@ -1283,7 +1283,7 @@ void il2cpp_mono_error_assert_ok_pos (MonoError *error, const char* filename, in g_error ("%s:%d\n", filename, lineno); } -void* il2cpp_mono_gc_alloc_fixed (size_t size, void* descr, MonoGCRootSource source, const char *msg) +void* il2cpp_mono_gc_alloc_fixed (size_t size, void* descr, MonoGCRootSource source, void *key, const char *msg) { return il2cpp_gc_alloc_fixed(size); } From 4068aab9f29affc54403b13d3b3bff30d0dc9387 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Thu, 4 Jan 2018 14:08:01 -0500 Subject: [PATCH 086/582] Enable IPv6 support in the settings files It looks like the upstream Mono code uses either the class library PAL or a fallback to a hard-coded value to enable IPv6 support. The fallback is not compiled in for the Unity code, so the class library code tries a final fallback to the settings file. In the old Mono this setting was present, but it does not exist in the new Mono, as it is not needed upstream. This change corrects Unity case 941946 by enabling IPv6 support in the settings file. --- data/net_2_0/machine.config | 3 +++ data/net_4_0/machine.config | 3 +++ data/net_4_5/machine.config | 3 +++ 3 files changed, 9 insertions(+) diff --git a/data/net_2_0/machine.config b/data/net_2_0/machine.config index 2f8090f02884..9da7be987191 100644 --- a/data/net_2_0/machine.config +++ b/data/net_2_0/machine.config @@ -118,6 +118,9 @@ + + + diff --git a/data/net_4_0/machine.config b/data/net_4_0/machine.config index 30bc2105f3af..12839c1f6a3c 100644 --- a/data/net_4_0/machine.config +++ b/data/net_4_0/machine.config @@ -135,6 +135,9 @@ + + + diff --git a/data/net_4_5/machine.config b/data/net_4_5/machine.config index d17369394e31..61f7889871f8 100644 --- a/data/net_4_5/machine.config +++ b/data/net_4_5/machine.config @@ -138,6 +138,9 @@ + + + From f785be489b04feccd65279b4e9c4b11566ad39ce Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Thu, 4 Jan 2018 16:38:52 -0500 Subject: [PATCH 087/582] Always set GC_no_dls when using bdwgc (case 954427) --- mono/metadata/boehm-gc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index 32481b1510d2..152047aaae5b 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -180,8 +180,8 @@ mono_gc_base_init (void) default_push_other_roots = GC_push_other_roots; GC_push_other_roots = mono_push_other_roots; -#if !defined(HOST_ANDROID) - /* If GC_no_dls is set to true, GC_find_limit is not called. This causes a seg fault on Android. */ +#if defined(HAVE_BDWGC_GC) || !defined(HOST_ANDROID) + /* If GC_no_dls is set to true, GC_find_limit is not called. This causes a seg fault on Android With Mono's Older Boehm. */ GC_no_dls = TRUE; #endif { From 1382d288d2e3c6267b9b5a32e9cc561085be7f05 Mon Sep 17 00:00:00 2001 From: andreasr Date: Fri, 5 Jan 2018 11:46:42 +0100 Subject: [PATCH 088/582] [unitytls] Added missing MONO_API to mono_unity_get_unitytls_interface and added it to the header for completeness --- mono/metadata/unity-utils.c | 3 ++- mono/metadata/unity-utils.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mono/metadata/unity-utils.c b/mono/metadata/unity-utils.c index bec7eabd9918..c84dcfd923db 100644 --- a/mono/metadata/unity-utils.c +++ b/mono/metadata/unity-utils.c @@ -889,7 +889,8 @@ MonoClass* mono_unity_defaults_get_byte_class() static mono_unity_unitytls_interface* gUnitytlsInterface = NULL; -mono_unity_unitytls_interface* mono_unity_get_unitytls_interface() +MONO_API mono_unity_unitytls_interface* +mono_unity_get_unitytls_interface() { return gUnitytlsInterface; } diff --git a/mono/metadata/unity-utils.h b/mono/metadata/unity-utils.h index c1ef1131c0fb..f2b18f3c26f1 100644 --- a/mono/metadata/unity-utils.h +++ b/mono/metadata/unity-utils.h @@ -146,7 +146,8 @@ MonoClass* mono_unity_defaults_get_byte_class(); //unitytls typedef struct mono_unity_unitytls_interface mono_unity_unitytls_interface; -mono_unity_unitytls_interface* mono_unity_get_unitytls_interface(); +MONO_API mono_unity_unitytls_interface* mono_unity_get_unitytls_interface(); +MONO_API void mono_unity_install_unitytls_interface(mono_unity_unitytls_interface* callbacks); //misc MonoAssembly* mono_unity_assembly_get_mscorlib(); From 62e7a52d805a28e5ec739dcfca91815740e135e1 Mon Sep 17 00:00:00 2001 From: andreasr Date: Fri, 5 Jan 2018 17:20:49 +0100 Subject: [PATCH 089/582] [unitytls] Removed SslStream tests again since they are not passing with standard mono tls implementation. These tests are now part of Unity to ensure that UnityTls works properly --- .../SslStreamBadSslTest.cs | 76 ------ .../System.Net.Security/SslStreamTest2.cs | 228 ------------------ 2 files changed, 304 deletions(-) delete mode 100644 mcs/class/System/Test/System.Net.Security/SslStreamBadSslTest.cs delete mode 100644 mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs diff --git a/mcs/class/System/Test/System.Net.Security/SslStreamBadSslTest.cs b/mcs/class/System/Test/System.Net.Security/SslStreamBadSslTest.cs deleted file mode 100644 index 0f249ccaa31f..000000000000 --- a/mcs/class/System/Test/System.Net.Security/SslStreamBadSslTest.cs +++ /dev/null @@ -1,76 +0,0 @@ -#if UNITY // Does this test work with Mono's default tls implementations? - -using NUnit.Framework; -using System.Net.Security; -using System.Net.Sockets; -using System.Security.Authentication; - -namespace MonoTests.System.Net.Security -{ - -[TestFixture] -public class SslStreamBadSslTest -{ - private SslStream sslStream; - private TcpClient client; - - [SetUp] - public void InitClient() - { - const string machineName = "badssl.com"; - client = new TcpClient(machineName, 443); - sslStream = new SslStream(client.GetStream()); - } - - [TestCase("www.badssl.com")] - [TestCase("sha256.badssl.com")] - [TestCase("sha384.badssl.com")] - [TestCase("sha512.badssl.com")] - //[TestCase("1000-sans.badssl.com")] // MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE - //[TestCase("10000-sans.badssl.com")] - [TestCase("ecc256.badssl.com")] - [TestCase("ecc384.badssl.com")] - [TestCase("rsa2048.badssl.com")] - [TestCase("rsa8192.badssl.com")] - [TestCase("dh2048.badssl.com")] - [TestCase("tls-v1-0.badssl.com")] - [TestCase("tls-v1-1.badssl.com")] - [TestCase("long-extended-subdomain-name-containing-many-letters-and-dashes.badssl.com")] - [TestCase("longextendedsubdomainnamewithoutdashesinordertotestwordwrapping.badssl.com")] - public void SuccessFullHostProvider(string targetHost) - { - sslStream.AuthenticateAsClient(targetHost); - } - - [ExpectedException(typeof(AuthenticationException))] - [TestCase("expired.badssl.com")] - [TestCase("wrong.host.badssl.com")] - [TestCase("self-signed.badssl.com")] - [TestCase("untrusted-root.badssl.com")] - //[TestCase("revoked.badssl.com")] // No support for revoking yet - [TestCase("sha1-intermediate.badssl.com")] - [TestCase("dh480.badssl.com")] - [TestCase("dh512.badssl.com")] - //[TestCase("dh1024.badssl.com")] - //[TestCase("dh-small-subgroup.badssl.com")] - //[TestCase("dh-composite.badssl.com")] - //[TestCase("invalid-expected-sct.badssl.com")] - [TestCase("superfish.badssl.com")] - [TestCase("edellroot.badssl.com")] - [TestCase("dsdtestprovider.badssl.com")] - [TestCase("preact-cli.badssl.com")] - [TestCase("webpack-dev-server.badssl.com")] - [TestCase("sha1-2016.badssl.com")] - [TestCase("sha1-2017.badssl.com")] - public void FailingHostsProvider(string targetHost) - { - try { - sslStream.AuthenticateAsClient(targetHost); - } catch (global::System.AggregateException e) { - throw e.InnerException; - } - } -} -} - -#endif \ No newline at end of file diff --git a/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs b/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs deleted file mode 100644 index 766e441f3ace..000000000000 --- a/mcs/class/System/Test/System.Net.Security/SslStreamTest2.cs +++ /dev/null @@ -1,228 +0,0 @@ -#if UNITY // Does this test work with Mono's default tls implementations? - -using NUnit.Framework; -using System; -using System.Text; -using System.IO; -using System.Net; -using System.Net.Security; -using System.Net.Sockets; -using System.Security.Authentication; -using System.Security.Cryptography.X509Certificates; -using System.Threading; -using System.Threading.Tasks; -using MonoTests.Helpers; - -namespace MonoTests.System.Net.Security -{ - [TestFixture] - public class SslStreamTest2 - { - byte[] m_serverCertRaw = { 48, 130, 5, 165, 2, 1, 3, 48, 130, 5, 95, 6, 9, 42, 134, 72, 134, 247, 13, 1, 7, 1, 160, 130, 5, 80, 4, 130, 5, 76, 48, 130, 5, 72, 48, 130, 2, 87, 6, 9, 42, 134, 72, 134, 247, 13, 1, 7, 6, 160, 130, 2, 72, 48, 130, 2, 68, 2, 1, 0, 48, 130, 2, 61, 6, 9, 42, 134, 72, 134, 247, 13, 1, 7, 1, 48, 28, 6, 10, 42, 134, 72, 134, 247, 13, 1, 12, 1, 3, 48, 14, 4, 8, 211, 176, 234, 3, 252, 26, 32, 15, 2, 2, 7, 208, 128, 130, 2, 16, 183, 149, 35, 180, 127, 95, 163, 122, 138, 244, 29, 177, 220, 173, 46, 73, 208, 217, 211, 190, 164, 183, 21, 110, 33, 122, 98, 163, 251, 16, 23, 106, 154, 14, 52, 177, 3, 12, 248, 226, 48, 123, 211, 6, 216, 6, 192, 175, 203, 142, 141, 143, 252, 178, 7, 162, 81, 232, 159, 42, 56, 177, 191, 53, 7, 146, 189, 236, 75, 140, 210, 143, 11, 103, 64, 58, 10, 73, 123, 39, 97, 119, 166, 114, 123, 65, 68, 214, 42, 17, 156, 122, 8, 58, 184, 134, 255, 48, 64, 20, 229, 247, 196, 12, 130, 56, 176, 69, 179, 254, 216, 45, 25, 244, 240, 116, 88, 137, 66, 13, 18, 202, 199, 59, 200, 245, 19, 175, 232, 217, 211, 12, 191, 222, 26, 162, 253, 73, 201, 48, 61, 3, 248, 117, 16, 71, 233, 183, 90, 110, 91, 116, 56, 133, 223, 148, 19, 78, 140, 123, 159, 203, 78, 15, 172, 39, 190, 39, 71, 180, 155, 48, 156, 116, 212, 52, 1, 231, 201, 196, 73, 87, 68, 104, 208, 40, 104, 32, 218, 235, 245, 84, 136, 168, 51, 9, 93, 126, 46, 80, 180, 240, 144, 79, 88, 87, 159, 24, 108, 186, 9, 20, 48, 100, 148, 250, 4, 163, 115, 131, 44, 13, 38, 222, 117, 196, 196, 128, 114, 149, 97, 93, 37, 191, 3, 192, 231, 88, 80, 218, 147, 8, 192, 165, 27, 206, 56, 42, 157, 230, 223, 130, 253, 169, 182, 245, 192, 181, 18, 212, 133, 168, 73, 92, 66, 197, 117, 245, 107, 127, 23, 146, 249, 41, 66, 219, 210, 207, 221, 205, 205, 15, 110, 92, 12, 207, 76, 239, 4, 13, 129, 127, 170, 205, 253, 148, 208, 24, 129, 24, 210, 220, 85, 45, 179, 137, 66, 134, 142, 22, 112, 48, 160, 236, 232, 38, 83, 101, 55, 51, 18, 110, 99, 69, 41, 173, 107, 233, 11, 199, 23, 61, 135, 222, 94, 74, 29, 219, 80, 128, 167, 186, 254, 235, 42, 96, 134, 5, 13, 90, 59, 231, 137, 195, 207, 28, 165, 12, 218, 5, 72, 102, 61, 135, 198, 73, 250, 97, 89, 214, 179, 244, 194, 23, 142, 157, 4, 243, 90, 69, 54, 10, 139, 76, 95, 40, 225, 219, 59, 15, 54, 182, 206, 142, 228, 248, 79, 156, 129, 246, 63, 6, 6, 236, 44, 67, 116, 213, 170, 47, 193, 186, 139, 25, 80, 166, 57, 99, 231, 156, 191, 117, 65, 76, 7, 243, 244, 127, 225, 210, 190, 164, 141, 46, 36, 99, 111, 203, 133, 127, 80, 28, 61, 160, 36, 132, 182, 16, 41, 39, 185, 232, 123, 32, 57, 189, 100, 152, 38, 205, 5, 189, 240, 65, 3, 191, 73, 85, 12, 209, 180, 1, 194, 70, 124, 57, 71, 48, 230, 235, 122, 175, 157, 35, 233, 83, 40, 20, 169, 224, 14, 11, 216, 48, 194, 105, 25, 187, 210, 182, 6, 184, 73, 95, 85, 210, 227, 113, 58, 10, 186, 175, 254, 25, 102, 39, 3, 2, 200, 194, 197, 200, 224, 77, 164, 8, 36, 114, 48, 130, 2, 233, 6, 9, 42, 134, 72, 134, 247, 13, 1, 7, 1, 160, 130, 2, 218, 4, 130, 2, 214, 48, 130, 2, 210, 48, 130, 2, 206, 6, 11, 42, 134, 72, 134, 247, 13, 1, 12, 10, 1, 2, 160, 130, 2, 166, 48, 130, 2, 162, 48, 28, 6, 10, 42, 134, 72, 134, 247, 13, 1, 12, 1, 3, 48, 14, 4, 8, 178, 13, 52, 135, 85, 49, 79, 105, 2, 2, 7, 208, 4, 130, 2, 128, 21, 84, 227, 109, 230, 144, 140, 170, 117, 250, 179, 207, 129, 100, 126, 126, 29, 231, 94, 140, 45, 26, 168, 45, 240, 4, 170, 73, 98, 115, 109, 96, 177, 206, 6, 80, 170, 22, 237, 144, 58, 95, 59, 26, 85, 135, 178, 69, 184, 44, 122, 81, 213, 135, 149, 198, 246, 83, 68, 129, 2, 186, 118, 33, 44, 214, 227, 240, 220, 51, 175, 220, 220, 180, 113, 216, 101, 138, 81, 54, 38, 0, 216, 30, 29, 187, 213, 230, 12, 181, 130, 21, 241, 98, 120, 41, 150, 176, 69, 37, 169, 249, 123, 212, 254, 135, 154, 214, 127, 39, 105, 149, 180, 218, 41, 207, 75, 70, 105, 169, 185, 169, 132, 173, 188, 82, 251, 71, 234, 136, 5, 254, 110, 223, 34, 4, 145, 7, 19, 51, 123, 140, 75, 226, 0, 21, 220, 228, 223, 218, 8, 169, 210, 194, 139, 93, 218, 55, 40, 174, 50, 238, 38, 166, 222, 103, 0, 209, 88, 131, 51, 222, 154, 217, 18, 172, 73, 17, 133, 54, 173, 208, 118, 104, 167, 113, 153, 223, 251, 154, 120, 176, 18, 127, 51, 206, 164, 77, 86, 9, 82, 212, 86, 162, 206, 230, 79, 217, 178, 42, 217, 162, 152, 188, 217, 59, 212, 117, 200, 135, 75, 74, 43, 1, 42, 79, 180, 164, 250, 122, 103, 103, 157, 11, 14, 33, 48, 8, 108, 155, 46, 124, 223, 204, 169, 124, 104, 11, 246, 213, 226, 16, 125, 17, 228, 15, 178, 141, 79, 78, 115, 76, 131, 122, 166, 124, 154, 1, 174, 178, 176, 213, 208, 188, 71, 118, 220, 168, 64, 218, 176, 134, 38, 229, 14, 109, 162, 125, 16, 57, 249, 201, 180, 17, 182, 143, 184, 12, 248, 113, 65, 70, 109, 79, 249, 34, 170, 35, 228, 219, 121, 202, 228, 121, 127, 255, 22, 173, 202, 171, 33, 232, 4, 240, 142, 216, 80, 56, 177, 83, 93, 123, 217, 213, 157, 99, 34, 194, 61, 228, 239, 194, 20, 27, 9, 53, 132, 79, 19, 97, 107, 31, 51, 39, 176, 223, 90, 88, 67, 138, 194, 169, 176, 144, 202, 119, 146, 74, 27, 118, 63, 129, 230, 101, 104, 75, 116, 49, 223, 254, 225, 70, 206, 183, 11, 134, 148, 10, 55, 57, 50, 178, 144, 164, 139, 233, 169, 109, 186, 211, 95, 123, 75, 111, 192, 187, 127, 240, 45, 226, 194, 240, 128, 10, 79, 178, 192, 66, 21, 197, 24, 171, 141, 255, 185, 230, 84, 206, 151, 9, 93, 115, 162, 12, 115, 129, 218, 103, 219, 183, 142, 123, 3, 110, 139, 208, 4, 146, 76, 99, 246, 240, 32, 169, 148, 16, 146, 172, 230, 36, 56, 145, 23, 94, 209, 92, 38, 244, 127, 70, 121, 253, 66, 55, 36, 140, 98, 105, 233, 112, 24, 23, 230, 112, 62, 244, 12, 48, 30, 51, 0, 18, 244, 139, 66, 245, 234, 203, 195, 52, 119, 255, 84, 82, 204, 100, 176, 167, 24, 224, 8, 127, 214, 148, 115, 242, 56, 190, 72, 221, 68, 252, 36, 74, 254, 57, 52, 96, 20, 173, 32, 236, 87, 15, 16, 76, 9, 48, 3, 61, 2, 137, 137, 9, 68, 213, 99, 163, 63, 201, 83, 241, 98, 7, 117, 108, 4, 123, 170, 18, 10, 19, 198, 31, 170, 15, 247, 216, 145, 172, 239, 137, 181, 80, 160, 24, 11, 35, 131, 58, 218, 22, 250, 215, 52, 160, 246, 197, 183, 92, 137, 0, 245, 63, 49, 183, 246, 195, 58, 63, 4, 75, 10, 92, 131, 181, 59, 78, 247, 44, 150, 49, 49, 107, 211, 62, 71, 62, 222, 159, 161, 118, 236, 55, 219, 49, 0, 3, 82, 236, 96, 20, 83, 39, 245, 208, 240, 245, 174, 218, 49, 21, 48, 19, 6, 9, 42, 134, 72, 134, 247, 13, 1, 9, 21, 49, 6, 4, 4, 1, 0, 0, 0, 48, 61, 48, 33, 48, 9, 6, 5, 43, 14, 3, 2, 26, 5, 0, 4, 20, 30, 154, 48, 126, 198, 239, 114, 62, 12, 58, 129, 172, 67, 156, 76, 214, 62, 205, 89, 28, 4, 20, 135, 177, 105, 83, 79, 93, 181, 149, 169, 49, 112, 201, 70, 212, 153, 79, 198, 163, 137, 90, 2, 2, 7, 208 }; - const string m_serverHostName = "server"; - - private X509Certificate2 m_serverCert; - private IPEndPoint m_ipEndPoint; - private TcpClient m_tcpClient; - private TcpClient m_tcpServer; - private MemoryStream m_stream; - - class TestException : Exception - { - } - - [SetUp()] - public void GetReady() - { - m_serverCert = new X509Certificate2(m_serverCertRaw, m_serverHostName); - m_ipEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), NetworkHelpers.FindFreePort ()); - } - - private void SetupClientServerConnection() - { - m_tcpClient = new TcpClient(); - var tcpListener = new TcpListener(m_ipEndPoint); - tcpListener.Start(); - Task.Run(() => m_tcpClient.Connect(m_ipEndPoint.Address, m_ipEndPoint.Port)); - m_tcpServer = tcpListener.AcceptTcpClient(); - tcpListener.Stop(); - } - - [TestCase] - public void HandshakeVerification_CorrectPolicyError_ForSelfSignedCertificate() - { - SetupClientServerConnection(); - var clientStream = new SslStream(m_tcpClient.GetStream(), false, (sender, certificate, chain, sslPolicyErrors) => - { - Assert.AreEqual (SslPolicyErrors.RemoteCertificateChainErrors, sslPolicyErrors); - return true; - }); - var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); - DoHandshake(clientStream, serverStream); - } - - [TestCase] - public void HandshakeVerification_CorrectPolicyError_ForSelfSignedCertificateWithWrongCN() - { - SetupClientServerConnection(); - var clientStream = new SslStream(m_tcpClient.GetStream(), false, (sender, certificate, chain, sslPolicyErrors) => - { - Assert.AreEqual (SslPolicyErrors.RemoteCertificateChainErrors | SslPolicyErrors.RemoteCertificateNameMismatch, sslPolicyErrors); - return true; - }); - var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); - DoHandshake(clientStream, serverStream, "test"); - } - - [TestCase] - [ExpectedException(typeof(AuthenticationException))] - public void HandshakeVerification_FailureClient_ByCallback() - { - SetupClientServerConnection(); - var clientStream = new SslStream(m_tcpClient.GetStream(), false, RemoteCertificateValidationCallback_AlwaysFail); - var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); - DoHandshake(clientStream, serverStream); - } - - [TestCase] - [ExpectedException(typeof(AuthenticationException))] - public void HandshakeVerification_FailureServer_ByCallback_WithoutClientAuth() - { - SetupClientServerConnection(); - var clientStream = new SslStream(m_tcpClient.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); - var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysFail); - DoHandshake(clientStream, serverStream); - } - - [TestCase] - public void HandshakeVerification_CorrectCertificates_WithoutClientAuth() - { - SetupClientServerConnection(); - var clientStream = new SslStream(m_tcpClient.GetStream(), false, (sender, certificate, chain, sslPolicyErrors) => - { - Assert.AreEqual (m_serverCert.GetRawCertData(), certificate.GetRawCertData()); - return true; - }); - var serverStream = new SslStream(m_tcpServer.GetStream(), false, (sender, certificate, chain, sslPolicyErrors) => - { - Assert.IsNull (certificate); - return true; - }); - DoHandshake(clientStream, serverStream, "test"); - } - - [TestCase] - [ExpectedException(typeof(AuthenticationException))]//typeof(TestException))] // TODO: Can we support passing on the exception like .Net does? - public void HandshakeVerification_FailureClient_ByException() - { - SetupClientServerConnection(); - var clientStream = new SslStream(m_tcpClient.GetStream(), false, RemoteCertificateValidationCallback_ThrowException); - var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); - DoHandshake(clientStream, serverStream); - } - - [TestCase] - public void HandshakeVerification_CorrectEncryptionProperties() - { - SetupClientServerConnection(); - var clientStream = new SslStream(m_tcpClient.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); - var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); - DoHandshake(clientStream, serverStream); - - Assert.AreEqual(SslProtocols.Tls12, clientStream.SslProtocol); - Assert.AreEqual(SslProtocols.Tls12, serverStream.SslProtocol); - - // Expected cipher is TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA - //Assert.AreEqual(CipherAlgorithmType.Aes256, clientStream.CipherAlgorithm); // Not filled out by UnityTls binding - //Assert.AreEqual(256, clientStream.CipherStrength); // Not implemented by Mono.Net.Security.MobileAuthenticatedStream. - //Assert.AreEqual(HashAlgorithmType.Sha1, clientStream.HashAlgorithm); // Not filled out by UnityTls binding - //Assert.AreEqual(ExchangeAlgorithmType.DiffieHellman, clientStream.KeyExchangeAlgorithm); // Not filled out by UnityTls binding - } - - [TestCase] - public void ReadWriteData() - { - SetupClientServerConnection(); - var clientStream = new SslStream(m_tcpClient.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); - var serverStream = new SslStream(m_tcpServer.GetStream(), false, RemoteCertificateValidationCallback_AlwaysSucceed); - DoHandshake(clientStream, serverStream); - - // Send client to server. - byte[] message = Encoding.UTF8.GetBytes("Hello Mono!"); - byte[] receiveBuffer = new byte[message.Length]; - clientStream.Write(message); - serverStream.Read(receiveBuffer, 0, receiveBuffer.Length); - Assert.AreEqual(message, receiveBuffer); - - // Send server to client. - receiveBuffer = new byte[message.Length]; - serverStream.Write(message); - clientStream.Read(receiveBuffer, 0, receiveBuffer.Length); - Assert.AreEqual(message, receiveBuffer); - } - - - private void DoHandshake(SslStream clientStream, SslStream serverStream, string expectedCN = m_serverHostName) - { - try - { - Task.WaitAll( - Task.Run(() => { - try { - if (clientStream != null) - clientStream.AuthenticateAsClient(expectedCN); - } - catch (global::System.IO.IOException) {} // Failure on server side will close client connection. - catch { - m_tcpServer.Close(); - throw; - }}), - Task.Run(() => { - try { - if (serverStream != null) - serverStream.AuthenticateAsServer(m_serverCert); - } - catch (global::System.IO.IOException) {} // Failure on client side will close server connection. - catch { - m_tcpClient.Close(); - throw; - }}) - ); - } - // Filter for AuthentificationException - catch (AggregateException e) - { - FilterForAuthExceptionAndRethrow(e); - throw e; - } - } - - private void FilterForAuthExceptionAndRethrow(Exception e) - { - if (e is AuthenticationException) - throw e; - else if (e is AggregateException) - { - foreach (var inner in ((AggregateException)e).InnerExceptions) - FilterForAuthExceptionAndRethrow(inner); - } - } - - private bool RemoteCertificateValidationCallback_AlwaysSucceed(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) - { - return true; - } - - private bool RemoteCertificateValidationCallback_AlwaysFail(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) - { - return false; - } - - private bool RemoteCertificateValidationCallback_ThrowException(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) - { - throw new TestException(); - } - } -} - -#endif \ No newline at end of file From b9907009271109e5f6f9867b4627174042c23374 Mon Sep 17 00:00:00 2001 From: andreasr Date: Fri, 5 Jan 2018 18:13:59 +0100 Subject: [PATCH 090/582] [unitytls] mono_unity_unitytls_interface exposes now invalid_handle, removing the need for unitytls_x509list_get_size --- mcs/class/System/Mono.UnityTls/CertHelper.cs | 15 +++++++-------- mcs/class/System/Mono.UnityTls/UnityTls.cs | 12 ++++++------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/CertHelper.cs b/mcs/class/System/Mono.UnityTls/CertHelper.cs index f5d357af1dcc..b470b90a65c8 100644 --- a/mcs/class/System/Mono.UnityTls/CertHelper.cs +++ b/mcs/class/System/Mono.UnityTls/CertHelper.cs @@ -33,19 +33,18 @@ public static void AddCertificateToNativeChain (UnityTls.unitytls_x509list* nati public static X509CertificateCollection NativeChainToManagedCollection (UnityTls.unitytls_x509list_ref nativeCertificateChain, UnityTls.unitytls_errorstate* errorState) { X509CertificateCollection certificates = new X509CertificateCollection (); + var unityTls = UnityTls.GetInterface (); - // TODO: Should iterate until we get an invalid handle instead. Can't acces INVALID_HANDLE yet though due to limitations of UnityTls interface - size_t numCerts = UnityTls.GetInterface().unitytls_x509list_get_size (nativeCertificateChain, errorState); - for (int i = 0; i < numCerts; ++i) { - UnityTls.unitytls_x509_ref cert = UnityTls.GetInterface().unitytls_x509list_get_x509 (nativeCertificateChain, i, errorState); - size_t certBufferSize = UnityTls.GetInterface().unitytls_x509_export_der (cert, null, 0, errorState); + var cert = unityTls.unitytls_x509list_get_x509 (nativeCertificateChain, 0, errorState); + for (int i = 0; cert.handle != unityTls.UNITYTLS_INVALID_HANDLE; ++i) { + size_t certBufferSize = unityTls.unitytls_x509_export_der (cert, null, 0, errorState); var certBuffer = new byte[certBufferSize]; // Need to reallocate every time since X509Certificate constructor takes no length but only a byte array. - fixed(byte* certBufferPtr = certBuffer) { - UnityTls.GetInterface().unitytls_x509_export_der (cert, certBufferPtr, certBufferSize, errorState); + unityTls.unitytls_x509_export_der (cert, certBufferPtr, certBufferSize, errorState); } - certificates.Add (new X509Certificate (certBuffer)); + + cert = unityTls.unitytls_x509list_get_x509 (nativeCertificateChain, i, errorState); } return certificates; diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index 63a774619c98..23af1a1b1835 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -69,21 +69,21 @@ public struct unitytls_errorstate public struct unitytls_key {} [StructLayout (LayoutKind.Sequential)] - public struct unitytls_key_ref { UInt64 handle; } + public struct unitytls_key_ref { public UInt64 handle; } // ------------------------------------ // X.509 Certificate // ----------------------------------- public struct unitytls_x509 {} [StructLayout (LayoutKind.Sequential)] - public struct unitytls_x509_ref { UInt64 handle; } + public struct unitytls_x509_ref { public UInt64 handle; } // ------------------------------------ // X.509 Certificate List // ------------------------------------ public struct unitytls_x509list {} [StructLayout (LayoutKind.Sequential)] - public struct unitytls_x509list_ref { UInt64 handle; } + public struct unitytls_x509list_ref { public UInt64 handle; } // ------------------------------------ // X.509 Certificate Verification @@ -119,7 +119,7 @@ public enum unitytls_x509verify_result : UInt32 // ------------------------------------ public struct unitytls_tlsctx {} [StructLayout (LayoutKind.Sequential)] - public struct unitytls_tlsctx_ref { UInt64 handle; } + public struct unitytls_tlsctx_ref { public UInt64 handle; } public enum unitytls_ciphersuite : UInt32 { @@ -163,6 +163,8 @@ public struct unitytls_tlsctx_callbacks [StructLayout (LayoutKind.Sequential)] public class mono_unity_unitytls_interface { + public readonly UInt64 UNITYTLS_INVALID_HANDLE; + public delegate unitytls_errorstate unitytls_errorstate_create_t(); public unitytls_errorstate_create_t unitytls_errorstate_create; public delegate void unitytls_errorstate_raise_error_t(unitytls_errorstate* errorState, unitytls_error_code errorCode); @@ -180,8 +182,6 @@ public class mono_unity_unitytls_interface public delegate unitytls_x509list_ref unitytls_x509list_get_ref_t(unitytls_x509list* list, unitytls_errorstate* errorState); public unitytls_x509list_get_ref_t unitytls_x509list_get_ref; - public delegate size_t unitytls_x509list_get_size_t(unitytls_x509list_ref list, unitytls_errorstate* errorState); - public unitytls_x509list_get_size_t unitytls_x509list_get_size; public delegate unitytls_x509_ref unitytls_x509list_get_x509_t(unitytls_x509list_ref list, size_t index, unitytls_errorstate* errorState); public unitytls_x509list_get_x509_t unitytls_x509list_get_x509; public delegate unitytls_x509list* unitytls_x509list_create_t(unitytls_errorstate* errorState); From a47260d7e74def5a7502478d07a304a0a0f7ac6f Mon Sep 17 00:00:00 2001 From: andreasr Date: Fri, 5 Jan 2018 18:26:20 +0100 Subject: [PATCH 091/582] [unitytls] Removed calls to UnityTls.GetInterface --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 3 -- .../System/Mono.UnityTls/UnityTlsContext.cs | 51 ++++++++++--------- .../System/Mono.UnityTls/UnityTlsProvider.cs | 20 ++++---- 3 files changed, 39 insertions(+), 35 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index 23af1a1b1835..2fd6fec882c6 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -29,9 +29,6 @@ unsafe internal static partial class UnityTls private const string DLLNAME = "MacStandalonePlayer_TLSModule_Dynamic.dylib"; private const CallingConvention CALLCONV = CallingConvention.Cdecl; - // TODO - //extern const UInt64 UNITYTLS_INVALID_HANDLE; - // ------------------------------------ // Error Handling // ------------------------------------ diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index ba57cae9bb92..b2f18bb17685 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -28,6 +28,8 @@ unsafe internal class UnityTlsContext : MobileTlsContext { private const bool ActivateTracing = false; + private UnityTls.mono_unity_unitytls_interface unityTlsNative; + // Native UnityTls objects private UnityTls.unitytls_tlsctx* m_TlsContext = null; @@ -51,10 +53,12 @@ public UnityTlsContext ( X509CertificateCollection clientCertificates, bool askForClientCert) : base (parent, serverMode, targetHost, enabledProtocols, serverCertificate, clientCertificates, askForClientCert) { + unityTlsNative = UnityTls.GetInterface(); + // Need GCHandle to get a consistent pointer to this instance m_handle = GCHandle.Alloc (this); - var errorState = UnityTls.GetInterface().unitytls_errorstate_create (); + var errorState = unityTlsNative.unitytls_errorstate_create (); // Map selected protocols as best as we can. UnityTls.unitytls_tlsctx_protocolrange protocolRange = new UnityTls.unitytls_tlsctx_protocolrange { @@ -75,40 +79,41 @@ public UnityTlsContext ( if (serverCertificate2 == null || serverCertificate2.PrivateKey == null) throw new ArgumentException ("serverCertificate does not have a private key", "serverCertificate"); + UnityTls.unitytls_x509list* serverCerts = null; UnityTls.unitytls_key* serverPrivateKey = null; try { - serverCerts = UnityTls.GetInterface().unitytls_x509list_create (&errorState); + serverCerts = unityTlsNative.unitytls_x509list_create (&errorState); CertHelper.AddCertificateToNativeChain (serverCerts, serverCertificate, &errorState); - var serverCertsRef = UnityTls.GetInterface().unitytls_x509list_get_ref (serverCerts, &errorState); + var serverCertsRef = unityTlsNative.unitytls_x509list_get_ref (serverCerts, &errorState); byte[] privateKeyDer = PKCS8.PrivateKeyInfo.Encode (serverCertificate2.PrivateKey); fixed(byte* privateKeyDerPtr = privateKeyDer) { - serverPrivateKey = UnityTls.GetInterface().unitytls_key_parse_der (privateKeyDerPtr, privateKeyDer.Length, null, 0, &errorState); + serverPrivateKey = unityTlsNative.unitytls_key_parse_der (privateKeyDerPtr, privateKeyDer.Length, null, 0, &errorState); } - var serverKeyRef = UnityTls.GetInterface().unitytls_key_get_ref (serverPrivateKey, &errorState); + var serverKeyRef = unityTlsNative.unitytls_key_get_ref (serverPrivateKey, &errorState); Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to parse server key/certificate"); - m_TlsContext = UnityTls.GetInterface().unitytls_tlsctx_create_server (protocolRange, callbacks, serverCertsRef, serverKeyRef, &errorState); + m_TlsContext = unityTlsNative.unitytls_tlsctx_create_server (protocolRange, callbacks, serverCertsRef, serverKeyRef, &errorState); } finally { - UnityTls.GetInterface().unitytls_x509list_free (serverCerts); - UnityTls.GetInterface().unitytls_key_free (serverPrivateKey); + unityTlsNative.unitytls_x509list_free (serverCerts); + unityTlsNative.unitytls_key_free (serverPrivateKey); } } else { byte [] targetHostUtf8 = Encoding.UTF8.GetBytes (targetHost); fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { - m_TlsContext = UnityTls.GetInterface().unitytls_tlsctx_create_client (protocolRange, callbacks, targetHostUtf8Ptr, targetHostUtf8.Length, &errorState); + m_TlsContext = unityTlsNative.unitytls_tlsctx_create_client (protocolRange, callbacks, targetHostUtf8Ptr, targetHostUtf8.Length, &errorState); } } - UnityTls.GetInterface().unitytls_tlsctx_set_x509verify_callback (m_TlsContext, VerifyCallback, (void*)(IntPtr)m_handle, &errorState); + unityTlsNative.unitytls_tlsctx_set_x509verify_callback (m_TlsContext, VerifyCallback, (void*)(IntPtr)m_handle, &errorState); Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to create UnityTls context"); if (ActivateTracing) { - UnityTls.GetInterface().unitytls_tlsctx_set_trace_callback (m_TlsContext, TraceCallback, null, &errorState); + unityTlsNative.unitytls_tlsctx_set_trace_callback (m_TlsContext, TraceCallback, null, &errorState); Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to set trace callback"); } @@ -149,9 +154,9 @@ public override (int ret, bool wantMore) Read (byte[] buffer, int offset, int co bool wouldBlock = false; int numBytesRead = 0; - var errorState = UnityTls.GetInterface().unitytls_errorstate_create (); + var errorState = unityTlsNative.unitytls_errorstate_create (); fixed (byte* bufferPtr = buffer) { - numBytesRead = UnityTls.GetInterface().unitytls_tlsctx_read (m_TlsContext, bufferPtr + offset, count, &errorState); + numBytesRead = unityTlsNative.unitytls_tlsctx_read (m_TlsContext, bufferPtr + offset, count, &errorState); } if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) @@ -167,9 +172,9 @@ public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int c bool wouldBlock = false; int numBytesWritten = 0; - var errorState = UnityTls.GetInterface().unitytls_errorstate_create (); + var errorState = unityTlsNative.unitytls_errorstate_create (); fixed (byte* bufferPtr = buffer) { - numBytesWritten = UnityTls.GetInterface().unitytls_tlsctx_write (m_TlsContext, bufferPtr + offset, count, &errorState); + numBytesWritten = unityTlsNative.unitytls_tlsctx_write (m_TlsContext, bufferPtr + offset, count, &errorState); } if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) @@ -183,7 +188,7 @@ public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int c public override void Shutdown () { // Destroy native UnityTls objects - UnityTls.GetInterface().unitytls_tlsctx_free (m_TlsContext); + unityTlsNative.unitytls_tlsctx_free (m_TlsContext); m_TlsContext = null; m_HasContext = false; @@ -248,8 +253,8 @@ public override bool ProcessHandshake () public override void FinishHandshake () { // Query some data. Ignore errors on the way since failure is not crucial. - var cipherSuite = UnityTls.GetInterface().unitytls_tlsctx_get_ciphersuite(m_TlsContext, null); - var protocolVersion = UnityTls.GetInterface().unitytls_tlsctx_get_protocol(m_TlsContext, null); + var cipherSuite = unityTlsNative.unitytls_tlsctx_get_ciphersuite(m_TlsContext, null); + var protocolVersion = unityTlsNative.unitytls_tlsctx_get_protocol(m_TlsContext, null); m_Connectioninfo = new MonoTlsConnectionInfo () { CipherSuiteCode = (CipherSuiteCode)cipherSuite, @@ -283,13 +288,13 @@ private size_t WriteCallback (byte* data, size_t bufferLen, UnityTls.unitytls_er Marshal.Copy ((IntPtr)data, m_WriteBuffer, 0, bufferLen); if (!Parent.InternalWrite (m_WriteBuffer, 0, bufferLen)) { - UnityTls.GetInterface().unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WRITE_FAILED); + unityTlsNative.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WRITE_FAILED); return 0; } return bufferLen; } catch { // handle all exceptions since we don't want to let them go through native code. - UnityTls.GetInterface().unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); + unityTlsNative.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); return 0; } } @@ -311,18 +316,18 @@ private size_t ReadCallback (byte* buffer, size_t bufferLen, UnityTls.unitytls_e bool wouldBlock; int numBytesRead = Parent.InternalRead (m_ReadBuffer, 0, bufferLen, out wouldBlock); if (wouldBlock) { - UnityTls.GetInterface().unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK); + unityTlsNative.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK); return 0; } if (numBytesRead < 0) { - UnityTls.GetInterface().unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_READ_FAILED); + unityTlsNative.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_READ_FAILED); return 0; } Marshal.Copy (m_ReadBuffer, 0, (IntPtr)buffer, bufferLen); return numBytesRead; } catch { // handle all exceptions since we don't want to let them go through native code. - UnityTls.GetInterface().unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); + unityTlsNative.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); return 0; } } diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs index 582faa094da4..039b3c2983f2 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs @@ -71,9 +71,11 @@ internal override bool ValidateCertificate ( targetHost = targetHost.Substring (0, pos); } + var unityTlsNative = UnityTls.GetInterface(); + // convert cert to native - var errorState = UnityTls.GetInterface().unitytls_errorstate_create (); - var certificatesNative = UnityTls.GetInterface().unitytls_x509list_create (&errorState); + var errorState = unityTlsNative.unitytls_errorstate_create (); + var certificatesNative = unityTlsNative.unitytls_x509list_create (&errorState); var result = UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_NOT_DONE; try { @@ -85,28 +87,28 @@ internal override bool ValidateCertificate ( //validator.Settings.SendCloseNotify // UnityTls always sends a close notify if the underlying impl supports it. Currently only used by MonoBtlsProvider CertHelper.AddCertificatesToNativeChain (certificatesNative, certificates, &errorState); - var certificatesNativeRef = UnityTls.GetInterface().unitytls_x509list_get_ref (certificatesNative, &errorState); + var certificatesNativeRef = unityTlsNative.unitytls_x509list_get_ref (certificatesNative, &errorState); var targetHostUtf8 = Encoding.UTF8.GetBytes (targetHost); if (validator.Settings.TrustAnchors != null) { - var trustCAnative = UnityTls.GetInterface().unitytls_x509list_create (&errorState); + var trustCAnative = unityTlsNative.unitytls_x509list_create (&errorState); CertHelper.AddCertificatesToNativeChain (trustCAnative, validator.Settings.TrustAnchors, &errorState); - var trustCAnativeRef = UnityTls.GetInterface().unitytls_x509list_get_ref (certificatesNative, &errorState); + var trustCAnativeRef = unityTlsNative.unitytls_x509list_get_ref (certificatesNative, &errorState); fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { - result = UnityTls.GetInterface().unitytls_x509verify_explicit_ca (certificatesNativeRef, trustCAnativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); + result = unityTlsNative.unitytls_x509verify_explicit_ca (certificatesNativeRef, trustCAnativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); } - UnityTls.GetInterface().unitytls_x509list_free (trustCAnative); + unityTlsNative.unitytls_x509list_free (trustCAnative); } else { fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { - result = UnityTls.GetInterface().unitytls_x509verify_default_ca (certificatesNativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); + result = unityTlsNative.unitytls_x509verify_default_ca (certificatesNativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); } } } finally { - UnityTls.GetInterface().unitytls_x509list_free (certificatesNative); + unityTlsNative.unitytls_x509list_free (certificatesNative); } errors = UnityTlsConversions.VerifyResultToPolicyErrror(result); From 7924b373d2674c84318aaf2d46d9d08d76c48706 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 5 Jan 2018 14:15:57 -0500 Subject: [PATCH 092/582] Reduce allocations and perform name calculation outside of lock. --- mono/mini/mixed_callstack_plugin.c | 49 +++++++----------------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/mono/mini/mixed_callstack_plugin.c b/mono/mini/mixed_callstack_plugin.c index c4377f008e39..696b4ae060b3 100644 --- a/mono/mini/mixed_callstack_plugin.c +++ b/mono/mini/mixed_callstack_plugin.c @@ -2,36 +2,6 @@ #include "mono/metadata/mono-debug.h" #include "mono/metadata/profiler.h" -static char * -pmip_pretty(MonoCompile* monoCompile) -{ - char* methodName; - char* assemblyName; - char* formattedPMIP; - MonoDebugSourceLocation* debugSourceLocation; - MonoDebugMethodInfo* debugMethodInfo; - MonoDomain* domain; - MonoMethod* method = monoCompile->method; - - domain = mono_domain_get(); - if (!domain) - domain = mono_get_root_domain(); - - methodName = mono_method_full_name(method, TRUE); - - debugSourceLocation = mono_debug_lookup_source_location(method, 0, domain); - debugMethodInfo = mono_debug_lookup_method(method); - - assemblyName = method->klass->image->module_name; - - formattedPMIP = g_strdup_printf("[%s] %s", assemblyName, methodName); - - mono_debug_free_source_location(debugSourceLocation); - g_free(methodName); - - return formattedPMIP; -} - #if !defined(DISABLE_JIT) && defined(HOST_WIN32) static gboolean enabled; @@ -99,24 +69,27 @@ mixed_callstack_plugin_on_domain_unload_end() void mixed_callstack_plugin_save_method_info (MonoCompile *cfg) { - char* pretty_name; - char* frame; + char* method_name; long bytesWritten = 0; + char frame[1024]; + int bytes; if (!enabled) return; - pretty_name = pmip_pretty(cfg); + method_name = mono_method_full_name (cfg->method, TRUE); + + bytes = snprintf (frame, sizeof (frame), "%p;%p;[%s] %s\n", cfg->native_code, ((char*)cfg->native_code) + cfg->code_size, cfg->method->klass->image->module_name, method_name); + /* negative value is encoding error */ + if (bytes < 0 || bytes > sizeof (frame)) + return; mixed_callstack_plugin_lock (); - frame = g_strdup_printf("%p;%p;%s\n", cfg->native_code, ((char*)cfg->native_code) + cfg->code_size, pretty_name); - WriteFile(fileHandle, frame, strlen(frame), &bytesWritten, NULL); + WriteFile(fileHandle, frame, bytes, &bytesWritten, NULL); FlushFileBuffers(fileHandle); - mixed_callstack_plugin_unlock (); - g_free(pretty_name); - g_free(frame); + g_free(method_name); } void From dc8d8fb25e1d4f4eb8fdcd0e0cac9fb261cf5e2d Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 5 Jan 2018 14:30:15 -0500 Subject: [PATCH 093/582] Avoid some code paths on IL2CPP on Mono to avoid test failures. --- mono/metadata/gc.c | 2 +- mono/metadata/object.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mono/metadata/gc.c b/mono/metadata/gc.c index 99ba7244fce6..11d20fe6a9a7 100644 --- a/mono/metadata/gc.c +++ b/mono/metadata/gc.c @@ -708,7 +708,7 @@ static volatile gboolean finished; void mono_gc_finalize_notify (void) { -#ifdef DEBUG +#if defined(DEBUG) && !defined(IL2CPP_ON_MONO) g_message ( "%s: prodding finalizer", __func__); #endif diff --git a/mono/metadata/object.c b/mono/metadata/object.c index 3d69dca594e3..6cc790cb0817 100644 --- a/mono/metadata/object.c +++ b/mono/metadata/object.c @@ -5196,7 +5196,9 @@ mono_runtime_try_invoke_array (MonoMethod *method, void *obj, MonoArray *params, if (mono_class_is_nullable (method->klass)) { /* Need to create a boxed vtype instead */ +#ifndef IL2CPP_ON_MONO g_assert (!obj); +#endif if (!params) return NULL; From b1a8eca4b643b9481c94c985af0b14abf33eaf70 Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 8 Jan 2018 11:36:35 +0100 Subject: [PATCH 094/582] [unitytls] Making use of Settings.EnabledCiphers now --- .../System/Mono.UnityTls/UnityTlsContext.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index b2f18bb17685..5478942a0eb1 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -218,19 +218,27 @@ protected override void Dispose (bool disposing) public override void StartHandshake () { - // TODO: Check if we started a handshake already? - // TODO, Not supported by UnityTls as of writing + // TODO: Client->Server authentification is not supported by UnityTls as of writing if (IsServer && AskForClientCertificate) { throw new NotImplementedException ("No support for server-sided client certificate check yet."); } - // TODO: Set ciphers from Settings.EnabledCiphers + if (Settings != null && Settings.EnabledCiphers != null) { + var ciphers = new UnityTls.unitytls_ciphersuite [Settings.EnabledCiphers.Length]; + for (int i = 0; i < ciphers.Length; i++) + ciphers [i] = (UnityTls.unitytls_ciphersuite)Settings.EnabledCiphers [i]; + + var errorState = unityTlsNative.unitytls_errorstate_create (); + fixed (UnityTls.unitytls_ciphersuite* ciphersPtr = ciphers) + unityTlsNative.unitytls_tlsctx_set_supported_ciphersuites (m_TlsContext, ciphersPtr, ciphers.Length, &errorState); + Unity.Debug.CheckAndThrow (errorState, "Failed to set list of supported ciphers", AlertDescription.HandshakeFailure); + } } public override bool ProcessHandshake () { - var errorState = UnityTls.GetInterface().unitytls_errorstate_create (); - var result = UnityTls.GetInterface().unitytls_tlsctx_process_handshake (m_TlsContext, &errorState); + var errorState = unityTlsNative.unitytls_errorstate_create (); + var result = unityTlsNative.unitytls_tlsctx_process_handshake (m_TlsContext, &errorState); if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) return false; From 589f1300abfd99835c8fc0e7ed2f4b2c6bef49b2 Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 8 Jan 2018 11:42:17 +0100 Subject: [PATCH 095/582] [unitytls] Native interface is retrieved via static property now instead of function call --- mcs/class/System/Mono.UnityTls/CertHelper.cs | 4 ++-- mcs/class/System/Mono.UnityTls/UnityTls.cs | 13 ++++++++----- mcs/class/System/Mono.UnityTls/UnityTlsContext.cs | 2 +- mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/CertHelper.cs b/mcs/class/System/Mono.UnityTls/CertHelper.cs index b470b90a65c8..1d7694161b98 100644 --- a/mcs/class/System/Mono.UnityTls/CertHelper.cs +++ b/mcs/class/System/Mono.UnityTls/CertHelper.cs @@ -16,7 +16,7 @@ public static void AddCertificateToNativeChain (UnityTls.unitytls_x509list* nati { byte[] certDer = certificate.GetRawCertData (); fixed(byte* certDerPtr = certDer) { - UnityTls.GetInterface().unitytls_x509list_append_der (nativeCertificateChain, certDerPtr, certDer.Length, errorState); + UnityTls.NativeInterface.unitytls_x509list_append_der (nativeCertificateChain, certDerPtr, certDer.Length, errorState); } var certificateImpl2 = certificate.Impl as X509Certificate2Impl; @@ -33,7 +33,7 @@ public static void AddCertificateToNativeChain (UnityTls.unitytls_x509list* nati public static X509CertificateCollection NativeChainToManagedCollection (UnityTls.unitytls_x509list_ref nativeCertificateChain, UnityTls.unitytls_errorstate* errorState) { X509CertificateCollection certificates = new X509CertificateCollection (); - var unityTls = UnityTls.GetInterface (); + var unityTls = UnityTls.NativeInterface; var cert = unityTls.unitytls_x509list_get_x509 (nativeCertificateChain, 0, errorState); for (int i = 0; cert.handle != unityTls.UNITYTLS_INVALID_HANDLE; ++i) { diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index 2fd6fec882c6..a68177eceb81 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -227,17 +227,20 @@ public class mono_unity_unitytls_interface public static bool IsSupported() { try { - return GetInterface() != null; + return NativeInterface != null; } catch (System.Exception) { return false; } } - public static mono_unity_unitytls_interface GetInterface() + public static mono_unity_unitytls_interface NativeInterface { - if (marshalledInterface == null) - marshalledInterface = Marshal.PtrToStructure(mono_unity_get_unitytls_interface()); - return marshalledInterface; + get + { + if (marshalledInterface == null) + marshalledInterface = Marshal.PtrToStructure(mono_unity_get_unitytls_interface()); + return marshalledInterface; + } } } } \ No newline at end of file diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index 5478942a0eb1..8568191a55a5 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -53,7 +53,7 @@ public UnityTlsContext ( X509CertificateCollection clientCertificates, bool askForClientCert) : base (parent, serverMode, targetHost, enabledProtocols, serverCertificate, clientCertificates, askForClientCert) { - unityTlsNative = UnityTls.GetInterface(); + unityTlsNative = UnityTls.NativeInterface; // Need GCHandle to get a consistent pointer to this instance m_handle = GCHandle.Alloc (this); diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs index 039b3c2983f2..82821657100d 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs @@ -71,7 +71,7 @@ internal override bool ValidateCertificate ( targetHost = targetHost.Substring (0, pos); } - var unityTlsNative = UnityTls.GetInterface(); + var unityTlsNative = UnityTls.NativeInterface; // convert cert to native var errorState = unityTlsNative.unitytls_errorstate_create (); From ca2058f714b443ab55184be16fb8616218f2e7e4 Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 8 Jan 2018 11:45:13 +0100 Subject: [PATCH 096/582] [unitytls] Removed local caching of unitytls native interface again. Adds code complexity with little gain. With native interface being a property this also feels more natural now. --- mcs/class/System/Mono.UnityTls/CertHelper.cs | 11 ++-- .../System/Mono.UnityTls/UnityTlsContext.cs | 58 +++++++++---------- .../System/Mono.UnityTls/UnityTlsProvider.cs | 20 +++---- 3 files changed, 41 insertions(+), 48 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/CertHelper.cs b/mcs/class/System/Mono.UnityTls/CertHelper.cs index 1d7694161b98..d669ca3cdafa 100644 --- a/mcs/class/System/Mono.UnityTls/CertHelper.cs +++ b/mcs/class/System/Mono.UnityTls/CertHelper.cs @@ -33,18 +33,17 @@ public static void AddCertificateToNativeChain (UnityTls.unitytls_x509list* nati public static X509CertificateCollection NativeChainToManagedCollection (UnityTls.unitytls_x509list_ref nativeCertificateChain, UnityTls.unitytls_errorstate* errorState) { X509CertificateCollection certificates = new X509CertificateCollection (); - var unityTls = UnityTls.NativeInterface; - var cert = unityTls.unitytls_x509list_get_x509 (nativeCertificateChain, 0, errorState); - for (int i = 0; cert.handle != unityTls.UNITYTLS_INVALID_HANDLE; ++i) { - size_t certBufferSize = unityTls.unitytls_x509_export_der (cert, null, 0, errorState); + var cert = UnityTls.NativeInterface.unitytls_x509list_get_x509 (nativeCertificateChain, 0, errorState); + for (int i = 0; cert.handle != UnityTls.NativeInterface.UNITYTLS_INVALID_HANDLE; ++i) { + size_t certBufferSize = UnityTls.NativeInterface.unitytls_x509_export_der (cert, null, 0, errorState); var certBuffer = new byte[certBufferSize]; // Need to reallocate every time since X509Certificate constructor takes no length but only a byte array. fixed(byte* certBufferPtr = certBuffer) { - unityTls.unitytls_x509_export_der (cert, certBufferPtr, certBufferSize, errorState); + UnityTls.NativeInterface.unitytls_x509_export_der (cert, certBufferPtr, certBufferSize, errorState); } certificates.Add (new X509Certificate (certBuffer)); - cert = unityTls.unitytls_x509list_get_x509 (nativeCertificateChain, i, errorState); + cert = UnityTls.NativeInterface.unitytls_x509list_get_x509 (nativeCertificateChain, i, errorState); } return certificates; diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index 8568191a55a5..b81f83748deb 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -28,8 +28,6 @@ unsafe internal class UnityTlsContext : MobileTlsContext { private const bool ActivateTracing = false; - private UnityTls.mono_unity_unitytls_interface unityTlsNative; - // Native UnityTls objects private UnityTls.unitytls_tlsctx* m_TlsContext = null; @@ -53,12 +51,10 @@ public UnityTlsContext ( X509CertificateCollection clientCertificates, bool askForClientCert) : base (parent, serverMode, targetHost, enabledProtocols, serverCertificate, clientCertificates, askForClientCert) { - unityTlsNative = UnityTls.NativeInterface; - // Need GCHandle to get a consistent pointer to this instance m_handle = GCHandle.Alloc (this); - var errorState = unityTlsNative.unitytls_errorstate_create (); + var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); // Map selected protocols as best as we can. UnityTls.unitytls_tlsctx_protocolrange protocolRange = new UnityTls.unitytls_tlsctx_protocolrange { @@ -83,37 +79,37 @@ public UnityTlsContext ( UnityTls.unitytls_x509list* serverCerts = null; UnityTls.unitytls_key* serverPrivateKey = null; try { - serverCerts = unityTlsNative.unitytls_x509list_create (&errorState); + serverCerts = UnityTls.NativeInterface.unitytls_x509list_create (&errorState); CertHelper.AddCertificateToNativeChain (serverCerts, serverCertificate, &errorState); - var serverCertsRef = unityTlsNative.unitytls_x509list_get_ref (serverCerts, &errorState); + var serverCertsRef = UnityTls.NativeInterface.unitytls_x509list_get_ref (serverCerts, &errorState); byte[] privateKeyDer = PKCS8.PrivateKeyInfo.Encode (serverCertificate2.PrivateKey); fixed(byte* privateKeyDerPtr = privateKeyDer) { - serverPrivateKey = unityTlsNative.unitytls_key_parse_der (privateKeyDerPtr, privateKeyDer.Length, null, 0, &errorState); + serverPrivateKey = UnityTls.NativeInterface.unitytls_key_parse_der (privateKeyDerPtr, privateKeyDer.Length, null, 0, &errorState); } - var serverKeyRef = unityTlsNative.unitytls_key_get_ref (serverPrivateKey, &errorState); + var serverKeyRef = UnityTls.NativeInterface.unitytls_key_get_ref (serverPrivateKey, &errorState); Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to parse server key/certificate"); - m_TlsContext = unityTlsNative.unitytls_tlsctx_create_server (protocolRange, callbacks, serverCertsRef, serverKeyRef, &errorState); + m_TlsContext = UnityTls.NativeInterface.unitytls_tlsctx_create_server (protocolRange, callbacks, serverCertsRef, serverKeyRef, &errorState); } finally { - unityTlsNative.unitytls_x509list_free (serverCerts); - unityTlsNative.unitytls_key_free (serverPrivateKey); + UnityTls.NativeInterface.unitytls_x509list_free (serverCerts); + UnityTls.NativeInterface.unitytls_key_free (serverPrivateKey); } } else { byte [] targetHostUtf8 = Encoding.UTF8.GetBytes (targetHost); fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { - m_TlsContext = unityTlsNative.unitytls_tlsctx_create_client (protocolRange, callbacks, targetHostUtf8Ptr, targetHostUtf8.Length, &errorState); + m_TlsContext = UnityTls.NativeInterface.unitytls_tlsctx_create_client (protocolRange, callbacks, targetHostUtf8Ptr, targetHostUtf8.Length, &errorState); } } - unityTlsNative.unitytls_tlsctx_set_x509verify_callback (m_TlsContext, VerifyCallback, (void*)(IntPtr)m_handle, &errorState); + UnityTls.NativeInterface.unitytls_tlsctx_set_x509verify_callback (m_TlsContext, VerifyCallback, (void*)(IntPtr)m_handle, &errorState); Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to create UnityTls context"); if (ActivateTracing) { - unityTlsNative.unitytls_tlsctx_set_trace_callback (m_TlsContext, TraceCallback, null, &errorState); + UnityTls.NativeInterface.unitytls_tlsctx_set_trace_callback (m_TlsContext, TraceCallback, null, &errorState); Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to set trace callback"); } @@ -154,9 +150,9 @@ public override (int ret, bool wantMore) Read (byte[] buffer, int offset, int co bool wouldBlock = false; int numBytesRead = 0; - var errorState = unityTlsNative.unitytls_errorstate_create (); + var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); fixed (byte* bufferPtr = buffer) { - numBytesRead = unityTlsNative.unitytls_tlsctx_read (m_TlsContext, bufferPtr + offset, count, &errorState); + numBytesRead = UnityTls.NativeInterface.unitytls_tlsctx_read (m_TlsContext, bufferPtr + offset, count, &errorState); } if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) @@ -172,9 +168,9 @@ public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int c bool wouldBlock = false; int numBytesWritten = 0; - var errorState = unityTlsNative.unitytls_errorstate_create (); + var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); fixed (byte* bufferPtr = buffer) { - numBytesWritten = unityTlsNative.unitytls_tlsctx_write (m_TlsContext, bufferPtr + offset, count, &errorState); + numBytesWritten = UnityTls.NativeInterface.unitytls_tlsctx_write (m_TlsContext, bufferPtr + offset, count, &errorState); } if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) @@ -188,7 +184,7 @@ public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int c public override void Shutdown () { // Destroy native UnityTls objects - unityTlsNative.unitytls_tlsctx_free (m_TlsContext); + UnityTls.NativeInterface.unitytls_tlsctx_free (m_TlsContext); m_TlsContext = null; m_HasContext = false; @@ -228,17 +224,17 @@ public override void StartHandshake () for (int i = 0; i < ciphers.Length; i++) ciphers [i] = (UnityTls.unitytls_ciphersuite)Settings.EnabledCiphers [i]; - var errorState = unityTlsNative.unitytls_errorstate_create (); + var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); fixed (UnityTls.unitytls_ciphersuite* ciphersPtr = ciphers) - unityTlsNative.unitytls_tlsctx_set_supported_ciphersuites (m_TlsContext, ciphersPtr, ciphers.Length, &errorState); + UnityTls.NativeInterface.unitytls_tlsctx_set_supported_ciphersuites (m_TlsContext, ciphersPtr, ciphers.Length, &errorState); Unity.Debug.CheckAndThrow (errorState, "Failed to set list of supported ciphers", AlertDescription.HandshakeFailure); } } public override bool ProcessHandshake () { - var errorState = unityTlsNative.unitytls_errorstate_create (); - var result = unityTlsNative.unitytls_tlsctx_process_handshake (m_TlsContext, &errorState); + var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); + var result = UnityTls.NativeInterface.unitytls_tlsctx_process_handshake (m_TlsContext, &errorState); if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) return false; @@ -261,8 +257,8 @@ public override bool ProcessHandshake () public override void FinishHandshake () { // Query some data. Ignore errors on the way since failure is not crucial. - var cipherSuite = unityTlsNative.unitytls_tlsctx_get_ciphersuite(m_TlsContext, null); - var protocolVersion = unityTlsNative.unitytls_tlsctx_get_protocol(m_TlsContext, null); + var cipherSuite = UnityTls.NativeInterface.unitytls_tlsctx_get_ciphersuite(m_TlsContext, null); + var protocolVersion = UnityTls.NativeInterface.unitytls_tlsctx_get_protocol(m_TlsContext, null); m_Connectioninfo = new MonoTlsConnectionInfo () { CipherSuiteCode = (CipherSuiteCode)cipherSuite, @@ -296,13 +292,13 @@ private size_t WriteCallback (byte* data, size_t bufferLen, UnityTls.unitytls_er Marshal.Copy ((IntPtr)data, m_WriteBuffer, 0, bufferLen); if (!Parent.InternalWrite (m_WriteBuffer, 0, bufferLen)) { - unityTlsNative.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WRITE_FAILED); + UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WRITE_FAILED); return 0; } return bufferLen; } catch { // handle all exceptions since we don't want to let them go through native code. - unityTlsNative.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); + UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); return 0; } } @@ -324,18 +320,18 @@ private size_t ReadCallback (byte* buffer, size_t bufferLen, UnityTls.unitytls_e bool wouldBlock; int numBytesRead = Parent.InternalRead (m_ReadBuffer, 0, bufferLen, out wouldBlock); if (wouldBlock) { - unityTlsNative.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK); + UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK); return 0; } if (numBytesRead < 0) { - unityTlsNative.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_READ_FAILED); + UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_READ_FAILED); return 0; } Marshal.Copy (m_ReadBuffer, 0, (IntPtr)buffer, bufferLen); return numBytesRead; } catch { // handle all exceptions since we don't want to let them go through native code. - unityTlsNative.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); + UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); return 0; } } diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs index 82821657100d..4e39a338b01f 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs @@ -71,11 +71,9 @@ internal override bool ValidateCertificate ( targetHost = targetHost.Substring (0, pos); } - var unityTlsNative = UnityTls.NativeInterface; - // convert cert to native - var errorState = unityTlsNative.unitytls_errorstate_create (); - var certificatesNative = unityTlsNative.unitytls_x509list_create (&errorState); + var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); + var certificatesNative = UnityTls.NativeInterface.unitytls_x509list_create (&errorState); var result = UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_NOT_DONE; try { @@ -87,28 +85,28 @@ internal override bool ValidateCertificate ( //validator.Settings.SendCloseNotify // UnityTls always sends a close notify if the underlying impl supports it. Currently only used by MonoBtlsProvider CertHelper.AddCertificatesToNativeChain (certificatesNative, certificates, &errorState); - var certificatesNativeRef = unityTlsNative.unitytls_x509list_get_ref (certificatesNative, &errorState); + var certificatesNativeRef = UnityTls.NativeInterface.unitytls_x509list_get_ref (certificatesNative, &errorState); var targetHostUtf8 = Encoding.UTF8.GetBytes (targetHost); if (validator.Settings.TrustAnchors != null) { - var trustCAnative = unityTlsNative.unitytls_x509list_create (&errorState); + var trustCAnative = UnityTls.NativeInterface.unitytls_x509list_create (&errorState); CertHelper.AddCertificatesToNativeChain (trustCAnative, validator.Settings.TrustAnchors, &errorState); - var trustCAnativeRef = unityTlsNative.unitytls_x509list_get_ref (certificatesNative, &errorState); + var trustCAnativeRef = UnityTls.NativeInterface.unitytls_x509list_get_ref (certificatesNative, &errorState); fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { - result = unityTlsNative.unitytls_x509verify_explicit_ca (certificatesNativeRef, trustCAnativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); + result = UnityTls.NativeInterface.unitytls_x509verify_explicit_ca (certificatesNativeRef, trustCAnativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); } - unityTlsNative.unitytls_x509list_free (trustCAnative); + UnityTls.NativeInterface.unitytls_x509list_free (trustCAnative); } else { fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { - result = unityTlsNative.unitytls_x509verify_default_ca (certificatesNativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); + result = UnityTls.NativeInterface.unitytls_x509verify_default_ca (certificatesNativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); } } } finally { - unityTlsNative.unitytls_x509list_free (certificatesNative); + UnityTls.NativeInterface.unitytls_x509list_free (certificatesNative); } errors = UnityTlsConversions.VerifyResultToPolicyErrror(result); From d90ff2f31b84daa0a453129e387e69f057f135ce Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 8 Jan 2018 12:09:29 +0100 Subject: [PATCH 097/582] [unitytls] Removed commented debug output in MonoTlsProviderFactory and simplified branch-flow for UnityTls support --- .../System/Mono.Net.Security/MonoTlsProviderFactory.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs index b6379ad0a5a8..d4fbf85a801c 100644 --- a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs +++ b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs @@ -233,12 +233,8 @@ static void InitializeProviderRegistration () var unityTlsEntry = new Tuple (UnityTlsId, "Mono.Unity.UnityTlsProvider"); providerRegistration.Add ("default", unityTlsEntry); providerRegistration.Add ("unitytls", unityTlsEntry); - - //Console.Out.WriteLine("UnityTls activated"); + return; } - else - { - //Console.Out.WriteLine("UnityTls not available, using Mono's default implementations"); #endif var appleTlsEntry = new Tuple (AppleTlsId, "Mono.AppleTls.AppleTlsProvider"); @@ -257,7 +253,7 @@ static void InitializeProviderRegistration () providerRegistration.Add ("btls", btlsEntry); } #endif -#endif + if (Platform.IsMacOS) providerRegistration.Add ("default", appleTlsEntry); else if (btlsEntry != null) @@ -266,8 +262,6 @@ static void InitializeProviderRegistration () providerRegistration.Add ("default", legacyEntry); providerRegistration.Add ("apple", appleTlsEntry); -#if UNITY - } #endif } } From f9e79da24220b0b79eba70677b415a668c022e73 Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 8 Jan 2018 12:16:58 +0100 Subject: [PATCH 098/582] [unitytls] Reverted remaining changes in system tests All additional tests are now done from unity to ensure that unitytls inkl binding to unity is working properly --- mcs/class/System/System_test.dll.sources | 2 -- mcs/class/System/Test/System.Net.Security/SslStreamTest.cs | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/mcs/class/System/System_test.dll.sources b/mcs/class/System/System_test.dll.sources index dae376afcb16..6cd61c08477f 100644 --- a/mcs/class/System/System_test.dll.sources +++ b/mcs/class/System/System_test.dll.sources @@ -275,8 +275,6 @@ System.Net.NetworkInformation/NetworkInterfaceTest.cs System.Net.NetworkInformation/PhysicalAddressTest.cs System.Net.NetworkInformation/PingTest.cs System.Net.Security/SslStreamTest.cs -System.Net.Security/SslStreamTest2.cs -System.Net.Security/SslStreamBadSslTest.cs System.Runtime.Versioning/FrameworkNameTest.cs System.Security.AccessControl/SemaphoreSecurityTest.cs System.Security.Cryptography/AsnEncodedDataTest.cs diff --git a/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs b/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs index f95a9af066c3..be4e5ad98315 100644 --- a/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs +++ b/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs @@ -59,9 +59,7 @@ public void GetReady () { } [Test] //bug https://bugzilla.novell.com/show_bug.cgi?id=457120 -#if !UNITY [Category ("MacNotWorking")] // Works but launches a prompt on 10.12 that will fail if you don't click in a few seconds -#endif #if FEATURE_NO_BSD_SOCKETS [ExpectedException (typeof (PlatformNotSupportedException))] #endif @@ -149,3 +147,4 @@ private class ClientServerState { } } } + From 9889bec2c51bff21ea7fe8ddeb249e9582f67904 Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 8 Jan 2018 13:00:33 +0100 Subject: [PATCH 099/582] [unitytls] added comment explaining use of mono_unity_unitytls_interface --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index a68177eceb81..f30c8828fee9 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -157,6 +157,9 @@ public struct unitytls_tlsctx_callbacks // ------------------------------------------------------------------------ // unitytls interface defintion // ------------------------------------------------------------------------ + + // This native struct is used to provide all necessary fields and function calls from unitytls to the mono-unitytls-binding. + // Native implementation lives in unity:Modules/TLS/TLSMonoIntegration.cpp and needs to be adapted to every change. [StructLayout (LayoutKind.Sequential)] public class mono_unity_unitytls_interface { From a5df54c6e9bce5a2e37b3afb020a33ad5cfea999 Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 8 Jan 2018 18:07:45 +0100 Subject: [PATCH 100/582] [unitytls] FinishHandshake no longer passes null for errorState when retrieving information about the connection from tlsctx. Passing null for the errorstate is no longer supported in an upcoming unitytls version. --- mcs/class/System/Mono.UnityTls/UnityTlsContext.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index b81f83748deb..a88a8e4f69b1 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -257,8 +257,9 @@ public override bool ProcessHandshake () public override void FinishHandshake () { // Query some data. Ignore errors on the way since failure is not crucial. - var cipherSuite = UnityTls.NativeInterface.unitytls_tlsctx_get_ciphersuite(m_TlsContext, null); - var protocolVersion = UnityTls.NativeInterface.unitytls_tlsctx_get_protocol(m_TlsContext, null); + var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); + var cipherSuite = UnityTls.NativeInterface.unitytls_tlsctx_get_ciphersuite(m_TlsContext, &errorState); + var protocolVersion = UnityTls.NativeInterface.unitytls_tlsctx_get_protocol(m_TlsContext, &errorState); m_Connectioninfo = new MonoTlsConnectionInfo () { CipherSuiteCode = (CipherSuiteCode)cipherSuite, From fe8bf683a55477d3e30094a9c8e792cf9d5c54f9 Mon Sep 17 00:00:00 2001 From: andreasr Date: Tue, 9 Jan 2018 10:29:52 +0100 Subject: [PATCH 101/582] [unitytls] Removed leftover from previous p/invoke based integration. --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index f30c8828fee9..d63e57bd0239 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -26,9 +26,6 @@ public static implicit operator int(size_t s) { unsafe internal static partial class UnityTls { - private const string DLLNAME = "MacStandalonePlayer_TLSModule_Dynamic.dylib"; - private const CallingConvention CALLCONV = CallingConvention.Cdecl; - // ------------------------------------ // Error Handling // ------------------------------------ From 1165e17f90060e72100fd28e103635a93a8d68f4 Mon Sep 17 00:00:00 2001 From: andreasr Date: Tue, 9 Jan 2018 18:47:35 +0100 Subject: [PATCH 102/582] [unitytls] User exceptions from read/write/handshake are now passed on properly. --- .../System/Mono.UnityTls/UnityTlsContext.cs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index a88a8e4f69b1..a3016638c9a4 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -43,6 +43,7 @@ unsafe internal class UnityTlsContext : MobileTlsContext byte [] m_ReadBuffer; GCHandle m_handle; + Exception lastException; public UnityTlsContext ( MobileAuthenticatedStream parent, @@ -150,10 +151,13 @@ public override (int ret, bool wantMore) Read (byte[] buffer, int offset, int co bool wouldBlock = false; int numBytesRead = 0; + lastException = null; var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); fixed (byte* bufferPtr = buffer) { numBytesRead = UnityTls.NativeInterface.unitytls_tlsctx_read (m_TlsContext, bufferPtr + offset, count, &errorState); } + if (lastException != null) + throw lastException; if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) wouldBlock = true; @@ -168,10 +172,13 @@ public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int c bool wouldBlock = false; int numBytesWritten = 0; + lastException = null; var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); fixed (byte* bufferPtr = buffer) { numBytesWritten = UnityTls.NativeInterface.unitytls_tlsctx_write (m_TlsContext, bufferPtr + offset, count, &errorState); } + if (lastException != null) + throw lastException; if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) wouldBlock = true; @@ -233,10 +240,13 @@ public override void StartHandshake () public override bool ProcessHandshake () { + lastException = null; var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); var result = UnityTls.NativeInterface.unitytls_tlsctx_process_handshake (m_TlsContext, &errorState); if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) return false; + if (lastException != null) + throw lastException; // Not done is not an error if we are server and don't ask for ClientCertificate if (result == UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_NOT_DONE && IsServer && !AskForClientCertificate) @@ -298,8 +308,10 @@ private size_t WriteCallback (byte* data, size_t bufferLen, UnityTls.unitytls_er } return bufferLen; - } catch { // handle all exceptions since we don't want to let them go through native code. + } catch (Exception ex) { // handle all exceptions and store them for later since we don't want to let them go through native code. UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); + if (lastException == null) + lastException = ex; return 0; } } @@ -331,8 +343,10 @@ private size_t ReadCallback (byte* buffer, size_t bufferLen, UnityTls.unitytls_e Marshal.Copy (m_ReadBuffer, 0, (IntPtr)buffer, bufferLen); return numBytesRead; - } catch { // handle all exceptions since we don't want to let them go through native code. + } catch (Exception ex) { // handle all exceptions and store them for later since we don't want to let them go through native code. UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); + if (lastException == null) + lastException = ex; return 0; } } @@ -354,7 +368,9 @@ private UnityTls.unitytls_x509verify_result VerifyCallback (UnityTls.unitytls_x5 return UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_SUCCESS; else return UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED; - } catch { // handle all exceptions since we don't want to let them go through native code. + } catch (Exception ex) { // handle all exceptions and store them for later since we don't want to let them go through native code. + if (lastException == null) + lastException = ex; return UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_FATAL_ERROR; } } From 8f7503bdaf72c87e635801dd4aaf2ec2b38045b3 Mon Sep 17 00:00:00 2001 From: andreasr Date: Tue, 9 Jan 2018 18:47:57 +0100 Subject: [PATCH 103/582] [unitytls] Commented on UInt8/Int8 aliases --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index d63e57bd0239..18701bcf8723 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -4,6 +4,9 @@ namespace Mono.Unity { + // Unitytls uses UInt8 to denote raw buffers and Int8/char for strings. + // Since we need to funnel all in- and outgoing strings through Encoding.UTF8 it is easier to let the Int8 alias point to Byte instead of SByte. + // The aliases here are just there to keep the semantic in the interface and make it more similar to the c original. using UInt8 = Byte; using Int8 = Byte; From 88d2f0849274b967b3783c35e8d01e2d64c8edce Mon Sep 17 00:00:00 2001 From: Brian Raderman Date: Tue, 9 Jan 2018 16:38:10 -0500 Subject: [PATCH 104/582] breakpoints_cleanup() in the debugger agent can be called multiple times when used with IL2CPP, so added some defense against this to prevent already-cleared hashtables and arrays from being destroyed multiple times. --- mono/mini/debugger-agent.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 5cade0588401..fe7191a3ea87 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -4930,14 +4930,20 @@ breakpoints_cleanup (void) } } - for (i = 0; i < breakpoints->len; ++i) - g_free (g_ptr_array_index (breakpoints, i)); - - g_ptr_array_free (breakpoints, TRUE); - g_hash_table_destroy (bp_locs); - - breakpoints = NULL; - bp_locs = NULL; + if (breakpoints) + { + for (i = 0; i < breakpoints->len; ++i) + g_free (g_ptr_array_index (breakpoints, i)); + + g_ptr_array_free (breakpoints, TRUE); + breakpoints = NULL; + } + + if (bp_locs) + { + g_hash_table_destroy (bp_locs); + bp_locs = NULL; + } mono_loader_unlock (); } From 02aa17917073f753e0408a8c5e6e3542330827c3 Mon Sep 17 00:00:00 2001 From: andreasr Date: Wed, 10 Jan 2018 14:37:22 +0100 Subject: [PATCH 105/582] [unitytls] Implemented client->server authentification Fixed RemoteCertificate property always being null --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 117 +++++++++-------- .../System/Mono.UnityTls/UnityTlsContext.cs | 121 ++++++++++++++---- 2 files changed, 158 insertions(+), 80 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index 18701bcf8723..c6ac51d2d390 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -118,6 +118,8 @@ public struct unitytls_tlsctx {} [StructLayout (LayoutKind.Sequential)] public struct unitytls_tlsctx_ref { public UInt64 handle; } + public struct unitytls_x509name {} + public enum unitytls_ciphersuite : UInt32 { // With exception of the INVALID value, this enum represents an IANA cipher ID. @@ -142,6 +144,7 @@ public struct unitytls_tlsctx_protocolrange public delegate size_t unitytls_tlsctx_write_callback(void* userData, UInt8* data, size_t bufferLen, unitytls_errorstate* errorState); public delegate size_t unitytls_tlsctx_read_callback(void* userData, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); public delegate void unitytls_tlsctx_trace_callback(void* userData, unitytls_tlsctx* ctx, Int8* traceMessage, size_t traceMessageLen); + public delegate void unitytls_tlsctx_certificate_callback(void* userData, unitytls_tlsctx* ctx, Int8* cn, size_t cnLen, unitytls_x509name* caList, size_t caListLen, unitytls_x509list_ref* chain, unitytls_key_ref* key, unitytls_errorstate* errorState); public delegate unitytls_x509verify_result unitytls_tlsctx_x509verify_callback(void* userData, unitytls_x509list_ref chain, unitytls_errorstate* errorState); [StructLayout (LayoutKind.Sequential)] @@ -165,61 +168,65 @@ public class mono_unity_unitytls_interface { public readonly UInt64 UNITYTLS_INVALID_HANDLE; - public delegate unitytls_errorstate unitytls_errorstate_create_t(); - public unitytls_errorstate_create_t unitytls_errorstate_create; - public delegate void unitytls_errorstate_raise_error_t(unitytls_errorstate* errorState, unitytls_error_code errorCode); - public unitytls_errorstate_raise_error_t unitytls_errorstate_raise_error; - - public delegate unitytls_key_ref unitytls_key_get_ref_t(unitytls_key* key, unitytls_errorstate* errorState); - public unitytls_key_get_ref_t unitytls_key_get_ref; - public delegate unitytls_key* unitytls_key_parse_der_t(UInt8* buffer, size_t bufferLen, UInt8* password, size_t passwordLen, unitytls_errorstate* errorState); - public unitytls_key_parse_der_t unitytls_key_parse_der; - public delegate void unitytls_key_free_t(unitytls_key* key); - public unitytls_key_free_t unitytls_key_free; - - public delegate size_t unitytls_x509_export_der_t(unitytls_x509_ref cert, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - public unitytls_x509_export_der_t unitytls_x509_export_der; - - public delegate unitytls_x509list_ref unitytls_x509list_get_ref_t(unitytls_x509list* list, unitytls_errorstate* errorState); - public unitytls_x509list_get_ref_t unitytls_x509list_get_ref; - public delegate unitytls_x509_ref unitytls_x509list_get_x509_t(unitytls_x509list_ref list, size_t index, unitytls_errorstate* errorState); - public unitytls_x509list_get_x509_t unitytls_x509list_get_x509; - public delegate unitytls_x509list* unitytls_x509list_create_t(unitytls_errorstate* errorState); - public unitytls_x509list_create_t unitytls_x509list_create; - public delegate void unitytls_x509list_append_t(unitytls_x509list* list, unitytls_x509_ref cert, unitytls_errorstate* errorState); - public unitytls_x509list_append_t unitytls_x509list_append; - public delegate void unitytls_x509list_append_der_t(unitytls_x509list* list, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - public unitytls_x509list_append_der_t unitytls_x509list_append_der; - public delegate void unitytls_x509list_free_t(unitytls_x509list* list); - public unitytls_x509list_free_t unitytls_x509list_free; - - public delegate unitytls_x509verify_result unitytls_x509verify_default_ca_t(unitytls_x509list_ref chain, Int8* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); - public unitytls_x509verify_default_ca_t unitytls_x509verify_default_ca; - public delegate unitytls_x509verify_result unitytls_x509verify_explicit_ca_t(unitytls_x509list_ref chain, unitytls_x509list_ref trustCA, Int8* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); - public unitytls_x509verify_explicit_ca_t unitytls_x509verify_explicit_ca; - - public delegate unitytls_tlsctx* unitytls_tlsctx_create_server_t(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, unitytls_x509list_ref certChain, unitytls_key_ref leafCertificateKey, unitytls_errorstate* errorState); - public unitytls_tlsctx_create_server_t unitytls_tlsctx_create_server; - public delegate unitytls_tlsctx* unitytls_tlsctx_create_client_t(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, Int8* cn, size_t cnLen, unitytls_errorstate* errorState); - public unitytls_tlsctx_create_client_t unitytls_tlsctx_create_client; - public delegate void unitytls_tlsctx_set_trace_callback_t(unitytls_tlsctx* ctx, unitytls_tlsctx_trace_callback cb, void* userData, unitytls_errorstate* errorState); - public unitytls_tlsctx_set_trace_callback_t unitytls_tlsctx_set_trace_callback; - public delegate void unitytls_tlsctx_set_x509verify_callback_t(unitytls_tlsctx* ctx, unitytls_tlsctx_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); - public unitytls_tlsctx_set_x509verify_callback_t unitytls_tlsctx_set_x509verify_callback; - public delegate void unitytls_tlsctx_set_supported_ciphersuites_t(unitytls_tlsctx* ctx, unitytls_ciphersuite* supportedCiphersuites, size_t supportedCiphersuitesLen, unitytls_errorstate* errorState); - public unitytls_tlsctx_set_supported_ciphersuites_t unitytls_tlsctx_set_supported_ciphersuites; - public delegate unitytls_ciphersuite unitytls_tlsctx_get_ciphersuite_t(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); - public unitytls_tlsctx_get_ciphersuite_t unitytls_tlsctx_get_ciphersuite; - public delegate unitytls_protocol unitytls_tlsctx_get_protocol_t(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); - public unitytls_tlsctx_get_protocol_t unitytls_tlsctx_get_protocol; - public delegate unitytls_x509verify_result unitytls_tlsctx_process_handshake_t(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); - public unitytls_tlsctx_process_handshake_t unitytls_tlsctx_process_handshake; - public delegate size_t unitytls_tlsctx_read_t(unitytls_tlsctx* ctx, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); - public unitytls_tlsctx_read_t unitytls_tlsctx_read; - public delegate size_t unitytls_tlsctx_write_t(unitytls_tlsctx* ctx, UInt8* data, size_t bufferLen, unitytls_errorstate* errorState); - public unitytls_tlsctx_write_t unitytls_tlsctx_write; - public delegate void unitytls_tlsctx_free_t(unitytls_tlsctx* ctx); - public unitytls_tlsctx_free_t unitytls_tlsctx_free; + public delegate unitytls_errorstate unitytls_errorstate_create_t(); + public unitytls_errorstate_create_t unitytls_errorstate_create; + public delegate void unitytls_errorstate_raise_error_t(unitytls_errorstate* errorState, unitytls_error_code errorCode); + public unitytls_errorstate_raise_error_t unitytls_errorstate_raise_error; + + public delegate unitytls_key_ref unitytls_key_get_ref_t(unitytls_key* key, unitytls_errorstate* errorState); + public unitytls_key_get_ref_t unitytls_key_get_ref; + public delegate unitytls_key* unitytls_key_parse_der_t(UInt8* buffer, size_t bufferLen, UInt8* password, size_t passwordLen, unitytls_errorstate* errorState); + public unitytls_key_parse_der_t unitytls_key_parse_der; + public delegate void unitytls_key_free_t(unitytls_key* key); + public unitytls_key_free_t unitytls_key_free; + + public delegate size_t unitytls_x509_export_der_t(unitytls_x509_ref cert, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + public unitytls_x509_export_der_t unitytls_x509_export_der; + + public delegate unitytls_x509list_ref unitytls_x509list_get_ref_t(unitytls_x509list* list, unitytls_errorstate* errorState); + public unitytls_x509list_get_ref_t unitytls_x509list_get_ref; + public delegate unitytls_x509_ref unitytls_x509list_get_x509_t(unitytls_x509list_ref list, size_t index, unitytls_errorstate* errorState); + public unitytls_x509list_get_x509_t unitytls_x509list_get_x509; + public delegate unitytls_x509list* unitytls_x509list_create_t(unitytls_errorstate* errorState); + public unitytls_x509list_create_t unitytls_x509list_create; + public delegate void unitytls_x509list_append_t(unitytls_x509list* list, unitytls_x509_ref cert, unitytls_errorstate* errorState); + public unitytls_x509list_append_t unitytls_x509list_append; + public delegate void unitytls_x509list_append_der_t(unitytls_x509list* list, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + public unitytls_x509list_append_der_t unitytls_x509list_append_der; + public delegate void unitytls_x509list_free_t(unitytls_x509list* list); + public unitytls_x509list_free_t unitytls_x509list_free; + + public delegate unitytls_x509verify_result unitytls_x509verify_default_ca_t(unitytls_x509list_ref chain, Int8* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); + public unitytls_x509verify_default_ca_t unitytls_x509verify_default_ca; + public delegate unitytls_x509verify_result unitytls_x509verify_explicit_ca_t(unitytls_x509list_ref chain, unitytls_x509list_ref trustCA, Int8* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); + public unitytls_x509verify_explicit_ca_t unitytls_x509verify_explicit_ca; + + public delegate unitytls_tlsctx* unitytls_tlsctx_create_server_t(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, unitytls_x509list_ref certChain, unitytls_key_ref leafCertificateKey, unitytls_errorstate* errorState); + public unitytls_tlsctx_create_server_t unitytls_tlsctx_create_server; + public delegate unitytls_tlsctx* unitytls_tlsctx_create_client_t(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, Int8* cn, size_t cnLen, unitytls_errorstate* errorState); + public unitytls_tlsctx_create_client_t unitytls_tlsctx_create_client; + public delegate void unitytls_tlsctx_server_require_client_authentication_t(unitytls_tlsctx* ctx, unitytls_x509list_ref clientAuthCAList, unitytls_errorstate* errorState); + public unitytls_tlsctx_server_require_client_authentication_t unitytls_tlsctx_server_require_client_authentication; + public delegate void unitytls_tlsctx_set_certificate_callback_t(unitytls_tlsctx* ctx, unitytls_tlsctx_certificate_callback cb, void* userData, unitytls_errorstate* errorState); + public unitytls_tlsctx_set_certificate_callback_t unitytls_tlsctx_set_certificate_callback; + public delegate void unitytls_tlsctx_set_trace_callback_t(unitytls_tlsctx* ctx, unitytls_tlsctx_trace_callback cb, void* userData, unitytls_errorstate* errorState); + public unitytls_tlsctx_set_trace_callback_t unitytls_tlsctx_set_trace_callback; + public delegate void unitytls_tlsctx_set_x509verify_callback_t(unitytls_tlsctx* ctx, unitytls_tlsctx_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); + public unitytls_tlsctx_set_x509verify_callback_t unitytls_tlsctx_set_x509verify_callback; + public delegate void unitytls_tlsctx_set_supported_ciphersuites_t(unitytls_tlsctx* ctx, unitytls_ciphersuite* supportedCiphersuites, size_t supportedCiphersuitesLen, unitytls_errorstate* errorState); + public unitytls_tlsctx_set_supported_ciphersuites_t unitytls_tlsctx_set_supported_ciphersuites; + public delegate unitytls_ciphersuite unitytls_tlsctx_get_ciphersuite_t(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); + public unitytls_tlsctx_get_ciphersuite_t unitytls_tlsctx_get_ciphersuite; + public delegate unitytls_protocol unitytls_tlsctx_get_protocol_t(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); + public unitytls_tlsctx_get_protocol_t unitytls_tlsctx_get_protocol; + public delegate unitytls_x509verify_result unitytls_tlsctx_process_handshake_t(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); + public unitytls_tlsctx_process_handshake_t unitytls_tlsctx_process_handshake; + public delegate size_t unitytls_tlsctx_read_t(unitytls_tlsctx* ctx, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + public unitytls_tlsctx_read_t unitytls_tlsctx_read; + public delegate size_t unitytls_tlsctx_write_t(unitytls_tlsctx* ctx, UInt8* data, size_t bufferLen, unitytls_errorstate* errorState); + public unitytls_tlsctx_write_t unitytls_tlsctx_write; + public delegate void unitytls_tlsctx_free_t(unitytls_tlsctx* ctx); + public unitytls_tlsctx_free_t unitytls_tlsctx_free; } [DllImport("__Internal")] diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index a3016638c9a4..be6c09fc0658 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -22,6 +22,8 @@ using Mono.Net.Security; using Mono.Util; +using Int8 = System.Byte; + namespace Mono.Unity { unsafe internal class UnityTlsContext : MobileTlsContext @@ -30,10 +32,12 @@ unsafe internal class UnityTlsContext : MobileTlsContext // Native UnityTls objects private UnityTls.unitytls_tlsctx* m_TlsContext = null; + private UnityTls.unitytls_x509list* m_RequestedClientCertChain = null; + private UnityTls.unitytls_key* m_RequestedClientKey = null; // States and certificates X509Certificate m_LocalClientCertificate; - X509Certificate2 m_RemoteCertificate; + X509Certificate m_RemoteCertificate; MonoTlsConnectionInfo m_Connectioninfo; bool m_IsAuthenticated = false; bool m_HasContext = false; @@ -70,29 +74,24 @@ public UnityTlsContext ( }; if (serverMode) { - if (serverCertificate == null) - throw new ArgumentNullException ("serverCertificate"); - X509Certificate2 serverCertificate2 = serverCertificate as X509Certificate2; - if (serverCertificate2 == null || serverCertificate2.PrivateKey == null) - throw new ArgumentException ("serverCertificate does not have a private key", "serverCertificate"); - - - UnityTls.unitytls_x509list* serverCerts = null; - UnityTls.unitytls_key* serverPrivateKey = null; + ExtractNativeKeyAndChainFromManagedCertificate(serverCertificate, &errorState, out var serverCerts, out var serverPrivateKey); try { - serverCerts = UnityTls.NativeInterface.unitytls_x509list_create (&errorState); - CertHelper.AddCertificateToNativeChain (serverCerts, serverCertificate, &errorState); var serverCertsRef = UnityTls.NativeInterface.unitytls_x509list_get_ref (serverCerts, &errorState); - - byte[] privateKeyDer = PKCS8.PrivateKeyInfo.Encode (serverCertificate2.PrivateKey); - fixed(byte* privateKeyDerPtr = privateKeyDer) { - serverPrivateKey = UnityTls.NativeInterface.unitytls_key_parse_der (privateKeyDerPtr, privateKeyDer.Length, null, 0, &errorState); - } var serverKeyRef = UnityTls.NativeInterface.unitytls_key_get_ref (serverPrivateKey, &errorState); - Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to parse server key/certificate"); m_TlsContext = UnityTls.NativeInterface.unitytls_tlsctx_create_server (protocolRange, callbacks, serverCertsRef, serverKeyRef, &errorState); + + if (askForClientCert) { + UnityTls.unitytls_x509list* clientAuthCAList = null; + try { + clientAuthCAList = UnityTls.NativeInterface.unitytls_x509list_create (&errorState); + var clientAuthCAListRef = UnityTls.NativeInterface.unitytls_x509list_get_ref (clientAuthCAList, &errorState); + UnityTls.NativeInterface.unitytls_tlsctx_server_require_client_authentication (m_TlsContext, clientAuthCAListRef, &errorState); + } finally { + UnityTls.NativeInterface.unitytls_x509list_free (clientAuthCAList); + } + } } finally { UnityTls.NativeInterface.unitytls_x509list_free (serverCerts); UnityTls.NativeInterface.unitytls_key_free (serverPrivateKey); @@ -103,6 +102,8 @@ public UnityTlsContext ( fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { m_TlsContext = UnityTls.NativeInterface.unitytls_tlsctx_create_client (protocolRange, callbacks, targetHostUtf8Ptr, targetHostUtf8.Length, &errorState); } + + UnityTls.NativeInterface.unitytls_tlsctx_set_certificate_callback (m_TlsContext, CertificateCallback, (void*)(IntPtr)m_handle, &errorState); } UnityTls.NativeInterface.unitytls_tlsctx_set_x509verify_callback (m_TlsContext, VerifyCallback, (void*)(IntPtr)m_handle, &errorState); @@ -117,14 +118,37 @@ public UnityTlsContext ( m_HasContext = true; } + static private void ExtractNativeKeyAndChainFromManagedCertificate(X509Certificate cert, UnityTls.unitytls_errorstate* errorState, out UnityTls.unitytls_x509list* nativeCertChain, out UnityTls.unitytls_key* nativeKey) + { + if (cert == null) + throw new ArgumentNullException ("cert"); + X509Certificate2 cert2 = cert as X509Certificate2; + if (cert2 == null || cert2.PrivateKey == null) + throw new ArgumentException ("Certificate does not have a private key", "cert"); + + nativeCertChain = null; + nativeKey = null; + try { + nativeCertChain = UnityTls.NativeInterface.unitytls_x509list_create (errorState); + CertHelper.AddCertificateToNativeChain (nativeCertChain, cert, errorState); + + byte[] privateKeyDer = PKCS8.PrivateKeyInfo.Encode (cert2.PrivateKey); + fixed(byte* privateKeyDerPtr = privateKeyDer) { + nativeKey = UnityTls.NativeInterface.unitytls_key_parse_der (privateKeyDerPtr, privateKeyDer.Length, null, 0, errorState); + } + } catch { + UnityTls.NativeInterface.unitytls_x509list_free (nativeCertChain); + UnityTls.NativeInterface.unitytls_key_free (nativeKey); + throw; + } + } + public override bool HasContext { get { return m_HasContext; } } - public override bool IsAuthenticated { get { return m_IsAuthenticated; } } - public override MonoTlsConnectionInfo ConnectionInfo { get { return m_Connectioninfo; } } @@ -191,6 +215,8 @@ public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int c public override void Shutdown () { // Destroy native UnityTls objects + UnityTls.NativeInterface.unitytls_x509list_free (m_RequestedClientCertChain); + UnityTls.NativeInterface.unitytls_key_free (m_RequestedClientKey); UnityTls.NativeInterface.unitytls_tlsctx_free (m_TlsContext); m_TlsContext = null; @@ -207,6 +233,16 @@ protected override void Dispose (bool disposing) // reset states m_LocalClientCertificate = null; m_RemoteCertificate = null; + + if (m_LocalClientCertificate != null) { + m_LocalClientCertificate.Dispose (); + m_LocalClientCertificate = null; + } + if (m_RemoteCertificate != null) { + m_RemoteCertificate.Dispose (); + m_RemoteCertificate = null; + } + m_Connectioninfo = null; m_IsAuthenticated = false; m_HasContext = false; @@ -221,11 +257,6 @@ protected override void Dispose (bool disposing) public override void StartHandshake () { - // TODO: Client->Server authentification is not supported by UnityTls as of writing - if (IsServer && AskForClientCertificate) { - throw new NotImplementedException ("No support for server-sided client certificate check yet."); - } - if (Settings != null && Settings.EnabledCiphers != null) { var ciphers = new UnityTls.unitytls_ciphersuite [Settings.EnabledCiphers.Length]; for (int i = 0; i < ciphers.Length; i++) @@ -363,6 +394,7 @@ private UnityTls.unitytls_x509verify_result VerifyCallback (UnityTls.unitytls_x5 { try { X509CertificateCollection certificates = CertHelper.NativeChainToManagedCollection (chain, errorState); + m_RemoteCertificate = new X509Certificate (certificates [0]); if (ValidateCertificate (certificates)) return UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_SUCCESS; @@ -375,6 +407,45 @@ private UnityTls.unitytls_x509verify_result VerifyCallback (UnityTls.unitytls_x5 } } + + [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_certificate_callback))] + static private void CertificateCallback (void* userData, UnityTls.unitytls_tlsctx* ctx, Int8* cn, size_t cnLen, UnityTls.unitytls_x509name* caList, size_t caListLen, UnityTls.unitytls_x509list_ref* chain, UnityTls.unitytls_key_ref* key, UnityTls.unitytls_errorstate* errorState) + { + var handle = (GCHandle)(IntPtr)userData; + var context = (UnityTlsContext)handle.Target; + context.CertificateCallback (ctx, cn, cnLen, caList, caListLen, chain, key, errorState); + } + + private void CertificateCallback (UnityTls.unitytls_tlsctx* ctx, Int8* cn, size_t cnLen, UnityTls.unitytls_x509name* caList, size_t caListLen, UnityTls.unitytls_x509list_ref* chain, UnityTls.unitytls_key_ref* key, UnityTls.unitytls_errorstate* errorState) + { + try { + if (m_RemoteCertificate == null) + throw new TlsException (AlertDescription.InternalError, "Cannot request client certificate before receiving one from the server."); + + m_LocalClientCertificate = SelectClientCertificate (m_RemoteCertificate, null); + + if (m_LocalClientCertificate == null) { + *chain = new UnityTls.unitytls_x509list_ref { handle = UnityTls.NativeInterface.UNITYTLS_INVALID_HANDLE }; + *key = new UnityTls.unitytls_key_ref { handle = UnityTls.NativeInterface.UNITYTLS_INVALID_HANDLE }; + } else { + // Need to create native objects for client chain/key. Need to keep them cached. + // Make sure we don't have old native objects still around. + UnityTls.NativeInterface.unitytls_x509list_free (m_RequestedClientCertChain); + UnityTls.NativeInterface.unitytls_key_free (m_RequestedClientKey); + + ExtractNativeKeyAndChainFromManagedCertificate(m_LocalClientCertificate, errorState, out m_RequestedClientCertChain, out m_RequestedClientKey); + *chain = UnityTls.NativeInterface.unitytls_x509list_get_ref (m_RequestedClientCertChain, errorState); + *key = UnityTls.NativeInterface.unitytls_key_get_ref (m_RequestedClientKey, errorState); + } + + Unity.Debug.CheckAndThrow (*errorState, "Failed to retrieve certificates on request.", AlertDescription.HandshakeFailure); + } catch (Exception ex) { // handle all exceptions and store them for later since we don't want to let them go through native code. + UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); + if (lastException == null) + lastException = ex; + } + } + [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_trace_callback))] static private void TraceCallback (void* userData, UnityTls.unitytls_tlsctx* ctx, byte* traceMessage, size_t traceMessageLen) { From 3843d8ed69fe8c0dc2cd0c04f57a79c0550d3fda Mon Sep 17 00:00:00 2001 From: andreasr Date: Wed, 10 Jan 2018 15:01:11 +0100 Subject: [PATCH 106/582] [unitytls] Update of error code to newest version --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index c6ac51d2d390..999e28ef97a8 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -35,21 +35,22 @@ unsafe internal static partial class UnityTls public enum unitytls_error_code : UInt32 { UNITYTLS_SUCCESS = 0, - UNITYTLS_INVALID_ARGUMENT, // One of the arguments has an invalid value (e.g. null where not allowed) - UNITYTLS_INVALID_FORMAT, // The passed data does not have a valid format. - UNITYTLS_INVALID_STATE, // The object operating being operated on is not in a state that allows this function call. - UNITYTLS_BUFFER_OVERFLOW, // A passed buffer was not large enough. - UNITYTLS_OUT_OF_MEMORY, // Out of memory error - UNITYTLS_INTERNAL_ERROR, // public implementation error. - UNITYTLS_NOT_SUPPORTED, // The requested action is not supported on the current platform/implementation. + UNITYTLS_INVALID_ARGUMENT, // One of the arguments has an invalid value (e.g. null where not allowed) + UNITYTLS_INVALID_FORMAT, // The passed data does not have a valid format. + UNITYTLS_INVALID_PASSWORD, // Invalid password + UNITYTLS_INVALID_STATE, // The object operating being operated on is not in a state that allows this function call. + UNITYTLS_BUFFER_OVERFLOW, // A passed buffer was not large enough. + UNITYTLS_OUT_OF_MEMORY, // Out of memory error + UNITYTLS_INTERNAL_ERROR, // Internal implementation error. + UNITYTLS_NOT_SUPPORTED, // The requested action is not supported on the current platform/implementation. UNITYTLS_ENTROPY_SOURCE_FAILED, // Failed to generate requested amount of entropy data. - UNITYTLS_USER_WOULD_BLOCK, // Can be set by the user to signal that a call (e.g. read/write callback) would block and needs to be called again. - // Some implementations may set this if not all bytes have been read/written. - UNITYTLS_USER_STREAM_CLOSED, // Can be set by the user to cancel a read/write operation. - UNITYTLS_USER_READ_FAILED, // Can be set by the user to indicate a failed read operation. - UNITYTLS_USER_WRITE_FAILED, // Can be set by the user to indicate a failed write operation. - UNITYTLS_USER_UNKNOWN_ERROR, // Can be set by the user to indicate a generic error. + UNITYTLS_USER_WOULD_BLOCK, // Can be set by the user to signal that a call (e.g. read/write callback) would block and needs to be called again. + // Some implementations may set this if not all bytes have been read/written. + UNITYTLS_USER_STREAM_CLOSED, // Can be set by the user to cancel a read/write operation. + UNITYTLS_USER_READ_FAILED, // Can be set by the user to indicate a failed read operation. + UNITYTLS_USER_WRITE_FAILED, // Can be set by the user to indicate a failed write operation. + UNITYTLS_USER_UNKNOWN_ERROR, // Can be set by the user to indicate a generic error. } [StructLayout (LayoutKind.Sequential)] From f332f26526dfe62bbb284118b6186b5af2230395 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Wed, 10 Jan 2018 09:22:48 -0500 Subject: [PATCH 107/582] Add API to control behavior of thread abort within handler blocks (case 979679). Unity unloads domains and this is accomplished via thread abort exceptions. Mono now matches .NET behavior by not interrupting catch/finally blocks with thread abort exceptions. This can lead to hangs in Unity as domain unload blocks until all thread are interrupted. --- mono/metadata/threads.c | 4 +++- mono/metadata/unity-utils.c | 14 ++++++++++++++ mono/metadata/unity-utils.h | 6 ++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index b2d2bdd66e05..9f77e1e7a25e 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -55,6 +55,8 @@ #include #include +#include + #ifdef HAVE_SIGNAL_H #include #endif @@ -4851,7 +4853,7 @@ async_abort_critical (MonoThreadInfo *info, gpointer ud) gboolean protected_wrapper; gboolean running_managed; - if (mono_get_eh_callbacks ()->mono_install_handler_block_guard (mono_thread_info_get_suspend_state (info))) + if (mono_unity_get_enable_handler_block_guards () && mono_get_eh_callbacks ()->mono_install_handler_block_guard (mono_thread_info_get_suspend_state (info))) return MonoResumeThread; /*someone is already interrupting it*/ diff --git a/mono/metadata/unity-utils.c b/mono/metadata/unity-utils.c index 4fbfdb1781f4..36d5ffefb4cf 100644 --- a/mono/metadata/unity-utils.c +++ b/mono/metadata/unity-utils.c @@ -1293,3 +1293,17 @@ mono_class_set_allow_gc_aware_layout(mono_bool allow) { mono_allow_gc_aware_layout = allow; } + +static mono_bool enable_handler_block_guards = TRUE; + +void +mono_unity_set_enable_handler_block_guards (mono_bool allow) +{ + enable_handler_block_guards = allow; +} + +mono_bool +mono_unity_get_enable_handler_block_guards (void) +{ + return enable_handler_block_guards; +} diff --git a/mono/metadata/unity-utils.h b/mono/metadata/unity-utils.h index 7b32452fd68c..a9e5279dcbc7 100644 --- a/mono/metadata/unity-utils.h +++ b/mono/metadata/unity-utils.h @@ -180,4 +180,10 @@ mono_method_get_method_definition(MonoMethod *method); void mono_class_set_allow_gc_aware_layout(mono_bool allow); +MONO_API void +mono_unity_set_enable_handler_block_guards (mono_bool allow); + +mono_bool +mono_unity_get_enable_handler_block_guards (void); + #endif From 601111c1f57b91a7ee41826070f921c8fb011432 Mon Sep 17 00:00:00 2001 From: andreasr Date: Wed, 10 Jan 2018 15:57:31 +0100 Subject: [PATCH 108/582] [unitytls] Mono convention compliance fixes --- .../System/Mono.UnityTls/UnityTlsContext.cs | 136 +++++++++--------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index be6c09fc0658..7b1cc8a472bb 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -31,22 +31,22 @@ unsafe internal class UnityTlsContext : MobileTlsContext private const bool ActivateTracing = false; // Native UnityTls objects - private UnityTls.unitytls_tlsctx* m_TlsContext = null; - private UnityTls.unitytls_x509list* m_RequestedClientCertChain = null; - private UnityTls.unitytls_key* m_RequestedClientKey = null; + UnityTls.unitytls_tlsctx* tlsContext = null; + UnityTls.unitytls_x509list* requestedClientCertChain = null; + UnityTls.unitytls_key* requestedClientKey = null; // States and certificates - X509Certificate m_LocalClientCertificate; - X509Certificate m_RemoteCertificate; - MonoTlsConnectionInfo m_Connectioninfo; - bool m_IsAuthenticated = false; - bool m_HasContext = false; + X509Certificate localClientCertificate; + X509Certificate remoteCertificate; + MonoTlsConnectionInfo connectioninfo; + bool isAuthenticated = false; + bool hasContext = false; // Memory-buffer - byte [] m_WriteBuffer; - byte [] m_ReadBuffer; + byte [] writeBuffer; + byte [] readBuffer; - GCHandle m_handle; + GCHandle handle; Exception lastException; public UnityTlsContext ( @@ -57,7 +57,7 @@ public UnityTlsContext ( : base (parent, serverMode, targetHost, enabledProtocols, serverCertificate, clientCertificates, askForClientCert) { // Need GCHandle to get a consistent pointer to this instance - m_handle = GCHandle.Alloc (this); + handle = GCHandle.Alloc (this); var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); @@ -70,7 +70,7 @@ public UnityTlsContext ( UnityTls.unitytls_tlsctx_callbacks callbacks = new UnityTls.unitytls_tlsctx_callbacks { write = WriteCallback, read = ReadCallback, - data = (void*)(IntPtr)m_handle, + data = (void*)(IntPtr)handle, }; if (serverMode) { @@ -80,14 +80,14 @@ public UnityTlsContext ( var serverKeyRef = UnityTls.NativeInterface.unitytls_key_get_ref (serverPrivateKey, &errorState); Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to parse server key/certificate"); - m_TlsContext = UnityTls.NativeInterface.unitytls_tlsctx_create_server (protocolRange, callbacks, serverCertsRef, serverKeyRef, &errorState); + tlsContext = UnityTls.NativeInterface.unitytls_tlsctx_create_server (protocolRange, callbacks, serverCertsRef, serverKeyRef, &errorState); if (askForClientCert) { UnityTls.unitytls_x509list* clientAuthCAList = null; try { clientAuthCAList = UnityTls.NativeInterface.unitytls_x509list_create (&errorState); var clientAuthCAListRef = UnityTls.NativeInterface.unitytls_x509list_get_ref (clientAuthCAList, &errorState); - UnityTls.NativeInterface.unitytls_tlsctx_server_require_client_authentication (m_TlsContext, clientAuthCAListRef, &errorState); + UnityTls.NativeInterface.unitytls_tlsctx_server_require_client_authentication (tlsContext, clientAuthCAListRef, &errorState); } finally { UnityTls.NativeInterface.unitytls_x509list_free (clientAuthCAList); } @@ -100,22 +100,22 @@ public UnityTlsContext ( else { byte [] targetHostUtf8 = Encoding.UTF8.GetBytes (targetHost); fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { - m_TlsContext = UnityTls.NativeInterface.unitytls_tlsctx_create_client (protocolRange, callbacks, targetHostUtf8Ptr, targetHostUtf8.Length, &errorState); + tlsContext = UnityTls.NativeInterface.unitytls_tlsctx_create_client (protocolRange, callbacks, targetHostUtf8Ptr, targetHostUtf8.Length, &errorState); } - UnityTls.NativeInterface.unitytls_tlsctx_set_certificate_callback (m_TlsContext, CertificateCallback, (void*)(IntPtr)m_handle, &errorState); + UnityTls.NativeInterface.unitytls_tlsctx_set_certificate_callback (tlsContext, CertificateCallback, (void*)(IntPtr)handle, &errorState); } - UnityTls.NativeInterface.unitytls_tlsctx_set_x509verify_callback (m_TlsContext, VerifyCallback, (void*)(IntPtr)m_handle, &errorState); + UnityTls.NativeInterface.unitytls_tlsctx_set_x509verify_callback (tlsContext, VerifyCallback, (void*)(IntPtr)handle, &errorState); Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to create UnityTls context"); if (ActivateTracing) { - UnityTls.NativeInterface.unitytls_tlsctx_set_trace_callback (m_TlsContext, TraceCallback, null, &errorState); + UnityTls.NativeInterface.unitytls_tlsctx_set_trace_callback (tlsContext, TraceCallback, null, &errorState); Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to set trace callback"); } - m_HasContext = true; + hasContext = true; } static private void ExtractNativeKeyAndChainFromManagedCertificate(X509Certificate cert, UnityTls.unitytls_errorstate* errorState, out UnityTls.unitytls_x509list* nativeCertChain, out UnityTls.unitytls_key* nativeKey) @@ -144,22 +144,22 @@ static private void ExtractNativeKeyAndChainFromManagedCertificate(X509Certifica } public override bool HasContext { - get { return m_HasContext; } + get { return hasContext; } } public override bool IsAuthenticated { - get { return m_IsAuthenticated; } + get { return isAuthenticated; } } public override MonoTlsConnectionInfo ConnectionInfo { - get { return m_Connectioninfo; } + get { return connectioninfo; } } internal override bool IsRemoteCertificateAvailable { - get { return m_RemoteCertificate != null; } + get { return remoteCertificate != null; } } internal override X509Certificate LocalClientCertificate { - get { return m_LocalClientCertificate; } + get { return localClientCertificate; } } public override X509Certificate RemoteCertificate { - get { return m_RemoteCertificate; } + get { return remoteCertificate; } } public override TlsProtocols NegotiatedProtocol { get { return ConnectionInfo.ProtocolVersion; } @@ -178,7 +178,7 @@ public override (int ret, bool wantMore) Read (byte[] buffer, int offset, int co lastException = null; var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); fixed (byte* bufferPtr = buffer) { - numBytesRead = UnityTls.NativeInterface.unitytls_tlsctx_read (m_TlsContext, bufferPtr + offset, count, &errorState); + numBytesRead = UnityTls.NativeInterface.unitytls_tlsctx_read (tlsContext, bufferPtr + offset, count, &errorState); } if (lastException != null) throw lastException; @@ -199,7 +199,7 @@ public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int c lastException = null; var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); fixed (byte* bufferPtr = buffer) { - numBytesWritten = UnityTls.NativeInterface.unitytls_tlsctx_write (m_TlsContext, bufferPtr + offset, count, &errorState); + numBytesWritten = UnityTls.NativeInterface.unitytls_tlsctx_write (tlsContext, bufferPtr + offset, count, &errorState); } if (lastException != null) throw lastException; @@ -215,12 +215,12 @@ public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int c public override void Shutdown () { // Destroy native UnityTls objects - UnityTls.NativeInterface.unitytls_x509list_free (m_RequestedClientCertChain); - UnityTls.NativeInterface.unitytls_key_free (m_RequestedClientKey); - UnityTls.NativeInterface.unitytls_tlsctx_free (m_TlsContext); - m_TlsContext = null; + UnityTls.NativeInterface.unitytls_x509list_free (requestedClientCertChain); + UnityTls.NativeInterface.unitytls_key_free (requestedClientKey); + UnityTls.NativeInterface.unitytls_tlsctx_free (tlsContext); + tlsContext = null; - m_HasContext = false; + hasContext = false; } protected override void Dispose (bool disposing) @@ -231,24 +231,24 @@ protected override void Dispose (bool disposing) Shutdown(); // reset states - m_LocalClientCertificate = null; - m_RemoteCertificate = null; + localClientCertificate = null; + remoteCertificate = null; - if (m_LocalClientCertificate != null) { - m_LocalClientCertificate.Dispose (); - m_LocalClientCertificate = null; + if (localClientCertificate != null) { + localClientCertificate.Dispose (); + localClientCertificate = null; } - if (m_RemoteCertificate != null) { - m_RemoteCertificate.Dispose (); - m_RemoteCertificate = null; + if (remoteCertificate != null) { + remoteCertificate.Dispose (); + remoteCertificate = null; } - m_Connectioninfo = null; - m_IsAuthenticated = false; - m_HasContext = false; + connectioninfo = null; + isAuthenticated = false; + hasContext = false; } - m_handle.Free(); + handle.Free(); } finally { base.Dispose (disposing); @@ -264,7 +264,7 @@ public override void StartHandshake () var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); fixed (UnityTls.unitytls_ciphersuite* ciphersPtr = ciphers) - UnityTls.NativeInterface.unitytls_tlsctx_set_supported_ciphersuites (m_TlsContext, ciphersPtr, ciphers.Length, &errorState); + UnityTls.NativeInterface.unitytls_tlsctx_set_supported_ciphersuites (tlsContext, ciphersPtr, ciphers.Length, &errorState); Unity.Debug.CheckAndThrow (errorState, "Failed to set list of supported ciphers", AlertDescription.HandshakeFailure); } } @@ -273,7 +273,7 @@ public override bool ProcessHandshake () { lastException = null; var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); - var result = UnityTls.NativeInterface.unitytls_tlsctx_process_handshake (m_TlsContext, &errorState); + var result = UnityTls.NativeInterface.unitytls_tlsctx_process_handshake (tlsContext, &errorState); if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) return false; if (lastException != null) @@ -299,10 +299,10 @@ public override void FinishHandshake () { // Query some data. Ignore errors on the way since failure is not crucial. var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); - var cipherSuite = UnityTls.NativeInterface.unitytls_tlsctx_get_ciphersuite(m_TlsContext, &errorState); - var protocolVersion = UnityTls.NativeInterface.unitytls_tlsctx_get_protocol(m_TlsContext, &errorState); + var cipherSuite = UnityTls.NativeInterface.unitytls_tlsctx_get_ciphersuite(tlsContext, &errorState); + var protocolVersion = UnityTls.NativeInterface.unitytls_tlsctx_get_protocol(tlsContext, &errorState); - m_Connectioninfo = new MonoTlsConnectionInfo () { + connectioninfo = new MonoTlsConnectionInfo () { CipherSuiteCode = (CipherSuiteCode)cipherSuite, ProtocolVersion = UnityTlsConversions.ConvertProtocolVersion(protocolVersion), PeerDomainName = ServerName @@ -315,7 +315,7 @@ public override void FinishHandshake () //HashAlgorithmType //ExchangeAlgorithmType }; - m_IsAuthenticated = true; + isAuthenticated = true; } [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_write_callback))] @@ -329,11 +329,11 @@ static private size_t WriteCallback (void* userData, byte* data, size_t bufferLe private size_t WriteCallback (byte* data, size_t bufferLen, UnityTls.unitytls_errorstate* errorState) { try { - if (m_WriteBuffer == null || m_WriteBuffer.Length < bufferLen) - m_WriteBuffer = new byte[bufferLen]; - Marshal.Copy ((IntPtr)data, m_WriteBuffer, 0, bufferLen); + if (writeBuffer == null || writeBuffer.Length < bufferLen) + writeBuffer = new byte[bufferLen]; + Marshal.Copy ((IntPtr)data, writeBuffer, 0, bufferLen); - if (!Parent.InternalWrite (m_WriteBuffer, 0, bufferLen)) { + if (!Parent.InternalWrite (writeBuffer, 0, bufferLen)) { UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WRITE_FAILED); return 0; } @@ -358,11 +358,11 @@ static private size_t ReadCallback (void* userData, byte* buffer, size_t bufferL private size_t ReadCallback (byte* buffer, size_t bufferLen, UnityTls.unitytls_errorstate* errorState) { try { - if (m_ReadBuffer == null || m_ReadBuffer.Length < bufferLen) - m_ReadBuffer = new byte [bufferLen]; + if (readBuffer == null || readBuffer.Length < bufferLen) + readBuffer = new byte [bufferLen]; bool wouldBlock; - int numBytesRead = Parent.InternalRead (m_ReadBuffer, 0, bufferLen, out wouldBlock); + int numBytesRead = Parent.InternalRead (readBuffer, 0, bufferLen, out wouldBlock); if (wouldBlock) { UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK); return 0; @@ -372,7 +372,7 @@ private size_t ReadCallback (byte* buffer, size_t bufferLen, UnityTls.unitytls_e return 0; } - Marshal.Copy (m_ReadBuffer, 0, (IntPtr)buffer, bufferLen); + Marshal.Copy (readBuffer, 0, (IntPtr)buffer, bufferLen); return numBytesRead; } catch (Exception ex) { // handle all exceptions and store them for later since we don't want to let them go through native code. UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); @@ -394,7 +394,7 @@ private UnityTls.unitytls_x509verify_result VerifyCallback (UnityTls.unitytls_x5 { try { X509CertificateCollection certificates = CertHelper.NativeChainToManagedCollection (chain, errorState); - m_RemoteCertificate = new X509Certificate (certificates [0]); + remoteCertificate = new X509Certificate (certificates [0]); if (ValidateCertificate (certificates)) return UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_SUCCESS; @@ -419,23 +419,23 @@ static private void CertificateCallback (void* userData, UnityTls.unitytls_tlsct private void CertificateCallback (UnityTls.unitytls_tlsctx* ctx, Int8* cn, size_t cnLen, UnityTls.unitytls_x509name* caList, size_t caListLen, UnityTls.unitytls_x509list_ref* chain, UnityTls.unitytls_key_ref* key, UnityTls.unitytls_errorstate* errorState) { try { - if (m_RemoteCertificate == null) + if (remoteCertificate == null) throw new TlsException (AlertDescription.InternalError, "Cannot request client certificate before receiving one from the server."); - m_LocalClientCertificate = SelectClientCertificate (m_RemoteCertificate, null); + localClientCertificate = SelectClientCertificate (remoteCertificate, null); - if (m_LocalClientCertificate == null) { + if (localClientCertificate == null) { *chain = new UnityTls.unitytls_x509list_ref { handle = UnityTls.NativeInterface.UNITYTLS_INVALID_HANDLE }; *key = new UnityTls.unitytls_key_ref { handle = UnityTls.NativeInterface.UNITYTLS_INVALID_HANDLE }; } else { // Need to create native objects for client chain/key. Need to keep them cached. // Make sure we don't have old native objects still around. - UnityTls.NativeInterface.unitytls_x509list_free (m_RequestedClientCertChain); - UnityTls.NativeInterface.unitytls_key_free (m_RequestedClientKey); + UnityTls.NativeInterface.unitytls_x509list_free (requestedClientCertChain); + UnityTls.NativeInterface.unitytls_key_free (requestedClientKey); - ExtractNativeKeyAndChainFromManagedCertificate(m_LocalClientCertificate, errorState, out m_RequestedClientCertChain, out m_RequestedClientKey); - *chain = UnityTls.NativeInterface.unitytls_x509list_get_ref (m_RequestedClientCertChain, errorState); - *key = UnityTls.NativeInterface.unitytls_key_get_ref (m_RequestedClientKey, errorState); + ExtractNativeKeyAndChainFromManagedCertificate(localClientCertificate, errorState, out requestedClientCertChain, out requestedClientKey); + *chain = UnityTls.NativeInterface.unitytls_x509list_get_ref (requestedClientCertChain, errorState); + *key = UnityTls.NativeInterface.unitytls_key_get_ref (requestedClientKey, errorState); } Unity.Debug.CheckAndThrow (*errorState, "Failed to retrieve certificates on request.", AlertDescription.HandshakeFailure); From 4c76fc9a3956f921005939763172c41413d4f258 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Wed, 10 Jan 2018 10:16:03 -0500 Subject: [PATCH 109/582] Fix instrumentation with legacy profiler APIs (case 979612) Add call instrumentation filter that is enabled for all methods when legacy embedding API mono_profiler_set_events is used to enable method enter/leave instrumentation. --- mono/metadata/profiler.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/mono/metadata/profiler.c b/mono/metadata/profiler.c index cb05578eebe8..e1061c197cf1 100644 --- a/mono/metadata/profiler.c +++ b/mono/metadata/profiler.c @@ -1069,9 +1069,41 @@ mono_profiler_install_jit_end (MonoLegacyProfileJitResult end) } } + +static MonoProfilerCallInstrumentationFlags +call_instrumentation_filter_callback (MonoProfiler *prof, MonoMethod *method) +{ + return MONO_PROFILER_CALL_INSTRUMENTATION_ENTER | MONO_PROFILER_CALL_INSTRUMENTATION_LEAVE | MONO_PROFILER_CALL_INSTRUMENTATION_TAIL_CALL | MONO_PROFILER_CALL_INSTRUMENTATION_EXCEPTION_LEAVE; +} + +typedef enum +{ + MONO_PROFILE_NONE = 0, + MONO_PROFILE_APPDOMAIN_EVENTS = 1 << 0, + MONO_PROFILE_ASSEMBLY_EVENTS = 1 << 1, + MONO_PROFILE_MODULE_EVENTS = 1 << 2, + MONO_PROFILE_CLASS_EVENTS = 1 << 3, + MONO_PROFILE_JIT_COMPILATION = 1 << 4, + MONO_PROFILE_INLINING = 1 << 5, + MONO_PROFILE_EXCEPTIONS = 1 << 6, + MONO_PROFILE_ALLOCATIONS = 1 << 7, + MONO_PROFILE_GC = 1 << 8, + MONO_PROFILE_THREADS = 1 << 9, + MONO_PROFILE_REMOTING = 1 << 10, + MONO_PROFILE_TRANSITIONS = 1 << 11, + MONO_PROFILE_ENTER_LEAVE = 1 << 12, + MONO_PROFILE_COVERAGE = 1 << 13, + MONO_PROFILE_INS_COVERAGE = 1 << 14, + MONO_PROFILE_STATISTICAL = 1 << 15 +} LegacyMonoProfileFlags; + void mono_profiler_set_events (int flags) { + if (flags & MONO_PROFILE_ENTER_LEAVE) + mono_profiler_set_call_instrumentation_filter_callback (current->handle, call_instrumentation_filter_callback); + else + mono_profiler_set_call_instrumentation_filter_callback (current->handle, NULL); /* Do nothing. */ } From 26c4caf65ce995b7b99ccbf8d0839f9c52a0da3a Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 9 Jan 2018 11:29:10 -0500 Subject: [PATCH 110/582] Fix Windows Socket.Send not blocking (case 984723) This matches behavior of receive variants. Fixes blocking send call where Win32 returns WSAEWOULDBLOCK. Related to issue https://github.com/mono/mono/issues/6464 --- mono/metadata/w32socket-win32.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mono/metadata/w32socket-win32.c b/mono/metadata/w32socket-win32.c index 400497ac3597..07ca648260c2 100644 --- a/mono/metadata/w32socket-win32.c +++ b/mono/metadata/w32socket-win32.c @@ -185,7 +185,7 @@ int mono_w32socket_send (SOCKET s, char *buf, int len, int flags, gboolean block { int ret = SOCKET_ERROR; MONO_ENTER_GC_SAFE; - ALERTABLE_SOCKET_CALL (FD_WRITE_BIT, blocking, FALSE, ret, send, s, buf, len, flags); + ALERTABLE_SOCKET_CALL (FD_WRITE_BIT, blocking, TRUE, ret, send, s, buf, len, flags); MONO_EXIT_GC_SAFE; return ret; } @@ -194,7 +194,7 @@ int mono_w32socket_sendto (SOCKET s, const char *buf, int len, int flags, const { int ret = SOCKET_ERROR; MONO_ENTER_GC_SAFE; - ALERTABLE_SOCKET_CALL (FD_WRITE_BIT, blocking, FALSE, ret, sendto, s, buf, len, flags, to, tolen); + ALERTABLE_SOCKET_CALL (FD_WRITE_BIT, blocking, TRUE, ret, sendto, s, buf, len, flags, to, tolen); MONO_EXIT_GC_SAFE; return ret; } @@ -203,7 +203,7 @@ int mono_w32socket_sendbuffers (SOCKET s, WSABUF *lpBuffers, guint32 dwBufferCou { int ret = SOCKET_ERROR; MONO_ENTER_GC_SAFE; - ALERTABLE_SOCKET_CALL (FD_WRITE_BIT, blocking, FALSE, ret, WSASend, s, lpBuffers, dwBufferCount, lpNumberOfBytesRecvd, lpFlags, lpOverlapped, lpCompletionRoutine); + ALERTABLE_SOCKET_CALL (FD_WRITE_BIT, blocking, TRUE, ret, WSASend, s, lpBuffers, dwBufferCount, lpNumberOfBytesRecvd, lpFlags, lpOverlapped, lpCompletionRoutine); MONO_EXIT_GC_SAFE; return ret; } From eb39683833b2813fa9d481053b3b10b9d9e28ddd Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Wed, 10 Jan 2018 11:07:23 -0500 Subject: [PATCH 111/582] Fix crash on startup when script debugging is enabled due to shared signals between mono and the GC (case 973794) --- mono/utils/mono-threads-posix-signals.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mono/utils/mono-threads-posix-signals.c b/mono/utils/mono-threads-posix-signals.c index b39277393f5d..bcb3effc00e7 100644 --- a/mono/utils/mono-threads-posix-signals.c +++ b/mono/utils/mono-threads-posix-signals.c @@ -84,7 +84,7 @@ static int suspend_signal_get (void) { #if defined(HOST_ANDROID) - return SIGPWR; + return SIGUSR1; #elif defined (SIGRTMIN) static int suspend_signum = -1; if (suspend_signum == -1) @@ -103,7 +103,7 @@ static int restart_signal_get (void) { #if defined(HOST_ANDROID) - return SIGXCPU; + return SIGUSR2; #elif defined (SIGRTMIN) static int restart_signum = -1; if (restart_signum == -1) From 2e82f4d7be85e5526a04b9966336af8384aae982 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Thu, 11 Jan 2018 10:13:31 -0500 Subject: [PATCH 112/582] Use new MonoBleedingEdge builds.zip for bootstrap Mono. Our previous committed mono versions are too old to build latest mono and we were falling back to monolite to build. --- external/buildscripts/build.pl | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/external/buildscripts/build.pl b/external/buildscripts/build.pl index b4f3ba85a3d9..49f28ec72b19 100644 --- a/external/buildscripts/build.pl +++ b/external/buildscripts/build.pl @@ -181,20 +181,23 @@ # abs_path ends up returning an empty string $externalBuildDeps = abs_path($externalBuildDeps) if (-d $externalBuildDeps); -my $existingExternalMonoRoot = "$externalBuildDeps/mono"; +my $existingExternalMonoRoot = "$externalBuildDeps/MonoBleedingEdge"; my $existingExternalMono = ""; +my $existingExternalMonoBinDir = ""; my $monoHostArch = ""; my $monoprefix = "$monoroot/tmp"; my $runningOnWindows=0; if($^O eq "linux") { $monoHostArch = $arch32 ? "i686" : "x86_64"; - $existingExternalMono = "$existingExternalMonoRoot/linux"; + $existingExternalMono = "$existingExternalMonoRoot"; + $existingExternalMonoBinDir = "bin-linux64"; } elsif($^O eq 'darwin') { $monoHostArch = $arch32 ? "i386" : "x86_64"; - $existingExternalMono = "$existingExternalMonoRoot/osx"; + $existingExternalMono = "$existingExternalMonoRoot"; + $existingExternalMonoBinDir = "bin"; # From Massi: I was getting failures in install_name_tool about space # for the commands being too small, and adding here things like @@ -211,7 +214,8 @@ else { $monoHostArch = "i686"; - $existingExternalMono = "$existingExternalMonoRoot/win"; + $existingExternalMono = "$existingExternalMonoRoot"; + $existingExternalMonoBinDir = "bin-x64"; $runningOnWindows = 1; # We only care about an existing mono if we need to build. @@ -317,10 +321,10 @@ { # We need to extract builds.zip print(">>> Extracting mono builds.zip...\n"); - system("unzip", "$existingExternalMono/builds.zip", "-d", "$existingExternalMono") eq 0 or die("failed to extract mono builds.zip\n"); + system("unzip", "$existingExternalMono/builds.zip", "-d", "$existingExternalMono/builds") eq 0 or die("failed to extract mono builds.zip\n"); } - $existingMonoRootPath = "$existingExternalMono/builds"; + $existingMonoRootPath = "$existingExternalMono/builds/monodistribution"; } else { @@ -1242,7 +1246,7 @@ } print ">>> Existing Mono : $existingMonoRootPath\n\n"; - $ENV{'PATH'} = "$existingMonoRootPath/bin:$ENV{'PATH'}"; + $ENV{'PATH'} = "$existingMonoRootPath/$existingExternalMonoBinDir:$ENV{'PATH'}"; print ">>> PATH before Build = $ENV{PATH}\n\n"; From d93250bc6c0b66500af3d1a93a8bd3b00badd5eb Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Thu, 11 Jan 2018 12:07:50 -0500 Subject: [PATCH 113/582] Add folder specifically for UnityScript and Boo assemblies. This starts process of treating them as not part of standard set of system assemblies. We can easily reference them as needed rather than assuming they are in all the mono profile directories. --- external/buildscripts/build_us_and_boo.pl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/external/buildscripts/build_us_and_boo.pl b/external/buildscripts/build_us_and_boo.pl index c5565e450b64..8d406d26a876 100644 --- a/external/buildscripts/build_us_and_boo.pl +++ b/external/buildscripts/build_us_and_boo.pl @@ -137,4 +137,21 @@ sub BuildUnityScriptFor45 print(">>> Copying $monoprefix45/us.exe to $usBuildDir\n"); copy("$monoprefix45/us.exe", "$usBuildDir/."); + + # put unityscript and boo into their own directories that we can reference for compilation only in Unity + my $usLibDir = "$monoprefix/lib/mono/unityscript"; + + if (!(-d "$usLibDir")) + { + print(">>> Removing directory $usLibDir\n"); + rmtree($usLibDir); + } + + mkdir($usLibDir); + + foreach my $file (glob "$usBuildDir/*") + { + print(">>> Copying $file to $usLibDir\n"); + copy($file, "$usLibDir/."); + } } \ No newline at end of file From 52e347bd68b350a87e8d965a86922d53fd305ce5 Mon Sep 17 00:00:00 2001 From: andreasr Date: Fri, 12 Jan 2018 11:05:27 +0100 Subject: [PATCH 114/582] [unitytls] UnityTls.IsSupported no longer relies on exception handling but on a simple null check --- .../Mono.Net.Security/MonoTlsProviderFactory.cs | 2 +- mcs/class/System/Mono.UnityTls/UnityTls.cs | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs index d4fbf85a801c..7e2135f49c55 100644 --- a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs +++ b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs @@ -228,7 +228,7 @@ static void InitializeProviderRegistration () providerCache = new Dictionary (); #if UNITY - if (Mono.Unity.UnityTls.IsSupported()) + if (Mono.Unity.UnityTls.IsSupported) { var unityTlsEntry = new Tuple (UnityTlsId, "Mono.Unity.UnityTlsProvider"); providerRegistration.Add ("default", unityTlsEntry); diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index 999e28ef97a8..60eaf41d8315 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -235,21 +235,18 @@ public class mono_unity_unitytls_interface private static mono_unity_unitytls_interface marshalledInterface = null; - public static bool IsSupported() - { - try { - return NativeInterface != null; - } catch (System.Exception) { - return false; - } - } + public static bool IsSupported => NativeInterface != null; public static mono_unity_unitytls_interface NativeInterface { get { - if (marshalledInterface == null) - marshalledInterface = Marshal.PtrToStructure(mono_unity_get_unitytls_interface()); + if (marshalledInterface == null) { + IntPtr rawInterface = mono_unity_get_unitytls_interface (); + if (rawInterface == IntPtr.Zero) + return null; + marshalledInterface = Marshal.PtrToStructure (rawInterface); + } return marshalledInterface; } } From 65af3e711c50cd6547b3fcf5a9166bafa3890e5c Mon Sep 17 00:00:00 2001 From: andreasr Date: Fri, 12 Jan 2018 12:18:20 +0100 Subject: [PATCH 115/582] [unitytls] mono_unity_get_unitytls_interface is now called via icall --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 6 +++--- mono/metadata/icall-def.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index 60eaf41d8315..849d83c0edc6 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -230,8 +230,8 @@ public class mono_unity_unitytls_interface public unitytls_tlsctx_free_t unitytls_tlsctx_free; } - [DllImport("__Internal")] - private static extern IntPtr mono_unity_get_unitytls_interface(); + [MethodImplAttribute (MethodImplOptions.InternalCall)] + private static extern IntPtr GetUnityTlsInterface (); private static mono_unity_unitytls_interface marshalledInterface = null; @@ -242,7 +242,7 @@ public static mono_unity_unitytls_interface NativeInterface get { if (marshalledInterface == null) { - IntPtr rawInterface = mono_unity_get_unitytls_interface (); + IntPtr rawInterface = GetUnityTlsInterface (); if (rawInterface == IntPtr.Zero) return null; marshalledInterface = Marshal.PtrToStructure (rawInterface); diff --git a/mono/metadata/icall-def.h b/mono/metadata/icall-def.h index 6bc2d9b2a27d..ee166e92e01f 100644 --- a/mono/metadata/icall-def.h +++ b/mono/metadata/icall-def.h @@ -114,6 +114,9 @@ ICALL(KPAIR_4, "_ProtectMachine", ves_icall_Mono_Security_Cryptography_KeyPairPe ICALL(KPAIR_5, "_ProtectUser", ves_icall_Mono_Security_Cryptography_KeyPairPersistence_ProtectUser) #endif /* !PLATFORM_RO_FS */ +ICALL_TYPE(UNITYTLS, "Mono.Unity.UnityTls", UNITYTLS_1) +ICALL(UNITYTLS_1, "GetUnityTlsInterface", mono_unity_get_unitytls_interface) + ICALL_TYPE(APPDOM, "System.AppDomain", APPDOM_23) HANDLES(ICALL(APPDOM_23, "DoUnhandledException", ves_icall_System_AppDomain_DoUnhandledException)) HANDLES(ICALL(APPDOM_1, "ExecuteAssembly", ves_icall_System_AppDomain_ExecuteAssembly)) From 7162bf5741f8a4a87ea116eb0bf3e5aa7ec258df Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Mon, 8 Jan 2018 17:19:50 -0500 Subject: [PATCH 116/582] Various cleanups for the Il2cpp Debugger --- mono/mini/debugger-agent.c | 150 ++++++++++++++++++++---------------- mono/mini/il2cpp-c-types.h | 107 ++++---------------------- mono/mini/il2cpp-compat.h | 97 ++++++----------------- mono/mini/il2cpp-stubs.cpp | 152 +++++++------------------------------ 4 files changed, 146 insertions(+), 360 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index fe7191a3ea87..75e60c97d055 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -53,9 +53,12 @@ #include #endif +#ifndef IL2CPP_MONO_DEBUGGER #include #include +#endif #include +#ifndef IL2CPP_MONO_DEBUGGER #include #include #include @@ -63,6 +66,7 @@ #include #include #include +#endif #include #include #include @@ -140,7 +144,9 @@ typedef struct */ MonoMethod *api_method; MonoContext ctx; +#ifndef IL2CPP_MONO_DEBUGGER MonoDebugMethodJitInfo *jit; +#endif MonoJitInfo *ji; MonoInterpFrameHandle interp_frame; int flags; @@ -808,13 +814,14 @@ static void ids_cleanup (void); static void suspend_init (void); +#ifndef IL2CPP_MONO_DEBUGGER static void ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint *sp, MonoSeqPointInfo *info, MonoContext *ctx, DebuggerTlsData *tls, gboolean step_to_catch, StackFrame **frames, int nframes); -#ifdef IL2CPP_MONO_DEBUGGER +#else static Il2CppSequencePoint* il2cpp_find_catch_sequence_point(DebuggerTlsData *tls); static void ss_start_il2cpp(SingleStepReq *ss_req, DebuggerTlsData *tls, Il2CppSequencePoint *catchFrameSp); static void GetSequencePointsAndSourceFilesUniqueSequencePoints(MonoMethod* method, GPtrArray** sequencePoints, GPtrArray** uniqueFileSequencePoints, GArray** uniqueFileSequencePointIndices); -#endif +#endif //IL2CPP_MONO_DEBUGGER static ErrorCode ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilter filter, EventRequest *req); static void ss_destroy (SingleStepReq *req); @@ -2559,7 +2566,7 @@ buffer_add_assemblyid (Buffer *buf, MonoDomain *domain, MonoAssembly *assembly) id = buffer_add_ptr_id (buf, domain, ID_ASSEMBLY, assembly); if (G_UNLIKELY (log_level >= 2) && assembly) { - DEBUG_PRINTF (2, "[dbg] send assembly [%s][%s][%d]\n", assembly->aname.name, VM_DOMAIN_GET_NAME(domain), id); + DEBUG_PRINTF (2, "[dbg] send assembly [%s][%s][%d]\n", assembly->aname.name, domain->friendly_name, id); } } @@ -3047,8 +3054,10 @@ free_frames (StackFrame **frames, int nframes) int i; for (i = 0; i < nframes; ++i) { +#ifndef IL2CPP_MONO_DEBUGGER if (frames [i]->jit) mono_debug_free_method_jit_info (frames [i]->jit); +#endif g_free (frames [i]); } g_free (frames); @@ -3542,6 +3551,7 @@ dbg_path_get_basename (const char *filename) return g_strdup (&r[1]); } +#ifndef IL2CPP_MONO_DEBUGGER static void init_jit_info_dbg_attrs (MonoJitInfo *ji) { @@ -3586,6 +3596,7 @@ init_jit_info_dbg_attrs (MonoJitInfo *ji) mono_memory_barrier (); ji->dbg_attrs_inited = TRUE; } +#endif //IL2CPP_MONO_DEBUGGER static gboolean find_source_file_in_hash_table(const char* needle, GHashTable* haystack) { @@ -3660,9 +3671,9 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv if (mod->data.thread != mono_thread_internal_current ()) filtered = TRUE; } else if (mod->kind == MOD_KIND_EXCEPTION_ONLY && ei) { - if (mod->data.exc_class && mod->subclasses && !mono_class_is_assignable_from (mod->data.exc_class, VM_OBJECT_GET_CLASS(ei->exc))) + if (mod->data.exc_class && mod->subclasses && !mono_class_is_assignable_from (mod->data.exc_class, ei->exc->vtable->klass)) filtered = TRUE; - if (mod->data.exc_class && !mod->subclasses && mod->data.exc_class != VM_OBJECT_GET_CLASS(ei->exc)) + if (mod->data.exc_class && !mod->subclasses && mod->data.exc_class != ei->exc->vtable->klass) filtered = TRUE; if (ei->caught && !mod->caught) filtered = TRUE; @@ -3690,7 +3701,9 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv } else if (mod->kind == MOD_KIND_SOURCE_FILE_ONLY && ei && ei->klass) { gpointer iter = NULL; MonoMethod *method; +#ifndef IL2CPP_MONO_DEBUGGER MonoDebugSourceInfo *sinfo; +#endif char *source_file, *s; gboolean found = FALSE; int i; @@ -4117,8 +4130,10 @@ thread_startup (MonoProfiler *prof, uintptr_t tid) tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id); if (tls) { +#ifndef IL2CPP_MONO_DEBUGGER if (!tls->terminated) MONO_GC_UNREGISTER_ROOT(tls->thread); +#endif #ifdef IL2CPP_MONO_DEBUGGER il2cpp_gc_free_fixed (tls); #else @@ -5000,6 +5015,7 @@ static void ss_calculate_framecount (DebuggerTlsData *tls, MonoContext *ctx) compute_frame_info (tls->thread, tls); } +#ifndef IL2CPP_MONO_DEBUGGER static gboolean ensure_jit (StackFrame* frame) { @@ -5019,6 +5035,7 @@ ensure_jit (StackFrame* frame) } return TRUE; } +#endif /* * ss_update: @@ -5070,6 +5087,7 @@ ss_update (SingleStepReq *req, MonoJitInfo *ji, SeqPoint *sp, DebuggerTlsData *t } } +#ifndef IL2CPP_MONO_DEBUGGER MonoDebugMethodAsyncInfo* async_method = mono_debug_lookup_method_async_debug_info (method); if (async_method) { for (int i = 0; i < async_method->num_awaits; i++) { @@ -5080,6 +5098,7 @@ ss_update (SingleStepReq *req, MonoJitInfo *ji, SeqPoint *sp, DebuggerTlsData *t } mono_debug_free_method_async_debug_info (async_method); } +#endif if (req->size != STEP_SIZE_LINE) return TRUE; @@ -5329,6 +5348,7 @@ get_notify_debugger_of_wait_completion_method (void) return notify_debugger_of_wait_completion_method_cache; } +#ifndef IL2CPP_MONO_DEBUGGER static void process_breakpoint (DebuggerTlsData *tls, gboolean from_signal) { @@ -5352,7 +5372,6 @@ process_breakpoint (DebuggerTlsData *tls, gboolean from_signal) ip = (guint8 *)MONO_CONTEXT_GET_IP (ctx); ji = mini_jit_info_table_find (mono_domain_get (), (char*)ip, NULL); -#ifndef IL2CPP_MONO_DEBUGGER if (!ji) { /* Interpreter */ // FIXME: Pass a flag instead to detect this @@ -5367,7 +5386,6 @@ process_breakpoint (DebuggerTlsData *tls, gboolean from_signal) ji = mini_get_interp_callbacks ()->frame_get_jit_info (frame); ip = mini_get_interp_callbacks ()->frame_get_ip (frame); } -#endif g_assert (ji && !ji->is_trampoline); method = jinfo_get_method (ji); @@ -5449,14 +5467,12 @@ process_breakpoint (DebuggerTlsData *tls, gboolean from_signal) //make sure we have enough data to get current async method instance id if (tls->frame_count == 0 || !ensure_jit (tls->frames [0])) continue; - //Check method is async before calling get_this_async_id MonoDebugMethodAsyncInfo* asyncMethod = mono_debug_lookup_method_async_debug_info (method); if (!asyncMethod) continue; else mono_debug_free_method_async_debug_info (asyncMethod); - //breakpoint was hit in parallelly executing async method, ignore it if (ss_req->async_id != get_this_async_id (tls->frames [0])) continue; @@ -5498,24 +5514,13 @@ process_breakpoint (DebuggerTlsData *tls, gboolean from_signal) * resume. */ if (ss_events) -#ifndef IL2CPP_MONO_DEBUGGER process_event (EVENT_KIND_STEP, method, 0, ctx, ss_events, suspend_policy); -#else - process_event (EVENT_KIND_STEP, method, 0, ctx, ss_events, suspend_policy, 0); -#endif if (bp_events) -#ifndef IL2CPP_MONO_DEBUGGER process_event (kind, method, 0, ctx, bp_events, suspend_policy); -#else - process_event (kind, method, 0, ctx, bp_events, suspend_policy, 0); -#endif if (enter_leave_events) -#ifndef IL2CPP_MONO_DEBUGGER process_event (kind, method, 0, ctx, enter_leave_events, suspend_policy); -#else - process_event (kind, method, 0, ctx, enter_leave_events, suspend_policy, 0); -#endif } +#endif /* Process a breakpoint/single step event after resuming from a signal handler */ static void @@ -5539,11 +5544,13 @@ process_signal_event (void (*func) (DebuggerTlsData*, gboolean)) g_assert_not_reached (); } +#ifndef IL2CPP_MONO_DEBUGGER static void process_breakpoint_from_signal (void) { process_signal_event (process_breakpoint); } +#endif static void resume_from_signal_handler (void *sigctx, void *func) @@ -5576,6 +5583,7 @@ resume_from_signal_handler (void *sigctx, void *func) #endif } +#ifndef IL2CPP_MONO_DEBUGGER void mono_debugger_agent_breakpoint_hit (void *sigctx) { @@ -5586,6 +5594,7 @@ mono_debugger_agent_breakpoint_hit (void *sigctx) */ resume_from_signal_handler (sigctx, process_breakpoint_from_signal); } +#endif typedef struct { gboolean found; @@ -5895,6 +5904,7 @@ debugger_agent_single_step_from_context (MonoContext *ctx, uint64_t sequencePoin #endif } +#ifndef IL2CPP_MONO_DEBUGGER void debugger_agent_breakpoint_from_context (MonoContext *ctx) { @@ -5921,6 +5931,7 @@ debugger_agent_breakpoint_from_context (MonoContext *ctx) if (MONO_CONTEXT_GET_IP (ctx) == orig_ip - 1) MONO_CONTEXT_SET_IP (ctx, orig_ip); } +#endif /* * start_single_stepping: @@ -6126,6 +6137,7 @@ is_last_non_empty (SeqPoint* sp, MonoSeqPointInfo *info) * belong to the same thread as CTX. * If FRAMES is not-null, use that instead of tls->frames for placing breakpoints etc. */ +#ifndef IL2CPP_MONO_DEBUGGER static void ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointInfo *info, MonoContext *ctx, DebuggerTlsData *tls, gboolean step_to_catch, StackFrame **frames, int nframes) @@ -6156,12 +6168,8 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI if (ctx && !frames) { /* Need parent frames */ -#ifndef IL2CPP_MONO_DEBUGGER if (!tls->context.valid) mono_thread_state_init_from_monoctx (&tls->context, ctx); -#else - NOT_IMPLEMENTED; -#endif compute_frame_info (tls->thread, tls); frames = tls->frames; nframes = tls->frame_count; @@ -6233,11 +6241,7 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI StackFrame *frame = frames [frame_index]; method = frame->method; -#ifndef IL2CPP_MONO_DEBUGGER found_sp = mono_find_prev_seq_point_for_native_offset (frame->domain, frame->method, frame->native_offset, &info, &local_sp); -#else - found_sp = FALSE; -#endif sp = (found_sp)? &local_sp : NULL; frame_index ++; if (sp && sp->next_len != 0) @@ -6252,11 +6256,7 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI StackFrame *frame = frames [frame_index]; method = frame->method; -#ifndef IL2CPP_MONO_DEBUGGER found_sp = mono_find_prev_seq_point_for_native_offset (frame->domain, frame->method, frame->native_offset, &info, &local_sp); -#else - found_sp = FALSE; -#endif sp = (found_sp)? &local_sp : NULL; if (sp && sp->next_len != 0) break; @@ -6269,11 +6269,7 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI StackFrame *frame = frames [frame_index]; parent_sp_method = frame->method; -#ifndef IL2CPP_MONO_DEBUGGER found_sp = mono_find_prev_seq_point_for_native_offset (frame->domain, frame->method, frame->native_offset, &parent_info, &local_parent_sp); -#else - found_sp = FALSE; -#endif parent_sp = found_sp ? &local_parent_sp : NULL; if (found_sp && parent_sp->next_len != 0) break; @@ -6284,7 +6280,6 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI } if (sp && sp->next_len > 0) { -#ifndef IL2CPP_MONO_DEBUGGER SeqPoint* next = g_new(SeqPoint, sp->next_len); mono_seq_point_init_next (info, *sp, next); @@ -6294,13 +6289,9 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI ss_bp_add_one (ss_req, &ss_req_bp_count, &ss_req_bp_cache, method, next_sp->il_offset); } g_free (next); -#else - NOT_IMPLEMENTED; -#endif } if (parent_sp) { -#ifndef IL2CPP_MONO_DEBUGGER SeqPoint* next = g_new(SeqPoint, parent_sp->next_len); mono_seq_point_init_next (parent_info, *parent_sp, next); @@ -6310,9 +6301,6 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI ss_bp_add_one (ss_req, &ss_req_bp_count, &ss_req_bp_cache, parent_sp_method, next_sp->il_offset); } g_free (next); -#else - NOT_IMPLEMENTED; -#endif } if (ss_req->nframes == 0) @@ -6330,7 +6318,6 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI } if (ss_req->depth == STEP_DEPTH_OVER) { -#ifndef IL2CPP_MONO_DEBUGGER /* Need to stop in catch clauses as well */ for (i = 0; i < nframes; ++i) { StackFrame *frame = frames[i]; @@ -6348,9 +6335,6 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI } } } -#else - NOT_IMPLEMENTED; -#endif } if (ss_req->depth == STEP_DEPTH_INTO) { @@ -6382,7 +6366,7 @@ ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointI g_hash_table_destroy (ss_req_bp_cache); } -#ifdef IL2CPP_MONO_DEBUGGER +#else static void ss_start_il2cpp(SingleStepReq *ss_req, DebuggerTlsData *tls, Il2CppSequencePoint *catchFrameSp) @@ -6466,7 +6450,7 @@ ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilte SeqPoint local_sp; gboolean found_sp; MonoMethod *method = NULL; -#ifndef IL2CPP_DEBUGGER +#ifndef IL2CPP_MONO_DEBUGGER MonoDebugMethodInfo *minfo; #endif gboolean step_to_catch = FALSE; @@ -6734,7 +6718,7 @@ static Il2CppSequencePoint* il2cpp_find_catch_sequence_point_in_method(Il2CppSeq void *seqPointIter = NULL; while (sp = il2cpp_get_method_sequence_points(method, &seqPointIter)) { - if (sp->tryDepth == tryDepth && sp->ilOffset > ilOffset && sp->catchType != NULL && mono_class_is_assignable_from(sp->catchType, VM_OBJECT_GET_CLASS(exc))) + if (sp->tryDepth == tryDepth && sp->ilOffset > ilOffset && sp->catchType != NULL && mono_class_is_assignable_from(sp->catchType, exc->object.vtable->klass)) return sp; } @@ -7469,7 +7453,7 @@ buffer_add_value (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain) static gboolean obj_is_of_type (MonoObject *obj, MonoType *t) { - MonoClass *klass = VM_OBJECT_GET_CLASS(obj); + MonoClass *klass = obj->vtable->klass; if (!mono_class_is_assignable_from (mono_class_from_mono_type (t), klass)) { if (mono_class_is_transparent_proxy (klass)) { klass = ((MonoTransparentProxy *)obj)->remote_class->proxy_class; @@ -7616,11 +7600,11 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr, return err; if (!obj) return ERR_INVALID_ARGUMENT; - if (VM_OBJECT_GET_CLASS(obj) != mono_class_from_mono_type (t)) { - DEBUG_PRINTF (1, "Expected type '%s', got object '%s'\n", mono_type_full_name (t), VM_OBJECT_GET_CLASS(obj)->name); + if (obj->vtable->klass != mono_class_from_mono_type (t)) { + DEBUG_PRINTF (1, "Expected type '%s', got object '%s'\n", mono_type_full_name (t), obj->vtable->klass->name); return ERR_INVALID_ARGUMENT; } - memcpy (addr, mono_object_unbox (obj), mono_class_value_size (VM_OBJECT_GET_CLASS(obj), NULL)); + memcpy (addr, mono_object_unbox (obj), mono_class_value_size (obj->vtable->klass, NULL)); } else { err = decode_vtype (t, domain, addr, buf, &buf, limit); if (err != ERR_NONE) @@ -7751,6 +7735,7 @@ decode_value (MonoType *t, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8 return decode_value_internal (t, type, domain, addr, buf, endbuf, limit); } +#ifndef IL2CPP_MONO_DEBUGGER static void add_var (Buffer *buf, MonoDebugMethodJitInfo *jit, MonoType *t, MonoDebugVarInfo *var, MonoContext *ctx, MonoDomain *domain, gboolean as_vtype) { @@ -7837,7 +7822,9 @@ add_var (Buffer *buf, MonoDebugMethodJitInfo *jit, MonoType *t, MonoDebugVarInfo g_assert_not_reached (); } } +#endif +#ifndef IL2CPP_MONO_DEBUGGER static void set_var (MonoType *t, MonoDebugVarInfo *var, MonoContext *ctx, MonoDomain *domain, guint8 *val, mgreg_t **reg_locations, MonoContext *restore_ctx) { @@ -7941,6 +7928,7 @@ set_var (MonoType *t, MonoDebugVarInfo *var, MonoContext *ctx, MonoDomain *domai g_assert_not_reached (); } } +#endif static void set_interp_var (MonoType *t, gpointer addr, guint8 *val_buf) @@ -8131,7 +8119,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 * Invoke this method directly, currently only Environment.Exit () is supported. */ this_arg = NULL; - DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (invoke->method, TRUE), this_arg ? VM_OBJECT_GET_CLASS(this_arg)->name : ""); + DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (invoke->method, TRUE), this_arg ? this_arg->vtable->klass->name : ""); mono_runtime_try_invoke (invoke->method, NULL, invoke->args, &exc, &error); mono_error_assert_ok (&error); @@ -8205,7 +8193,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 } } - DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (m, TRUE), this_arg ? VM_OBJECT_GET_CLASS(this_arg)->name : ""); + DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (m, TRUE), this_arg ? this_arg->vtable->klass->name : ""); if (this_arg && VM_OBJECT_GET_DOMAIN(this_arg) != domain) NOT_IMPLEMENTED; @@ -8298,7 +8286,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 mono_error_cleanup (&error); /* FIXME report error */ } mono_stopwatch_stop (&watch); - DEBUG_PRINTF (1, "[%p] Invoke result: %p, exc: %s, time: %ld ms.\n", (gpointer) (gsize) mono_native_thread_id_get (), res, exc ? VM_OBJECT_GET_CLASS (exc)->name : NULL, (long)mono_stopwatch_elapsed_ms (&watch)); + DEBUG_PRINTF (1, "[%p] Invoke result: %p, exc: %s, time: %ld ms.\n", (gpointer) (gsize) mono_native_thread_id_get (), res, exc ? exc->vtable->klass->name : NULL, (long)mono_stopwatch_elapsed_ms (&watch)); if (exc) { buffer_add_byte (buf, 0); buffer_add_value (buf, &VM_DEFAULTS_OBJECT_CLASS->byval_arg, &exc, domain); @@ -8497,7 +8485,9 @@ get_source_files_for_type (MonoClass *klass) { gpointer iter = NULL; MonoMethod *method; +#ifndef IL2CPP_MONO_DEBUGGER MonoDebugSourceInfo *sinfo; +#endif GPtrArray *files; int i, j; @@ -9251,7 +9241,7 @@ domain_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (err != ERR_NONE) return err; - buffer_add_assemblyid (buf, domain, VM_DOMAIN_GET_CORLIB(domain)); + buffer_add_assemblyid (buf, domain, domain->domain->mbr.obj.vtable->klass->image->assembly); break; } case CMD_APPDOMAIN_CREATE_STRING: { @@ -9511,6 +9501,7 @@ buffer_add_cattr_arg (Buffer *buf, MonoType *t, MonoDomain *domain, MonoObject * buffer_add_value (buf, t, mono_object_unbox (val), domain); } +#ifndef IL2CPP_MONO_DEBUGGER static ErrorCode buffer_add_cattrs (Buffer *buf, MonoDomain *domain, MonoImage *image, MonoClass *attr_klass, MonoCustomAttrInfo *cinfo) { @@ -9587,6 +9578,7 @@ buffer_add_cattrs (Buffer *buf, MonoDomain *domain, MonoImage *image, MonoClass return ERR_NONE; } +#endif //IL2CPP_MONO_DEBUGGER /* FIXME: Code duplication with icall.c */ static void @@ -9763,6 +9755,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint break; } case CMD_TYPE_GET_CATTRS: { +#ifndef IL2CPP_MONO_DEBUGGER MonoClass *attr_klass; MonoCustomAttrInfo *cinfo; @@ -9781,8 +9774,12 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint if (err != ERR_NONE) return err; break; +#else + return ERR_NOT_IMPLEMENTED; +#endif //IL2CPP_MONO_DEBUGGER } case CMD_TYPE_GET_FIELD_CATTRS: { +#ifndef IL2CPP_MONO_DEBUGGER MonoClass *attr_klass; MonoCustomAttrInfo *cinfo; MonoClassField *field; @@ -9804,8 +9801,12 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint if (err != ERR_NONE) return err; break; +#else + return ERR_NOT_IMPLEMENTED; +#endif //IL2CPP_MONO_DEBUGGER } case CMD_TYPE_GET_PROPERTY_CATTRS: { +#ifndef IL2CPP_MONO_DEBUGGER MonoClass *attr_klass; MonoCustomAttrInfo *cinfo; MonoProperty *prop; @@ -9827,6 +9828,9 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint if (err != ERR_NONE) return err; break; +#else + return ERR_NOT_IMPLEMENTED; +#endif //IL2CPP_MONO_DEBUGGER } case CMD_TYPE_GET_VALUES: case CMD_TYPE_GET_VALUES_2: { @@ -10069,7 +10073,11 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint MonoVTable *vtable = mono_class_vtable (domain, klass); if (vtable) +#ifndef IL2CPP_MONO_DEBUGGER buffer_add_int (buf, (vtable->initialized || vtable->init_failed) ? 1 : 0); +#else + buffer_add_int (buf, vtable->initialized ? 1 : 0); +#endif else buffer_add_int (buf, 0); break; @@ -10678,6 +10686,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g break; } case CMD_METHOD_GET_CATTRS: { +#ifndef IL2CPP_MONO_DEBUGGER MonoError error; MonoClass *attr_klass; MonoCustomAttrInfo *cinfo; @@ -10697,6 +10706,9 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g if (err != ERR_NONE) return err; break; +#else + return ERR_NOT_IMPLEMENTED; +#endif //IL2CPP_MONO_DEBUGGER } case CMD_METHOD_MAKE_GENERIC_METHOD: { MonoError error; @@ -11286,12 +11298,12 @@ array_commands (int command, guint8 *p, guint8 *end, Buffer *buf) switch (command) { case CMD_ARRAY_REF_GET_LENGTH: - buffer_add_int (buf, VM_ARRAY_GET_RANK(arr)); + buffer_add_int (buf, arr->obj.vtable->klass->rank); if (!arr->bounds) { buffer_add_int (buf, arr->max_length); buffer_add_int (buf, 0); } else { - for (i = 0; i < VM_ARRAY_GET_RANK(arr); ++i) { + for (i = 0; i < arr->obj.vtable->klass->rank; ++i) { buffer_add_int (buf, arr->bounds[i].length); buffer_add_int (buf, arr->bounds[i].lower_bound); } @@ -11305,10 +11317,10 @@ array_commands (int command, guint8 *p, guint8 *end, Buffer *buf) // Reordered to avoid integer overflow g_assert (!(index > arr->max_length - len)); - esize = mono_array_element_size (VM_OBJECT_GET_CLASS(arr)); + esize = mono_array_element_size (arr->obj.vtable->klass); for (i = index; i < index + len; ++i) { elem = (gpointer*)((char*)arr->vector + (i * esize)); - buffer_add_value (buf, &VM_OBJECT_GET_CLASS(arr)->element_class->byval_arg, elem, VM_OBJECT_GET_DOMAIN(arr)); + buffer_add_value (buf, &arr->obj.vtable->klass->element_class->byval_arg, elem, VM_OBJECT_GET_DOMAIN(arr)); } break; case CMD_ARRAY_REF_SET_VALUES: @@ -11319,10 +11331,10 @@ array_commands (int command, guint8 *p, guint8 *end, Buffer *buf) // Reordered to avoid integer overflow g_assert (!(index > arr->max_length - len)); - esize = mono_array_element_size (VM_OBJECT_GET_CLASS(arr)); + esize = mono_array_element_size (arr->obj.vtable->klass); for (i = index; i < index + len; ++i) { elem = (gpointer*)((char*)arr->vector + (i * esize)); - decode_value (&VM_OBJECT_GET_CLASS(arr)->element_class->byval_arg, VM_OBJECT_GET_DOMAIN(arr), (guint8 *)elem, p, &p, end); + decode_value (&arr->obj.vtable->klass->element_class->byval_arg, VM_OBJECT_GET_DOMAIN(arr), (guint8 *)elem, p, &p, end); } break; default: @@ -11416,7 +11428,7 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) MonoClass *obj_type; gboolean remote_obj = FALSE; - obj_type = VM_OBJECT_GET_CLASS(obj); + obj_type = obj->vtable->klass; if (mono_class_is_transparent_proxy (obj_type)) { obj_type = ((MonoTransparentProxy *)obj)->remote_class->proxy_class; remote_obj = TRUE; @@ -11426,8 +11438,12 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) switch (command) { case CMD_OBJECT_REF_GET_TYPE: +#ifndef IL2CPP_MONO_DEBUGGER /* This handles transparent proxies too */ buffer_add_typeid (buf, VM_OBJECT_GET_DOMAIN(obj), mono_class_from_mono_type (((MonoReflectionType*)obj->vtable->type)->type)); +#else + buffer_add_typeid (buf, VM_OBJECT_GET_DOMAIN(obj), obj->vtable->klass); +#endif //IL2CPP_MONO_DEBUGGER break; case CMD_OBJECT_REF_GET_VALUES: len = decode_int (p, &p, end); diff --git a/mono/mini/il2cpp-c-types.h b/mono/mini/il2cpp-c-types.h index 32c4eefeadfd..ecf664d0a3e9 100644 --- a/mono/mini/il2cpp-c-types.h +++ b/mono/mini/il2cpp-c-types.h @@ -14,6 +14,7 @@ #define MonoClass Il2CppClass #define MonoImage Il2CppImage #define MonoMethod MethodInfo +#define MonoMethodInflated MethodInfo #define MonoClassField FieldInfo #define MonoArrayType Il2CppArrayType #define MonoGenericParam Il2CppGenericParameter @@ -35,103 +36,30 @@ #define MonoAppDomain Il2CppAppDomain #define MonoDomain Il2CppDomain #define MonoDomainFunc Il2CppDomainFunc +#define MonoObject Il2CppObject +#define MonoVTable Il2CppVTable +#define MonoException Il2CppException +#define MonoMarshalByRefObject Il2CppMarshalByRefObject + +//Unsupported in il2cpp, should never be referenced +#define MonoCustomAttrInfo #error Custom Attributes Not Supported +#define MonoCustomAttrEntry #error Custom Attributes Not Supported +#define CattrNamedArg #error Custom Attributes Not Supported +#define MonoJitTlsData #error Jit TLS Data Unsupported //still stubs everywhere typedef struct _Il2CppMonoMethodSignature Il2CppMonoMethodSignature; -typedef struct _Il2CppMonoVTable Il2CppMonoVTable; -typedef struct _Il2CppMonoMarshalByRefObject Il2CppMonoMarshalByRefObject; -typedef struct _Il2CppMonoObject Il2CppMonoObject; -typedef struct _Il2CppMonoCustomAttrInfo Il2CppMonoCustomAttrInfo; -typedef struct _Il2CppMonoJitTlsData Il2CppMonoJitTlsData; typedef struct _Il2CppMonoRuntimeExceptionHandlingCallbacks Il2CppMonoRuntimeExceptionHandlingCallbacks; -typedef struct _Il2CppMonoCustomAttrEntry Il2CppMonoCustomAttrEntry; -typedef struct _Il2CppMonoStackFrameInfo Il2CppMonoStackFrameInfo; typedef struct Il2CppDefaults Il2CppMonoDefaults; -typedef struct _Il2CppMonoMethodInflated Il2CppMonoMethodInflated; -typedef struct _Il2CppMonoException Il2CppMonoException; -typedef struct _Il2CppCattrNamedArg Il2CppCattrNamedArg; typedef struct _Il2CppMonoTypeNameParse Il2CppMonoTypeNameParse; - -struct _Il2CppMonoJitTlsData { void *dummy; }; - -struct _Il2CppCattrNamedArg -{ - MonoType *type; - MonoClassField *field; - MonoProperty *prop; -}; - -struct _Il2CppMonoObject -{ - Il2CppMonoVTable *vtable; - void *synchronization; -}; - -struct _Il2CppMonoException -{ - Il2CppMonoObject object; -}; - -struct _Il2CppMonoMethodInflated -{ - MonoMethod *declaring; - MonoGenericContext context; -}; - -struct _Il2CppMonoStackFrameInfo -{ - MonoStackFrameType type; - MonoJitInfo *ji; - MonoMethod *method; - MonoMethod *actual_method; - MonoDomain *domain; - gboolean managed; - gboolean async_context; - int native_offset; - int il_offset; - gpointer interp_exit_data; - gpointer interp_frame; - gpointer lmf; - guint32 unwind_info_len; - guint8 *unwind_info; - mgreg_t **reg_locations; -}; - -struct _Il2CppMonoCustomAttrEntry -{ - MonoMethod *ctor; - uint32_t data_size; - const mono_byte* data; -}; - -struct _Il2CppMonoCustomAttrInfo -{ - int num_attrs; - Il2CppMonoCustomAttrEntry attrs [MONO_ZERO_LEN_ARRAY]; -}; - -typedef gboolean (*Il2CppMonoInternalStackWalk) (Il2CppMonoStackFrameInfo *frame, MonoContext *ctx, gpointer data); +typedef gboolean (*Il2CppMonoInternalStackWalk) (MonoStackFrameInfo *frame, MonoContext *ctx, gpointer data); struct _Il2CppMonoRuntimeExceptionHandlingCallbacks { void (*il2cpp_mono_walk_stack_with_state) (Il2CppMonoInternalStackWalk func, MonoThreadUnwindState *state, MonoUnwindOptions options, void *user_data); }; -struct _Il2CppMonoMarshalByRefObject -{ - Il2CppMonoObject obj; -}; - -struct _Il2CppMonoVTable -{ - MonoClass *klass; - MonoDomain *domain; - guint8 initialized; - gpointer type; - guint init_failed : 1; -}; - struct _Il2CppMonoMethodSignature { MonoType *ret; @@ -148,14 +76,7 @@ struct _Il2CppMonoTypeNameParse void *il2cppTypeNameParseInfo; }; -typedef struct Il2CppThreadUnwindState -{ - Il2CppSequencePoint** sequencePoints; - Il2CppSequencePointExecutionContext** executionContexts; - uint32_t frameCount; -} Il2CppThreadUnwindState; - -TYPED_HANDLE_DECL (Il2CppMonoObject); +TYPED_HANDLE_DECL (MonoObject); TYPED_HANDLE_DECL (MonoReflectionAssembly); Il2CppMonoDefaults il2cpp_mono_defaults; MonoDebugOptions il2cpp_mono_debug_options; @@ -167,7 +88,7 @@ typedef void (*Il2CppMonoProfileAssemblyFunc) (MonoProfiler *prof, MonoAssembly typedef void (*Il2CppMonoProfileJitResult) (MonoProfiler *prof, MonoMethod *method, MonoJitInfo* jinfo, int result); typedef void (*Il2CppMonoProfileAssemblyResult) (MonoProfiler *prof, MonoAssembly *assembly, int result); typedef void (*Il2CppMonoProfileThreadFunc) (MonoProfiler *prof, uintptr_t tid); -typedef gboolean (*Il2CppMonoJitStackWalk) (Il2CppMonoStackFrameInfo *frame, MonoContext *ctx, gpointer data); +typedef gboolean (*Il2CppMonoJitStackWalk) (MonoStackFrameInfo *frame, MonoContext *ctx, gpointer data); typedef void (*Il2CppDomainFunc) (MonoDomain *domain, void* user_data); typedef void (*emit_assembly_load_callback)(void*, void*); diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index c1e00efae761..32e9755ed5c7 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -4,10 +4,11 @@ #if defined(RUNTIME_IL2CPP) #include "il2cpp-c-types.h" #include "il2cpp-api.h" -#endif // RUNTIME_IL2CPP +#else #include #include #include +#endif //RUNTIME_IL2CPP #ifdef IL2CPP_MONO_DEBUGGER @@ -15,56 +16,38 @@ #define VM_DOMAIN_GET_AGENT_INFO(domain) il2cpp_domain_get_agent_info(domain) #define VM_DOMAIN_SET_AGENT_INFO(domain, value) il2cpp_domain_set_agent_info(domain, value) -#define VM_DOMAIN_GET_NAME(domain) il2cpp_domain_get_name(domain) -#define VM_DOMAIN_GET_CORLIB(domain) il2cpp_image_get_assembly(il2cpp_get_corlib()) #define VM_METHOD_IS_STRING_CTOR(method) il2cpp_method_is_string_ctor(method) #define VM_INFLATED_METHOD_GET_DECLARING(imethod) il2cpp_method_get_generic_definition(imethod) #define VM_INFLATED_METHOD_GET_CLASS_INST(imethod) il2cpp_method_get_generic_class_inst(imethod) #define VM_OBJECT_GET_DOMAIN(object) il2cpp_mono_domain_get() -#define VM_OBJECT_GET_CLASS(object) il2cpp_object_get_class(object) #define VM_OBJECT_GET_TYPE(object) il2cpp_mono_object_get_type(object) #define VM_GENERIC_CLASS_GET_CONTAINER_CLASS(gklass) il2cpp_generic_class_get_container_class(gklass) #define VM_DEFAULTS_OBJECT_CLASS il2cpp_defaults_object_class() #define VM_DEFAULTS_EXCEPTION_CLASS il2cpp_defaults_exception_class() #define VM_DEFAULTS_CORLIB_IMAGE il2cpp_defaults_corlib_image() #define VM_DEFAULTS_VOID_CLASS il2cpp_defaults_void_class() -#define VM_ARRAY_GET_RANK(arr) il2cpp_array_rank(arr) //Fixme module name as image name seems bad #define VM_IMAGE_GET_MODULE_NAME(image) il2cpp_image_name(image) #else #define VM_DOMAIN_GET_AGENT_INFO(domain) domain_jit_info (domain)->agent_info #define VM_DOMAIN_SET_AGENT_INFO(domain, value) domain_jit_info (domain)->agent_info = value -#define VM_DOMAIN_GET_NAME(domain) domain->friendly_name -#define VM_DOMAIN_GET_CORLIB(domain) domain->domain->mbr.obj.vtable->klass->image->assembly #define VM_METHOD_IS_STRING_CTOR(method) method->string_ctor #define VM_INFLATED_METHOD_GET_DECLARING(imethod) (imethod)->declaring #define VM_INFLATED_METHOD_GET_CLASS_INST(imethod) (imethod)->context.class_inst #define VM_OBJECT_GET_DOMAIN(object) ((MonoObject*)object)->vtable->domain -#define VM_OBJECT_GET_CLASS(object) ((MonoObject*)object)->vtable->klass #define VM_OBJECT_GET_TYPE(object) ((MonoReflectionType*)object->vtable->type)->type #define VM_GENERIC_CLASS_GET_CONTAINER_CLASS(gklass) (gklass)->container_class #define VM_DEFAULTS_OBJECT_CLASS mono_defaults.object_class #define VM_DEFAULTS_EXCEPTION_CLASS mono_defaults.exception_class #define VM_DEFAULTS_CORLIB_IMAGE mono_defaults.corlib #define VM_DEFAULTS_VOID_CLASS mono_defaults.void_class -#define VM_ARRAY_GET_RANK(arr) (arr)->obj.vtable->klass->rank #define VM_IMAGE_GET_MODULE_NAME(image) (image)->module_name #endif #if defined(RUNTIME_IL2CPP) -#define MonoVTable Il2CppMonoVTable #define MonoMethodSignature Il2CppMonoMethodSignature -#define MonoMarshalByRefObject Il2CppMonoMarshalByRefObject -#define MonoObject Il2CppMonoObject -#define MonoCustomAttrInfo Il2CppMonoCustomAttrInfo -#define MonoJitTlsData Il2CppMonoJitTlsData #define MonoRuntimeExceptionHandlingCallbacks Il2CppMonoRuntimeExceptionHandlingCallbacks -#define MonoCustomAttrEntry Il2CppMonoCustomAttrEntry -#define StackFrameInfo Il2CppMonoStackFrameInfo -#define MonoMethodInflated Il2CppMonoMethodInflated -#define MonoException Il2CppMonoException -#define CattrNamedArg Il2CppCattrNamedArg #define debug_options il2cpp_mono_debug_options #define MonoTypeNameParse Il2CppMonoTypeNameParse @@ -116,8 +99,6 @@ #define mono_gc_wbarrier_generic_store il2cpp_mono_gc_wbarrier_generic_store #define mono_reflection_parse_type_checked il2cpp_mono_reflection_parse_type_checked #define mono_reflection_free_type_info il2cpp_mono_reflection_free_type_info -#define mono_custom_attrs_has_attr il2cpp_mono_custom_attrs_has_attr -#define mono_custom_attrs_free il2cpp_mono_custom_attrs_free #define mono_get_root_domain il2cpp_mono_get_root_domain #define mono_runtime_quit il2cpp_mono_runtime_quit #define mono_runtime_is_shutting_down il2cpp_mono_runtime_is_shutting_down @@ -126,20 +107,12 @@ #define mono_domain_foreach il2cpp_mono_domain_foreach #define mono_jit_info_table_find il2cpp_mono_jit_info_table_find #define mono_jit_info_get_method il2cpp_mono_jit_info_get_method -#define mono_debug_lookup_method il2cpp_mono_debug_lookup_method #define mono_debug_find_method il2cpp_mono_debug_find_method #define mono_debug_free_method_jit_info il2cpp_mono_debug_free_method_jit_info -#define mono_debug_lookup_locals il2cpp_mono_debug_lookup_locals -#define mono_debug_lookup_method_async_debug_info il2cpp_mono_debug_lookup_method_async_debug_info -#define mono_debug_method_lookup_location il2cpp_mono_debug_method_lookup_location #define mono_debug_il_offset_from_address il2cpp_mono_debug_il_offset_from_address -#define mono_debug_free_source_location il2cpp_mono_debug_free_source_location #define mono_set_is_debugger_attached il2cpp_mono_set_is_debugger_attached #define mono_type_full_name il2cpp_mono_type_full_name #define mono_method_full_name il2cpp_mono_method_full_name -#define mono_debug_get_seq_points il2cpp_mono_debug_get_seq_points -#define mono_debug_free_locals il2cpp_mono_debug_free_locals -#define mono_debug_free_method_async_debug_info il2cpp_mono_debug_free_method_async_debug_info #define mono_thread_current il2cpp_mono_thread_current #define mono_thread_get_main il2cpp_mono_thread_get_main #define mono_thread_attach il2cpp_mono_thread_attach @@ -185,7 +158,6 @@ #define mono_thread_suspend_all_other_threads il2cpp_mono_thread_suspend_all_other_threads #define mono_stack_mark_record_size il2cpp_mono_stack_mark_record_size #define mono_get_eh_callbacks il2cpp_mono_get_eh_callbacks -#define mono_reflection_create_custom_attr_data_args il2cpp_mono_reflection_create_custom_attr_data_args #define mono_nullable_init il2cpp_mono_nullable_init #define mono_value_box_checked il2cpp_mono_value_box_checked #define mono_field_static_get_value_checked il2cpp_mono_field_static_get_value_checked @@ -206,10 +178,6 @@ #define mono_runtime_try_shutdown il2cpp_mono_runtime_try_shutdown #define mono_verifier_is_method_valid_generic_instantiation il2cpp_mono_verifier_is_method_valid_generic_instantiation #define mono_reflection_get_type_checked il2cpp_mono_reflection_get_type_checked -#define mono_custom_attrs_from_method_checked il2cpp_mono_custom_attrs_from_method_checked -#define mono_custom_attrs_from_class_checked il2cpp_mono_custom_attrs_from_class_checked -#define mono_custom_attrs_from_property_checked il2cpp_mono_custom_attrs_from_property_checked -#define mono_custom_attrs_from_field_checked il2cpp_mono_custom_attrs_from_field_checked #define mono_assembly_get_object_handle il2cpp_mono_assembly_get_object_handle #define mono_type_get_object_checked il2cpp_mono_type_get_object_checked #define mono_network_init il2cpp_mono_network_init @@ -237,7 +205,6 @@ #define mono_thread_state_init_from_monoctx il2cpp_mono_thread_state_init_from_monoctx #define mini_jit_info_table_find il2cpp_mini_jit_info_table_find #define mono_restore_context il2cpp_mono_restore_context -#define mono_find_jit_info_ext il2cpp_mono_find_jit_info_ext #define mono_method_get_declaring_generic_method il2cpp_mono_method_get_declaring_generic_method #define jinfo_get_method il2cpp_jinfo_get_method #define mono_defaults il2cpp_mono_defaults @@ -303,7 +270,7 @@ void il2cpp_mono_method_get_param_names (MonoMethod *method, const char **names) mono_bool il2cpp_mono_type_generic_inst_is_valuetype (MonoType *type); MonoMethodHeader* il2cpp_mono_method_get_header_checked (MonoMethod *method, MonoError *error); gboolean il2cpp_mono_class_init (MonoClass *klass); -Il2CppMonoVTable* il2cpp_mono_class_vtable (MonoDomain *domain, MonoClass *klass); +MonoVTable* il2cpp_mono_class_vtable (MonoDomain *domain, MonoClass *klass); MonoClassField* il2cpp_mono_class_get_field_from_name (MonoClass *klass, const char *name); int32_t il2cpp_mono_array_element_size (MonoClass *ac); int32_t il2cpp_mono_class_instance_size (MonoClass *klass); @@ -325,18 +292,16 @@ MonoString* il2cpp_mono_string_new (MonoDomain *domain, const char *text); MonoString* il2cpp_mono_string_new (MonoDomain *domain, const char *text); MonoString* il2cpp_mono_string_new_checked (MonoDomain *domain, const char *text, MonoError *merror); char* il2cpp_mono_string_to_utf8_checked (MonoString *string_obj, MonoError *error); -int il2cpp_mono_object_hash (Il2CppMonoObject* obj); -void* il2cpp_mono_object_unbox (Il2CppMonoObject *obj); -void il2cpp_mono_field_set_value (Il2CppMonoObject *obj, MonoClassField *field, void *value); -void il2cpp_mono_field_static_set_value (Il2CppMonoVTable *vt, MonoClassField *field, void *value); -uint32_t il2cpp_mono_gchandle_new_weakref (Il2CppMonoObject *obj, mono_bool track_resurrection); -Il2CppMonoObject* il2cpp_mono_gchandle_get_target (uint32_t gchandle); +int il2cpp_mono_object_hash (MonoObject* obj); +void* il2cpp_mono_object_unbox (MonoObject *obj); +void il2cpp_mono_field_set_value (MonoObject *obj, MonoClassField *field, void *value); +void il2cpp_mono_field_static_set_value (MonoVTable *vt, MonoClassField *field, void *value); +uint32_t il2cpp_mono_gchandle_new_weakref (MonoObject *obj, mono_bool track_resurrection); +MonoObject* il2cpp_mono_gchandle_get_target (uint32_t gchandle); void il2cpp_mono_gchandle_free (uint32_t gchandle); -void il2cpp_mono_gc_wbarrier_generic_store (void* ptr, Il2CppMonoObject* value); +void il2cpp_mono_gc_wbarrier_generic_store (void* ptr, MonoObject* value); int il2cpp_mono_reflection_parse_type_checked (char *name, Il2CppMonoTypeNameParse *info, MonoError *error); void il2cpp_mono_reflection_free_type_info (Il2CppMonoTypeNameParse *info); -mono_bool il2cpp_mono_custom_attrs_has_attr (Il2CppMonoCustomAttrInfo *ainfo, MonoClass *attr_klass); -void il2cpp_mono_custom_attrs_free (Il2CppMonoCustomAttrInfo *ainfo); MonoDomain* il2cpp_mono_get_root_domain (void); void il2cpp_mono_runtime_quit (void); gboolean il2cpp_mono_runtime_is_shutting_down (void); @@ -345,20 +310,10 @@ gboolean il2cpp_mono_domain_set (MonoDomain *domain, gboolean force); void il2cpp_mono_domain_foreach(MonoDomainFunc func, gpointer user_data); MonoJitInfo* il2cpp_mono_jit_info_table_find(MonoDomain* domain, char* addr); MonoMethod* il2cpp_mono_jit_info_get_method(MonoJitInfo* ji); -MonoDebugMethodInfo* il2cpp_mono_debug_lookup_method(MonoMethod* method); -MonoDebugMethodJitInfo* il2cpp_mono_debug_find_method(MonoMethod* method, MonoDomain* domain); -void il2cpp_mono_debug_free_method_jit_info(MonoDebugMethodJitInfo* jit); -MonoDebugLocalsInfo* il2cpp_mono_debug_lookup_locals(MonoMethod* method); -MonoDebugMethodAsyncInfo* il2cpp_mono_debug_lookup_method_async_debug_info(MonoMethod* method); -MonoDebugSourceLocation* il2cpp_mono_debug_method_lookup_location(MonoDebugMethodInfo* minfo, int il_offset); gint32 il2cpp_mono_debug_il_offset_from_address(MonoMethod* method, MonoDomain* domain, guint32 native_offset); -void il2cpp_mono_debug_free_source_location(MonoDebugSourceLocation* location); void il2cpp_mono_set_is_debugger_attached(gboolean attached); char* il2cpp_mono_type_full_name(MonoType* type); char* il2cpp_mono_method_full_name(MonoMethod* method, gboolean signature); -void il2cpp_mono_debug_get_seq_points(MonoDebugMethodInfo* minfo, char** source_file, GPtrArray** source_file_list, int** source_files, MonoSymSeqPoint** seq_points, int* n_seq_points); -void il2cpp_mono_debug_free_locals(MonoDebugLocalsInfo* info); -void il2cpp_mono_debug_free_method_async_debug_info(MonoDebugMethodAsyncInfo* info); MonoThread* il2cpp_mono_thread_current(); MonoThread* il2cpp_mono_thread_get_main(); MonoThread* il2cpp_mono_thread_attach(MonoDomain* domain); @@ -402,16 +357,15 @@ void il2cpp_mono_thread_set_name_internal(MonoInternalThread* this_obj, MonoStri void il2cpp_mono_thread_suspend_all_other_threads(); void il2cpp_mono_stack_mark_record_size(MonoThreadInfo* info, HandleStackMark* stackmark, const char* func_name); Il2CppMonoRuntimeExceptionHandlingCallbacks* il2cpp_mono_get_eh_callbacks(); -void il2cpp_mono_reflection_create_custom_attr_data_args(MonoImage* image, MonoMethod* method, const guchar* data, guint32 len, MonoArray** typed_args, MonoArray** named_args, CattrNamedArg** named_arg_info, MonoError* error); -void il2cpp_mono_nullable_init(guint8* buf, Il2CppMonoObject* value, MonoClass* klass); -Il2CppMonoObject* il2cpp_mono_value_box_checked(MonoDomain* domain, MonoClass* klass, gpointer value, MonoError* error); -void il2cpp_mono_field_static_get_value_checked(Il2CppMonoVTable* vt, MonoClassField* field, void* value, MonoError* error); -void il2cpp_mono_field_static_get_value_for_thread(MonoInternalThread* thread, Il2CppMonoVTable* vt, MonoClassField* field, void* value, MonoError* error); -Il2CppMonoObject* il2cpp_mono_field_get_value_object_checked(MonoDomain* domain, MonoClassField* field, Il2CppMonoObject* obj, MonoError* error); -Il2CppMonoObject* il2cpp_mono_object_new_checked(MonoDomain* domain, MonoClass* klass, MonoError* error); +void il2cpp_mono_nullable_init(guint8* buf, MonoObject* value, MonoClass* klass); +MonoObject* il2cpp_mono_value_box_checked(MonoDomain* domain, MonoClass* klass, gpointer value, MonoError* error); +void il2cpp_mono_field_static_get_value_checked(MonoVTable* vt, MonoClassField* field, void* value, MonoError* error); +void il2cpp_mono_field_static_get_value_for_thread(MonoInternalThread* thread, MonoVTable* vt, MonoClassField* field, void* value, MonoError* error); +MonoObject* il2cpp_mono_field_get_value_object_checked(MonoDomain* domain, MonoClassField* field, MonoObject* obj, MonoError* error); +MonoObject* il2cpp_mono_object_new_checked(MonoDomain* domain, MonoClass* klass, MonoError* error); MonoString* il2cpp_mono_ldstr_checked(MonoDomain* domain, MonoImage* image, guint32 idx, MonoError* error); -Il2CppMonoObject* il2cpp_mono_runtime_try_invoke(MonoMethod* method, void* obj, void** params, Il2CppMonoObject** exc, MonoError* error); -Il2CppMonoObject* il2cpp_mono_runtime_invoke_checked(MonoMethod* method, void* obj, void** params, MonoError* error); +MonoObject* il2cpp_mono_runtime_try_invoke(MonoMethod* method, void* obj, void** params, MonoObject** exc, MonoError* error); +MonoObject* il2cpp_mono_runtime_invoke_checked(MonoMethod* method, void* obj, void** params, MonoError* error); void il2cpp_mono_gc_base_init(); int il2cpp_mono_gc_register_root(char* start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, void *key, const char* msg); void il2cpp_mono_gc_deregister_root(char* addr); @@ -422,10 +376,6 @@ void il2cpp_mono_threadpool_resume(); gboolean il2cpp_mono_runtime_try_shutdown(); gboolean il2cpp_mono_verifier_is_method_valid_generic_instantiation(MonoMethod* method); MonoType* il2cpp_mono_reflection_get_type_checked(MonoImage* rootimage, MonoImage* image, Il2CppMonoTypeNameParse* info, gboolean ignorecase, gboolean* type_resolve, MonoError* error); -Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_method_checked(MonoMethod* method, MonoError* error); -Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_class_checked(MonoClass* klass, MonoError* error); -Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_property_checked(MonoClass* klass, MonoProperty* property, MonoError* error); -Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_field_checked(MonoClass* klass, MonoClassField* field, MonoError* error); MonoReflectionAssemblyHandle il2cpp_mono_assembly_get_object_handle(MonoDomain* domain, MonoAssembly* assembly, MonoError* error); MonoReflectionType* il2cpp_mono_type_get_object_checked(MonoDomain* domain, MonoType* type, MonoError* error); void il2cpp_mono_network_init(); @@ -453,7 +403,6 @@ gboolean il2cpp_mono_thread_state_init_from_current(MonoThreadUnwindState* ctx); gboolean il2cpp_mono_thread_state_init_from_monoctx(MonoThreadUnwindState* ctx, MonoContext* mctx); MonoJitInfo* il2cpp_mini_jit_info_table_find(MonoDomain* domain, char* addr, MonoDomain** out_domain); void il2cpp_mono_restore_context(MonoContext* ctx); -gboolean il2cpp_mono_find_jit_info_ext(MonoDomain* domain, Il2CppMonoJitTlsData* jit_tls, MonoJitInfo* prev_ji, MonoContext* ctx, MonoContext* new_ctx, char** trace, MonoLMF** lmf, mgreg_t** save_locations, StackFrameInfo* frame); MonoMethod* il2cpp_mono_method_get_declaring_generic_method(MonoMethod* method); MonoMethod* il2cpp_jinfo_get_method (MonoJitInfo *ji); gboolean il2cpp_mono_find_prev_seq_point_for_native_offset (MonoDomain *domain, MonoMethod *method, gint32 native_offset, MonoSeqPointInfo **info, SeqPoint* seq_point); @@ -469,7 +418,7 @@ MonoSeqPointInfo* il2cpp_mono_get_seq_points (MonoDomain *domain, MonoMethod *me void IL2CPP_G_BREAKPOINT(); void il2cpp_mono_thread_info_safe_suspend_and_run (MonoNativeThreadId id, gboolean interrupt_kernel, MonoSuspendThreadCallback callback, gpointer user_data); void il2cpp_mono_error_cleanup (MonoError *oerror); -Il2CppMonoException* il2cpp_mono_error_convert_to_exception (MonoError *target_error); +MonoException* il2cpp_mono_error_convert_to_exception (MonoError *target_error); const char* il2cpp_mono_error_get_message (MonoError *oerror); void il2cpp_mono_error_assert_ok_pos (MonoError *error, const char* filename, int lineno); Il2CppSequencePoint* il2cpp_get_sequence_points(void* *iter); @@ -478,8 +427,8 @@ MonoClass* il2cpp_class_get_nested_types_accepts_generic(MonoClass *monoClass, v MonoClass* il2cpp_defaults_object_class(); guint8 il2cpp_array_rank(MonoArray *monoArr); const char* il2cpp_image_name(MonoImage *monoImage); -guint8* il2cpp_field_get_address(Il2CppMonoObject *obj, MonoClassField *monoField); -MonoType* il2cpp_mono_object_get_type(Il2CppMonoObject* object); +guint8* il2cpp_field_get_address(MonoObject *obj, MonoClassField *monoField); +MonoType* il2cpp_mono_object_get_type(MonoObject* object); MonoClass* il2cpp_defaults_exception_class(); MonoImage* il2cpp_defaults_corlib_image(); bool il2cpp_method_is_string_ctor (const MonoMethod * method); @@ -490,8 +439,8 @@ gboolean il2cpp_field_is_deleted(MonoClassField *field); MonoClass* il2cpp_iterate_loaded_classes(void* *iter); MonoAssembly* il2cpp_domain_get_assemblies_iter(MonoAppDomain *domain, void* *iter); const char** il2cpp_get_source_files_for_type(MonoClass *klass, int *count); -MonoMethod* il2cpp_method_get_generic_definition(Il2CppMonoMethodInflated *imethod); -MonoGenericInst* il2cpp_method_get_generic_class_inst(Il2CppMonoMethodInflated *imethod); +MonoMethod* il2cpp_method_get_generic_definition(MonoMethodInflated *imethod); +MonoGenericInst* il2cpp_method_get_generic_class_inst(MonoMethodInflated *imethod); MonoClass* il2cpp_generic_class_get_container_class(MonoGenericClass *gclass); void il2cpp_mono_thread_detach(MonoThread* thread); MonoClass* il2cpp_mono_get_string_class (void); diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index 4bb03e76b8f4..4eb703a7089a 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -172,9 +172,9 @@ gboolean il2cpp_mono_class_init (MonoClass *klass) return 0; } -Il2CppMonoVTable* il2cpp_mono_class_vtable (MonoDomain *domain, MonoClass *klass) +MonoVTable* il2cpp_mono_class_vtable (MonoDomain *domain, MonoClass *klass) { - return (Il2CppMonoVTable*)((Il2CppClass*)klass)->vtable; + return (MonoVTable*)((Il2CppClass*)klass)->vtable; } MonoClassField* il2cpp_mono_class_get_field_from_name (MonoClass *klass, const char *name) @@ -288,35 +288,35 @@ char* il2cpp_mono_string_to_utf8_checked (MonoString *string_obj, MonoError *err return g_strdup(s.c_str()); } -int il2cpp_mono_object_hash (Il2CppMonoObject* obj) +int il2cpp_mono_object_hash (MonoObject* obj) { return (int)((intptr_t)obj >> 3); } -void* il2cpp_mono_object_unbox (Il2CppMonoObject *monoObj) +void* il2cpp_mono_object_unbox (MonoObject *monoObj) { Il2CppObject *obj = (Il2CppObject*)monoObj; return il2cpp::vm::Object::Unbox(obj); } -void il2cpp_mono_field_set_value (Il2CppMonoObject *obj, MonoClassField *field, void *value) +void il2cpp_mono_field_set_value (MonoObject *obj, MonoClassField *field, void *value) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); } -void il2cpp_mono_field_static_set_value (Il2CppMonoVTable *vt, MonoClassField *field, void *value) +void il2cpp_mono_field_static_set_value (MonoVTable *vt, MonoClassField *field, void *value) { il2cpp::vm::Field::StaticSetValue((FieldInfo*)field, value); } -uint32_t il2cpp_mono_gchandle_new_weakref (Il2CppMonoObject *obj, mono_bool track_resurrection) +uint32_t il2cpp_mono_gchandle_new_weakref (MonoObject *obj, mono_bool track_resurrection) { return il2cpp::gc::GCHandle::NewWeakref((Il2CppObject*)obj, track_resurrection == 0 ? false : true); } -Il2CppMonoObject* il2cpp_mono_gchandle_get_target (uint32_t gchandle) +MonoObject* il2cpp_mono_gchandle_get_target (uint32_t gchandle) { - return (Il2CppMonoObject*)il2cpp::gc::GCHandle::GetTarget(gchandle); + return (MonoObject*)il2cpp::gc::GCHandle::GetTarget(gchandle); } void il2cpp_mono_gchandle_free (uint32_t gchandle) @@ -324,7 +324,7 @@ void il2cpp_mono_gchandle_free (uint32_t gchandle) il2cpp::gc::GCHandle::Free(gchandle); } -void il2cpp_mono_gc_wbarrier_generic_store (void* ptr, Il2CppMonoObject* value) +void il2cpp_mono_gc_wbarrier_generic_store (void* ptr, MonoObject* value) { il2cpp::gc::WriteBarrier::GenericStore(ptr, (Il2CppObject*)value); } @@ -346,17 +346,6 @@ void il2cpp_mono_reflection_free_type_info (Il2CppMonoTypeNameParse *info) delete (il2cpp::vm::TypeNameParseInfo*)info->il2cppTypeNameParseInfo; } -mono_bool il2cpp_mono_custom_attrs_has_attr (Il2CppMonoCustomAttrInfo *ainfo, MonoClass *attr_klass) -{ - IL2CPP_ASSERT(0 && "This method is not yet implemented"); - return 0; -} - -void il2cpp_mono_custom_attrs_free (Il2CppMonoCustomAttrInfo *ainfo) -{ - IL2CPP_ASSERT(0 && "This method is not yet implemented"); -} - MonoDomain* il2cpp_mono_get_root_domain (void) { return (MonoDomain*)il2cpp::vm::Domain::GetCurrent(); @@ -400,51 +389,12 @@ MonoMethod* il2cpp_mono_jit_info_get_method(MonoJitInfo* ji) return NULL; } -MonoDebugMethodInfo* il2cpp_mono_debug_lookup_method(MonoMethod* method) -{ - return NULL; -} - -MonoDebugMethodJitInfo* il2cpp_mono_debug_find_method(MonoMethod* method, MonoDomain* domain) -{ - IL2CPP_ASSERT(0 && "This method is not yet implemented"); - return NULL; -} - -void il2cpp_mono_debug_free_method_jit_info(MonoDebugMethodJitInfo* jit) -{ - IL2CPP_ASSERT(0 && "This method is not yet implemented"); -} - -MonoDebugLocalsInfo* il2cpp_mono_debug_lookup_locals(MonoMethod* method) -{ - IL2CPP_ASSERT(0 && "This method is not yet implemented"); - return NULL; -} - -MonoDebugMethodAsyncInfo* il2cpp_mono_debug_lookup_method_async_debug_info(MonoMethod* method) -{ - IL2CPP_ASSERT(0 && "This method is not yet implemented"); - return NULL; -} - -MonoDebugSourceLocation* il2cpp_mono_debug_method_lookup_location(MonoDebugMethodInfo* minfo, int il_offset) -{ - IL2CPP_ASSERT(0 && "This method is not yet implemented"); - return NULL; -} - gint32 il2cpp_mono_debug_il_offset_from_address(MonoMethod* method, MonoDomain* domain, guint32 native_offset) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return 0; } -void il2cpp_mono_debug_free_source_location(MonoDebugSourceLocation* location) -{ - IL2CPP_ASSERT(0 && "This method is not yet implemented"); -} - void il2cpp_mono_set_is_debugger_attached(gboolean attached) { il2cpp::utils::Debugger::SetIsDebuggerAttached(attached == TRUE); @@ -461,21 +411,6 @@ char* il2cpp_mono_method_full_name(MonoMethod* method, gboolean signature) return g_strdup(((MethodInfo*)method)->name); } -void il2cpp_mono_debug_get_seq_points(MonoDebugMethodInfo* minfo, char** source_file, GPtrArray** source_file_list, int** source_files, MonoSymSeqPoint** seq_points, int* n_seq_points) -{ - IL2CPP_ASSERT(0 && "This method is not yet implemented"); -} - -void il2cpp_mono_debug_free_locals(MonoDebugLocalsInfo* info) -{ - IL2CPP_ASSERT(0 && "This method is not yet implemented"); -} - -void il2cpp_mono_debug_free_method_async_debug_info(MonoDebugMethodAsyncInfo* info) -{ - IL2CPP_ASSERT(0 && "This method is not yet implemented"); -} - MonoThread* il2cpp_mono_thread_current() { return (MonoThread*)il2cpp::vm::Thread::Current(); @@ -851,44 +786,39 @@ Il2CppMonoRuntimeExceptionHandlingCallbacks* il2cpp_mono_get_eh_callbacks() return NULL; } -void il2cpp_mono_reflection_create_custom_attr_data_args(MonoImage* image, MonoMethod* method, const guchar* data, guint32 len, MonoArray** typed_args, MonoArray** named_args, CattrNamedArg** named_arg_info, MonoError* error) -{ - IL2CPP_ASSERT(0 && "This method is not yet implemented"); -} - -void il2cpp_mono_nullable_init(guint8* buf, Il2CppMonoObject* value, MonoClass* klass) +void il2cpp_mono_nullable_init(guint8* buf, MonoObject* value, MonoClass* klass) { il2cpp::vm::Object::NullableInit(buf, (Il2CppObject*)value, (Il2CppClass*)klass); } -Il2CppMonoObject* il2cpp_mono_value_box_checked(MonoDomain* domain, MonoClass* klass, gpointer value, MonoError* error) +MonoObject* il2cpp_mono_value_box_checked(MonoDomain* domain, MonoClass* klass, gpointer value, MonoError* error) { error_init(error); - return (Il2CppMonoObject*)il2cpp::vm::Object::Box((Il2CppClass*)klass, value); + return (MonoObject*)il2cpp::vm::Object::Box((Il2CppClass*)klass, value); } -void il2cpp_mono_field_static_get_value_checked(Il2CppMonoVTable* vt, MonoClassField* field, void* value, MonoError* error) +void il2cpp_mono_field_static_get_value_checked(MonoVTable* vt, MonoClassField* field, void* value, MonoError* error) { error_init(error); il2cpp::vm::Field::StaticGetValue((FieldInfo*)field, value); } -void il2cpp_mono_field_static_get_value_for_thread(MonoInternalThread* thread, Il2CppMonoVTable* vt, MonoClassField* field, void* value, MonoError* error) +void il2cpp_mono_field_static_get_value_for_thread(MonoInternalThread* thread, MonoVTable* vt, MonoClassField* field, void* value, MonoError* error) { error_init(error); il2cpp::vm::Field::StaticGetValueForThread((FieldInfo*)field, value, (Il2CppInternalThread*)thread); } -Il2CppMonoObject* il2cpp_mono_field_get_value_object_checked(MonoDomain* domain, MonoClassField* field, Il2CppMonoObject* obj, MonoError* error) +MonoObject* il2cpp_mono_field_get_value_object_checked(MonoDomain* domain, MonoClassField* field, MonoObject* obj, MonoError* error) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; } -Il2CppMonoObject* il2cpp_mono_object_new_checked(MonoDomain* domain, MonoClass* klass, MonoError* error) +MonoObject* il2cpp_mono_object_new_checked(MonoDomain* domain, MonoClass* klass, MonoError* error) { error_init(error); - return (Il2CppMonoObject*)il2cpp::vm::Object::New((Il2CppClass*)klass); + return (MonoObject*)il2cpp::vm::Object::New((Il2CppClass*)klass); } MonoString* il2cpp_mono_ldstr_checked(MonoDomain* domain, MonoImage* image, guint32 idx, MonoError* error) @@ -897,17 +827,17 @@ MonoString* il2cpp_mono_ldstr_checked(MonoDomain* domain, MonoImage* image, guin return NULL; } -Il2CppMonoObject* il2cpp_mono_runtime_try_invoke(MonoMethod* method, void* obj, void** params, Il2CppMonoObject** exc, MonoError* error) +MonoObject* il2cpp_mono_runtime_try_invoke(MonoMethod* method, void* obj, void** params, MonoObject** exc, MonoError* error) { error_init(error); if (((MethodInfo*)method)->klass->valuetype) obj = static_cast(obj) - 1; - return (Il2CppMonoObject*)il2cpp::vm::Runtime::Invoke((MethodInfo*)method, obj, params, (Il2CppException**)exc); + return (MonoObject*)il2cpp::vm::Runtime::Invoke((MethodInfo*)method, obj, params, (Il2CppException**)exc); } -Il2CppMonoObject* il2cpp_mono_runtime_invoke_checked(MonoMethod* method, void* obj, void** params, MonoError* error) +MonoObject* il2cpp_mono_runtime_invoke_checked(MonoMethod* method, void* obj, void** params, MonoError* error) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; @@ -999,30 +929,6 @@ MonoType* il2cpp_mono_reflection_get_type_checked(MonoImage* rootimage, MonoImag return (MonoType*)il2cpp::vm::Class::GetType(klass); } -Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_method_checked(MonoMethod* method, MonoError* error) -{ - error_init(error); - return NULL; -} - -Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_class_checked(MonoClass* klass, MonoError* error) -{ - error_init(error); - return NULL; -} - -Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_property_checked(MonoClass* klass, MonoProperty* property, MonoError* error) -{ - error_init(error); - return NULL; -} - -Il2CppMonoCustomAttrInfo* il2cpp_mono_custom_attrs_from_field_checked(MonoClass* klass, MonoClassField* field, MonoError* error) -{ - error_init(error); - return NULL; -} - MonoReflectionAssemblyHandle il2cpp_mono_assembly_get_object_handle(MonoDomain* domain, MonoAssembly* assembly, MonoError* error) { return (MonoReflectionAssemblyHandle)il2cpp::vm::Reflection::GetAssemblyObject((const Il2CppAssembly *)assembly); @@ -1163,12 +1069,6 @@ void il2cpp_mono_restore_context(MonoContext* ctx) IL2CPP_ASSERT(0 && "This method is not yet implemented"); } -gboolean il2cpp_mono_find_jit_info_ext(MonoDomain* domain, MonoJitTlsData* jit_tls, MonoJitInfo* prev_ji, MonoContext* ctx, MonoContext* new_ctx, char** trace, MonoLMF** lmf, mgreg_t** save_locations, StackFrameInfo* frame) -{ - IL2CPP_ASSERT(0 && "This method is not yet implemented"); - return 0; -} - MonoMethod* il2cpp_mono_method_get_declaring_generic_method(MonoMethod* method) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); @@ -1263,7 +1163,7 @@ void il2cpp_mono_thread_info_safe_suspend_and_run (MonoNativeThreadId id, gboole callback(NULL, user_data); } -Il2CppMonoException* il2cpp_mono_error_convert_to_exception (MonoError *target_error) +MonoException* il2cpp_mono_error_convert_to_exception (MonoError *target_error) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; @@ -1427,13 +1327,13 @@ const char* il2cpp_image_name(MonoImage *monoImage) return image->name; } -guint8* il2cpp_field_get_address(Il2CppMonoObject *obj, MonoClassField *monoField) +guint8* il2cpp_field_get_address(MonoObject *obj, MonoClassField *monoField) { FieldInfo *field = (FieldInfo*)monoField; return (guint8*)obj + field->offset; } -MonoType* il2cpp_mono_object_get_type(Il2CppMonoObject* object) +MonoType* il2cpp_mono_object_get_type(MonoObject* object) { return (MonoType*)&(((Il2CppObject*)object)->klass->byval_arg); } @@ -1534,7 +1434,7 @@ const char** il2cpp_get_source_files_for_type(MonoClass *klass, int *count) return il2cpp::utils::Debugger::GetTypeSourceFiles((Il2CppClass*)klass, *count); } -MonoMethod* il2cpp_method_get_generic_definition(Il2CppMonoMethodInflated *imethod) +MonoMethod* il2cpp_method_get_generic_definition(MonoMethodInflated *imethod) { MethodInfo *method = (MethodInfo*)imethod; @@ -1545,7 +1445,7 @@ MonoMethod* il2cpp_method_get_generic_definition(Il2CppMonoMethodInflated *imeth } -MonoGenericInst* il2cpp_method_get_generic_class_inst(Il2CppMonoMethodInflated *imethod) +MonoGenericInst* il2cpp_method_get_generic_class_inst(MonoMethodInflated *imethod) { MethodInfo *method = (MethodInfo*)imethod; From 9500a30178a1e838f21022e09a8a0194f554b294 Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Tue, 16 Jan 2018 23:22:29 +0800 Subject: [PATCH 117/582] for some regions, specifically Asia/Singapore, the native icall returns incorrectly because the country's timezone changed. In this case in 1981 Asia/Singapore changed from +0730 to +08....Since the UTC offset changed, our logic thinks that daylight savings may have started, and the icall returns incorrect data, which causes the CreateLocalUnity function to throw. Fixing the icall is important, but for the time being we'll wrap the CreateLocalUnity function with a try catch. then fix the native icall... --- mcs/class/corlib/System/TimeZoneInfo.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mcs/class/corlib/System/TimeZoneInfo.cs b/mcs/class/corlib/System/TimeZoneInfo.cs index b69139680789..d05ff302d814 100644 --- a/mcs/class/corlib/System/TimeZoneInfo.cs +++ b/mcs/class/corlib/System/TimeZoneInfo.cs @@ -170,9 +170,15 @@ static TimeZoneInfo CreateLocal () #endif #if UNITY - var localTimeZoneFallback = CreateLocalUnity(); - if(localTimeZoneFallback == null) - localTimeZoneFallback = Utc; + TimeZoneInfo localTimeZoneFallback = null; + try { + localTimeZoneFallback = CreateLocalUnity(); + } catch { + localTimeZoneFallback = null; + } + + if (localTimeZoneFallback == null) + localTimeZoneFallback = Utc; #endif var tz = Environment.GetEnvironmentVariable ("TZ"); From 5a2837984b8e0eea6645bf407617546e3b5c2bf7 Mon Sep 17 00:00:00 2001 From: andreasr Date: Tue, 16 Jan 2018 16:32:08 +0100 Subject: [PATCH 118/582] [unitytls] Renamed mono_unity_unitytls_interface to unitytls_interface_struct Change due the fact that the interface is soon to be used in other places. --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 10 +++++----- mono/metadata/unity-utils.c | 6 +++--- mono/metadata/unity-utils.h | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index 849d83c0edc6..963ec0be4b7a 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -163,9 +163,9 @@ public struct unitytls_tlsctx_callbacks // ------------------------------------------------------------------------ // This native struct is used to provide all necessary fields and function calls from unitytls to the mono-unitytls-binding. - // Native implementation lives in unity:Modules/TLS/TLSMonoIntegration.cpp and needs to be adapted to every change. + // Native implementation lives in unity:Modules/TLS/InterfaceStruct.cpp and needs to be adapted to every change. [StructLayout (LayoutKind.Sequential)] - public class mono_unity_unitytls_interface + public class unitytls_interface_struct { public readonly UInt64 UNITYTLS_INVALID_HANDLE; @@ -233,11 +233,11 @@ public class mono_unity_unitytls_interface [MethodImplAttribute (MethodImplOptions.InternalCall)] private static extern IntPtr GetUnityTlsInterface (); - private static mono_unity_unitytls_interface marshalledInterface = null; + private static unitytls_interface_struct marshalledInterface = null; public static bool IsSupported => NativeInterface != null; - public static mono_unity_unitytls_interface NativeInterface + public static unitytls_interface_struct NativeInterface { get { @@ -245,7 +245,7 @@ public static mono_unity_unitytls_interface NativeInterface IntPtr rawInterface = GetUnityTlsInterface (); if (rawInterface == IntPtr.Zero) return null; - marshalledInterface = Marshal.PtrToStructure (rawInterface); + marshalledInterface = Marshal.PtrToStructure (rawInterface); } return marshalledInterface; } diff --git a/mono/metadata/unity-utils.c b/mono/metadata/unity-utils.c index c84dcfd923db..4621bb3ef894 100644 --- a/mono/metadata/unity-utils.c +++ b/mono/metadata/unity-utils.c @@ -887,16 +887,16 @@ MonoClass* mono_unity_defaults_get_byte_class() //unitytls -static mono_unity_unitytls_interface* gUnitytlsInterface = NULL; +static unitytls_interface_struct* gUnitytlsInterface = NULL; -MONO_API mono_unity_unitytls_interface* +MONO_API unitytls_interface_struct* mono_unity_get_unitytls_interface() { return gUnitytlsInterface; } MONO_API void -mono_unity_install_unitytls_interface(mono_unity_unitytls_interface* callbacks) +mono_unity_install_unitytls_interface(unitytls_interface_struct* callbacks) { gUnitytlsInterface = callbacks; } diff --git a/mono/metadata/unity-utils.h b/mono/metadata/unity-utils.h index f2b18f3c26f1..a03c3fae1a2f 100644 --- a/mono/metadata/unity-utils.h +++ b/mono/metadata/unity-utils.h @@ -145,9 +145,9 @@ MonoClass* mono_unity_defaults_get_delegate_class(); MonoClass* mono_unity_defaults_get_byte_class(); //unitytls -typedef struct mono_unity_unitytls_interface mono_unity_unitytls_interface; -MONO_API mono_unity_unitytls_interface* mono_unity_get_unitytls_interface(); -MONO_API void mono_unity_install_unitytls_interface(mono_unity_unitytls_interface* callbacks); +typedef struct unitytls_interface_struct unitytls_interface_struct; +MONO_API unitytls_interface_struct* mono_unity_get_unitytls_interface(); +MONO_API void mono_unity_install_unitytls_interface(unitytls_interface_struct* callbacks); //misc MonoAssembly* mono_unity_assembly_get_mscorlib(); From 7356c3196afb55a19dd1d2db5a95c8f743e49d4a Mon Sep 17 00:00:00 2001 From: Brian Raderman Date: Fri, 12 Jan 2018 12:29:48 -0500 Subject: [PATCH 119/582] * Changed IL2CPP specific sections in debugger-agent.c to use the RUNTIME_IL2CPP macro instead of IL2CPP_MONO_DEBUGGER, as the latter is switched off on release builds to control debugger code usage. We will still build the debugger-agent in release, but the native linker should strip it out. * Stripping out code in stubs that reference code in utils::Debugger when the debugging code is turned off. utils::Debugger implementation is stripped out completey in this case. --- mono/mini/debugger-agent.c | 346 ++++++++++++++++++------------------- mono/mini/debugger-agent.h | 6 +- mono/mini/il2cpp-compat.h | 2 +- mono/mini/il2cpp-stubs.cpp | 20 +++ 4 files changed, 197 insertions(+), 177 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 75e60c97d055..1b7d734bf300 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -53,12 +53,12 @@ #include #endif -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP #include #include #endif #include -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP #include #include #include @@ -144,7 +144,7 @@ typedef struct */ MonoMethod *api_method; MonoContext ctx; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MonoDebugMethodJitInfo *jit; #endif MonoJitInfo *ji; @@ -183,7 +183,7 @@ struct _InvokeData typedef struct { MonoThreadUnwindState context; -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP Il2CppThreadUnwindState il2cpp_context; #endif @@ -256,7 +256,7 @@ typedef struct { InvokeData *invoke; StackFrameInfo catch_frame; -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP MonoException *exception; #endif gboolean has_catch_frame; @@ -772,7 +772,7 @@ static void invalidate_each_thread (gpointer key, gpointer value, gpointer user_ static void assembly_load (MonoProfiler *prof, MonoAssembly *assembly); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP static void assembly_unload (MonoProfiler *prof, MonoAssembly *assembly); #endif @@ -814,14 +814,14 @@ static void ids_cleanup (void); static void suspend_init (void); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP static void ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint *sp, MonoSeqPointInfo *info, MonoContext *ctx, DebuggerTlsData *tls, gboolean step_to_catch, StackFrame **frames, int nframes); #else static Il2CppSequencePoint* il2cpp_find_catch_sequence_point(DebuggerTlsData *tls); static void ss_start_il2cpp(SingleStepReq *ss_req, DebuggerTlsData *tls, Il2CppSequencePoint *catchFrameSp); static void GetSequencePointsAndSourceFilesUniqueSequencePoints(MonoMethod* method, GPtrArray** sequencePoints, GPtrArray** uniqueFileSequencePoints, GArray** uniqueFileSequencePointIndices); -#endif //IL2CPP_MONO_DEBUGGER +#endif //RUNTIME_IL2CPP static ErrorCode ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilter filter, EventRequest *req); static void ss_destroy (SingleStepReq *req); @@ -839,7 +839,7 @@ static void register_socket_transport (void); #endif -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP static MonoAssembly* mono_domain_get_assemblies_iter(MonoDomain *domain, void* *iter) { if (!iter) @@ -867,7 +867,7 @@ is_debugger_thread (void) if (!internal) return FALSE; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP return internal->debugger_thread; #else return debugger_thread_id == mono_native_thread_id_get (); @@ -1048,7 +1048,7 @@ mono_debugger_agent_init (void) mono_profiler_set_thread_started_callback (prof, thread_startup); mono_profiler_set_thread_stopped_callback (prof, thread_end); mono_profiler_set_assembly_loaded_callback (prof, assembly_load); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP mono_profiler_set_assembly_unloading_callback (prof, assembly_unload); #endif mono_profiler_set_jit_done_callback (prof, jit_done); @@ -1088,7 +1088,7 @@ mono_debugger_agent_init (void) breakpoints_init (); suspend_init (); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP mini_get_debug_options ()->gen_sdb_seq_points = TRUE; /* * This is needed because currently we don't handle liveness info. @@ -1107,7 +1107,7 @@ mono_debugger_agent_init (void) * workaround. */ mini_get_debug_options ()->load_aot_jit_info_eagerly = TRUE; -#endif // !IL2CPP_MONO_DEBUGGER +#endif // !RUNTIME_IL2CPP #ifdef HAVE_SETPGID if (agent_config.setpgid) @@ -1118,7 +1118,7 @@ mono_debugger_agent_init (void) finish_agent_init (TRUE); } -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP void mono_debugger_run_debugger_thread_func(void* arg) { @@ -1136,7 +1136,7 @@ void mono_debugger_install_runtime_callbacks(MonoDebuggerRuntimeCallbacks* cbs) callbacks = *cbs; } -#endif // IL2CPP_MONO_DEBUGGER +#endif // RUNTIME_IL2CPP /* * finish_agent_init: @@ -1265,7 +1265,7 @@ static int socket_transport_accept (int socket_fd) { MONO_ENTER_GC_SAFE; -#if defined(HOST_WIN32) && !defined(IL2CPP_MONO_DEBUGGER) +#if defined(HOST_WIN32) && !defined(RUNTIME_IL2CPP) conn_fd = mono_w32socket_accept (socket_fd, NULL, NULL, TRUE); if (conn_fd != -1) mono_w32socket_set_blocking (conn_fd, TRUE); @@ -1729,7 +1729,7 @@ start_debugger_thread (void) { MonoError error; MonoInternalThread *thread; -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP il2cpp_start_debugger_thread (); #else thread = mono_thread_create_internal (mono_get_root_domain (), debugger_thread, NULL, MONO_THREAD_CREATE_FLAGS_DEBUGGER, &error); @@ -1737,7 +1737,7 @@ start_debugger_thread (void) debugger_thread_handle = mono_threads_open_thread_handle (thread->handle); g_assert (debugger_thread_handle); -#endif // IL2CPP_MONO_DEBUGGER; +#endif // RUNTIME_IL2CPP; } /* @@ -2254,7 +2254,7 @@ typedef struct { /* Protected by the dbg lock */ static GPtrArray *ids [ID_NUM]; -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP static GHashTable* s_jit_info_hashtable; @@ -2282,7 +2282,7 @@ unity_mono_jit_find_compiled_method_with_jit_info(MonoDomain *domain, MonoMethod return ji2->code_start; } -#endif // IL2CPP_MONO_DEBUGGER +#endif // RUNTIME_IL2CPP static void ids_init (void) @@ -2445,7 +2445,7 @@ decode_ptr_id (guint8 *buf, guint8 **endbuf, guint8 *limit, IdType type, MonoDom res = (Id *)g_ptr_array_index (ids [type], GPOINTER_TO_INT (id - 1)); dbg_unlock (); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP if (res->domain == NULL || res->domain->state == MONO_APPDOMAIN_UNLOADED) { DEBUG_PRINTF (1, "ERR_UNLOADED, id=%d, type=%d.\n", id, type); *err = ERR_UNLOADED; @@ -2599,7 +2599,7 @@ static void invoke_method (void); /* * SUSPEND/RESUME */ -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP static MonoJitInfo* get_top_method_ji (gpointer ip, MonoDomain **domain, gpointer *out_ip) { @@ -2644,14 +2644,14 @@ save_thread_context (MonoContext *ctx) tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id); g_assert (tls); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP if (ctx) mono_thread_state_init_from_monoctx (&tls->context, ctx); else mono_thread_state_init_from_current (&tls->context); #else callbacks.il2cpp_debugger_save_thread_context(&tls->il2cpp_context); -#endif // !IL2CPP_MONO_DEBUGGER +#endif // !RUNTIME_IL2CPP } /* Number of threads suspended */ @@ -2718,7 +2718,7 @@ copy_unwind_state_from_frame_data (MonoThreadUnwindState *to, GetLastFrameUserDa to->unwind_data [MONO_UNWIND_DATA_JIT_TLS] = jit_tls; to->valid = TRUE; } -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP /* * thread_interrupt: * @@ -2839,7 +2839,7 @@ debugger_interrupt_critical (MonoThreadInfo *info, gpointer user_data) MonoJitInfo *ji; data->valid_info = TRUE; -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP if (!data->tls->suspended && !data->tls->suspending) { data->tls->suspended = TRUE; mono_coop_sem_post(&suspend_sem); @@ -2853,7 +2853,7 @@ debugger_interrupt_critical (MonoThreadInfo *info, gpointer user_data) /* This is signal safe */ thread_interrupt (data->tls, info, ji); -#endif // IL2CPP_MONO_DEBUGGER +#endif // RUNTIME_IL2CPP return MonoResumeThread; } @@ -2891,7 +2891,7 @@ notify_thread (gpointer key, gpointer value, gpointer user_data) static void process_suspend (DebuggerTlsData *tls, MonoContext *ctx) { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP guint8 *ip = (guint8 *)MONO_CONTEXT_GET_IP (ctx); MonoJitInfo *ji; MonoMethod *method; @@ -2925,7 +2925,7 @@ process_suspend (DebuggerTlsData *tls, MonoContext *ctx) return; } -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP ji = get_top_method_ji (ip, NULL, NULL); g_assert (ji); /* Can't suspend in these methods */ @@ -3054,7 +3054,7 @@ free_frames (StackFrame **frames, int nframes) int i; for (i = 0; i < nframes; ++i) { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP if (frames [i]->jit) mono_debug_free_method_jit_info (frames [i]->jit); #endif @@ -3349,7 +3349,7 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) { ComputeFramesUserData user_data; GSList *tmp; - int i, findex, new_frame_count; + int i=0, findex, new_frame_count; StackFrame **new_frames, *f; MonoUnwindOptions opts = (MonoUnwindOptions)(MONO_UNWIND_DEFAULT | MONO_UNWIND_REG_LOCATIONS); @@ -3365,15 +3365,15 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) tls->frame_count = 0; return; } if (!tls->really_suspended && tls->async_state.valid) { -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP NOT_IMPLEMENTED; #else /* Have to use the state saved by the signal handler */ process_frame (&tls->async_last_frame, NULL, &user_data); mono_walk_stack_with_state (process_frame, &tls->async_state, opts, &user_data); -#endif // IL2CPP_MONO_DEBUGGER +#endif // RUNTIME_IL2CPP } else if (tls->filter_state.valid) { -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP NOT_IMPLEMENTED; #else /* @@ -3389,14 +3389,14 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) * After that, we resume unwinding from the location where the exception has been thrown. */ mono_walk_stack_with_state (process_frame, &tls->filter_state, opts, &user_data); -#endif // IL2CPP_MONO_DEBUGGER +#endif // RUNTIME_IL2CPP } else if (tls->context.valid) { -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP NOT_IMPLEMENTED; #else mono_walk_stack_with_state (process_frame, &tls->context, opts, &user_data); -#endif // IL2CPP_MONO_DEBUGGER -#ifdef IL2CPP_MONO_DEBUGGER +#endif // RUNTIME_IL2CPP +#ifdef RUNTIME_IL2CPP } else if (tls->il2cpp_context.frameCount > 0) { for (int frame_index = tls->il2cpp_context.frameCount - 1; frame_index >= 0; --frame_index) { @@ -3414,7 +3414,7 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) user_data.frames = g_slist_append(user_data.frames, frame); } -#endif // IL2CPP_MONO_DEBUGGER +#endif // RUNTIME_IL2CPP } else { // FIXME: tls->frame_count = 0; @@ -3427,7 +3427,7 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) for (tmp = user_data.frames; tmp; tmp = tmp->next) { f = (StackFrame *)tmp->data; -#ifndef IL2CPP_DEBUGGER +#ifndef RUNTIME_IL2CPP /* * Reuse the id for already existing stack frames, so invokes don't invalidate * the still valid stack frames. @@ -3438,7 +3438,7 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) break; } } -#endif // !IL2CPP_MONO_DEBUGGER +#endif // !RUNTIME_IL2CPP if (i >= tls->frame_count) f->id = mono_atomic_inc_i32 (&frame_id); @@ -3551,7 +3551,7 @@ dbg_path_get_basename (const char *filename) return g_strdup (&r[1]); } -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP static void init_jit_info_dbg_attrs (MonoJitInfo *ji) { @@ -3596,7 +3596,7 @@ init_jit_info_dbg_attrs (MonoJitInfo *ji) mono_memory_barrier (); ji->dbg_attrs_inited = TRUE; } -#endif //IL2CPP_MONO_DEBUGGER +#endif //RUNTIME_IL2CPP static gboolean find_source_file_in_hash_table(const char* needle, GHashTable* haystack) { @@ -3637,7 +3637,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv { int i, j; GSList *events = NULL; -#if IL2CPP_MONO_DEBUGGER +#if RUNTIME_IL2CPP Il2CppSequencePoint *sp = (Il2CppSequencePoint*)ji; #endif @@ -3686,7 +3686,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv if (assemblies) { for (k = 0; assemblies [k]; ++k) -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP { if (assemblies[k] == sp->method->klass->image->assembly) found = TRUE; @@ -3701,7 +3701,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv } else if (mod->kind == MOD_KIND_SOURCE_FILE_ONLY && ei && ei->klass) { gpointer iter = NULL; MonoMethod *method; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MonoDebugSourceInfo *sinfo; #endif char *source_file, *s; @@ -3709,7 +3709,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv int i; GPtrArray *source_file_list; -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP int fileCount; const char **files; @@ -3749,7 +3749,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv filtered = TRUE; g_free (s); } else if (mod->kind == MOD_KIND_STEP) { -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP Il2CppSequencePoint *sp = (Il2CppSequencePoint*)ji; if ((mod->data.filter & STEP_FILTER_STATIC_CTOR) && sp && (sp->method->flags & METHOD_ATTRIBUTE_SPECIAL_NAME) && @@ -3833,7 +3833,7 @@ event_to_string (EventKind event) * The EVENTS list is freed by this function. */ static void -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx, GSList *events, int suspend_policy) #else process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx, GSList *events, int suspend_policy, uint64_t il2cpp_seqpoint_id) @@ -3926,7 +3926,7 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx case EVENT_KIND_METHOD_ENTRY: case EVENT_KIND_METHOD_EXIT: buffer_add_methodid (&buf, domain, (MonoMethod *)arg); -#if defined(IL2CPP_MONO_DEBUGGER) && defined(IL2CPP_DEBUGGER_TESTS) +#if defined(RUNTIME_IL2CPP) && defined(IL2CPP_DEBUGGER_TESTS) buffer_add_long (&buf, il2cpp_seqpoint_id); #endif break; @@ -3951,7 +3951,7 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx case EVENT_KIND_STEP: buffer_add_methodid (&buf, domain, (MonoMethod *)arg); buffer_add_long (&buf, il_offset); -#if defined(IL2CPP_MONO_DEBUGGER) && defined(IL2CPP_DEBUGGER_TESTS) +#if defined(RUNTIME_IL2CPP) && defined(IL2CPP_DEBUGGER_TESTS) buffer_add_long (&buf, il2cpp_seqpoint_id); #endif break; @@ -3965,7 +3965,7 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx case EVENT_KIND_EXCEPTION: { DebuggerEventInfo *ei = (DebuggerEventInfo *)arg; buffer_add_objid (&buf, ei->exc); -#if defined(IL2CPP_MONO_DEBUGGER) && defined(IL2CPP_DEBUGGER_TESTS) +#if defined(RUNTIME_IL2CPP) && defined(IL2CPP_DEBUGGER_TESTS) buffer_add_long(&buf, il2cpp_seqpoint_id); #endif /* @@ -4068,7 +4068,7 @@ process_profiler_event (EventKind event, gpointer arg) events = create_event_list (event, NULL, NULL, ei_arg, &suspend_policy); mono_loader_unlock (); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP process_event (event, arg, 0, NULL, events, suspend_policy); #else process_event (event, arg, 0, NULL, events, suspend_policy, 0); @@ -4130,17 +4130,17 @@ thread_startup (MonoProfiler *prof, uintptr_t tid) tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id); if (tls) { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP if (!tls->terminated) MONO_GC_UNREGISTER_ROOT(tls->thread); #endif -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP il2cpp_gc_free_fixed (tls); #else g_free (tls); #endif } -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP tls = il2cpp_gc_alloc_fixed(sizeof(DebuggerTlsData)); #else tls = g_new0 (DebuggerTlsData, 1); @@ -4180,7 +4180,7 @@ thread_end (MonoProfiler *prof, uintptr_t tid) /* FIXME: Maybe we need to free this instead, but some code can't handle that */ tls->terminated = TRUE; /* Can't remove from tid_to_thread, as that would defeat the check in thread_start () */ -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MONO_GC_UNREGISTER_ROOT (tls->thread); #endif tls->thread = NULL; @@ -4276,7 +4276,7 @@ assembly_load (MonoProfiler *prof, MonoAssembly *assembly) dbg_unlock (); } -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP static void assembly_unload (MonoProfiler *prof, MonoAssembly *assembly) { @@ -4374,12 +4374,12 @@ jit_failed (MonoProfiler *prof, MonoMethod *method) static void jit_end (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *jinfo) { -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP //if (!result) { g_hash_table_insert(s_jit_info_hashtable, method, jinfo); } -#endif // IL2CPP_MONO_DEBUGGER +#endif // RUNTIME_IL2CPP /* * We emit type load events when the first method of the type is JITted, @@ -4423,7 +4423,7 @@ typedef struct { guint8 *ip; MonoJitInfo *ji; MonoDomain *domain; -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP Il2CppSequencePoint* seq_point; #endif } BreakpointInstance; @@ -4557,7 +4557,7 @@ insert_breakpoint (MonoSeqPointInfo *seq_points, MonoDomain *domain, MonoJitInfo DEBUG_PRINTF (1, "[dbg] Inserted breakpoint at %s:[il=0x%x,native=0x%x] [%p](%d).\n", mono_method_full_name (jinfo_get_method (ji), TRUE), (int)it.seq_point.il_offset, (int)it.seq_point.native_offset, inst->ip, count); } -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP static void remove_breakpoint (BreakpointInstance *inst) @@ -4586,7 +4586,7 @@ remove_breakpoint (BreakpointInstance *inst) #endif } -#endif // !IL2CPP_MONO_DEBUGGER +#endif // !RUNTIME_IL2CPP /* * This doesn't take any locks. @@ -4598,7 +4598,7 @@ bp_matches_method (MonoBreakpoint *bp, MonoMethod *method) if (!bp->method) return TRUE; -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP return il2cpp_mono_methods_match(bp->method, method); #else if (method == bp->method) @@ -4624,7 +4624,7 @@ bp_matches_method (MonoBreakpoint *bp, MonoMethod *method) } return FALSE; -#endif // IL2CPP_MONO_DEBUGGER +#endif // RUNTIME_IL2CPP } /* @@ -4635,7 +4635,7 @@ bp_matches_method (MonoBreakpoint *bp, MonoMethod *method) static void add_pending_breakpoints (MonoMethod *method, MonoJitInfo *ji) { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP int i, j; MonoSeqPointInfo *seq_points; MonoDomain *domain; @@ -4764,7 +4764,7 @@ set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req, MonoError method_seq_points = g_ptr_array_new (); mono_loader_lock (); -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP void *seqPointIter = NULL; Il2CppSequencePoint *seqPoint; while(seqPoint = il2cpp_get_method_sequence_points(method, &seqPointIter)) @@ -4816,7 +4816,7 @@ set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req, MonoError seq_points = (MonoSeqPointInfo *)g_ptr_array_index (method_seq_points, i); set_bp_in_method (domain, m, seq_points, bp, error); } -#endif // IL2CPP_MONO_DEBUGGER +#endif // RUNTIME_IL2CPP g_ptr_array_add (breakpoints, bp); mono_loader_unlock (); @@ -4833,7 +4833,7 @@ set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req, MonoError return bp; } -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP static MonoBreakpoint* set_breakpoint_fast(Il2CppSequencePoint *sp, EventRequest *req, MonoError *error) { @@ -4898,7 +4898,7 @@ static MonoBreakpoint* set_breakpoint_fast(Il2CppSequencePoint *sp, EventRequest return bp; } -#endif // IL2CPP_MONO_DEBUGGER +#endif // RUNTIME_IL2CPP static void clear_breakpoint (MonoBreakpoint *bp) @@ -4909,7 +4909,7 @@ clear_breakpoint (MonoBreakpoint *bp) for (i = 0; i < bp->children->len; ++i) { BreakpointInstance *inst = (BreakpointInstance *)g_ptr_array_index (bp->children, i); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP remove_breakpoint(inst); #else inst->seq_point->isActive--; @@ -4986,7 +4986,7 @@ clear_breakpoints_for_domain (MonoDomain *domain) BreakpointInstance *inst = (BreakpointInstance *)g_ptr_array_index (bp->children, j); if (inst->domain == domain) { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP remove_breakpoint (inst); #else inst->seq_point->isActive--; @@ -5015,7 +5015,7 @@ static void ss_calculate_framecount (DebuggerTlsData *tls, MonoContext *ctx) compute_frame_info (tls->thread, tls); } -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP static gboolean ensure_jit (StackFrame* frame) { @@ -5045,7 +5045,7 @@ ensure_jit (StackFrame* frame) static gboolean ss_update (SingleStepReq *req, MonoJitInfo *ji, SeqPoint *sp, DebuggerTlsData *tls, MonoContext *ctx, MonoMethod* method) { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MonoDebugMethodInfo *minfo; MonoDebugSourceLocation *loc = NULL; #endif @@ -5087,7 +5087,7 @@ ss_update (SingleStepReq *req, MonoJitInfo *ji, SeqPoint *sp, DebuggerTlsData *t } } -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MonoDebugMethodAsyncInfo* async_method = mono_debug_lookup_method_async_debug_info (method); if (async_method) { for (int i = 0; i < async_method->num_awaits; i++) { @@ -5105,7 +5105,7 @@ ss_update (SingleStepReq *req, MonoJitInfo *ji, SeqPoint *sp, DebuggerTlsData *t /* Have to check whenever a different source line was reached */ -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP minfo = mono_debug_lookup_method (method); if (minfo) @@ -5135,7 +5135,7 @@ ss_update (SingleStepReq *req, MonoJitInfo *ji, SeqPoint *sp, DebuggerTlsData *t return hit; } -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP /* * ss_update_il2cpp: * @@ -5206,7 +5206,7 @@ breakpoint_matches_assembly (MonoBreakpoint *bp, MonoAssembly *assembly) static gpointer get_this_addr (StackFrame *frame) { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP if (frame->ji->is_interp) return mini_get_interp_callbacks ()->frame_get_this (frame->interp_frame); @@ -5348,7 +5348,7 @@ get_notify_debugger_of_wait_completion_method (void) return notify_debugger_of_wait_completion_method_cache; } -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP static void process_breakpoint (DebuggerTlsData *tls, gboolean from_signal) { @@ -5544,7 +5544,7 @@ process_signal_event (void (*func) (DebuggerTlsData*, gboolean)) g_assert_not_reached (); } -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP static void process_breakpoint_from_signal (void) { @@ -5583,7 +5583,7 @@ resume_from_signal_handler (void *sigctx, void *func) #endif } -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP void mono_debugger_agent_breakpoint_hit (void *sigctx) { @@ -5634,7 +5634,7 @@ mono_debugger_agent_user_break (void) memset (&data, 0, sizeof (UserBreakCbData)); data.ctx = &ctx; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP /* Obtain a context */ MONO_CONTEXT_SET_IP (&ctx, NULL); mono_walk_stack_with_ctx (user_break_cb, NULL, (MonoUnwindOptions)0, &data); @@ -5645,7 +5645,7 @@ mono_debugger_agent_user_break (void) events = create_event_list (EVENT_KIND_USER_BREAK, NULL, NULL, NULL, &suspend_policy); mono_loader_unlock (); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP process_event (EVENT_KIND_USER_BREAK, NULL, 0, &ctx, events, suspend_policy); #else process_event (EVENT_KIND_USER_BREAK, NULL, 0, &ctx, events, suspend_policy, 0); @@ -5672,7 +5672,7 @@ ss_depth_to_string (StepDepth depth) } static void -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal) #else process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, uint64_t sequencePointId) @@ -5689,9 +5689,9 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, uint64_t SeqPoint sp; MonoSeqPointInfo *info; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP /* Skip the instruction causing the single step */ -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP if (from_signal) mono_arch_skip_single_step (ctx); #else @@ -5714,14 +5714,14 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, uint64_t if (mono_thread_internal_current () != ss_req->thread) return; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP ip = (guint8 *)MONO_CONTEXT_GET_IP (ctx); ji = get_top_method_ji (ip, &domain, (gpointer*)&ip); g_assert (ji && !ji->is_trampoline); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP if (log_level > 0) { DEBUG_PRINTF (1, "[%p] Single step event (depth=%s) at %s (%p)[0x%x], sp %p, last sp %p\n", (gpointer) (gsize) mono_native_thread_id_get (), ss_depth_to_string (ss_req->depth), mono_method_full_name (jinfo_get_method (ji), TRUE), MONO_CONTEXT_GET_IP (ctx), (int)((guint8*)MONO_CONTEXT_GET_IP (ctx) - (guint8*)ji->code_start), MONO_CONTEXT_GET_SP (ctx), ss_req->last_sp); } @@ -5788,7 +5788,7 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, uint64_t g_ptr_array_add (reqs, ss_req->req); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP events = create_event_list (EVENT_KIND_STEP, reqs, ji, NULL, &suspend_policy); #else events = create_event_list(EVENT_KIND_STEP, reqs, il2cpp_get_sequence_point(sequencePointId), NULL, &suspend_policy); @@ -5798,7 +5798,7 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, uint64_t mono_loader_unlock (); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP process_event (EVENT_KIND_STEP, jinfo_get_method (ji), il_offset, ctx, events, suspend_policy); #else Il2CppSequencePoint* sequence_pt = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]; @@ -5868,7 +5868,7 @@ mono_debugger_agent_single_step_event (void *sigctx) } void -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP debugger_agent_single_step_from_context (MonoContext *ctx) #else debugger_agent_single_step_from_context (MonoContext *ctx, uint64_t sequencePointId) @@ -5887,7 +5887,7 @@ debugger_agent_single_step_from_context (MonoContext *ctx, uint64_t sequencePoin g_assert (tls); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP /* Have to save/restore the restore_ctx as we can be called recursively during invokes etc. */ memcpy (&orig_restore_state, &tls->restore_state, sizeof (MonoThreadUnwindState)); mono_thread_state_init_from_monoctx (&tls->restore_state, ctx); @@ -5904,7 +5904,7 @@ debugger_agent_single_step_from_context (MonoContext *ctx, uint64_t sequencePoin #endif } -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP void debugger_agent_breakpoint_from_context (MonoContext *ctx) { @@ -5947,7 +5947,7 @@ start_single_stepping (void) if (val == 1) { mono_arch_start_single_stepping (); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP mini_get_interp_callbacks ()->start_single_stepping (); #endif } @@ -5964,7 +5964,7 @@ stop_single_stepping (void) if (val == 0) { mono_arch_stop_single_stepping (); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP mini_get_interp_callbacks ()->stop_single_stepping (); #endif } @@ -6078,7 +6078,7 @@ ss_bp_add_one (SingleStepReq *ss_req, int *ss_req_bp_count, GHashTable **ss_req_ } } -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP static void ss_bp_add_one_il2cpp(SingleStepReq *ss_req, int *ss_req_bp_count, GHashTable **ss_req_bp_cache, Il2CppSequencePoint *sp) { @@ -6105,7 +6105,7 @@ static void ss_bp_add_one_il2cpp(SingleStepReq *ss_req, int *ss_req_bp_count, GH } } -#endif // IL2CPP_MONO_DEBUGGER +#endif // RUNTIME_IL2CPP static gboolean is_last_non_empty (SeqPoint* sp, MonoSeqPointInfo *info) @@ -6137,7 +6137,7 @@ is_last_non_empty (SeqPoint* sp, MonoSeqPointInfo *info) * belong to the same thread as CTX. * If FRAMES is not-null, use that instead of tls->frames for placing breakpoints etc. */ -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP static void ss_start (SingleStepReq *ss_req, MonoMethod *method, SeqPoint* sp, MonoSeqPointInfo *info, MonoContext *ctx, DebuggerTlsData *tls, gboolean step_to_catch, StackFrame **frames, int nframes) @@ -6436,7 +6436,7 @@ ss_start_il2cpp(SingleStepReq *ss_req, DebuggerTlsData *tls, Il2CppSequencePoint } } -#endif // IL2CPP_MONO_DEBUGGER +#endif // RUNTIME_IL2CPP /* * Start single stepping of thread THREAD @@ -6450,7 +6450,7 @@ ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilte SeqPoint local_sp; gboolean found_sp; MonoMethod *method = NULL; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MonoDebugMethodInfo *minfo; #endif gboolean step_to_catch = FALSE; @@ -6491,7 +6491,7 @@ ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilte mono_loader_unlock (); g_assert (tls); -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP ss_req->nframes = tls->il2cpp_context.frameCount; Il2CppSequencePoint *catchFrameSp = NULL; @@ -6663,7 +6663,7 @@ mono_debugger_agent_debug_log (int level, MonoString *category, MonoString *mess ei.message = mono_string_to_utf8_checked (message, &error); mono_error_cleanup (&error); } -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP process_event (EVENT_KIND_USER_LOG, &ei, 0, NULL, events, suspend_policy); #else process_event (EVENT_KIND_USER_LOG, &ei, 0, NULL, events, suspend_policy, 0); @@ -6698,7 +6698,7 @@ mono_debugger_agent_unhandled_exception (MonoException *exc) events = create_event_list (EVENT_KIND_EXCEPTION, NULL, NULL, &ei, &suspend_policy); mono_loader_unlock (); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP process_event (EVENT_KIND_EXCEPTION, &ei, 0, NULL, events, suspend_policy); #else process_event (EVENT_KIND_EXCEPTION, &ei, 0, NULL, events, suspend_policy, 0); @@ -6706,7 +6706,7 @@ mono_debugger_agent_unhandled_exception (MonoException *exc) } #endif -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP static Il2CppSequencePoint* il2cpp_find_catch_sequence_point_in_method(Il2CppSequencePoint* callSp, MonoException *exc) { @@ -6890,7 +6890,7 @@ mono_debugger_agent_handle_exception (MonoException *exc, MonoContext *throw_ctx */ events = g_slist_append (NULL, GUINT_TO_POINTER (0xffffff)); ei.exc = (MonoObject*)exc; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP process_event (EVENT_KIND_EXCEPTION, &ei, 0, throw_ctx, events, SUSPEND_POLICY_ALL); #else process_event (EVENT_KIND_EXCEPTION, &ei, 0, throw_ctx, events, SUSPEND_POLICY_ALL, 0); @@ -6919,7 +6919,7 @@ mono_debugger_agent_handle_exception (MonoException *exc, MonoContext *throw_ctx */ events = g_slist_append (NULL, GUINT_TO_POINTER (0xffffff)); ei.exc = (MonoObject*)exc; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP process_event (EVENT_KIND_EXCEPTION, &ei, 0, throw_ctx, events, SUSPEND_POLICY_ALL); #else process_event (EVENT_KIND_EXCEPTION, &ei, 0, throw_ctx, events, SUSPEND_POLICY_ALL, 0); @@ -6979,7 +6979,7 @@ mono_debugger_agent_handle_exception (MonoException *exc, MonoContext *throw_ctx } } -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP process_event (EVENT_KIND_EXCEPTION, &ei, 0, throw_ctx, events, suspend_policy); #else process_event (EVENT_KIND_EXCEPTION, &ei, 0, throw_ctx, events, suspend_policy, 0); @@ -7050,7 +7050,7 @@ mono_debugger_agent_end_exception_filter (MonoException *exc, MonoContext *ctx, * AS_VTYPE determines whenever to treat primitive types as primitive types or * vtypes. */ -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP static void buffer_add_value_full (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain, gboolean as_vtype, GHashTable *parent_vtypes) { @@ -7735,7 +7735,7 @@ decode_value (MonoType *t, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8 return decode_value_internal (t, type, domain, addr, buf, endbuf, limit); } -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP static void add_var (Buffer *buf, MonoDebugMethodJitInfo *jit, MonoType *t, MonoDebugVarInfo *var, MonoContext *ctx, MonoDomain *domain, gboolean as_vtype) { @@ -7824,7 +7824,7 @@ add_var (Buffer *buf, MonoDebugMethodJitInfo *jit, MonoType *t, MonoDebugVarInfo } #endif -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP static void set_var (MonoType *t, MonoDebugVarInfo *var, MonoContext *ctx, MonoDomain *domain, guint8 *val, mgreg_t **reg_locations, MonoContext *restore_ctx) { @@ -8067,7 +8067,7 @@ type_comes_from_assembly (gpointer klass, gpointer also_klass, gpointer assembly * * Clears types from loaded_classes for a given assembly */ -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP static void clear_types_for_assembly (MonoAssembly *assembly) { @@ -8242,7 +8242,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 if (err != ERR_NONE) break; if (mono_class_is_nullable (arg_class)) { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP args [i] = mono_nullable_box (arg_buf [i], arg_class, &error); mono_error_assert_ok (&error); #else @@ -8265,7 +8265,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 /* * Add an LMF frame to link the stack frames on the invoke method with our caller. */ -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP #ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED if (invoke->has_ctx) { /* Setup our lmf */ @@ -8346,7 +8346,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 tls->disable_breakpoints = FALSE; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP #ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED if (invoke->has_ctx) mono_pop_lmf ((MonoLMF*)&ext); @@ -8485,7 +8485,7 @@ get_source_files_for_type (MonoClass *klass) { gpointer iter = NULL; MonoMethod *method; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MonoDebugSourceInfo *sinfo; #endif GPtrArray *files; @@ -8493,7 +8493,7 @@ get_source_files_for_type (MonoClass *klass) files = g_ptr_array_new (); -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP const char **fileNames = il2cpp_get_source_files_for_type(klass, &i); for (j = 0; j < i; ++j) g_ptr_array_add(files, g_strdup(fileNames[j])); @@ -9206,20 +9206,20 @@ domain_commands (int command, guint8 *p, guint8 *end, Buffer *buf) return err; mono_loader_lock (); count = 0; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) { #else while(il2cpp_domain_get_assemblies_iter(domain, &iter)) { -#endif //IL2CPP_MONO_DEBUGGER +#endif //RUNTIME_IL2CPP count ++; } buffer_add_int (buf, count); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) { ass = (MonoAssembly *)tmp->data; #else while(ass = il2cpp_domain_get_assemblies_iter(domain, &iter)) { -#endif //IL2CPP_MONO_DEBUGGER +#endif //RUNTIME_IL2CPP buffer_add_assemblyid (buf, domain, ass); } mono_loader_unlock (); @@ -9229,11 +9229,11 @@ domain_commands (int command, guint8 *p, guint8 *end, Buffer *buf) domain = decode_domainid (p, &p, end, NULL, &err); if (err != ERR_NONE) return err; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP buffer_add_assemblyid (buf, domain, domain->entry_assembly); #else buffer_add_assemblyid (buf, domain, NULL); -#endif //IL2CPP_MONO_DEBUGGER +#endif //RUNTIME_IL2CPP break; } case CMD_APPDOMAIN_GET_CORLIB: { @@ -9299,7 +9299,7 @@ domain_commands (int command, guint8 *p, guint8 *end, Buffer *buf) static ErrorCode get_assembly_object_command (MonoDomain *domain, MonoAssembly *ass, Buffer *buf, MonoError *error) { -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP MonoReflectionAssemblyHandle o = il2cpp_mono_assembly_get_object_handle(domain, ass, error); if (o == NULL) { return ERR_INVALID_OBJECT; @@ -9345,7 +9345,7 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (ass->image->dynamic) { buffer_add_id (buf, 0); } else { -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP m = il2cpp_mono_image_get_entry_point(ass->image); if (m == NULL) buffer_add_id (buf, 0); @@ -9362,7 +9362,7 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) mono_error_cleanup (&error); /* FIXME don't swallow the error */ buffer_add_methodid (buf, domain, m); } -#endif // IL2CPP_MONO_DEBUGGER +#endif // RUNTIME_IL2CPP } break; } @@ -9501,7 +9501,7 @@ buffer_add_cattr_arg (Buffer *buf, MonoType *t, MonoDomain *domain, MonoObject * buffer_add_value (buf, t, mono_object_unbox (val), domain); } -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP static ErrorCode buffer_add_cattrs (Buffer *buf, MonoDomain *domain, MonoImage *image, MonoClass *attr_klass, MonoCustomAttrInfo *cinfo) { @@ -9578,7 +9578,7 @@ buffer_add_cattrs (Buffer *buf, MonoDomain *domain, MonoImage *image, MonoClass return ERR_NONE; } -#endif //IL2CPP_MONO_DEBUGGER +#endif //RUNTIME_IL2CPP /* FIXME: Code duplication with icall.c */ static void @@ -9755,7 +9755,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint break; } case CMD_TYPE_GET_CATTRS: { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MonoClass *attr_klass; MonoCustomAttrInfo *cinfo; @@ -9776,10 +9776,10 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint break; #else return ERR_NOT_IMPLEMENTED; -#endif //IL2CPP_MONO_DEBUGGER +#endif //RUNTIME_IL2CPP } case CMD_TYPE_GET_FIELD_CATTRS: { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MonoClass *attr_klass; MonoCustomAttrInfo *cinfo; MonoClassField *field; @@ -9803,10 +9803,10 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint break; #else return ERR_NOT_IMPLEMENTED; -#endif //IL2CPP_MONO_DEBUGGER +#endif //RUNTIME_IL2CPP } case CMD_TYPE_GET_PROPERTY_CATTRS: { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MonoClass *attr_klass; MonoCustomAttrInfo *cinfo; MonoProperty *prop; @@ -9830,7 +9830,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint break; #else return ERR_NOT_IMPLEMENTED; -#endif //IL2CPP_MONO_DEBUGGER +#endif //RUNTIME_IL2CPP } case CMD_TYPE_GET_VALUES: case CMD_TYPE_GET_VALUES_2: { @@ -9864,7 +9864,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint if (!(f->type->attrs & FIELD_ATTRIBUTE_STATIC)) return ERR_INVALID_FIELDID; -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP if (!thread && f->offset == THREAD_STATIC_FIELD_OFFSET) return ERR_INVALID_FIELDID; #else @@ -10047,7 +10047,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint iclass = decode_typeid (p, &p, end, NULL, &err); if (err != ERR_NONE) return err; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP ioffset = mono_class_interface_offset_with_variance (klass, iclass, &variance_used); if (ioffset == -1) return ERR_INVALID_ARGUMENT; @@ -10061,7 +10061,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint } for (i = 0; i < nmethods; ++i) -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP buffer_add_methodid(buf, domain, il2cpp_get_interface_method(klass, iclass, i)); #else buffer_add_methodid(buf, domain, klass->vtable[i + ioffset]); @@ -10073,7 +10073,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint MonoVTable *vtable = mono_class_vtable (domain, klass); if (vtable) -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP buffer_add_int (buf, (vtable->initialized || vtable->init_failed) ? 1 : 0); #else buffer_add_int (buf, vtable->initialized ? 1 : 0); @@ -10121,7 +10121,7 @@ type_commands (int command, guint8 *p, guint8 *end, Buffer *buf) return err; } -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP gint CompareSeqPointsByIlOffset(gconstpointer a, gconstpointer b) { @@ -10194,7 +10194,7 @@ static void GetExecutionContextAndHeaderInfo(MonoMethod* method, uint32_t* execu g_assert(FALSE); // shouldn't be ever reached } -#endif // IL2CPP_MONO_DEBUGGER +#endif // RUNTIME_IL2CPP static ErrorCode method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, guint8 *p, guint8 *end, Buffer *buf) @@ -10214,7 +10214,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g case CMD_METHOD_GET_DEBUG_INFO: { MonoError error; int i, j; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MonoDebugMethodInfo *minfo; char *source_file; int n_il_offsets; @@ -10373,7 +10373,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g } case CMD_METHOD_GET_LOCALS_INFO: { MonoError error; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP int i, num_locals; MonoDebugLocalsInfo *locals; int *locals_map = NULL; @@ -10497,7 +10497,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g buffer_add_int(buf, executionContextInfo[i].m_end); } } -#endif // !IL2CPP_MONO_DEBUGGER +#endif // !RUNTIME_IL2CPP break; } case CMD_METHOD_GET_INFO: { @@ -10576,7 +10576,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g break; } case CMD_METHOD_GET_BODY: { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MonoError error; int i; @@ -10686,7 +10686,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g break; } case CMD_METHOD_GET_CATTRS: { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MonoError error; MonoClass *attr_klass; MonoCustomAttrInfo *cinfo; @@ -10708,7 +10708,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g break; #else return ERR_NOT_IMPLEMENTED; -#endif //IL2CPP_MONO_DEBUGGER +#endif //RUNTIME_IL2CPP } case CMD_METHOD_MAKE_GENERIC_METHOD: { MonoError error; @@ -10868,7 +10868,7 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf) buffer_add_long (buf, (guint64)thread->tid); break; case CMD_THREAD_SET_IP: { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP DebuggerTlsData *tls; MonoMethod *method; MonoDomain *domain; @@ -10925,7 +10925,7 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf) return ERR_NONE; } -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP static uint32_t GetExecutionContextIndex(const Il2CppSequencePoint* sequencePoint, MethodVariableKind variableKind, uint32_t variablePosition) { @@ -10982,7 +10982,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) StackFrame *frame; MonoMethodSignature *sig; gssize id; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MonoDebugMethodJitInfo *jit; MonoMethodHeader *header; #endif @@ -11021,7 +11021,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (!frame->has_ctx) return ERR_ABSENT_INFORMATION; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP if (!ensure_jit (frame)) return ERR_ABSENT_INFORMATION; @@ -11030,7 +11030,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) sig = mono_method_signature (frame->actual_method); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP if (!(jit->has_var_info || frame->ji->is_interp) || !mono_get_seq_points (frame->domain, frame->actual_method)) /* * The method is probably from an aot image compiled without soft-debug, variables might be dead, etc. @@ -11042,7 +11042,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) case CMD_STACK_FRAME_GET_VALUES: { MonoError error; len = decode_int (p, &p, end); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP header = mono_method_get_header_checked (frame->actual_method, &error); mono_error_assert_ok (&error); /* FIXME report error */ #endif @@ -11055,7 +11055,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) DEBUG_PRINTF (4, "[dbg] send arg %d.\n", pos); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP if (frame->ji->is_interp) { guint8 *addr; @@ -11071,7 +11071,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) SendVariableData (tls, frame, buf, kMethodVariableKind_Parameter, pos); #endif } else { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MonoDebugLocalsInfo *locals; locals = mono_debug_lookup_locals (frame->method); @@ -11099,7 +11099,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) #endif } } -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP mono_metadata_free_mh (header); #endif break; @@ -11112,7 +11112,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) MonoObject *p = NULL; buffer_add_value (buf, &VM_DEFAULTS_OBJECT_CLASS->byval_arg, &p, frame->domain); } else { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP if (frame->ji->is_interp) { guint8 *addr; @@ -11138,7 +11138,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) MonoObject *p = NULL; buffer_add_value (buf, &frame->actual_method->klass->byval_arg, &p, frame->domain); } else { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP if (frame->ji->is_interp) { guint8 *addr; @@ -11159,7 +11159,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) MonoError error; guint8 *val_buf; MonoType *t; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MonoDebugVarInfo *var = NULL; #else void *var; @@ -11167,7 +11167,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) gboolean is_arg = FALSE; len = decode_int (p, &p, end); -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP header = mono_method_get_header_checked (frame->actual_method, &error); mono_error_assert_ok (&error); /* FIXME report error */ #endif @@ -11178,7 +11178,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (pos < 0) { pos = - pos - 1; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP g_assert (pos >= 0 && pos < jit->num_params); t = sig->params [pos]; @@ -11188,7 +11188,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) #endif is_arg = TRUE; } else { -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MonoDebugLocalsInfo *locals; locals = mono_debug_lookup_locals (frame->method); @@ -11214,7 +11214,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (err != ERR_NONE) return err; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP if (frame->ji->is_interp) { guint8 *addr; @@ -11230,7 +11230,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) il2cpp_set_var (val_buf, var, t); #endif } -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP mono_metadata_free_mh (header); #endif break; @@ -11243,7 +11243,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) case CMD_STACK_FRAME_SET_THIS: { guint8 *val_buf; MonoType *t; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP MonoDebugVarInfo *var; #else void *var; @@ -11258,7 +11258,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (err != ERR_NONE) return err; -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP if (frame->ji->is_interp) { guint8 *addr; @@ -11438,12 +11438,12 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) switch (command) { case CMD_OBJECT_REF_GET_TYPE: -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP /* This handles transparent proxies too */ buffer_add_typeid (buf, VM_OBJECT_GET_DOMAIN(obj), mono_class_from_mono_type (((MonoReflectionType*)obj->vtable->type)->type)); #else buffer_add_typeid (buf, VM_OBJECT_GET_DOMAIN(obj), obj->vtable->klass); -#endif //IL2CPP_MONO_DEBUGGER +#endif //RUNTIME_IL2CPP break; case CMD_OBJECT_REF_GET_VALUES: len = decode_int (p, &p, end); @@ -11849,12 +11849,12 @@ debugger_thread (void *arg) DEBUG_PRINTF (1, "[dbg] Agent thread started, pid=%p\n", (gpointer) (gsize) mono_native_thread_id_get ()); debugger_thread_id = mono_native_thread_id_get (); -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP MonoThread *thread = mono_thread_attach (il2cpp_mono_get_root_domain ()); #endif MonoInternalThread *internal = mono_thread_internal_current (); -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP internal->debugger_thread = 1; #endif MonoString *str = mono_string_new_checked (mono_domain_get (), "Debugger agent", &error); @@ -11873,7 +11873,7 @@ debugger_thread (void *arg) mono_set_is_debugger_attached (TRUE); /* Send start event to client */ process_profiler_event (EVENT_KIND_VM_START, mono_thread_get_main ()); -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP { MonoDomain* domain = il2cpp_mono_get_root_domain(); appdomain_load(NULL, domain); @@ -12015,7 +12015,7 @@ debugger_thread (void *arg) mono_set_is_debugger_attached (FALSE); -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP il2cpp_mono_free_method_signatures(); #endif @@ -12031,13 +12031,13 @@ debugger_thread (void *arg) start_debugger_thread (); } -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP mono_thread_detach (thread); #endif return 0; } -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP static void unity_process_breakpoint_inner(DebuggerTlsData *tls, gboolean from_signal, Il2CppSequencePoint* sequencePoint) @@ -12231,7 +12231,7 @@ gboolean unity_sequence_point_active(Il2CppSequencePoint *seqPoint) return FALSE; } -#endif // IL2CPP_MONO_DEBUGGER +#endif // RUNTIME_IL2CPP #else /* DISABLE_DEBUGGER_AGENT */ diff --git a/mono/mini/debugger-agent.h b/mono/mini/debugger-agent.h index dcfab1cf25f7..3891fb828558 100644 --- a/mono/mini/debugger-agent.h +++ b/mono/mini/debugger-agent.h @@ -12,10 +12,10 @@ MONO_API void mono_debugger_agent_parse_options (char *options); -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP void mono_debugger_run_debugger_thread_func(void* arg); -#endif // IL2CPP_MONO_DEBUGGER +#endif // RUNTIME_IL2CPP void mono_debugger_agent_init (void); @@ -27,7 +27,7 @@ void mono_debugger_agent_single_step_event (void *sigctx); void -#ifndef IL2CPP_MONO_DEBUGGER +#ifndef RUNTIME_IL2CPP debugger_agent_single_step_from_context (MonoContext *ctx); #else debugger_agent_single_step_from_context (MonoContext *ctx, uint64_t sequencePointId); diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index 32e9755ed5c7..ad27e8deba1a 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -10,7 +10,7 @@ #include #endif //RUNTIME_IL2CPP -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP #define THREAD_STATIC_FIELD_OFFSET -1 diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index 4eb703a7089a..22d21b2a2b7d 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -397,7 +397,9 @@ gint32 il2cpp_mono_debug_il_offset_from_address(MonoMethod* method, MonoDomain* void il2cpp_mono_set_is_debugger_attached(gboolean attached) { +#if IL2CPP_MONO_DEBUGGER il2cpp::utils::Debugger::SetIsDebuggerAttached(attached == TRUE); +#endif } char* il2cpp_mono_type_full_name(MonoType* type) @@ -1238,7 +1240,9 @@ MonoAssembly* il2cpp_domain_get_assemblies_iter(MonoAppDomain *domain, void* *it void il2cpp_start_debugger_thread() { +#if IL2CPP_MONO_DEBUGGER il2cpp::utils::Debugger::StartDebuggerThread(); +#endif } void* il2cpp_gc_alloc_fixed(size_t size) @@ -1258,15 +1262,23 @@ const char* il2cpp_domain_get_name(MonoDomain* domain) Il2CppSequencePoint* il2cpp_get_sequence_points(void* *iter) { +#if IL2CPP_MONO_DEBUGGER return (Il2CppSequencePoint*)il2cpp::utils::Debugger::GetSequencePoints(iter); +#else + return NULL; +#endif } Il2CppSequencePoint* il2cpp_get_method_sequence_points(MonoMethod* method, void* *iter) { +#if IL2CPP_MONO_DEBUGGER if (!method) return (Il2CppSequencePoint*)il2cpp::utils::Debugger::GetSequencePoints(iter); else return (Il2CppSequencePoint*)il2cpp::utils::Debugger::GetSequencePoints((const MethodInfo*)method, iter); +#else + return NULL; +#endif } gboolean il2cpp_mono_methods_match(MonoMethod* left, MonoMethod* right) @@ -1431,7 +1443,11 @@ MonoClass* il2cpp_iterate_loaded_classes(void* *iter) const char** il2cpp_get_source_files_for_type(MonoClass *klass, int *count) { +#if IL2CPP_MONO_DEBUGGER return il2cpp::utils::Debugger::GetTypeSourceFiles((Il2CppClass*)klass, *count); +#else + return NULL; +#endif } MonoMethod* il2cpp_method_get_generic_definition(MonoMethodInflated *imethod) @@ -1468,7 +1484,11 @@ MonoClass* il2cpp_mono_get_string_class (void) Il2CppSequencePoint* il2cpp_get_sequence_point(size_t id) { +#if IL2CPP_MONO_DEBUGGER return il2cpp::utils::Debugger::GetSequencePoint(id); +#else + return NULL; +#endif } } #endif // RUNTIME_IL2CPP From 7fa476f45cf82c2897d98cf9719630031ffa79a7 Mon Sep 17 00:00:00 2001 From: Brian Raderman Date: Wed, 17 Jan 2018 11:17:09 -0500 Subject: [PATCH 120/582] Changing the CMD_TYPE_IS_INITIALIZED command for the il2cpp case in the debugger agent to use the klass instead of the vtable. The local vtable variable in this case points to the actual IL2CPP vtable and will not have the "initialized" bit we are looking for. --- mono/mini/debugger-agent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 1b7d734bf300..47c9a10ff41d 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -10076,7 +10076,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint #ifndef RUNTIME_IL2CPP buffer_add_int (buf, (vtable->initialized || vtable->init_failed) ? 1 : 0); #else - buffer_add_int (buf, vtable->initialized ? 1 : 0); + buffer_add_int (buf, klass->initialized ? 1 : 0); #endif else buffer_add_int (buf, 0); From eee354c4dacce9856d67f97d02e57ac3dcd8d7df Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Wed, 17 Jan 2018 16:50:17 -0500 Subject: [PATCH 121/582] Support timezones without daylight savings time (case 988428) (case 943047) --- mcs/class/corlib/System/TimeZoneInfo.Unity.cs | 181 ++++++++---------- 1 file changed, 84 insertions(+), 97 deletions(-) diff --git a/mcs/class/corlib/System/TimeZoneInfo.Unity.cs b/mcs/class/corlib/System/TimeZoneInfo.Unity.cs index 934dde9490b3..7f10ac91be9b 100644 --- a/mcs/class/corlib/System/TimeZoneInfo.Unity.cs +++ b/mcs/class/corlib/System/TimeZoneInfo.Unity.cs @@ -1,36 +1,13 @@ // -// System.TimeZoneInfo helper for MonoTouch -// because the devices cannot access the file system to read the data +// System.TimeZoneInfo helper for Unity +// because the devices cannot access the file system to read the data // // Authors: -// Sebastien Pouliot -// -// Copyright 2011-2013 Xamarin Inc. -// -// The class can be either constructed from a string (from user code) -// or from a handle (from iphone-sharp.dll internal calls). This -// delays the creation of the actual managed string until actually -// required -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// Michael DeRoy +// Jonathan Chambers // +// Copyright 2018 Unity Technologies, Inc. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. #if UNITY @@ -45,90 +22,100 @@ namespace System { public partial class TimeZoneInfo { enum TimeZoneData { - DaylightSavingStartIdx, - DaylightSavingEndIdx, - UtcOffsetIdx, - AdditionalDaylightOffsetIdx + DaylightSavingStartIdx, + DaylightSavingEndIdx, + UtcOffsetIdx, + AdditionalDaylightOffsetIdx }; enum TimeZoneNames { - StandardNameIdx, - DaylightNameIdx + StandardNameIdx, + DaylightNameIdx }; + + static AdjustmentRule CreateAdjustmentRule(int year, out Int64[] data, out string[] names, string standardNameCurrentYear, string daylightNameCurrentYear) + { + if(!System.CurrentSystemTimeZone.GetTimeZoneData(year, out data, out names)) + return null; + var startTime = new DateTime (data[(int)TimeZoneData.DaylightSavingStartIdx]); + var endTime = new DateTime (data[(int)TimeZoneData.DaylightSavingEndIdx]); + var daylightOffset = new TimeSpan (data[(int)TimeZoneData.AdditionalDaylightOffsetIdx]); + + /* C# TimeZoneInfo does not support timezones the same way as unix. In unix, timezone files are specified by region such as + * America/New_York or Asia/Singapore. If a region like Asia/Singapore changes it's timezone from +0730 to +08, the UTC offset + * has changed, but there is no support in the C# code to transition to this new UTC offset except for the case of daylight + * savings time. As such we'll only generate timezone rules for a region at the times associated with the timezone of the current year. + */ + if(standardNameCurrentYear != names[(int)TimeZoneNames.StandardNameIdx]) + return null; + if(daylightNameCurrentYear != names[(int)TimeZoneNames.DaylightNameIdx]) + return null; + + var dlsTransitionStart = TransitionTime.CreateFixedDateRule(new DateTime(1,1,1).Add(startTime.TimeOfDay), + startTime.Month, startTime.Day); + var dlsTransitionEnd = TransitionTime.CreateFixedDateRule(new DateTime(1,1,1).Add(endTime.TimeOfDay), + endTime.Month, endTime.Day); + + var rule = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(new DateTime(year, 1, 1), + new DateTime(year, 12, DateTime.DaysInMonth(year, 12)), + daylightOffset, + dlsTransitionStart, + dlsTransitionEnd); + return rule; + } + static TimeZoneInfo CreateLocalUnity () { Int64[] data; - string[] names; - if (!System.CurrentSystemTimeZone.GetTimeZoneData (1973, out data, out names)) + string[] names; + int currentYear = DateTime.UtcNow.Year; + if (!System.CurrentSystemTimeZone.GetTimeZoneData (currentYear, out data, out names)) throw new NotSupportedException ("Can't get timezone name."); - TimeSpan utcOffsetTS = TimeSpan.FromTicks(data[(int)TimeZoneData.UtcOffsetIdx]); - char utcOffsetSign = (utcOffsetTS >= TimeSpan.Zero) ? '+' : '-'; - string displayName = "(GMT" + utcOffsetSign + utcOffsetTS.ToString(@"hh\:mm") + ") Local Time"; - string standardDisplayName = names[(int)TimeZoneNames.StandardNameIdx]; - string daylightDisplayName = names[(int)TimeZoneNames.DaylightNameIdx]; - - //Create The Adjustment Rules For This TimeZoneInfo. - var adjustmentList = new List(); - for(int year = 1973; year <= 2037; year++) - { - if (!System.CurrentSystemTimeZone.GetTimeZoneData (year, out data, out names)) - continue; - - DaylightTime dlt = new DaylightTime (new DateTime (data[(int)TimeZoneData.DaylightSavingStartIdx]), - new DateTime (data[(int)TimeZoneData.DaylightSavingEndIdx]), - new TimeSpan (data[(int)TimeZoneData.AdditionalDaylightOffsetIdx])); - - DateTime dltStartTime = new DateTime(1, 1, 1).Add(dlt.Start.TimeOfDay); - DateTime dltEndTime = new DateTime(1, 1, 1).Add(dlt.End.TimeOfDay); + var utcOffsetTS = TimeSpan.FromTicks(data[(int)TimeZoneData.UtcOffsetIdx]); + char utcOffsetSign = (utcOffsetTS >= TimeSpan.Zero) ? '+' : '-'; + string displayName = "(GMT" + utcOffsetSign + utcOffsetTS.ToString(@"hh\:mm") + ") Local Time"; + string standardDisplayName = names[(int)TimeZoneNames.StandardNameIdx]; + string daylightDisplayName = names[(int)TimeZoneNames.DaylightNameIdx]; - if (dlt.Start == dlt.End) - continue; + var adjustmentList = new List(); + bool disableDaylightSavings = data[(int)TimeZoneData.AdditionalDaylightOffsetIdx] <= 0; + //If the timezone supports daylight savings time, generate adjustment rules for the timezone + if(!disableDaylightSavings) + { + //the icall only supports years from 1970 through 2037. + int firstSupportedDate = 1970; + int lastSupportedDate = 2037; - TimeZoneInfo.TransitionTime startTime = TimeZoneInfo.TransitionTime.CreateFixedDateRule(dltStartTime, dlt.Start.Month, dlt.Start.Day); - TimeZoneInfo.TransitionTime endTime = TimeZoneInfo.TransitionTime.CreateFixedDateRule(dltEndTime, dlt.End.Month, dlt.End.Day); - - - //mktime only supports dates starting in 1973, so create an adjustment rule for years before 1973 following 1973s rules - if (year == 1973) + //first, generate rules from the current year until the last year mktime is guaranteed to supports + for(int year = currentYear; year <= lastSupportedDate; year++) { - TimeZoneInfo.AdjustmentRule firstRule = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(DateTime.MinValue, - new DateTime(1969, 12, 31), - dlt.Delta, - startTime, - endTime); - adjustmentList.Add(firstRule); + var rule = CreateAdjustmentRule(year, out data, out names, standardDisplayName, daylightDisplayName); + //breakout if timezone changes, or fails + if(rule == null) + break; + adjustmentList.Add(rule); } - - TimeZoneInfo.AdjustmentRule rule = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(new DateTime(year, 1, 1), - new DateTime(year, 12, 31), - dlt.Delta, - startTime, - endTime); - adjustmentList.Add(rule); - - //mktime only supports dates up to 2037, so create an adjustment rule for years after 2037 following 2037s rules - if (year == 2037) + + for(int year = currentYear - 1; year >= firstSupportedDate; year--) { - // create a max date that does not include any time of day offset to make CreateAdjustmentRule happy - var maxDate = new DateTime(DateTime.MaxValue.Year, DateTime.MaxValue.Month, DateTime.MaxValue.Day); - TimeZoneInfo.AdjustmentRule lastRule = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(new DateTime(2038, 1, 1), - maxDate, - dlt.Delta, - startTime, - endTime); - adjustmentList.Add(lastRule); + var rule = CreateAdjustmentRule(year, out data, out names, standardDisplayName, daylightDisplayName); + //breakout if timezone changes, or fails + if(rule == null) + break; + adjustmentList.Add(rule); } - } - - return TimeZoneInfo.CreateCustomTimeZone("local", - utcOffsetTS, - displayName, - standardDisplayName, - daylightDisplayName, - adjustmentList.ToArray(), - false); + + adjustmentList.Sort( (rule1, rule2) => rule1.DateStart.CompareTo(rule2.DateStart) ); + } + return TimeZoneInfo.CreateCustomTimeZone("Local", + utcOffsetTS, + displayName, + standardDisplayName, + daylightDisplayName, + adjustmentList.ToArray(), + disableDaylightSavings); } } } From 682e1af7ccbbb1f11a532f5431c8ecf8a4e16d0a Mon Sep 17 00:00:00 2001 From: andreasr Date: Fri, 19 Jan 2018 15:39:34 +0100 Subject: [PATCH 122/582] [unitytls] Updated unitytls_interface_struct to newest version --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index 963ec0be4b7a..c2b131c0ad7e 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -168,6 +168,7 @@ public struct unitytls_tlsctx_callbacks public class unitytls_interface_struct { public readonly UInt64 UNITYTLS_INVALID_HANDLE; + public readonly unitytls_tlsctx_protocolrange UNITYTLS_TLSCTX_PROTOCOLRANGE_DEFAULT; public delegate unitytls_errorstate unitytls_errorstate_create_t(); public unitytls_errorstate_create_t unitytls_errorstate_create; @@ -176,6 +177,8 @@ public class unitytls_interface_struct public delegate unitytls_key_ref unitytls_key_get_ref_t(unitytls_key* key, unitytls_errorstate* errorState); public unitytls_key_get_ref_t unitytls_key_get_ref; + public delegate unitytls_key* unitytls_key_parse_pem_t(Int8* buffer, size_t bufferLen, UInt8* password, size_t passwordLen, unitytls_errorstate* errorState); + public unitytls_key_parse_der_t unitytls_key_parse_pem; public delegate unitytls_key* unitytls_key_parse_der_t(UInt8* buffer, size_t bufferLen, UInt8* password, size_t passwordLen, unitytls_errorstate* errorState); public unitytls_key_parse_der_t unitytls_key_parse_der; public delegate void unitytls_key_free_t(unitytls_key* key); @@ -194,6 +197,8 @@ public class unitytls_interface_struct public unitytls_x509list_append_t unitytls_x509list_append; public delegate void unitytls_x509list_append_der_t(unitytls_x509list* list, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); public unitytls_x509list_append_der_t unitytls_x509list_append_der; + public delegate void unitytls_x509list_append_pem_t(unitytls_x509list* list, Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + public unitytls_x509list_append_der_t unitytls_x509list_append_pem; public delegate void unitytls_x509list_free_t(unitytls_x509list* list); public unitytls_x509list_free_t unitytls_x509list_free; From d9dda456b276fc790027e51c47f7ca6453b1233d Mon Sep 17 00:00:00 2001 From: Brian Raderman Date: Fri, 19 Jan 2018 14:42:41 -0500 Subject: [PATCH 123/582] Changing sequence point IDs to integers because they are array indexes now instead of arbitrary hash codes. --- mono/mini/debugger-agent.c | 4 ++-- mono/mini/debugger-agent.h | 2 +- mono/mini/il2cpp-compat.h | 2 +- mono/mini/il2cpp-stubs.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 47c9a10ff41d..7e1b375d9dfe 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -5675,7 +5675,7 @@ static void #ifndef RUNTIME_IL2CPP process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal) #else -process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, uint64_t sequencePointId) +process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, int sequencePointId) #endif { MonoJitInfo *ji; @@ -5871,7 +5871,7 @@ void #ifndef RUNTIME_IL2CPP debugger_agent_single_step_from_context (MonoContext *ctx) #else -debugger_agent_single_step_from_context (MonoContext *ctx, uint64_t sequencePointId) +debugger_agent_single_step_from_context (MonoContext *ctx, int sequencePointId) #endif { DebuggerTlsData *tls; diff --git a/mono/mini/debugger-agent.h b/mono/mini/debugger-agent.h index 3891fb828558..1cef217a04dc 100644 --- a/mono/mini/debugger-agent.h +++ b/mono/mini/debugger-agent.h @@ -30,7 +30,7 @@ void #ifndef RUNTIME_IL2CPP debugger_agent_single_step_from_context (MonoContext *ctx); #else -debugger_agent_single_step_from_context (MonoContext *ctx, uint64_t sequencePointId); +debugger_agent_single_step_from_context (MonoContext *ctx, int sequencePointId); #endif void diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index ad27e8deba1a..229ccf5e5383 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -444,6 +444,6 @@ MonoGenericInst* il2cpp_method_get_generic_class_inst(MonoMethodInflated *imetho MonoClass* il2cpp_generic_class_get_container_class(MonoGenericClass *gclass); void il2cpp_mono_thread_detach(MonoThread* thread); MonoClass* il2cpp_mono_get_string_class (void); -Il2CppSequencePoint* il2cpp_get_sequence_point(size_t id); +Il2CppSequencePoint* il2cpp_get_sequence_point(int id); #endif // RUNTIME_IL2CPP diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index 22d21b2a2b7d..5d2678ac7407 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -1482,7 +1482,7 @@ MonoClass* il2cpp_mono_get_string_class (void) return (MonoClass*)il2cpp_defaults.string_class; } -Il2CppSequencePoint* il2cpp_get_sequence_point(size_t id) +Il2CppSequencePoint* il2cpp_get_sequence_point(int id) { #if IL2CPP_MONO_DEBUGGER return il2cpp::utils::Debugger::GetSequencePoint(id); From 3ea4ed4895fc5fc74e5ad71c4ec1cceb27f25944 Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 22 Jan 2018 16:46:23 +0100 Subject: [PATCH 124/582] [unitytls] Fixed type in interface: key_parse password is char/int8 not uint8 --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index c2b131c0ad7e..6ab0c550d7c2 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -177,9 +177,9 @@ public class unitytls_interface_struct public delegate unitytls_key_ref unitytls_key_get_ref_t(unitytls_key* key, unitytls_errorstate* errorState); public unitytls_key_get_ref_t unitytls_key_get_ref; - public delegate unitytls_key* unitytls_key_parse_pem_t(Int8* buffer, size_t bufferLen, UInt8* password, size_t passwordLen, unitytls_errorstate* errorState); + public delegate unitytls_key* unitytls_key_parse_pem_t(Int8* buffer, size_t bufferLen, Int8* password, size_t passwordLen, unitytls_errorstate* errorState); public unitytls_key_parse_der_t unitytls_key_parse_pem; - public delegate unitytls_key* unitytls_key_parse_der_t(UInt8* buffer, size_t bufferLen, UInt8* password, size_t passwordLen, unitytls_errorstate* errorState); + public delegate unitytls_key* unitytls_key_parse_der_t(UInt8* buffer, size_t bufferLen, Int8* password, size_t passwordLen, unitytls_errorstate* errorState); public unitytls_key_parse_der_t unitytls_key_parse_der; public delegate void unitytls_key_free_t(unitytls_key* key); public unitytls_key_free_t unitytls_key_free; From 71ad5455ce4fcac885bbb33f5980e1f1356e9cff Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Mon, 22 Jan 2018 16:32:44 -0500 Subject: [PATCH 125/582] Fixes an issue where a pipestream handle may be closed twice (Case 942966) --- mcs/class/System.Core/System.IO.Pipes/PipeStream.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcs/class/System.Core/System.IO.Pipes/PipeStream.cs b/mcs/class/System.Core/System.IO.Pipes/PipeStream.cs index d60b71b1f5b7..738342c76e88 100644 --- a/mcs/class/System.Core/System.IO.Pipes/PipeStream.cs +++ b/mcs/class/System.Core/System.IO.Pipes/PipeStream.cs @@ -137,7 +137,7 @@ internal Stream Stream { #pragma warning disable 618 stream = new FileStream (handle.DangerousGetHandle (), CanRead ? (CanWrite ? FileAccess.ReadWrite : FileAccess.Read) - : FileAccess.Write, true, buffer_size, IsAsync); + : FileAccess.Write, false, buffer_size, IsAsync); #pragma warning restore 618 } return stream; From 79f86ded49bb95e5db6f36b42663951489cd54e4 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 23 Jan 2018 10:32:55 -0500 Subject: [PATCH 126/582] Reuse class unload cache filter logic from metadata in debugger (case 974228) Debugger maintains it's own list of loaded classes. The unload/filter logic does not handle composite types like arrays and generic instances. Expose and reuse the logic from metadata that properly detects any usage of an image within a type. This prevents the cache from containing MonoClass values which have already been freed by the metadata cleaning code. --- mono/metadata/metadata-internals.h | 3 +++ mono/metadata/metadata.c | 6 ++++++ mono/mini/debugger-agent.c | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mono/metadata/metadata-internals.h b/mono/metadata/metadata-internals.h index e849706e19e9..1ad92b319a65 100644 --- a/mono/metadata/metadata-internals.h +++ b/mono/metadata/metadata-internals.h @@ -964,5 +964,8 @@ mono_loader_get_strict_strong_names (void); char* mono_signature_get_managed_fmt_string (MonoMethodSignature *sig); +gboolean +mono_type_in_image (MonoType *type, MonoImage *image); + #endif /* __MONO_METADATA_INTERNALS_H__ */ diff --git a/mono/metadata/metadata.c b/mono/metadata/metadata.c index b8cad0f3d584..378ceb4dc139 100644 --- a/mono/metadata/metadata.c +++ b/mono/metadata/metadata.c @@ -2401,6 +2401,12 @@ type_in_image (MonoType *type, MonoImage *image) } } +gboolean +mono_type_in_image (MonoType *type, MonoImage *image) +{ + return type_in_image (type, image); +} + static inline void image_sets_lock (void) { diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 7e1b375d9dfe..18960b58a905 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -8059,7 +8059,7 @@ clear_event_requests_for_assembly (MonoAssembly *assembly) static gboolean type_comes_from_assembly (gpointer klass, gpointer also_klass, gpointer assembly) { - return (mono_class_get_image ((MonoClass*)klass) == mono_assembly_get_image ((MonoAssembly*)assembly)); + return mono_type_in_image (mono_class_get_type ((MonoClass*)klass), mono_assembly_get_image ((MonoAssembly*)assembly)); } /* From c7ff2069b0747771c8a206925329cd1097567a2a Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 23 Jan 2018 15:14:36 -0500 Subject: [PATCH 127/582] Add legacy profiler support for allocations (case 988906) Return in Boehm 0 for number of managed allocators. If GC has no managed allocators, allow allocation profiling to be set lazily. --- mono/metadata/boehm-gc.c | 2 +- mono/metadata/profiler.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index 152047aaae5b..260a09842a69 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -1307,7 +1307,7 @@ mono_gc_get_managed_allocator_by_type (int atype, ManagedAllocatorVariant varian guint32 mono_gc_get_managed_allocator_types (void) { - return ATYPE_NUM; + return 0; } MonoMethod* diff --git a/mono/metadata/profiler.c b/mono/metadata/profiler.c index e1061c197cf1..274e4206ff2d 100644 --- a/mono/metadata/profiler.c +++ b/mono/metadata/profiler.c @@ -559,7 +559,7 @@ mono_profiler_sampling_thread_wait (void) mono_bool mono_profiler_enable_allocations (void) { - if (mono_profiler_state.startup_done) + if (mono_gc_get_managed_allocator_types () > 0 && mono_profiler_state.startup_done) return FALSE; return mono_profiler_state.allocations = TRUE; @@ -1105,6 +1105,9 @@ mono_profiler_set_events (int flags) else mono_profiler_set_call_instrumentation_filter_callback (current->handle, NULL); /* Do nothing. */ + + if (flags & MONO_PROFILE_ALLOCATIONS) + mono_profiler_enable_allocations (); } static void From 4ca758fe2045648f701e5898b72d650905528ff6 Mon Sep 17 00:00:00 2001 From: Pete Lewis Date: Mon, 24 Jul 2017 09:48:47 -0700 Subject: [PATCH 128/582] Add out of process crash handler APIs. Taken from https://github.com/PeteLewisUnity/mono/commits/unity-2017-02-staging-oop --- mono/metadata/jit-info.c | 2 + mono/metadata/oop.c | 434 ++++++++++++++++++++++ mono/mini/exceptions-amd64.c | 6 +- msvc/libmonoruntime-unity.targets | 1 + msvc/libmonoruntime-unity.targets.filters | 3 + msvc/libmonoruntime.vcxproj | 2 +- 6 files changed, 444 insertions(+), 4 deletions(-) create mode 100644 mono/metadata/oop.c diff --git a/mono/metadata/jit-info.c b/mono/metadata/jit-info.c index 3344679e8123..cc04f866005f 100644 --- a/mono/metadata/jit-info.c +++ b/mono/metadata/jit-info.c @@ -196,6 +196,8 @@ jit_info_table_chunk_index (MonoJitInfoTableChunk *chunk, MonoThreadHazardPointe return left; } +/* When changing this method, make sure to also update oop_jit_info_table_find + in mono/metadata/oop.c. */ static MonoJitInfo* jit_info_table_find (MonoJitInfoTable *table, MonoThreadHazardPointers *hp, gint8 *addr) { diff --git a/mono/metadata/oop.c b/mono/metadata/oop.c new file mode 100644 index 000000000000..9d8251ed37ff --- /dev/null +++ b/mono/metadata/oop.c @@ -0,0 +1,434 @@ +/* + * oop.c: These functions allow us to access the MonoDomain internals for purposes of post-mortem + * inspection by another process. All data is immutable: these calls are guaranteed to have no + * side-effects. These routines are not thread safe. This does not work with AOT modules. + * + * Author: + * Pete Lewis + * + * Copyright 2017 Unity Technologies (http://www.unity3d.com) + * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com) + * Copyright 2004-2009 Novell, Inc (http://www.novell.com) + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _M_X64 +#include +extern GList* g_dynamic_function_table_begin; +extern SRWLOCK g_dynamic_function_table_lock; +#endif + +// petele: todo: move this structure into a mono header +typedef struct _MonoStackFrameDetails +{ + char* methodName; + size_t methodNameLen; + char* className; + size_t classNameLen; + char* assemblyName; + size_t assemblyNameLen; +} MonoStackFrameDetails; + +typedef gboolean(*ReadMemoryCallback)(void* buffer, gsize* read, const void* address, gsize size, void* userdata); +typedef gboolean(*ReadExceptionCallback)(const void* address, gsize size, void* userdata); + +typedef struct _OutOfProcessMono +{ + ReadMemoryCallback readMemory; + ReadExceptionCallback readException; + void* userData; +} OutOfProcessMono; + +static OutOfProcessMono g_oop = { NULL, NULL }; + +#define OFFSET_MEMBER(type, base, member) ((gpointer)((gchar*)(base) + offsetof(type, member))) + +void read_exception(const void* address, gsize size) +{ + g_assert(g_oop.readException); + g_oop.readException(address, size, g_oop.userData); +} + +gsize read_memory(void* buffer, const void* address, gsize size) +{ + if (!buffer || !size) + return 0; + + gsize read = 0; + if (!g_oop.readMemory || !g_oop.readMemory(buffer, &read, address, size, g_oop.userData)) { + read_exception(address, size); + } + + return read; +} + +// Read a null-terminated string out-of-process +gsize read_nt_string(char* buffer, gsize max_size, const void* address) +{ + if (!buffer || !max_size) + return 0; + + if (!g_oop.readMemory) { + read_exception(address, 1); + return 0; + } + + gsize read = 0; + if (!g_oop.readMemory(buffer, &read, address, max_size, g_oop.userData)) { + // Failed to read, but just because we may not have read max_size, we still + // might be OK if at least one character was read (i.e. the null-terminator) + if (read == 0) + read_exception(address, 1); + } + + // Ensure there's a null-terminator + buffer[min(read, max_size-1)] = '\0'; + + return read; +} + +gpointer read_pointer(const void* address) +{ + gpointer ptr = NULL; + read_memory(&ptr, address, sizeof(ptr)); + return ptr; +} + +gint64 read_qword(const void* address) +{ + gint64 v = 0; + read_memory(&v, address, sizeof(v)); + return v; +} + +gint32 read_dword(const void* address) +{ + gint32 v = 0; + read_memory(&v, address, sizeof(v)); + return v; +} + +GList* read_glist_next(GList* list) { return (GList*) read_pointer(OFFSET_MEMBER(GList, list, next)); } +gpointer read_glist_data(GList* list) { return read_pointer(OFFSET_MEMBER(GList, list, data)); } + +MONO_API void +mono_unity_oop_init( + ReadMemoryCallback rmcb, + ReadExceptionCallback recb, + void* userdata) +{ + g_oop.readMemory = rmcb; + g_oop.readException = recb; + g_oop.userData = userdata; +} + +MONO_API void +mono_unity_oop_shutdown(void) +{ + memset(&g_oop, 0, sizeof(g_oop)); +} + +#ifdef _M_X64 +gboolean TryAcquireSpinWait(PSRWLOCK lock, unsigned int spinWait) +{ + do + { + if (TryAcquireSRWLockExclusive(&g_dynamic_function_table_lock)) + return TRUE; + } while (spinWait--); + + return FALSE; +} +#endif + +MONO_API GList* +mono_unity_lock_dynamic_function_access_tables64(unsigned int spinWait) +{ +#ifdef _M_X64 + if (spinWait >= 0x7fffffff) { + AcquireSRWLockExclusive(&g_dynamic_function_table_lock); + } + else if (!TryAcquireSpinWait(&g_dynamic_function_table_lock, spinWait)) { + return NULL; + } + return g_dynamic_function_table_begin; +#else + return NULL; +#endif +} + +MONO_API void +mono_unity_unlock_dynamic_function_access_tables64(void) +{ +#ifdef _M_X64 + ReleaseSRWLockExclusive(&g_dynamic_function_table_lock); +#else + return NULL; +#endif +} + +MONO_API GList* +mono_unity_oop_iterate_dynamic_function_access_tables64( + GList* current) +{ +#ifdef _M_X64 + if (current != NULL) + return read_glist_next(current); + else + return NULL; +#else + return NULL; +#endif +} + +MONO_API gboolean +mono_unity_oop_get_dynamic_function_access_table64( + GList* tableEntry, + gsize* moduleStart, + gsize* moduleEnd, + void** functionTable, + gsize* functionTableSize) +{ +#ifdef _M_X64 + if (!tableEntry || !moduleStart || !moduleEnd || !functionTable || !functionTableSize) + return FALSE; + + const DynamicFunctionTableEntry* entry = read_glist_data(tableEntry); + *moduleStart = read_qword(OFFSET_MEMBER(DynamicFunctionTableEntry, entry, begin_range)); + *moduleEnd = read_qword(OFFSET_MEMBER(DynamicFunctionTableEntry, entry, end_range)); + *functionTable = read_pointer(OFFSET_MEMBER(DynamicFunctionTableEntry, entry, rt_funcs)); + *functionTableSize = read_dword(OFFSET_MEMBER(DynamicFunctionTableEntry, entry, rt_funcs_max_count)); + + return TRUE; +#else + return FALSE; +#endif +} + +static int oop_jit_info_table_index( + const MonoJitInfoTableChunk** chunks, // non-local + int num_chunks, + const gint8* addr) +{ + static const int error = 0x7fffffff; + + int left = 0, right = num_chunks; + + g_assert(left < right); + + do { + const MonoJitInfoTableChunk* chunkPtr; + const gint8* last_code_end; + int pos = (left + right) / 2; + + chunkPtr = read_pointer(chunks + pos); + if (chunkPtr == NULL) + return error; + + last_code_end = read_pointer(OFFSET_MEMBER(MonoJitInfoTableChunk, chunkPtr, last_code_end)); + if (last_code_end == NULL) + return error; + + if (addr < last_code_end) + right = pos; + else + left = pos + 1; + } while (left < right); + g_assert(left == right); + + if (left >= num_chunks) + return num_chunks - 1; + return left; +} + +static int +oop_jit_info_table_chunk_index( + const MonoJitInfo** chunk_data, + int num_elements, + const gint8 *addr) +{ + const MonoJitInfo* ji; + int left = 0, right = num_elements; + + while (left < right) { + int pos = (left + right) / 2; + + const gint8 *code_start; + const gint8 *code_end; + int code_size; + + ji = chunk_data[pos]; + + code_start = (const gint8*)read_pointer(OFFSET_MEMBER(MonoJitInfo, ji, code_start)); + code_size = read_dword(OFFSET_MEMBER(MonoJitInfo, ji, code_size)); + code_end = code_start + code_size; + + if (addr < code_end) + right = pos; + else + left = pos + 1; + } + + g_assert(left == right); + + return left; +} + +/* This method is an out-of-process version of jit_info_table_find. */ +static const MonoJitInfo* +oop_jit_info_table_find( + const MonoDomain *domain, + const char *addr, + gboolean allow_trampolines) +{ + const MonoJitInfoTable* tablePtr; + const MonoJitInfoTableChunk** chunkListPtr; + MonoJitInfoTableChunk chunk; + MonoJitInfo ji; + int chunk_pos, pos; + + // Get the domain's jit_info_table pointer. + tablePtr = read_pointer(OFFSET_MEMBER(MonoDomain, domain, jit_info_table)); + if (tablePtr == NULL) + return NULL; + + int num_chunks = read_dword(OFFSET_MEMBER(MonoJitInfoTable, tablePtr, num_chunks)); + + // Get the chunk array + chunkListPtr = (const MonoJitInfoTableChunk**)OFFSET_MEMBER(MonoJitInfoTable, tablePtr, chunks); + + chunk_pos = oop_jit_info_table_index(chunkListPtr, num_chunks, (const gint8*)addr); + if (chunk_pos > num_chunks) + return NULL; + + // read the entire chunk + read_memory(&chunk, read_pointer(chunkListPtr + chunk_pos), sizeof(MonoJitInfoTableChunk)); + + pos = oop_jit_info_table_chunk_index((const MonoJitInfo**)chunk.data, chunk.num_elements, addr); + if (pos > chunk.num_elements) + return NULL; + + /* We now have a position that's very close to that of the + first element whose end address is higher than the one + we're looking for. If we don't have the exact position, + then we have a position below that one, so we'll just + search upward until we find our element. */ + do { + read_memory(&chunk, read_pointer(chunkListPtr + chunk_pos), sizeof(MonoJitInfoTableChunk)); + + while (pos < chunk.num_elements) { + read_memory(&ji, chunk.data[pos], sizeof(ji)); + + ++pos; + + if (ji.d.method == NULL) { + continue; + } + if ((gint8*)addr >= (gint8*)ji.code_start + && (gint8*)addr < (gint8*)ji.code_start + ji.code_size) { + if (ji.is_trampoline && !allow_trampolines) { + return NULL; + } + return chunk.data[pos-1]; + } + + /* If we find a non-tombstone element which is already + beyond what we're looking for, we have to end the + search. */ + if ((gint8*)addr < (gint8*)ji.code_start) + return NULL; + } + + ++chunk_pos; + pos = 0; + } while (chunk_pos < num_chunks); + + return NULL; +} + +int +mono_unity_oop_get_stack_frame_details( + const MonoDomain* domain, + const void* frameAddress, + MonoStackFrameDetails* frameDetails) +{ + const MonoJitInfo* ji; + + ji = oop_jit_info_table_find(domain, (const char*)frameAddress, FALSE); + if (ji) + { + const MonoMethod* method = read_pointer(OFFSET_MEMBER(MonoJitInfo, ji, d.method)); + const MonoClass* klass = read_pointer(OFFSET_MEMBER(MonoMethod, method, klass)); + const MonoImage* image = read_pointer(OFFSET_MEMBER(MonoClass, klass, image)); + size_t classNameLen = max(frameDetails->classNameLen, 256); + char* className = (char*)malloc(classNameLen); + char* nsName = (char*)malloc(classNameLen); + + frameDetails->methodNameLen = read_nt_string( + frameDetails->methodName, + frameDetails->methodNameLen, + read_pointer(OFFSET_MEMBER(MonoMethod, method, name))); + + if (frameDetails->className && frameDetails->classNameLen > 0) { + read_nt_string( + nsName, + classNameLen, + read_pointer(OFFSET_MEMBER(MonoClass, klass, name_space))); + + read_nt_string( + className, + classNameLen, + read_pointer(OFFSET_MEMBER(MonoClass, klass, name))); + + if (*nsName) { + frameDetails->classNameLen = sprintf_s( + frameDetails->className, + frameDetails->classNameLen, + "%s.%s", + nsName, + className); + } else { + frameDetails->classNameLen = sprintf_s( + frameDetails->className, + frameDetails->classNameLen, + "%s", + className); + } + } + + frameDetails->assemblyNameLen = read_nt_string( + frameDetails->assemblyName, + frameDetails->assemblyNameLen, + read_pointer(OFFSET_MEMBER(MonoImage, image, assembly_name))); + + free(className); + free(nsName); + + return TRUE; + } + + return FALSE; +} diff --git a/mono/mini/exceptions-amd64.c b/mono/mini/exceptions-amd64.c index 5a4c0fdfce40..1773c784acec 100644 --- a/mono/mini/exceptions-amd64.c +++ b/mono/mini/exceptions-amd64.c @@ -1069,11 +1069,11 @@ mono_arch_unwindinfo_add_alloc_stack (PUNWIND_INFO unwindinfo, MonoUnwindOp *unw static gboolean g_dyn_func_table_inited; // Dynamic function table used when registering unwind info for OS unwind support. -static GList *g_dynamic_function_table_begin; -static GList *g_dynamic_function_table_end; +GList *g_dynamic_function_table_begin; +GList *g_dynamic_function_table_end; // SRW lock (lightweight read/writer lock) protecting dynamic function table. -static SRWLOCK g_dynamic_function_table_lock = SRWLOCK_INIT; +SRWLOCK g_dynamic_function_table_lock = SRWLOCK_INIT; // Module handle used when explicit loading ntdll. static HMODULE g_ntdll; diff --git a/msvc/libmonoruntime-unity.targets b/msvc/libmonoruntime-unity.targets index 4a7c19738af5..6ab9b117ab82 100644 --- a/msvc/libmonoruntime-unity.targets +++ b/msvc/libmonoruntime-unity.targets @@ -7,5 +7,6 @@ + diff --git a/msvc/libmonoruntime-unity.targets.filters b/msvc/libmonoruntime-unity.targets.filters index 46ccf1069f0d..d01749153e47 100644 --- a/msvc/libmonoruntime-unity.targets.filters +++ b/msvc/libmonoruntime-unity.targets.filters @@ -19,6 +19,9 @@ Source Files$(MonoRuntimeFilterSubFolder)\unity + + Source Files$(MonoRuntimeFilterSubFolder)\unity + diff --git a/msvc/libmonoruntime.vcxproj b/msvc/libmonoruntime.vcxproj index b9b512dddb3c..287a7c1236e3 100644 --- a/msvc/libmonoruntime.vcxproj +++ b/msvc/libmonoruntime.vcxproj @@ -170,4 +170,4 @@ - \ No newline at end of file + From f26d7c9afe73b2098961fb0a8cadb04b3b49ba98 Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Thu, 25 Jan 2018 12:24:43 -0500 Subject: [PATCH 129/582] adds the option to build android runtime with windows subsystem for linux --- external/buildscripts/build_runtime_android.pl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/external/buildscripts/build_runtime_android.pl b/external/buildscripts/build_runtime_android.pl index 2bcbb6eb6d8c..b827b191968e 100644 --- a/external/buildscripts/build_runtime_android.pl +++ b/external/buildscripts/build_runtime_android.pl @@ -10,21 +10,23 @@ my $androidArch = ""; my $clean = 1; +my $windowsSubsystemForLinux = 0; GetOptions( "androidarch=s"=>\$androidArch, "clean=i"=>\$clean, + "windowssubsystemforlinux=i"=>\$windowsSubsystemForLinux, ) or die ("illegal cmdline options"); # By default, build runtime for all the variants we need. But allow something to specify an individual variation to build if ($androidArch eq "") { - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv5", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for armv5\n"); - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv6_vfp", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for armv6_vfp\n"); - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv7a", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for armv7a\n"); - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=x86", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for x86\n"); + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv5", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv5\n"); + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv6_vfp", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv6_vfp\n"); + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv7a", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv7a\n"); + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=x86", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for x86\n"); } else { - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--androidarch=$androidArch", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for $androidArch\n"); + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--androidarch=$androidArch", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for $androidArch\n"); } From 95ab5eb90b53449e7d71f9bad660b33139bc75ad Mon Sep 17 00:00:00 2001 From: Brian Raderman Date: Thu, 25 Jan 2018 13:47:05 -0500 Subject: [PATCH 130/582] Fixes for il2cpp debugger running with Visual Studio for Mac: * Returning an empty "list" of custom attributes for types, fields, properties, and methods instead of a not-implemented error. * Updating debugger ASSEMBLY_GET_NAME command to use Il2Cpp code for generating the fully qualified name with public key tokens. The Mono code generates invalid strings for the token with the Il2Cpp assembly name data, which will cause the VSfM debug client to disconnect. --- mono/mini/debugger-agent.c | 17 ++++++++++++----- mono/mini/il2cpp-compat.h | 1 + mono/mini/il2cpp-stubs.cpp | 7 +++++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 18960b58a905..2bf93d94a09e 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -9418,6 +9418,9 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) case CMD_ASSEMBLY_GET_NAME: { gchar *name; MonoAssembly *mass = ass; +#ifdef RUNTIME_IL2CPP + name = il2cpp_assembly_get_full_name(mass); +#else name = g_strdup_printf ( "%s, Version=%d.%d.%d.%d, Culture=%s, PublicKeyToken=%s%s", mass->aname.name, @@ -9425,7 +9428,7 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) mass->aname.culture && *mass->aname.culture ? mass->aname.culture : "neutral", mass->aname.public_key_token[0] ? (char *)mass->aname.public_key_token : "null", (mass->aname.flags & ASSEMBLYREF_RETARGETABLE_FLAG) ? ", Retargetable=Yes" : ""); - +#endif buffer_add_string (buf, name); g_free (name); break; @@ -9775,7 +9778,8 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint return err; break; #else - return ERR_NOT_IMPLEMENTED; + buffer_add_int (buf, 0); + return ERR_NONE; #endif //RUNTIME_IL2CPP } case CMD_TYPE_GET_FIELD_CATTRS: { @@ -9802,7 +9806,8 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint return err; break; #else - return ERR_NOT_IMPLEMENTED; + buffer_add_int (buf, 0); + return ERR_NONE; #endif //RUNTIME_IL2CPP } case CMD_TYPE_GET_PROPERTY_CATTRS: { @@ -9829,7 +9834,8 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint return err; break; #else - return ERR_NOT_IMPLEMENTED; + buffer_add_int (buf, 0); + return ERR_NONE; #endif //RUNTIME_IL2CPP } case CMD_TYPE_GET_VALUES: @@ -10707,7 +10713,8 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g return err; break; #else - return ERR_NOT_IMPLEMENTED; + buffer_add_int (buf, 0); + return ERR_NONE; #endif //RUNTIME_IL2CPP } case CMD_METHOD_MAKE_GENERIC_METHOD: { diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index 229ccf5e5383..9ace27b5d6b5 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -445,5 +445,6 @@ MonoClass* il2cpp_generic_class_get_container_class(MonoGenericClass *gclass); void il2cpp_mono_thread_detach(MonoThread* thread); MonoClass* il2cpp_mono_get_string_class (void); Il2CppSequencePoint* il2cpp_get_sequence_point(int id); +char* il2cpp_assembly_get_full_name(MonoAssembly *assembly); #endif // RUNTIME_IL2CPP diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index 5d2678ac7407..e2a72d2e01e8 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -1490,5 +1490,12 @@ Il2CppSequencePoint* il2cpp_get_sequence_point(int id) return NULL; #endif } + +char* il2cpp_assembly_get_full_name(MonoAssembly *assembly) +{ + std::string s = il2cpp::vm::AssemblyName::AssemblyNameToString(assembly->aname); + return g_strdup(s.c_str()); +} + } #endif // RUNTIME_IL2CPP From 7c0dec0c64f189ae13e2dfdd6f6c86b269d2c9fe Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 28 Jul 2017 10:20:29 -0400 Subject: [PATCH 131/582] Remove extra reference count on images loaded via byte array (case 923165) --- mono/metadata/appdomain.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mono/metadata/appdomain.c b/mono/metadata/appdomain.c index 304432e39c34..3234f6228ea9 100644 --- a/mono/metadata/appdomain.c +++ b/mono/metadata/appdomain.c @@ -2175,6 +2175,9 @@ ves_icall_System_AppDomain_LoadAssemblyRaw (MonoAppDomainHandle ad, return refass; } + /* Clear the reference added by mono_image_open_from_data_full above */ + mono_image_close (image); + refass = mono_assembly_get_object_handle (domain, ass, error); if (!MONO_HANDLE_IS_NULL(refass)) MONO_HANDLE_SET (refass, evidence, evidence); From 5ef7ea586aafcaf68d92f9e7f089bc6cc3327133 Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Thu, 25 Jan 2018 16:13:30 -0500 Subject: [PATCH 132/582] Fix issue on android where HTTPClient.GetAsync will fail with libc error (case 935292) --- .../IPGlobalProperties.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs b/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs index 92bd3ffb363e..b93b53ae0a28 100644 --- a/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs +++ b/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs @@ -59,8 +59,17 @@ public override string DhcpScopeName { public override string DomainName { get { byte [] bytes = new byte [256]; - if (getdomainname (bytes, 256) != 0) - throw new NetworkInformationException (); +#if UNITY + try + { +#endif + if (getdomainname (bytes, 256) != 0) + throw new NetworkInformationException (); +#if UNITY + } catch (EntryPointNotFoundException) { + return String.Empty; + } +#endif int len = Array.IndexOf (bytes, 0); return Encoding.ASCII.GetString (bytes, 0, len < 0 ? 256 : len); } From 59240d127dcc1d77463e91add37eb3f221687f2d Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Thu, 25 Jan 2018 17:14:24 -0500 Subject: [PATCH 133/582] Revert il2cpp as dependency of mono f16d00efca44d61f69450d5d9e45aef020642b5e --- external/buildscripts/build.pl | 13 ------------- external/buildscripts/build_win_no_cygwin.pl | 13 ------------- external/buildscripts/build_win_wrapper.pl | 13 ------------- 3 files changed, 39 deletions(-) diff --git a/external/buildscripts/build.pl b/external/buildscripts/build.pl index 49f28ec72b19..f186145f0e90 100644 --- a/external/buildscripts/build.pl +++ b/external/buildscripts/build.pl @@ -166,7 +166,6 @@ # Do any settings agnostic per-platform stuff my $externalBuildDeps = ""; -my $externalBuildDepsIl2Cpp = "$monoroot/../../il2cpp/build"; if ($buildDeps ne "" && not $forceDefaultBuildDeps) { @@ -296,18 +295,6 @@ $externalBuildDeps = abs_path($externalBuildDeps) if (-d $externalBuildDeps); } - if (!(-d "$externalBuildDepsIl2Cpp")) - { - my $il2cpp_repo = "https://bitbucket.org/Unity-Technologies/il2cpp"; - print(">>> Cloning $il2cpp_repo at $externalBuildDepsIl2Cpp\n"); - $checkoutResult = system("hg", "clone", $il2cpp_repo, "$externalBuildDepsIl2Cpp"); - - if ($checkoutOnTheFly && $checkoutResult ne 0) - { - die("failed to checkout IL2CPP for the mono build dependencies\n"); - } - } - if (-d "$existingExternalMono") { print(">>> External mono found at : $existingExternalMono\n"); diff --git a/external/buildscripts/build_win_no_cygwin.pl b/external/buildscripts/build_win_no_cygwin.pl index 36bf68f24a0f..17c0d6927a92 100644 --- a/external/buildscripts/build_win_no_cygwin.pl +++ b/external/buildscripts/build_win_no_cygwin.pl @@ -65,7 +65,6 @@ # Do any settings agnostic per-platform stuff my $externalBuildDeps = ""; -my $externalBuildDepsIl2Cpp = "$monoroot/../../il2cpp/build"; if ($buildDeps ne "" && not $forceDefaultBuildDeps) { @@ -112,18 +111,6 @@ } } - if (!(-d "$externalBuildDepsIl2Cpp")) - { - my $il2cpp_repo = "https://bitbucket.org/Unity-Technologies/il2cpp"; - print(">>> Cloning $il2cpp_repo at $externalBuildDepsIl2Cpp\n"); - $checkoutResult = system("hg", "clone", $il2cpp_repo, "$externalBuildDepsIl2Cpp"); - - if ($checkoutOnTheFly && $checkoutResult ne 0) - { - die("failed to checkout IL2CPP for the mono build dependencies\n"); - } - } - if (-d "$existingExternalMono") { print(">>> External mono found at : $existingExternalMono\n"); diff --git a/external/buildscripts/build_win_wrapper.pl b/external/buildscripts/build_win_wrapper.pl index a160730672ce..bbe16f80b94b 100644 --- a/external/buildscripts/build_win_wrapper.pl +++ b/external/buildscripts/build_win_wrapper.pl @@ -66,7 +66,6 @@ ); my $externalBuildDeps = ""; -my $externalBuildDepsIl2Cpp = "$monoroot/../../il2cpp/build"; if ($buildDeps ne "") { @@ -97,18 +96,6 @@ die("failed to checkout mono build dependencies\n"); } } - - if (!(-d "$externalBuildDepsIl2Cpp")) - { - my $il2cpp_repo = "https://bitbucket.org/Unity-Technologies/il2cpp"; - print(">>> Cloning $il2cpp_repo at $externalBuildDepsIl2Cpp\n"); - $checkoutResult = system("hg", "clone", $il2cpp_repo, "$externalBuildDepsIl2Cpp"); - - if ($checkoutOnTheFly && $checkoutResult ne 0) - { - die("failed to checkout IL2CPP for the mono build dependencies\n"); - } - } } print(">>> externalBuildDeps = $externalBuildDeps\n"); From 155ca60a7b8caf3cd667f1b2444e6d6f7aa5c30d Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 26 Jan 2018 15:23:10 -0500 Subject: [PATCH 134/582] Implement path remapping support (case 992909) This was previously stubbed out when rebasing onto mono master branch. --- mono/metadata/image.c | 14 ++--- mono/metadata/loader.c | 10 +-- mono/metadata/unity-utils.c | 95 +++++++++++++--------------- mono/metadata/unity-utils.h | 11 ++-- mono/metadata/w32file.c | 121 +++++++++++++++++++++++++++++------- 5 files changed, 160 insertions(+), 91 deletions(-) diff --git a/mono/metadata/image.c b/mono/metadata/image.c index 6a0601d02e8f..b0b9b285ae58 100644 --- a/mono/metadata/image.c +++ b/mono/metadata/image.c @@ -1360,8 +1360,9 @@ do_mono_image_open (const char *fname, MonoImageOpenStatus *status, MonoCLIImageInfo *iinfo; MonoImage *image; MonoFileMap *filed; - - gboolean remapped = mono_unity_file_remap_path(&fname); + const char *fname_remap; + if (fname_remap = mono_unity_remap_path (fname)) + fname = fname_remap; if ((filed = mono_file_map_open (fname)) == NULL){ if (IS_PORTABILITY_SET) { @@ -1375,8 +1376,7 @@ do_mono_image_open (const char *fname, MonoImageOpenStatus *status, if (filed == NULL) { if (status) *status = MONO_IMAGE_ERROR_ERRNO; - if (remapped) - g_free((void*)fname); + g_free((void*)fname_remap); return NULL; } } @@ -1396,8 +1396,7 @@ do_mono_image_open (const char *fname, MonoImageOpenStatus *status, g_free (image); if (status) *status = MONO_IMAGE_IMAGE_INVALID; - if (remapped) - g_free((void*)fname); + g_free((void*)fname_remap); return NULL; } iinfo = g_new0 (MonoCLIImageInfo, 1); @@ -1411,8 +1410,7 @@ do_mono_image_open (const char *fname, MonoImageOpenStatus *status, image->core_clr_platform_code = mono_security_core_clr_determine_platform_image (image); mono_file_map_close (filed); - if (remapped) - g_free((void*)fname); + g_free((void*)fname_remap); return do_mono_image_load (image, status, care_about_cli, care_about_pecoff); } diff --git a/mono/metadata/loader.c b/mono/metadata/loader.c index 45bfceac6b37..c2a959705486 100644 --- a/mono/metadata/loader.c +++ b/mono/metadata/loader.c @@ -1115,26 +1115,26 @@ static MonoDl* cached_module_load (const char *name, int flags, char **err) { MonoDl *res; + const char *name_remap; if (err) *err = NULL; - gboolean remapped = mono_unity_file_remap_path(&name); + if (name_remap = mono_unity_remap_path (name)) + name = name_remap; global_loader_data_lock (); if (!global_module_map) global_module_map = g_hash_table_new (g_str_hash, g_str_equal); res = (MonoDl *)g_hash_table_lookup (global_module_map, name); if (res) { global_loader_data_unlock (); - if (remapped) - g_free((void*)name); + g_free((void*)name_remap); return res; } res = mono_dl_open (name, flags, err); if (res) g_hash_table_insert (global_module_map, g_strdup (name), res); global_loader_data_unlock (); - if (remapped) - g_free((void*)name); + g_free((void*)name_remap); return res; } diff --git a/mono/metadata/unity-utils.c b/mono/metadata/unity-utils.c index 6527c1b3ba26..d1ddb0bc8a2a 100644 --- a/mono/metadata/unity-utils.c +++ b/mono/metadata/unity-utils.c @@ -1197,6 +1197,12 @@ size_t RemapPathFunction (const char* path, char* buffer, size_t buffer_len) */ static RemapPathFunction g_RemapPathFunc = NULL; +void +mono_unity_register_path_remapper (RemapPathFunction func) +{ + g_RemapPathFunc = func; +} + /* calls remapper function if registered; allocates memory if remapping is available */ static inline size_t call_remapper(const char* path, char** buf) @@ -1204,7 +1210,7 @@ call_remapper(const char* path, char** buf) size_t len; if (!g_RemapPathFunc) - return FALSE; + return 0; *buf = NULL; len = g_RemapPathFunc(path, *buf, 0); @@ -1218,80 +1224,67 @@ call_remapper(const char* path, char** buf) return len; } -/* updates 'path' if remapping is available; returns TRUE if updated (path must be free()'d) */ -gboolean -mono_unity_file_remap_path(const char** path) +MonoBoolean +ves_icall_System_IO_MonoIO_RemapPath (MonoString *path, MonoString **new_path) { - size_t len; - char * buf; + MonoError error; + const gunichar2* path_remapped; - len = call_remapper(*path, &buf); - if (len == 0) + if (!g_RemapPathFunc) + return 0; + + path_remapped = mono_unity_remap_path_utf16 (mono_string_chars (path)); + + if (!path_remapped) return FALSE; - *path = buf; + mono_gc_wbarrier_generic_store (new_path, (MonoObject*)mono_string_from_utf16_checked (path_remapped, &error)); + + g_free (path_remapped); + + mono_error_set_pending_exception (&error); + return TRUE; } +const char* +mono_unity_remap_path (const char* path) +{ + const char* path_remap = NULL; + call_remapper (path, &path_remap); + return path_remap; +} -/* sets 'new_path', and returns TRUE, if remapping is available */ -static gboolean -remap_path (MonoString *path, MonoString** new_path) +const gunichar2* +mono_unity_remap_path_utf16 (const gunichar2* path) { - MonoError error; - MonoString * str; + const gunichar2* path_remap = NULL; char * utf8_path; char * buf; char * path_end; size_t len; - *new_path = NULL; - if (!g_RemapPathFunc) - return FALSE; + return path_remap; - utf8_path = mono_string_to_utf8_ignore(path); - len = call_remapper(utf8_path, &buf); + utf8_path = g_utf16_to_utf8 (path, -1, NULL, NULL, NULL); + len = call_remapper (utf8_path, &buf); if (len == 0) { - g_free(utf8_path); - return FALSE; + g_free (utf8_path); + return path_remap; } - path_end = memchr(buf, '\0', len); - len = path_end ? (size_t) (path_end - buf) : len; - str = mono_string_new_len_checked (mono_domain_get (), buf, (guint)len, &error); + path_end = memchr (buf, '\0', len); + len = path_end ? (size_t)(path_end - buf) : len; - g_free(utf8_path); - g_free (buf); + path_remap = g_utf8_to_utf16 (buf, len, NULL, NULL, NULL); - mono_gc_wbarrier_generic_store(new_path, (MonoObject*)str); - mono_error_set_pending_exception (&error); - - return *new_path ? TRUE : FALSE; -} - -/* returns remapped path, if remapping is available. otherwise returns original path */ -const gunichar2 * -mono_unity_get_remapped_path (const gunichar2 *path) -{ - // JON TODO: - return path; - //MonoString * new_path; - //return remap_path(path, &new_path) ? new_path : path; -} - -MonoBoolean -ves_icall_System_IO_MonoIO_RemapPath (MonoString *path, MonoString **new_path) -{ - return remap_path(path, new_path); -} + g_free (utf8_path); + g_free (buf); -void -mono_unity_register_path_remapper(RemapPathFunction func) -{ - g_RemapPathFunc = func; + return path_remap; } MonoMethod* diff --git a/mono/metadata/unity-utils.h b/mono/metadata/unity-utils.h index ba20e7d0b15a..d4c19aa043b2 100644 --- a/mono/metadata/unity-utils.h +++ b/mono/metadata/unity-utils.h @@ -172,12 +172,15 @@ MONO_API MonoClass* mono_custom_attrs_get_attrs (MonoCustomAttrInfo *ainfo, gpoi typedef size_t (*RemapPathFunction)(const char* path, char* buffer, size_t buffer_len); MONO_API void mono_unity_register_path_remapper (RemapPathFunction func); -gboolean -mono_unity_file_remap_path(const char** path); + +const char* +mono_unity_remap_path (const char* path); + +const gunichar2* +mono_unity_remap_path_utf16 (const gunichar2* path); + MonoBoolean ves_icall_System_IO_MonoIO_RemapPath (MonoString *path, MonoString **new_path); -const gunichar2 * -mono_unity_get_remapped_path (const gunichar2 *path); MonoMethod* mono_method_get_method_definition(MonoMethod *method); diff --git a/mono/metadata/w32file.c b/mono/metadata/w32file.c index b9dfca997f30..78569331c169 100644 --- a/mono/metadata/w32file.c +++ b/mono/metadata/w32file.c @@ -191,8 +191,11 @@ MonoBoolean ves_icall_System_IO_MonoIO_CreateDirectory (const gunichar2 *path, gint32 *error) { gboolean ret; - path = mono_unity_get_remapped_path(path); + const gunichar2 *path_remapped; + if (path_remapped = mono_unity_remap_path_utf16 (path)) + path = path_remapped; + *error=ERROR_SUCCESS; ret=mono_w32file_create_directory (path); @@ -200,6 +203,8 @@ ves_icall_System_IO_MonoIO_CreateDirectory (const gunichar2 *path, gint32 *error *error=mono_w32error_get_last (); } + g_free (path_remapped); + return(ret); } @@ -207,7 +212,10 @@ MonoBoolean ves_icall_System_IO_MonoIO_RemoveDirectory (const gunichar2 *path, gint32 *error) { gboolean ret; - path = mono_unity_get_remapped_path(path); + const gunichar2 *path_remapped; + + if (path_remapped = mono_unity_remap_path_utf16 (path)) + path = path_remapped; *error=ERROR_SUCCESS; @@ -216,6 +224,8 @@ ves_icall_System_IO_MonoIO_RemoveDirectory (const gunichar2 *path, gint32 *error *error=mono_w32error_get_last (); } + g_free (path_remapped); + return(ret); } @@ -224,7 +234,10 @@ ves_icall_System_IO_MonoIO_FindFirstFile (const gunichar2 *path_with_pattern, Mo { HANDLE hnd; WIN32_FIND_DATA data; - path_with_pattern = mono_unity_get_remapped_path(path_with_pattern); + const gunichar2 *path_with_pattern_remapped; + + if (path_with_pattern_remapped = mono_unity_remap_path_utf16 (path_with_pattern)) + path_with_pattern = path_with_pattern_remapped; hnd = mono_w32file_find_first (path_with_pattern, &data); @@ -232,6 +245,7 @@ ves_icall_System_IO_MonoIO_FindFirstFile (const gunichar2 *path_with_pattern, Mo MONO_HANDLE_ASSIGN (file_name, NULL_HANDLE_STRING); *file_attr = 0; *ioerror = mono_w32error_get_last (); + g_free (path_with_pattern_remapped); return hnd; } @@ -243,6 +257,7 @@ ves_icall_System_IO_MonoIO_FindFirstFile (const gunichar2 *path_with_pattern, Mo *file_attr = data.dwFileAttributes; *ioerror = ERROR_SUCCESS; + g_free (path_with_pattern_remapped); return hnd; } @@ -319,7 +334,10 @@ ves_icall_System_IO_MonoIO_SetCurrentDirectory (const gunichar2 *path, gint32 *error) { gboolean ret; - path = mono_unity_get_remapped_path(path); + const gunichar2 *path_remapped; + + if (path_remapped = mono_unity_remap_path_utf16 (path)) + path = path_remapped; *error=ERROR_SUCCESS; @@ -327,21 +345,31 @@ ves_icall_System_IO_MonoIO_SetCurrentDirectory (const gunichar2 *path, if(ret==FALSE) { *error=mono_w32error_get_last (); } - + + g_free (path_remapped); + return(ret); } MonoBoolean ves_icall_System_IO_MonoIO_MoveFile (const gunichar2 *path, const gunichar2 *dest, gint32 *error) { - // TODO_UNITY gboolean ret; - - path = mono_unity_get_remapped_path(path); - dest = mono_unity_get_remapped_path(dest); + const gunichar2 *path_remapped; + const gunichar2 *dest_remapped; + + if (path_remapped = mono_unity_remap_path_utf16 (path)) + path = path_remapped; + if (dest_remapped = mono_unity_remap_path_utf16 (dest)) + dest = dest_remapped; *error=ERROR_SUCCESS; - return mono_w32file_move (path, dest, error); + ret = mono_w32file_move (path, dest, error); + + g_free (path_remapped); + g_free (dest_remapped); + + return ret; } MonoBoolean @@ -349,35 +377,63 @@ ves_icall_System_IO_MonoIO_ReplaceFile (const gunichar2 *source_file_name, const const gunichar2 *destination_backup_file_name, MonoBoolean ignore_metadata_errors, gint32 *error) { + gboolean ret; guint32 replace_flags = REPLACEFILE_WRITE_THROUGH; - source_file_name = mono_unity_get_remapped_path(source_file_name); - destination_file_name = mono_unity_get_remapped_path(destination_file_name); - destination_backup_file_name = mono_unity_get_remapped_path(destination_backup_file_name); + const gunichar2 *source_file_name_remapped; + const gunichar2 *destination_file_name_remapped; + const gunichar2 *destination_backup_file_name_remapped; + if (source_file_name_remapped = mono_unity_remap_path_utf16 (source_file_name)) + source_file_name = source_file_name_remapped; + if (destination_file_name_remapped = mono_unity_remap_path_utf16 (destination_file_name)) + destination_file_name = destination_file_name_remapped; + if (destination_backup_file_name_remapped = mono_unity_remap_path_utf16 (destination_backup_file_name)) + destination_backup_file_name = destination_backup_file_name_remapped; *error = ERROR_SUCCESS; if (ignore_metadata_errors) replace_flags |= REPLACEFILE_IGNORE_MERGE_ERRORS; /* FIXME: source and destination file names must not be NULL, but apparently they might be! */ - return mono_w32file_replace (destination_file_name, source_file_name, + ret = mono_w32file_replace (destination_file_name, source_file_name, destination_backup_file_name, replace_flags, error); + + g_free (source_file_name_remapped); + g_free (destination_file_name_remapped); + g_free (destination_backup_file_name_remapped); + + return ret; } MonoBoolean ves_icall_System_IO_MonoIO_CopyFile (const gunichar2 *path, const gunichar2 *dest, MonoBoolean overwrite, gint32 *error) { - path = mono_unity_get_remapped_path(path); - dest = mono_unity_get_remapped_path(dest); + gboolean ret; + const gunichar2 *path_remapped; + const gunichar2 *dest_remapped; + + if (path_remapped = mono_unity_remap_path_utf16 (path)) + path = path_remapped; + if (dest_remapped = mono_unity_remap_path_utf16 (dest)) + dest = dest_remapped; + *error=ERROR_SUCCESS; - return mono_w32file_copy (path, dest, overwrite, error); + ret = mono_w32file_copy (path, dest, overwrite, error); + + g_free (path_remapped); + g_free (dest_remapped); + + return ret; } MonoBoolean ves_icall_System_IO_MonoIO_DeleteFile (const gunichar2 *path, gint32 *error) { gboolean ret; - path = mono_unity_get_remapped_path(path); + const gunichar2 *path_remapped; + + if (path_remapped = mono_unity_remap_path_utf16 (path)) + path = path_remapped; *error=ERROR_SUCCESS; @@ -385,6 +441,8 @@ ves_icall_System_IO_MonoIO_DeleteFile (const gunichar2 *path, gint32 *error) if(ret==FALSE) { *error=mono_w32error_get_last (); } + + g_free (path_remapped); return(ret); } @@ -393,7 +451,11 @@ gint32 ves_icall_System_IO_MonoIO_GetFileAttributes (const gunichar2 *path, gint32 *error) { gint32 ret; - path = mono_unity_get_remapped_path(path); + const gunichar2 *path_remapped; + + if (path_remapped = mono_unity_remap_path_utf16 (path)) + path = path_remapped; + *error=ERROR_SUCCESS; ret = mono_w32file_get_attributes (path); @@ -408,6 +470,9 @@ ves_icall_System_IO_MonoIO_GetFileAttributes (const gunichar2 *path, gint32 *err /* if(ret==INVALID_FILE_ATTRIBUTES) { */ *error=mono_w32error_get_last (); } + + g_free (path_remapped); + return(ret); } @@ -448,7 +513,10 @@ MonoBoolean ves_icall_System_IO_MonoIO_GetFileStat (const gunichar2 *path, MonoIOStat *stat, gint32 *error) { gboolean result; - path = mono_unity_get_remapped_path(path); + const gunichar2 *path_remapped; + + if (path_remapped = mono_unity_remap_path_utf16 (path)) + path = path_remapped; *error=ERROR_SUCCESS; @@ -459,6 +527,8 @@ ves_icall_System_IO_MonoIO_GetFileStat (const gunichar2 *path, MonoIOStat *stat, memset (stat, 0, sizeof (MonoIOStat)); } + g_free (path_remapped); + return result; } @@ -469,7 +539,10 @@ ves_icall_System_IO_MonoIO_Open (const gunichar2 *filename, gint32 mode, { HANDLE ret; int attributes, attrs; - filename = mono_unity_get_remapped_path(filename); + const gunichar2 *filename_remapped; + + if (filename_remapped = mono_unity_remap_path_utf16 (filename)) + filename = filename_remapped; *error=ERROR_SUCCESS; @@ -505,8 +578,10 @@ ves_icall_System_IO_MonoIO_Open (const gunichar2 *filename, gint32 mode, ret=mono_w32file_create (filename, convert_access ((MonoFileAccess)access_mode), convert_share ((MonoFileShare)share), convert_mode ((MonoFileMode)mode), attributes); if(ret==INVALID_HANDLE_VALUE) { *error=mono_w32error_get_last (); - } - + } + + g_free (filename_remapped); + return(ret); } From 919015586333a62048005ceb897ba995f813cee4 Mon Sep 17 00:00:00 2001 From: Pete Lewis <30474896+PeteLewisUnity@users.noreply.github.com> Date: Tue, 19 Dec 2017 07:33:33 -0800 Subject: [PATCH 135/582] Only call `waitpid` for processes that Mono tracks, rather than all child processes owned by the calling process. (#6202) waitpid(-1,...) reaps all zombie child processes of the calling process (see `man waitpid`). After a child process is reaped, it can no longer be queried. Because this reaping step is invoked via the `SIGCHLD` signal, all zombie children of the calling process are reaped every time any child process terminates, regardless of whether that child process was tracked by Mono. The impact of this bug is that apps using Mono that spawn their own child processes (outside of Mono's `w32process` API) cannot query the exit state of its children. For example, a call to `waitpid(my_child_pid,...)` will return `ECHILD` for "no such child" because Mono has already cleaned up the child the moment `SIGCHLD` was raised. --- mono/metadata/w32process-unix.c | 43 +++++++++++++++++---------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/mono/metadata/w32process-unix.c b/mono/metadata/w32process-unix.c index 48d5e7af8465..2fb87faa4d44 100644 --- a/mono/metadata/w32process-unix.c +++ b/mono/metadata/w32process-unix.c @@ -1401,34 +1401,35 @@ process_add_sigchld_handler (void) void mono_w32process_signal_finished (void) { - int status; - int pid; - Process *process; + mono_coop_mutex_lock (&processes_mutex); + + for (Process* process = processes; process; process = process->next) { + int status = -1; + int pid; - do { do { - pid = waitpid (-1, &status, WNOHANG); + pid = waitpid (process->pid, &status, WNOHANG); } while (pid == -1 && errno == EINTR); - if (pid <= 0) - break; - - mono_coop_mutex_lock (&processes_mutex); + // possible values of 'pid': + // process->pid : the status changed for this child + // 0 : status unchanged for this PID + // ECHILD : process has been reaped elsewhere (or never existed) + // EINVAL : invalid PID or other argument - for (process = processes; process; process = process->next) { - if (process->pid != pid) - continue; - if (process->signalled) - continue; + // Therefore, we ignore status unchanged (nothing to do) and error + // events (process is cleaned up later). + if (pid <= 0) + continue; + if (process->signalled) + continue; - process->signalled = TRUE; - process->status = status; - mono_coop_sem_post (&process->exit_sem); - break; - } + process->signalled = TRUE; + process->status = status; + mono_coop_sem_post (&process->exit_sem); + } - mono_coop_mutex_unlock (&processes_mutex); - } while (1); + mono_coop_mutex_unlock (&processes_mutex); } static gboolean From d476b3926b71c0f556850455411bca5adead15e0 Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 29 Jan 2018 14:47:30 +0100 Subject: [PATCH 136/582] [unitytls] Updated interface --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index 6ab0c550d7c2..54771af296d2 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -44,13 +44,15 @@ public enum unitytls_error_code : UInt32 UNITYTLS_INTERNAL_ERROR, // Internal implementation error. UNITYTLS_NOT_SUPPORTED, // The requested action is not supported on the current platform/implementation. UNITYTLS_ENTROPY_SOURCE_FAILED, // Failed to generate requested amount of entropy data. + UNITYTLS_STREAM_CLOSED, // The operation is not possible because the stream between the peers was closed. + UNITYTLS_USER_CUSTOM_ERROR_START = 0x100000, UNITYTLS_USER_WOULD_BLOCK, // Can be set by the user to signal that a call (e.g. read/write callback) would block and needs to be called again. // Some implementations may set this if not all bytes have been read/written. - UNITYTLS_USER_STREAM_CLOSED, // Can be set by the user to cancel a read/write operation. UNITYTLS_USER_READ_FAILED, // Can be set by the user to indicate a failed read operation. UNITYTLS_USER_WRITE_FAILED, // Can be set by the user to indicate a failed write operation. UNITYTLS_USER_UNKNOWN_ERROR, // Can be set by the user to indicate a generic error. + UNITYTLS_USER_CUSTOM_ERROR_END = 0x200000, } [StructLayout (LayoutKind.Sequential)] @@ -177,10 +179,10 @@ public class unitytls_interface_struct public delegate unitytls_key_ref unitytls_key_get_ref_t(unitytls_key* key, unitytls_errorstate* errorState); public unitytls_key_get_ref_t unitytls_key_get_ref; - public delegate unitytls_key* unitytls_key_parse_pem_t(Int8* buffer, size_t bufferLen, Int8* password, size_t passwordLen, unitytls_errorstate* errorState); - public unitytls_key_parse_der_t unitytls_key_parse_pem; public delegate unitytls_key* unitytls_key_parse_der_t(UInt8* buffer, size_t bufferLen, Int8* password, size_t passwordLen, unitytls_errorstate* errorState); public unitytls_key_parse_der_t unitytls_key_parse_der; + public delegate unitytls_key* unitytls_key_parse_pem_t(Int8* buffer, size_t bufferLen, Int8* password, size_t passwordLen, unitytls_errorstate* errorState); + public unitytls_key_parse_pem_t unitytls_key_parse_pem; public delegate void unitytls_key_free_t(unitytls_key* key); public unitytls_key_free_t unitytls_key_free; @@ -231,8 +233,13 @@ public class unitytls_interface_struct public unitytls_tlsctx_read_t unitytls_tlsctx_read; public delegate size_t unitytls_tlsctx_write_t(unitytls_tlsctx* ctx, UInt8* data, size_t bufferLen, unitytls_errorstate* errorState); public unitytls_tlsctx_write_t unitytls_tlsctx_write; + public delegate void unitytls_tlsctx_notify_close_t(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); + public unitytls_tlsctx_notify_close_t unitytls_tlsctx_notify_close; public delegate void unitytls_tlsctx_free_t(unitytls_tlsctx* ctx); public unitytls_tlsctx_free_t unitytls_tlsctx_free; + + public delegate void unitytls_random_generate_bytes_t(UInt8 * buffer, size_t bufferLen, unitytls_errorstate * errorState); + public unitytls_random_generate_bytes_t unitytls_random_generate_bytes; } [MethodImplAttribute (MethodImplOptions.InternalCall)] From 07685083b85ea84f2768b8472fd43b4bc9d3bbce Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 29 Jan 2018 16:19:38 +0100 Subject: [PATCH 137/582] [unitytls] Handling gracefully closed connections properly now. Sending close notify if requested. --- mcs/class/System/Mono.UnityTls/UnityTlsContext.cs | 10 +++++++++- mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index 7b1cc8a472bb..314215e59b3b 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -185,6 +185,8 @@ public override (int ret, bool wantMore) Read (byte[] buffer, int offset, int co if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) wouldBlock = true; + else if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_STREAM_CLOSED) + return (0, false); // According to Apple and Btls implementation this is how we should handle gracefully closed connections. else Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to read data from TLS context"); @@ -206,6 +208,8 @@ public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int c if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) wouldBlock = true; + else if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_STREAM_CLOSED) + return (0, false); // According to Apple and Btls implementation this is how we should handle gracefully closed connections. else Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to write data to TLS context"); @@ -214,6 +218,11 @@ public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int c public override void Shutdown () { + if(Settings != null && Settings.SendCloseNotify) { + var err = UnityTls.NativeInterface.unitytls_errorstate_create (); + UnityTls.NativeInterface.unitytls_tlsctx_notify_close (tlsContext, &err); + } + // Destroy native UnityTls objects UnityTls.NativeInterface.unitytls_x509list_free (requestedClientCertChain); UnityTls.NativeInterface.unitytls_key_free (requestedClientKey); @@ -407,7 +416,6 @@ private UnityTls.unitytls_x509verify_result VerifyCallback (UnityTls.unitytls_x5 } } - [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_certificate_callback))] static private void CertificateCallback (void* userData, UnityTls.unitytls_tlsctx* ctx, Int8* cn, size_t cnLen, UnityTls.unitytls_x509name* caList, size_t caListLen, UnityTls.unitytls_x509list_ref* chain, UnityTls.unitytls_key_ref* key, UnityTls.unitytls_errorstate* errorState) { diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs index 4e39a338b01f..78c637c86803 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs @@ -82,7 +82,6 @@ internal override bool ValidateCertificate ( //validator.Settings.CheckCertificateRevocationStatus // not used by mono? //validator.Settings.CertificateValidationTime //validator.Settings.CertificateSearchPaths // currently only used by MonoBtlsProvider - //validator.Settings.SendCloseNotify // UnityTls always sends a close notify if the underlying impl supports it. Currently only used by MonoBtlsProvider CertHelper.AddCertificatesToNativeChain (certificatesNative, certificates, &errorState); var certificatesNativeRef = UnityTls.NativeInterface.unitytls_x509list_get_ref (certificatesNative, &errorState); From 2a3eb560a5ca9dd2196d86fc3b2bf881d9ea5932 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Wed, 31 Jan 2018 08:33:53 -0500 Subject: [PATCH 138/582] Sync IL2CPP changes to fix builds on older MSVC. --- mono/eglib/gdir-unity.c | 3 ++- mono/eglib/glib.h | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mono/eglib/gdir-unity.c b/mono/eglib/gdir-unity.c index a5a234137359..a3d8eec30e93 100644 --- a/mono/eglib/gdir-unity.c +++ b/mono/eglib/gdir-unity.c @@ -60,13 +60,14 @@ GDir * g_dir_open (const gchar *path, guint flags, GError **error) { GDir *dir; + gboolean success; g_return_val_if_fail (path != NULL, NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); dir = g_new0 (GDir, 1); - gboolean success = setup_dir_handle(dir, path, error); + success = setup_dir_handle(dir, path, error); if (!success) return NULL; diff --git a/mono/eglib/glib.h b/mono/eglib/glib.h index 333639f677ab..d4b5d0a2fb78 100644 --- a/mono/eglib/glib.h +++ b/mono/eglib/glib.h @@ -14,7 +14,10 @@ #endif #include + +#ifndef _MSC_VER // inttypes.h doesn't exist on VS2010 #include +#endif #include #ifndef EGLIB_NO_REMAP @@ -44,6 +47,10 @@ #define G_END_DECLS #endif +#if defined(_MSC_VER) && _MSC_VER < 1900 +#define inline __inline +#endif + G_BEGIN_DECLS /* From 6e036ac877a62640ca03d8e96b58d1d23b0a851e Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 2 Feb 2018 12:21:23 -0500 Subject: [PATCH 139/582] Improve MSVC check for inttypes.h --- mono/eglib/glib.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mono/eglib/glib.h b/mono/eglib/glib.h index d4b5d0a2fb78..9e3c61fe8b39 100644 --- a/mono/eglib/glib.h +++ b/mono/eglib/glib.h @@ -15,7 +15,8 @@ #include -#ifndef _MSC_VER // inttypes.h doesn't exist on VS2010 +/* inttypes.h is only available from VS2013 */ +#if !defined(_MSC_VER) || (_MSC_VER >= 1800) #include #endif From 16f0741bfd739a74ca8548f4c6d7a55900ab6f4e Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 2 Feb 2018 12:21:55 -0500 Subject: [PATCH 140/582] Avoid call to mono_gc_get_managed_allocator_types when running on IL2CPP runtime --- mono/metadata/profiler.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mono/metadata/profiler.c b/mono/metadata/profiler.c index 274e4206ff2d..705fa0cccc80 100644 --- a/mono/metadata/profiler.c +++ b/mono/metadata/profiler.c @@ -559,8 +559,10 @@ mono_profiler_sampling_thread_wait (void) mono_bool mono_profiler_enable_allocations (void) { +#ifndef RUNTIME_IL2CPP if (mono_gc_get_managed_allocator_types () > 0 && mono_profiler_state.startup_done) return FALSE; +#endif return mono_profiler_state.allocations = TRUE; } From d735272a0b72bf27b224f3323335d09f521cdd49 Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Fri, 2 Feb 2018 12:44:32 -0500 Subject: [PATCH 141/582] Don't flush buffers explicitly. let the file cache do that since it should most of the time flush before the plugin reads it anway --- mono/mini/mixed_callstack_plugin.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mono/mini/mixed_callstack_plugin.c b/mono/mini/mixed_callstack_plugin.c index 696b4ae060b3..0b26dcfa6d88 100644 --- a/mono/mini/mixed_callstack_plugin.c +++ b/mono/mini/mixed_callstack_plugin.c @@ -86,7 +86,6 @@ mixed_callstack_plugin_save_method_info (MonoCompile *cfg) mixed_callstack_plugin_lock (); WriteFile(fileHandle, frame, bytes, &bytesWritten, NULL); - FlushFileBuffers(fileHandle); mixed_callstack_plugin_unlock (); g_free(method_name); @@ -109,7 +108,6 @@ mixed_callstack_plugin_save_trampoline_info (MonoTrampInfo *info) mixed_callstack_plugin_lock (); frame = g_strdup_printf ("%p;%p;%s\n", info->code, ((char*)info->code) + info->code_size, info->name ? info->name : ""); WriteFile(fileHandle, frame, strlen(frame), &bytesWritten, NULL); - FlushFileBuffers(fileHandle); mixed_callstack_plugin_unlock (); g_free(frame); From 237c030a78027c914f063f66d5a18db2e7e37806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Thu, 8 Feb 2018 01:07:39 +0100 Subject: [PATCH 142/582] [reference-assemblies] Fix public key for some newer v4.7.1 facades (#6863) Fixes https://github.com/mono/mono/issues/6848 --- external/binary-reference-assemblies | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/binary-reference-assemblies b/external/binary-reference-assemblies index 9f07d0746d94..e048fe4a88d2 160000 --- a/external/binary-reference-assemblies +++ b/external/binary-reference-assemblies @@ -1 +1 @@ -Subproject commit 9f07d0746d94d2c2b055e3e689814ca07431e5fd +Subproject commit e048fe4a88d237d105ae02fe0363a68296099362 From 4d5b659d4700674972302f5572a3dc96ffc710b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tautvydas=20=C5=BDilys?= Date: Fri, 9 Feb 2018 15:10:00 -0800 Subject: [PATCH 143/582] Modify some defines so COM and Windows Runtime support works on Unity AOT profile. --- .../System.Runtime.InteropServices/Marshal.cs | 69 +++++++++++-------- .../runtime/interopservices/attributes.cs | 2 +- .../windowsruntime/windowsruntimemarshal.cs | 2 +- .../referencesource/mscorlib/system/type.cs | 4 +- 4 files changed, 43 insertions(+), 34 deletions(-) diff --git a/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs b/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs index e94898a5c386..e12d825cd58c 100644 --- a/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs +++ b/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs @@ -53,14 +53,14 @@ public static class Marshal public static readonly int SystemMaxDBCSCharSize = 2; // don't know what this is public static readonly int SystemDefaultCharSize = Environment.IsRunningOnWindows ? 2 : 1; -#if !MOBILE +#if !MOBILE || UNITY_AOT [MethodImplAttribute (MethodImplOptions.InternalCall)] private extern static int AddRefInternal (IntPtr pUnk); #endif public static int AddRef (IntPtr pUnk) { -#if !MOBILE +#if !MOBILE || UNITY_AOT if (pUnk == IntPtr.Zero) throw new ArgumentException ("Value cannot be null.", "pUnk"); return AddRefInternal (pUnk); @@ -210,7 +210,9 @@ public static IntPtr CreateAggregatedObject (IntPtr pOuter, T o) { public static object CreateWrapperOfType (object o, Type t) { -#if FULL_AOT_RUNTIME +#if UNITY_AOT + throw new NotImplementedException("Marshal.CreateWrapperOfType is not implemented."); +#elif FULL_AOT_RUNTIME throw new PlatformNotSupportedException (); #else __ComObject co = o as __ComObject; @@ -307,7 +309,7 @@ public static void ZeroFreeGlobalAllocUnicode (IntPtr s) FreeHGlobal (s); } -#if !FULL_AOT_RUNTIME +#if !FULL_AOT_RUNTIME || UNITY_AOT public static Guid GenerateGuidForType (Type type) { return type.GUID; @@ -342,15 +344,17 @@ public static object GetActiveObject (string progID) throw new NotImplementedException (); } -#if !MOBILE +#if !MOBILE || UNITY_AOT [MethodImplAttribute (MethodImplOptions.InternalCall)] private extern static IntPtr GetCCW (object o, Type T); private static IntPtr GetComInterfaceForObjectInternal (object o, Type T) { +#if !UNITY_AOT if (IsComObject (o)) return ((__ComObject)o).GetInterface (T); else +#endif return GetCCW (o, T); } #endif @@ -358,7 +362,7 @@ private static IntPtr GetComInterfaceForObjectInternal (object o, Type T) public static IntPtr GetComInterfaceForObject (object o, Type T) { -#if MOBILE +#if MOBILE && !UNITY_AOT throw new PlatformNotSupportedException (); #else IntPtr pItf = GetComInterfaceForObjectInternal (o, T); @@ -377,7 +381,7 @@ public static IntPtr GetComInterfaceForObject (T o) { return GetComInterfaceForObject ((object)o, typeof (T)); } -#if !FULL_AOT_RUNTIME +#if !FULL_AOT_RUNTIME || UNITY_AOT [MonoTODO] public static IntPtr GetComInterfaceForObjectInContext (object o, Type t) { @@ -430,7 +434,7 @@ public static IntPtr GetHINSTANCE (Module m) return m.GetHINSTANCE (); } -#endif // !FULL_AOT_RUNTIME +#endif // !FULL_AOT_RUNTIME || UNITY_AOT public static int GetExceptionCode () { @@ -453,14 +457,14 @@ public static int GetHRForException (Exception e) [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)] public static int GetHRForLastWin32Error() { -#if FULL_AOT_RUNTIME +#if FULL_AOT_RUNTIME && !UNITY_AOT throw new PlatformNotSupportedException (); #else throw new NotImplementedException (); #endif } - -#if !FULL_AOT_RUNTIME + +#if !FULL_AOT_RUNTIME || UNITY_AOT [MethodImplAttribute (MethodImplOptions.InternalCall)] private extern static IntPtr GetIDispatchForObjectInternal (object o); @@ -471,7 +475,9 @@ public static IntPtr GetIDispatchForObject (object o) AddRef (pUnk); return pUnk; } +#endif // !FULL_AOT_RUNTIME || UNITY_AOT +#if !FULL_AOT_RUNTIME [MonoTODO] public static IntPtr GetIDispatchForObjectInContext (object o) { @@ -502,15 +508,16 @@ public static MemberInfo GetMethodInfoForComSlot (Type t, int slot, ref ComMembe { throw new NotImplementedException (); } +#endif // !FULL_AOT_RUNTIME +#if !FULL_AOT_RUNTIME || UNITY_AOT [MethodImplAttribute (MethodImplOptions.InternalCall)] private extern static IntPtr GetIUnknownForObjectInternal (object o); - -#endif // !FULL_AOT_RUNTIME +#endif // !FULL_AOT_RUNTIME || UNITY_AOT public static IntPtr GetIUnknownForObject (object o) { -#if FULL_AOT_RUNTIME +#if FULL_AOT_RUNTIME && !UNITY_AOT throw new PlatformNotSupportedException (); #else IntPtr pUnk = GetIUnknownForObjectInternal (o); @@ -522,7 +529,7 @@ public static IntPtr GetIUnknownForObject (object o) public static void GetNativeVariantForObject (object obj, IntPtr pDstNativeVariant) { -#if FULL_AOT_RUNTIME +#if FULL_AOT_RUNTIME && !UNITY_AOT throw new PlatformNotSupportedException (); #else Variant vt = new Variant(); @@ -535,29 +542,31 @@ public static void GetNativeVariantForObject (T obj, IntPtr pDstNativeVariant GetNativeVariantForObject ((object)obj, pDstNativeVariant); } -#if !MOBILE && !FULL_AOT_RUNTIME +#if (!MOBILE && !FULL_AOT_RUNTIME) || UNITY_AOT [MethodImplAttribute (MethodImplOptions.InternalCall)] private static extern object GetObjectForCCW (IntPtr pUnk); #endif public static object GetObjectForIUnknown (IntPtr pUnk) { -#if MOBILE || FULL_AOT_RUNTIME +#if (MOBILE || FULL_AOT_RUNTIME) && !UNITY_AOT throw new PlatformNotSupportedException (); #else object obj = GetObjectForCCW (pUnk); +#if !UNITY_AOT // was not a CCW if (obj == null) { ComInteropProxy proxy = ComInteropProxy.GetProxy (pUnk, typeof (__ComObject)); obj = proxy.GetTransparentProxy (); } +#endif return obj; #endif } public static object GetObjectForNativeVariant (IntPtr pSrcNativeVariant) { -#if FULL_AOT_RUNTIME +#if FULL_AOT_RUNTIME && !UNITY_AOT throw new PlatformNotSupportedException (); #else Variant vt = (Variant)Marshal.PtrToStructure(pSrcNativeVariant, typeof(Variant)); @@ -567,7 +576,7 @@ public static object GetObjectForNativeVariant (IntPtr pSrcNativeVariant) public static T GetObjectForNativeVariant (IntPtr pSrcNativeVariant) { -#if FULL_AOT_RUNTIME +#if FULL_AOT_RUNTIME && !UNITY_AOT throw new PlatformNotSupportedException (); #else Variant vt = (Variant)Marshal.PtrToStructure(pSrcNativeVariant, typeof(Variant)); @@ -577,7 +586,7 @@ public static T GetObjectForNativeVariant (IntPtr pSrcNativeVariant) public static object[] GetObjectsForNativeVariants (IntPtr aSrcNativeVariant, int cVars) { -#if FULL_AOT_RUNTIME +#if FULL_AOT_RUNTIME && !UNITY_AOT throw new PlatformNotSupportedException (); #else if (cVars < 0) @@ -592,7 +601,7 @@ public static object[] GetObjectsForNativeVariants (IntPtr aSrcNativeVariant, in public static T[] GetObjectsForNativeVariants (IntPtr aSrcNativeVariant, int cVars) { -#if FULL_AOT_RUNTIME +#if FULL_AOT_RUNTIME && !UNITY_AOT throw new PlatformNotSupportedException (); #else if (cVars < 0) @@ -608,7 +617,7 @@ public static T[] GetObjectsForNativeVariants (IntPtr aSrcNativeVariant, int [MonoTODO] public static int GetStartComSlot (Type t) { -#if FULL_AOT_RUNTIME +#if FULL_AOT_RUNTIME && !UNITY_AOT throw new PlatformNotSupportedException (); #else throw new NotImplementedException (); @@ -735,7 +744,7 @@ public static object GetUniqueObjectForIUnknown (IntPtr unknown) throw new PlatformNotSupportedException (); } -#if !MOBILE +#if !MOBILE || UNITY_AOT [MethodImplAttribute (MethodImplOptions.InternalCall)] public extern static bool IsComObject (object o); #else @@ -815,14 +824,14 @@ public static T PtrToStructure (IntPtr ptr) { return (T) PtrToStructure (ptr, typeof (T)); } -#if !MOBILE +#if !MOBILE || UNITY_AOT [MethodImplAttribute (MethodImplOptions.InternalCall)] private extern static int QueryInterfaceInternal (IntPtr pUnk, ref Guid iid, out IntPtr ppv); #endif public static int QueryInterface (IntPtr pUnk, ref Guid iid, out IntPtr ppv) { -#if !MOBILE +#if !MOBILE || UNITY_AOT if (pUnk == IntPtr.Zero) throw new ArgumentException ("Value cannot be null.", "pUnk"); return QueryInterfaceInternal (pUnk, ref iid, out ppv); @@ -986,7 +995,7 @@ public static IntPtr ReadIntPtr ([In, MarshalAs (UnmanagedType.AsAny)] object pt [MethodImplAttribute(MethodImplOptions.InternalCall)] public extern static IntPtr ReAllocHGlobal (IntPtr pv, IntPtr cb); -#if !MOBILE +#if !MOBILE || UNITY_AOT [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)] [MethodImplAttribute (MethodImplOptions.InternalCall)] private extern static int ReleaseInternal (IntPtr pUnk); @@ -995,7 +1004,7 @@ public static IntPtr ReadIntPtr ([In, MarshalAs (UnmanagedType.AsAny)] object pt [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)] public static int Release (IntPtr pUnk) { -#if !MOBILE +#if !MOBILE || UNITY_AOT if (pUnk == IntPtr.Zero) throw new ArgumentException ("Value cannot be null.", "pUnk"); @@ -1005,14 +1014,14 @@ public static int Release (IntPtr pUnk) #endif } -#if !FULL_AOT_RUNTIME +#if !FULL_AOT_RUNTIME || UNITY_AOT [MethodImplAttribute (MethodImplOptions.InternalCall)] private extern static int ReleaseComObjectInternal (object co); #endif public static int ReleaseComObject (object o) { -#if FULL_AOT_RUNTIME +#if FULL_AOT_RUNTIME && !UNITY_AOT throw new PlatformNotSupportedException (); #else if (o == null) @@ -1752,7 +1761,7 @@ internal static void SetLastWin32Error (int error) { } -#if FEATURE_COMINTEROP || MONO_COM +#if FEATURE_COMINTEROP || MONO_COM || UNITY_AOT // Copied from referencesource/mscorlib/system/runtime/interopservices/marshal.cs //==================================================================== // return the raw IUnknown* for a COM Object not related to current diff --git a/mcs/class/referencesource/mscorlib/system/runtime/interopservices/attributes.cs b/mcs/class/referencesource/mscorlib/system/runtime/interopservices/attributes.cs index a970216007b9..1c5f52bcbb26 100644 --- a/mcs/class/referencesource/mscorlib/system/runtime/interopservices/attributes.cs +++ b/mcs/class/referencesource/mscorlib/system/runtime/interopservices/attributes.cs @@ -1,4 +1,4 @@ -#if MONO_COM +#if MONO_COM || UNITY_AOT #define FEATURE_COMINTEROP #endif // ==++== diff --git a/mcs/class/referencesource/mscorlib/system/runtime/interopservices/windowsruntime/windowsruntimemarshal.cs b/mcs/class/referencesource/mscorlib/system/runtime/interopservices/windowsruntime/windowsruntimemarshal.cs index 15a0c70d64dd..9ef7580c9e30 100644 --- a/mcs/class/referencesource/mscorlib/system/runtime/interopservices/windowsruntime/windowsruntimemarshal.cs +++ b/mcs/class/referencesource/mscorlib/system/runtime/interopservices/windowsruntime/windowsruntimemarshal.cs @@ -1278,7 +1278,7 @@ public static IActivationFactory GetActivationFactory(Type type) if (type == null) throw new ArgumentNullException("type"); -#if FEATURE_COMINTEROP || MONO_COM +#if FEATURE_COMINTEROP || MONO_COM || UNITY_AOT if (type.IsWindowsRuntimeObject && type.IsImport) { return (IActivationFactory)Marshal.GetNativeActivationFactory(type); diff --git a/mcs/class/referencesource/mscorlib/system/type.cs b/mcs/class/referencesource/mscorlib/system/type.cs index ef7472f5016d..1f337f0c1fef 100644 --- a/mcs/class/referencesource/mscorlib/system/type.cs +++ b/mcs/class/referencesource/mscorlib/system/type.cs @@ -1249,7 +1249,7 @@ public bool IsCOMObject { get {return IsCOMObjectImpl();} } -#if FEATURE_COMINTEROP || MONO_COM +#if FEATURE_COMINTEROP || MONO_COM || UNITY_AOT internal bool IsWindowsRuntimeObject { [Pure] get { return IsWindowsRuntimeObjectImpl(); } @@ -1313,7 +1313,7 @@ protected virtual bool IsValueTypeImpl() // Protected routine to determine if this class represents a COM object abstract protected bool IsCOMObjectImpl(); -#if FEATURE_COMINTEROP || MONO_COM +#if FEATURE_COMINTEROP || MONO_COM || UNITY_AOT // Protected routine to determine if this class represents a Windows Runtime object virtual internal bool IsWindowsRuntimeObjectImpl() { throw new NotImplementedException(); From 71f1c162abbd5862e9de7ee4e484d404950f1064 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Mon, 12 Feb 2018 13:31:50 -0500 Subject: [PATCH 144/582] Synchronize changes debugger from the IL2CPP repo --- mono/mini/il2cpp-stubs.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index e2a72d2e01e8..3f2696d5b943 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -763,7 +763,14 @@ void il2cpp_mono_thread_internal_reset_abort(MonoInternalThread* thread) gunichar2* il2cpp_mono_thread_get_name(MonoInternalThread* this_obj, guint32* name_len) { - return NULL; + std::string name = il2cpp::vm::Thread::GetName((Il2CppInternalThread*)this_obj); + + if (name_len != NULL) + *name_len = name.size(); + + if (name.empty()) + return NULL; + return g_utf8_to_utf16(name.c_str(), name.size(), NULL, NULL, NULL); } void il2cpp_mono_thread_set_name_internal(MonoInternalThread* this_obj, MonoString* name, gboolean permanent, gboolean reset, MonoError* error) From eab4eb5502ac7e98eda0a76a8b9567c67775d8f4 Mon Sep 17 00:00:00 2001 From: Brian Raderman Date: Tue, 13 Feb 2018 16:04:13 -0500 Subject: [PATCH 145/582] Changing debugger metadata to a format that will be faster to compile as well lend itself to being output as a binary format that can be memory-mapped at runtime. Changed everything to use static initializers instead of function calls, replaced externally linked pointers with indexes, and pulled out redundant string data into separate tables. Using a table-of-tables format with a separate index for large amounts of data that must be spread among multiple files. --- mono/mini/debugger-agent.c | 147 +++++++++++++++++++++---------------- mono/mini/il2cpp-compat.h | 3 + mono/mini/il2cpp-stubs.cpp | 18 +++++ 3 files changed, 106 insertions(+), 62 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 2bf93d94a09e..c22799d01345 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -109,6 +109,11 @@ #include "debugger-agent.h" +#ifdef RUNTIME_IL2CPP +const Il2CppDebuggerMetadataRegistration *g_il2cpp_metadata; +#endif + + typedef struct { gboolean enabled; char *transport; @@ -2258,9 +2263,10 @@ static GPtrArray *ids [ID_NUM]; static GHashTable* s_jit_info_hashtable; -void mono_debugger_il2cpp_init () +void mono_debugger_il2cpp_init (const Il2CppDebuggerMetadataRegistration *data) { s_jit_info_hashtable = g_hash_table_new_full(mono_aligned_addr_hash, NULL, NULL, NULL); + g_il2cpp_metadata = data; } static gpointer @@ -3402,9 +3408,10 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) { Il2CppSequencePoint* seq_point = tls->il2cpp_context.sequencePoints[frame_index]; StackFrame* frame = g_new0(StackFrame, 1); - frame->method = seq_point->method; - frame->actual_method = seq_point->method; - frame->api_method = seq_point->method; + MonoMethod *sp_method = il2cpp_get_seq_point_method(seq_point); + frame->method = sp_method; + frame->actual_method = sp_method; + frame->api_method = sp_method; frame->il_offset = seq_point->ilOffset; frame->native_offset = 0; frame->flags = 0; @@ -3639,6 +3646,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv GSList *events = NULL; #if RUNTIME_IL2CPP Il2CppSequencePoint *sp = (Il2CppSequencePoint*)ji; + MonoMethod *sp_method = ji ? il2cpp_get_seq_point_method(sp) : NULL; #endif *suspend_policy = SUSPEND_POLICY_NONE; @@ -3688,7 +3696,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv for (k = 0; assemblies [k]; ++k) #ifdef RUNTIME_IL2CPP { - if (assemblies[k] == sp->method->klass->image->assembly) + if (assemblies[k] == sp_method->klass->image->assembly) found = TRUE; } #else @@ -3750,11 +3758,10 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv g_free (s); } else if (mod->kind == MOD_KIND_STEP) { #ifdef RUNTIME_IL2CPP - Il2CppSequencePoint *sp = (Il2CppSequencePoint*)ji; if ((mod->data.filter & STEP_FILTER_STATIC_CTOR) && sp && - (sp->method->flags & METHOD_ATTRIBUTE_SPECIAL_NAME) && - !strcmp (sp->method->name, ".cctor") && - (sp->method != ((SingleStepReq*)req->info)->start_method)) + (sp_method->flags & METHOD_ATTRIBUTE_SPECIAL_NAME) && + !strcmp (sp_method->name, ".cctor") && + (sp_method != ((SingleStepReq*)req->info)->start_method)) filtered = TRUE; #else if ((mod->data.filter & STEP_FILTER_STATIC_CTOR) && ji && @@ -4769,7 +4776,7 @@ set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req, MonoError Il2CppSequencePoint *seqPoint; while(seqPoint = il2cpp_get_method_sequence_points(method, &seqPointIter)) { - if (bp_matches_method(bp, seqPoint->method) && seqPoint->ilOffset == bp->il_offset) + if (bp_matches_method(bp, il2cpp_get_seq_point_method(seqPoint)) && seqPoint->ilOffset == bp->il_offset) { if (req->event_kind == EVENT_KIND_BREAKPOINT && seqPoint->kind == kSequencePointKind_StepOut) continue; @@ -4857,7 +4864,7 @@ static MonoBreakpoint* set_breakpoint_fast(Il2CppSequencePoint *sp, EventRequest // - races bp = g_new0(MonoBreakpoint, 1); - bp->method = sp->method; + bp->method = il2cpp_get_seq_point_method(sp); bp->il_offset = sp->ilOffset; bp->req = req; bp->children = g_ptr_array_new(); @@ -5145,10 +5152,11 @@ static gboolean ss_update_il2cpp(SingleStepReq *req, DebuggerTlsData *tls, MonoContext *ctx, Il2CppSequencePoint *sequencePoint) { gboolean hit = TRUE; + MonoMethod *sp_method = il2cpp_get_seq_point_method(sequencePoint); - if (il2cpp_mono_methods_match(req->async_stepout_method, sequencePoint->method)) + if (il2cpp_mono_methods_match(req->async_stepout_method, sp_method)) { - DEBUG_PRINTF(1, "[%p] Breakpoint hit during async step-out at %s hit, continuing stepping out.\n", (gpointer)(gsize)mono_native_thread_id_get(), mono_method_get_name(sequencePoint->method)); + DEBUG_PRINTF(1, "[%p] Breakpoint hit during async step-out at %s hit, continuing stepping out.\n", (gpointer)(gsize)mono_native_thread_id_get(), mono_method_get_name(sp_method)); return FALSE; } @@ -5175,10 +5183,10 @@ ss_update_il2cpp(SingleStepReq *req, DebuggerTlsData *tls, MonoContext *ctx, Il2 if (sequencePoint->lineEnd < 0) { DEBUG_PRINTF(1, "[%p] No line number info for il offset %x, continuing single stepping.\n", (gpointer)(gsize)mono_native_thread_id_get(), sequencePoint->ilOffset); - ss_req->last_method = sequencePoint->method; + ss_req->last_method = sp_method; hit = FALSE; } - else if (sequencePoint->lineEnd >= 0 && sequencePoint->method == ss_req->last_method && sequencePoint->lineEnd == ss_req->last_line) + else if (sequencePoint->lineEnd >= 0 && sp_method == ss_req->last_method && sequencePoint->lineEnd == ss_req->last_line) { if (tls->il2cpp_context.frameCount == req->nframes) { // If the frame has changed we're clearly not on the same source line. @@ -5189,7 +5197,7 @@ ss_update_il2cpp(SingleStepReq *req, DebuggerTlsData *tls, MonoContext *ctx, Il2 if (sequencePoint->lineEnd >= 0) { - ss_req->last_method = sequencePoint->method; + ss_req->last_method = sp_method; ss_req->last_line = sequencePoint->lineEnd; } @@ -5802,6 +5810,7 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, int seque process_event (EVENT_KIND_STEP, jinfo_get_method (ji), il_offset, ctx, events, suspend_policy); #else Il2CppSequencePoint* sequence_pt = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]; + MonoMethod *sp_method = il2cpp_get_seq_point_method(sequence_pt); /* * This could be in ss_update method, but mono_find_next_seq_point_for_native_offset is pretty expensive method, @@ -5812,7 +5821,7 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, int seque gboolean found = FALSE; for (int k = 0; ss_req->user_assemblies[k]; k++) { - if (ss_req->user_assemblies[k] == sequence_pt->method->klass->image->assembly) + if (ss_req->user_assemblies[k] == sp_method->klass->image->assembly) { found = TRUE; break; @@ -5826,7 +5835,7 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, int seque if(!ss_update_il2cpp(ss_req,tls,ctx,sequence_pt)) return; - process_event(EVENT_KIND_STEP, sequence_pt->method, sequence_pt->ilOffset, NULL, events, suspend_policy, sequencePointId); + process_event(EVENT_KIND_STEP, sp_method, sequence_pt->ilOffset, NULL, events, suspend_policy, sequencePointId); #endif } @@ -6090,7 +6099,9 @@ static void ss_bp_add_one_il2cpp(SingleStepReq *ss_req, int *ss_req_bp_count, GH g_hash_table_insert(*ss_req_bp_cache, l->data, l->data); } - if (ss_bp_is_unique(ss_req->bps, *ss_req_bp_cache, sp->method, sp->ilOffset)) + MonoMethod *sp_method = il2cpp_get_seq_point_method(sp); + + if (ss_bp_is_unique(ss_req->bps, *ss_req_bp_cache, sp_method, sp->ilOffset)) { // Create and add breakpoint MonoBreakpoint *bp = set_breakpoint_fast(sp, ss_req->req, NULL); @@ -6101,7 +6112,7 @@ static void ss_bp_add_one_il2cpp(SingleStepReq *ss_req, int *ss_req_bp_count, GH } else { - DEBUG_PRINTF(1, "[dbg] Candidate breakpoint at %s:[il=0x%x] is a duplicate for this step request, will not add.\n", mono_method_full_name(sp->method, TRUE), (int)sp->ilOffset); + DEBUG_PRINTF(1, "[dbg] Candidate breakpoint at %s:[il=0x%x] is a duplicate for this step request, will not add.\n", mono_method_full_name(sp_method, TRUE), (int)sp->ilOffset); } } @@ -6387,7 +6398,7 @@ ss_start_il2cpp(SingleStepReq *ss_req, DebuggerTlsData *tls, Il2CppSequencePoint } else { if (ss_req->depth == STEP_DEPTH_OVER) { - MonoMethod* currentMethod = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]->method; + MonoMethod* currentMethod = il2cpp_get_seq_point_method(tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]); void *seqPointIter = NULL; Il2CppSequencePoint *seqPoint; @@ -6396,7 +6407,7 @@ ss_start_il2cpp(SingleStepReq *ss_req, DebuggerTlsData *tls, Il2CppSequencePoint if (seqPoint->kind != kSequencePointKind_Normal) continue; - if (il2cpp_mono_methods_match(seqPoint->method, currentMethod)) + if (il2cpp_mono_methods_match(il2cpp_get_seq_point_method(seqPoint), currentMethod)) ss_bp_add_one_il2cpp(ss_req, &ss_req_bp_count, &ss_req_bp_cache, seqPoint); } } @@ -6498,8 +6509,9 @@ ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilte if (tls->il2cpp_context.frameCount > 0) { Il2CppSequencePoint* seq_point = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]; - ss_req->start_method = seq_point->method; - ss_req->last_method = seq_point->method; + MonoMethod *sp_method = il2cpp_get_seq_point_method(seq_point); + ss_req->start_method = sp_method; + ss_req->last_method = sp_method; ss_req->last_line = seq_point->lineEnd; if (tls->exception) @@ -6711,14 +6723,15 @@ mono_debugger_agent_unhandled_exception (MonoException *exc) static Il2CppSequencePoint* il2cpp_find_catch_sequence_point_in_method(Il2CppSequencePoint* callSp, MonoException *exc) { uint8_t tryDepth = callSp->tryDepth; - MonoMethod *method = callSp->method; + MonoMethod *method = il2cpp_get_seq_point_method(callSp); int32_t ilOffset = callSp->ilOffset; Il2CppSequencePoint *sp; void *seqPointIter = NULL; while (sp = il2cpp_get_method_sequence_points(method, &seqPointIter)) { - if (sp->tryDepth == tryDepth && sp->ilOffset > ilOffset && sp->catchType != NULL && mono_class_is_assignable_from(sp->catchType, exc->object.vtable->klass)) + MonoClass *catchType = il2cpp_get_class_from_index(sp->catchTypeIndex); + if (sp->tryDepth == tryDepth && sp->ilOffset > ilOffset && catchType != NULL && mono_class_is_assignable_from(catchType, exc->object.vtable->klass)) return sp; } @@ -6801,6 +6814,8 @@ unity_debugger_agent_handle_exception(MonoException *exc, Il2CppSequencePoint *s mono_loader_lock(); + MonoMethod *sp_method = il2cpp_get_seq_point_method(sequencePoint); + /* Treat exceptions which are caught in non-user code as unhandled */ for (i = 0; i < event_requests->len; ++i) { @@ -6821,7 +6836,7 @@ unity_debugger_agent_handle_exception(MonoException *exc, Il2CppSequencePoint *s if (assemblies) { for (k = 0; assemblies[k]; ++k) - if (assemblies[k] == sequencePoint->method->klass->image->assembly) + if (assemblies[k] == sp_method->klass->image->assembly) found = TRUE; } if (!found) @@ -10156,7 +10171,7 @@ static void GetSequencePointsAndSourceFilesUniqueSequencePoints(MonoMethod* meth if(seqPoint->ilOffset == METHOD_ENTRY_IL_OFFSET || seqPoint->ilOffset == METHOD_EXIT_IL_OFFSET) continue; - if (il2cpp_mono_methods_match(seqPoint->method, method)) + if (il2cpp_mono_methods_match(il2cpp_get_seq_point_method(seqPoint), method)) g_ptr_array_add(*sequencePoints, seqPoint); } @@ -10170,7 +10185,7 @@ static void GetSequencePointsAndSourceFilesUniqueSequencePoints(MonoMethod* meth for (j = 0; j < (*uniqueFileSequencePoints)->len; j++) { Il2CppSequencePoint* uniqueSequencePoint = g_ptr_array_index(*uniqueFileSequencePoints, j); - if (strcmp(uniqueSequencePoint->sourceFile, seqPoint->sourceFile) == 0) + if (uniqueSequencePoint->sourceFileIndex == seqPoint->sourceFileIndex) break; } @@ -10182,17 +10197,19 @@ static void GetSequencePointsAndSourceFilesUniqueSequencePoints(MonoMethod* meth } } -static void GetExecutionContextAndHeaderInfo(MonoMethod* method, uint32_t* executionContextInfoCount, const Il2CppMethodExecutionContextInfo **executionContextInfo, const Il2CppMethodHeaderInfo **headerInfo) +static void GetExecutionContextAndHeaderInfo(MonoMethod* method, uint32_t* executionContextInfoCount, const Il2CppMethodExecutionContextInfo **executionContextInfo, const Il2CppMethodHeaderInfo **headerInfo, const Il2CppMethodScope **scopes) { void *seqPointIter = NULL; Il2CppSequencePoint *seqPoint; while (seqPoint = il2cpp_get_method_sequence_points(method, &seqPointIter)) { - if (il2cpp_mono_methods_match(seqPoint->method, method)) + if (il2cpp_mono_methods_match(il2cpp_get_seq_point_method(seqPoint), method)) { - *executionContextInfoCount = seqPoint->executionContextInfoCount; - *executionContextInfo = seqPoint->executionContextInfos; - *headerInfo = seqPoint->header; + Il2CppMethodExecutionContextInfoIndex *index = &g_il2cpp_metadata->methodExecutionContextInfoIndexes[seqPoint->methodIndex]; + *executionContextInfoCount = index->count; + *executionContextInfo = &g_il2cpp_metadata->methodExecutionContextInfos[index->tableIndex][index->startIndex]; + *headerInfo = &g_il2cpp_metadata->methodHeaderInfos[seqPoint->methodIndex]; + *scopes = &g_il2cpp_metadata->methodScopes[(*headerInfo)->startScope]; return; } } @@ -10299,15 +10316,15 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g buffer_add_int(buf, uniqueFileSequencePoints->len); for (i = 0; i < uniqueFileSequencePoints->len; ++i) { Il2CppSequencePoint* sequencePoint = g_ptr_array_index(uniqueFileSequencePoints, i); - buffer_add_string(buf, sequencePoint->sourceFile); + buffer_add_string(buf, g_il2cpp_metadata->sequencePointSourceFiles[sequencePoint->sourceFileIndex].file); if (CHECK_PROTOCOL_VERSION(2, 14)) { - buffer_add_data(buf, sequencePoint->sourceFileHash.m_hash, 16); + buffer_add_data(buf, g_il2cpp_metadata->sequencePointSourceFiles[sequencePoint->sourceFileIndex].hash, 16); } } } else { if (uniqueFileSequencePoints->len > 0) { - buffer_add_string(buf, ((Il2CppSequencePoint*)g_ptr_array_index(uniqueFileSequencePoints, 0))->sourceFile); + buffer_add_string(buf, g_il2cpp_metadata->sequencePointSourceFiles[((Il2CppSequencePoint*)g_ptr_array_index(uniqueFileSequencePoints, 0))->sourceFileIndex].file); } else { buffer_add_string(buf, ""); } @@ -10331,7 +10348,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g if (sequencePoint->kind == kSequencePointKind_StepOut) continue; - DEBUG_PRINTF(10, "IL%x -> %s:%d %d %d %d\n", sequencePoint->ilOffset, sequencePoint->sourceFile, + DEBUG_PRINTF(10, "IL%x -> %s:%d %d %d %d\n", sequencePoint->ilOffset, g_il2cpp_metadata->sequencePointSourceFiles[sequencePoint->sourceFileIndex], sequencePoint->lineStart, sequencePoint->columnStart, sequencePoint->lineEnd, sequencePoint->columnEnd); buffer_add_int(buf, sequencePoint->ilOffset); buffer_add_int(buf, sequencePoint->lineStart); @@ -10457,17 +10474,18 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g uint32_t executionInfoCount, localVariableCount = 0, i; const Il2CppMethodExecutionContextInfo* executionContextInfo; const Il2CppMethodHeaderInfo* headerInfo; + const Il2CppMethodScope* scopes; - GetExecutionContextAndHeaderInfo(method, &executionInfoCount, &executionContextInfo, &headerInfo); + GetExecutionContextAndHeaderInfo(method, &executionInfoCount, &executionContextInfo, &headerInfo, &scopes); if (CHECK_PROTOCOL_VERSION(2, 43)) { if (headerInfo) { - buffer_add_int(buf, headerInfo->m_numScopes); - for (i = 0; i < headerInfo->m_numScopes; ++i) + buffer_add_int(buf, headerInfo->numScopes); + for (i = 0; i < headerInfo->numScopes; ++i) { - buffer_add_int(buf, headerInfo->m_scopes[i].startOffset); - buffer_add_int(buf, headerInfo->m_scopes[i].endOffset); + buffer_add_int(buf, scopes[i].startOffset); + buffer_add_int(buf, scopes[i].endOffset); } } else @@ -10478,7 +10496,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g for (i = 0; i < executionInfoCount; i++) { - if (executionContextInfo[i].m_variableKind == kMethodVariableKind_LocalVariable) + if (executionContextInfo[i].variableKind == kMethodVariableKind_LocalVariable) localVariableCount++; } @@ -10486,21 +10504,21 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g for (i = 0; i < executionInfoCount; i++) { - if (executionContextInfo[i].m_variableKind == kMethodVariableKind_LocalVariable) - buffer_add_typeid(buf, domain, mono_class_from_mono_type(*executionContextInfo[i].m_type)); + if (executionContextInfo[i].variableKind == kMethodVariableKind_LocalVariable) + buffer_add_typeid(buf, domain, mono_class_from_mono_type(il2cpp_get_type_from_index(executionContextInfo[i].typeIndex))); } for (i = 0; i < executionInfoCount; i++) { - if (executionContextInfo[i].m_variableKind == kMethodVariableKind_LocalVariable) - buffer_add_string(buf, executionContextInfo[i].m_name); + if (executionContextInfo[i].variableKind == kMethodVariableKind_LocalVariable) + buffer_add_string(buf, g_il2cpp_metadata->methodExecutionContextInfoStrings[executionContextInfo[i].nameIndex]); } for (i = 0; i < executionInfoCount; i++) { - if (executionContextInfo[i].m_variableKind == kMethodVariableKind_LocalVariable) { - buffer_add_int(buf, executionContextInfo[i].m_start); - buffer_add_int(buf, executionContextInfo[i].m_end); + if (executionContextInfo[i].variableKind == kMethodVariableKind_LocalVariable) { + buffer_add_int(buf, executionContextInfo[i].startOffset); + buffer_add_int(buf, executionContextInfo[i].endOffset); } } #endif // !RUNTIME_IL2CPP @@ -10934,18 +10952,24 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf) #ifdef RUNTIME_IL2CPP -static uint32_t GetExecutionContextIndex(const Il2CppSequencePoint* sequencePoint, MethodVariableKind variableKind, uint32_t variablePosition) +static uint32_t GetExecutionContextIndexAndType(const Il2CppSequencePoint* sequencePoint, MethodVariableKind variableKind, uint32_t variablePosition, MonoType **type) { uint32_t executionContextPosition, variablesIterated = 0; + Il2CppMethodExecutionContextInfoIndex *index = &g_il2cpp_metadata->methodExecutionContextInfoIndexes[sequencePoint->methodIndex]; + Il2CppMethodExecutionContextInfo *executionContextInfos = &g_il2cpp_metadata->methodExecutionContextInfos[index->tableIndex][index->startIndex]; + for (executionContextPosition = 0;; executionContextPosition++) { - g_assert(executionContextPosition < sequencePoint->executionContextInfoCount); + g_assert(executionContextPosition < index->count); - if (sequencePoint->executionContextInfos[executionContextPosition].m_variableKind == variableKind) + if (executionContextInfos[executionContextPosition].variableKind == variableKind) { - if (variablesIterated == variablePosition) - return executionContextPosition; + if (variablesIterated == variablePosition) + { + *type = il2cpp_get_type_from_index(executionContextInfos[executionContextPosition].typeIndex); + return executionContextPosition; + } variablesIterated++; } @@ -10956,12 +10980,11 @@ static void GetVariable(DebuggerTlsData* tls, StackFrame* frame, MethodVariableK { for (int frame_index = 0; frame_index < tls->il2cpp_context.frameCount; ++frame_index) { - if (tls->il2cpp_context.sequencePoints[frame_index]->method == frame->actual_method) + if (il2cpp_get_seq_point_method(tls->il2cpp_context.sequencePoints[frame_index]) == frame->actual_method) { Il2CppSequencePoint* sequencePoint = tls->il2cpp_context.sequencePoints[frame_index]; Il2CppSequencePointExecutionContext* executionContext = tls->il2cpp_context.executionContexts[frame_index]; - uint32_t executionContextPosition = GetExecutionContextIndex(sequencePoint, variableKind, variablePosition); - *type = *sequencePoint->executionContextInfos[executionContextPosition].m_type; + uint32_t executionContextPosition = GetExecutionContextIndexAndType(sequencePoint, variableKind, variablePosition, type); *var = executionContext->values[executionContextPosition]; } } @@ -11132,7 +11155,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) #else for (int frame_index = 0; frame_index < tls->il2cpp_context.frameCount; ++frame_index) { - if (tls->il2cpp_context.sequencePoints[frame_index]->method == frame->actual_method) + if (il2cpp_get_seq_point_method(tls->il2cpp_context.sequencePoints[frame_index]) == frame->actual_method) { buffer_add_value_full (buf, &frame->actual_method->klass->this_arg, tls->il2cpp_context.executionContexts[frame_index]->values[0], frame->domain, TRUE, NULL); break; @@ -12061,7 +12084,7 @@ unity_process_breakpoint_inner(DebuggerTlsData *tls, gboolean from_signal, Il2Cp //MonoSeqPointInfo *info; SeqPoint sp; gboolean found_sp; - MonoMethod* method = sequencePoint->method; + MonoMethod* method = il2cpp_get_seq_point_method(sequencePoint); /* * Skip the instruction causing the breakpoint signal. @@ -12084,7 +12107,7 @@ unity_process_breakpoint_inner(DebuggerTlsData *tls, gboolean from_signal, Il2Cp for (i = 0; i < breakpoints->len; ++i) { bp = (MonoBreakpoint *)g_ptr_array_index(breakpoints, i); - if (!bp->method || !il2cpp_mono_methods_match(bp->method, sequencePoint->method)) + if (!bp->method || !il2cpp_mono_methods_match(bp->method, method)) continue; if (bp->req->event_kind == EVENT_KIND_STEP) diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index 9ace27b5d6b5..ed71752c12d1 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -446,5 +446,8 @@ void il2cpp_mono_thread_detach(MonoThread* thread); MonoClass* il2cpp_mono_get_string_class (void); Il2CppSequencePoint* il2cpp_get_sequence_point(int id); char* il2cpp_assembly_get_full_name(MonoAssembly *assembly); +const MonoMethod* il2cpp_get_seq_point_method(Il2CppSequencePoint *seqPoint); +const MonoClass* il2cpp_get_class_from_index(int index); +const MonoType* il2cpp_get_type_from_index(int index); #endif // RUNTIME_IL2CPP diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index 3f2696d5b943..e8ae454f227b 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -1504,5 +1504,23 @@ char* il2cpp_assembly_get_full_name(MonoAssembly *assembly) return g_strdup(s.c_str()); } +const MonoMethod* il2cpp_get_seq_point_method(Il2CppSequencePoint *seqPoint) +{ + return il2cpp::utils::Debugger::GetSequencePointMethod(seqPoint); +} + +const MonoClass* il2cpp_get_class_from_index(int index) +{ + if (index < 0) + return NULL; + + return il2cpp::vm::MetadataCache::GetTypeInfoFromTypeIndex(index); +} + +const MonoType* il2cpp_get_type_from_index(int index) +{ + return il2cpp::vm::MetadataCache::GetIl2CppTypeFromIndex(index); +} + } #endif // RUNTIME_IL2CPP From 6b9a6f9e4a311c7be51ed085ea18fd1955f96cac Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Wed, 14 Feb 2018 14:49:16 -0500 Subject: [PATCH 146/582] Initial changes to get the debugger to compile on PS4 --- mono/eglib/gpath.c | 4 ++++ mono/utils/dlmalloc.c | 2 +- mono/utils/mono-hwcap-x86.c | 2 +- mono/utils/mono-membar.h | 20 +++++++++++++++++++- mono/utils/mono-proclib.c | 11 +++++++---- mono/utils/networking-posix.c | 4 ++++ mono/utils/networking.c | 4 ++++ mono/utils/networking.h | 6 ++++++ 8 files changed, 46 insertions(+), 7 deletions(-) diff --git a/mono/eglib/gpath.c b/mono/eglib/gpath.c index 21e777046034..6448b0bac18d 100644 --- a/mono/eglib/gpath.c +++ b/mono/eglib/gpath.c @@ -251,11 +251,13 @@ g_find_program_in_path (const gchar *program) x = NULL; probe_path = g_build_path (G_DIR_SEPARATOR_S, l, program, NULL); +#if !defined(NO_HAVE_ACCESS) if (access (probe_path, X_OK) == 0){ /* FIXME: on windows this is just a read permissions test */ g_free (curdir); g_free (p); return probe_path; } +#endif g_free (probe_path); #ifdef G_OS_WIN32 @@ -265,12 +267,14 @@ g_find_program_in_path (const gchar *program) while (suffix_list[listx]) { program_exe = g_strjoin(NULL,program,suffix_list[listx],NULL); probe_path = g_build_path (G_DIR_SEPARATOR_S, l, program_exe, NULL); +#if !defined(NO_HAVE_ACCESS) if (access (probe_path, X_OK) == 0){ /* FIXME: on windows this is just a read permissions test */ g_free (curdir); g_free (p); g_free (program_exe); return probe_path; } +#endif listx++; g_free (probe_path); g_free (program_exe); diff --git a/mono/utils/dlmalloc.c b/mono/utils/dlmalloc.c index 296893ff2e7f..2f14c9e6a76d 100644 --- a/mono/utils/dlmalloc.c +++ b/mono/utils/dlmalloc.c @@ -1214,7 +1214,7 @@ extern void* sbrk(ptrdiff_t); # define _SC_PAGE_SIZE _SC_PAGESIZE # endif # endif -# ifdef _SC_PAGE_SIZE +# if defined (HAVE_SYSCONF) && defined (_SC_PAGESIZE) # define malloc_getpagesize sysconf(_SC_PAGE_SIZE) # else # if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) diff --git a/mono/utils/mono-hwcap-x86.c b/mono/utils/mono-hwcap-x86.c index 7a4b859a8e44..ae66294df88e 100644 --- a/mono/utils/mono-hwcap-x86.c +++ b/mono/utils/mono-hwcap-x86.c @@ -147,7 +147,7 @@ mono_hwcap_arch_init (void) } } -#if defined(HAVE_UNISTD_H) +#if defined(HAVE_UNISTD_H) && !defined(NO_HAVE_ACCESS) mono_hwcap_x86_is_xen = !access ("/proc/xen", F_OK); #endif } diff --git a/mono/utils/mono-membar.h b/mono/utils/mono-membar.h index 7abf273a6508..33e4eac22a34 100644 --- a/mono/utils/mono-membar.h +++ b/mono/utils/mono-membar.h @@ -76,7 +76,25 @@ static inline void mono_memory_write_barrier (void) { mono_memory_barrier (); } -#else + +#elif defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS) + +static inline void mono_memory_barrier (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +static inline void mono_memory_read_barrier (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +static inline void mono_memory_write_barrier (void) +{ + g_assert(0 && "This function is not yet implemented for the Unity platform."); +} + +#else #error "Don't know how to do memory barriers!" #endif diff --git a/mono/utils/mono-proclib.c b/mono/utils/mono-proclib.c index 714d9eb7a245..9238356926db 100644 --- a/mono/utils/mono-proclib.c +++ b/mono/utils/mono-proclib.c @@ -32,8 +32,10 @@ #ifdef HAVE_SYS_SYSCTL_H #include #endif +#ifdef HAVE_SYS_RESOURCE_H #include #endif +#endif #if defined(__HAIKU__) #include #endif @@ -519,7 +521,7 @@ get_user_hz (void) { static int user_hz = 0; if (user_hz == 0) { -#ifdef _SC_CLK_TCK +#if defined (_SC_CLK_TCK) && defined (HAVE_SYSCONF) user_hz = sysconf (_SC_CLK_TCK); #endif if (user_hz == 0) @@ -761,7 +763,7 @@ mono_cpu_count (void) * [5] https://github.com/dotnet/coreclr/blob/7058273693db2555f127ce16e6b0c5b40fb04867/src/pal/src/misc/sysinfo.cpp#L148 */ -#ifdef _SC_NPROCESSORS_CONF +#if defined (_SC_NPROCESSORS_CONF) && defined (HAVE_SYSCONF) { int count = sysconf (_SC_NPROCESSORS_CONF); if (count > 0) @@ -778,7 +780,7 @@ mono_cpu_count (void) return CPU_COUNT (&set); } #endif -#ifdef _SC_NPROCESSORS_ONLN +#if defined (_SC_NPROCESSORS_ONLN) && defined (HAVE_SYSCONF) { int count = sysconf (_SC_NPROCESSORS_ONLN); if (count > 0) @@ -913,6 +915,7 @@ gint32 mono_cpu_usage (MonoCpuUsageState *prev) { gint32 cpu_usage = 0; +#ifdef HAVE_GETRUSAGE gint64 cpu_total_time; gint64 cpu_busy_time; struct rusage resource_usage; @@ -940,7 +943,7 @@ mono_cpu_usage (MonoCpuUsageState *prev) if (cpu_total_time > 0 && cpu_busy_time > 0) cpu_usage = (gint32)(cpu_busy_time * 100 / cpu_total_time); - +#endif return cpu_usage; } #endif /* !HOST_WIN32 */ diff --git a/mono/utils/networking-posix.c b/mono/utils/networking-posix.c index caa2073a539e..a771f55e0e7c 100644 --- a/mono/utils/networking-posix.c +++ b/mono/utils/networking-posix.c @@ -36,8 +36,10 @@ get_address_from_sockaddr (struct sockaddr *sa) switch (sa->sa_family) { case AF_INET: return &((struct sockaddr_in*)sa)->sin_addr; +#ifdef HAVE_STRUCT_SOCKADDR_IN6 case AF_INET6: return &((struct sockaddr_in6*)sa)->sin6_addr; +#endif } return NULL; } @@ -92,9 +94,11 @@ mono_get_address_info (const char *hostname, int port, int flags, MonoAddressInf if (cur->family == PF_INET) { cur->address_len = sizeof (struct in_addr); cur->address.v4 = ((struct sockaddr_in*)res->ai_addr)->sin_addr; +#ifdef HAVE_STRUCT_SOCKADDR_IN6 } else if (cur->family == PF_INET6) { cur->address_len = sizeof (struct in6_addr); cur->address.v6 = ((struct sockaddr_in6*)res->ai_addr)->sin6_addr; +#endif } else { g_warning ("Cannot handle address family %d", cur->family); res = res->ai_next; diff --git a/mono/utils/networking.c b/mono/utils/networking.c index 104f3e5fa841..6f643dfd6923 100644 --- a/mono/utils/networking.c +++ b/mono/utils/networking.c @@ -17,8 +17,10 @@ mono_address_size_for_family (int family) switch (family) { case AF_INET: return sizeof (struct in_addr); +#ifdef HAVE_STRUCT_SOCKADDR_IN6 case AF_INET6: return sizeof (struct in6_addr); +#endif } return 0; } @@ -53,6 +55,7 @@ mono_socket_address_init (MonoSocketAddress *sa, socklen_t *len, int family, con #if HAVE_SOCKADDR_IN_SIN_LEN sa->v4.sin_len = sizeof (*len); #endif +#ifdef HAVE_STRUCT_SOCKADDR_IN6 } else if (family == AF_INET6) { *len = sizeof (struct sockaddr_in6); @@ -61,6 +64,7 @@ mono_socket_address_init (MonoSocketAddress *sa, socklen_t *len, int family, con sa->v6.sin6_port = htons (port); #if HAVE_SOCKADDR_IN6_SIN_LEN sa->v6.sin6_len = sizeof (*len); +#endif #endif } else { g_error ("Cannot handle address family %d", family); diff --git a/mono/utils/networking.h b/mono/utils/networking.h index f9c5f63dbc02..357c29933986 100644 --- a/mono/utils/networking.h +++ b/mono/utils/networking.h @@ -54,7 +54,9 @@ struct _MonoAddressEntry { int address_len; union { struct in_addr v4; +#ifdef HAVE_STRUCT_SOCKADDR_IN6 struct in6_addr v6; +#endif } address; const char *canonical_name; MonoAddressEntry *next; @@ -67,7 +69,9 @@ typedef struct { typedef union { struct sockaddr_in v4; +#ifdef HAVE_STRUCT_SOCKADDR_IN6 struct sockaddr_in6 v6; +#endif struct sockaddr addr; } MonoSocketAddress; @@ -75,7 +79,9 @@ typedef struct { int family; union { struct in_addr v4; +#ifdef HAVE_STRUCT_SOCKADDR_IN6 struct in6_addr v6; +#endif } addr; } MonoAddress; From 18b971e53b3d74e9b184f88d26c98f35e6782135 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Thu, 15 Feb 2018 10:04:41 -0500 Subject: [PATCH 147/582] Add missing files to be copied from Mono. Update the copy script to fail when an expected source file is not found. --- external/buildscripts/copy_il2cpp_sources.pl | 124 +- external/buildscripts/sources.txt | 1097 +++++++++--------- 2 files changed, 626 insertions(+), 595 deletions(-) diff --git a/external/buildscripts/copy_il2cpp_sources.pl b/external/buildscripts/copy_il2cpp_sources.pl index c8a28c9e5d0c..2f5b63364bb4 100644 --- a/external/buildscripts/copy_il2cpp_sources.pl +++ b/external/buildscripts/copy_il2cpp_sources.pl @@ -1,60 +1,64 @@ -# -# Use this script to copy the Mono file used by IL2CPP. -# perl external\buildscripts\copy_il2cpp_sources.pl --monoroot= --sourcesroot=\External\MonoBleedingEdge\builds\source -# - -use File::Basename; -use File::Copy; -use File::Path; -use Getopt::Long; - -my $monoroot =""; -my $sourcesroot = ""; - -GetOptions( - 'monoroot=s'=>\$monoroot, - 'sourcesroot=s'=>\$sourcesroot, -) or die ("illegal cmdline options"); - -my $sourcesFile = "$monoroot/external/buildscripts/sources.txt"; -open(SOURCE_FILE, $sourcesFile) or die "failed opening $sourcesFile\n"; -my @listOfSourceFilesLines = ; -close(SOURCE_FILE); -chomp(@listOfSourceFilesLines); - -my $isPrivateFile = 0; -foreach my $sourcesLine(@listOfSourceFilesLines) -{ - if($sourcesLine =~ /#.*/) - { - next; - } - elsif($sourcesLine =~ /SOURCES:/ or $sourcesLine =~ /HEADERS:/ or $sourcesLine =~ /METADATA:/) - { - $isPrivateFile = 0; - next; - } - elsif($sourcesLine =~ /PRIVATE:/) - { - $isPrivateFile = 1; - next; - } - - $fileToCopy = "$monoroot/$sourcesLine"; - $destFile = "$sourcesroot/$sourcesLine"; - if($isPrivateFile) - { - $destFile =~ s/(.*)\/(.*\.c)/$1\/private\/$2/g; - } - - $destDir = dirname("$destFile"); - if (!-d $destDir) - { - mkpath($destDir) or die "failed making directory $destDir\n"; - } - - if (-e $fileToCopy) - { - copy($fileToCopy, $destFile) or die "failed to copy $fileToCopy to $destFile\n"; - } -} +# +# Use this script to copy the Mono file used by IL2CPP. +# perl external\buildscripts\copy_il2cpp_sources.pl --monoroot= --sourcesroot=\External\MonoBleedingEdge\builds\source +# + +use File::Basename; +use File::Copy; +use File::Path; +use Getopt::Long; + +my $monoroot =""; +my $sourcesroot = ""; + +GetOptions( + 'monoroot=s'=>\$monoroot, + 'sourcesroot=s'=>\$sourcesroot, +) or die ("illegal cmdline options"); + +my $sourcesFile = "$monoroot/external/buildscripts/sources.txt"; +open(SOURCE_FILE, $sourcesFile) or die "failed opening $sourcesFile\n"; +my @listOfSourceFilesLines = ; +close(SOURCE_FILE); +chomp(@listOfSourceFilesLines); + +my $isPrivateFile = 0; +foreach my $sourcesLine(@listOfSourceFilesLines) +{ + if($sourcesLine =~ /#.*/) + { + next; + } + elsif($sourcesLine =~ /SOURCES:/ or $sourcesLine =~ /HEADERS:/ or $sourcesLine =~ /METADATA:/) + { + $isPrivateFile = 0; + next; + } + elsif($sourcesLine =~ /PRIVATE:/) + { + $isPrivateFile = 1; + next; + } + + $fileToCopy = "$monoroot/$sourcesLine"; + $destFile = "$sourcesroot/$sourcesLine"; + if($isPrivateFile) + { + $destFile =~ s/(.*)\/(.*\.c)/$1\/private\/$2/g; + } + + $destDir = dirname("$destFile"); + if (!-d $destDir) + { + mkpath($destDir) or die "failed making directory $destDir\n"; + } + + if (-e $fileToCopy) + { + copy($fileToCopy, $destFile) or die "failed to copy $fileToCopy to $destFile\n"; + } + else + { + die "Source file to copy does not exist: $fileToCopy\n"; + } +} diff --git a/external/buildscripts/sources.txt b/external/buildscripts/sources.txt index dd393f7b0718..09d977c41f3b 100644 --- a/external/buildscripts/sources.txt +++ b/external/buildscripts/sources.txt @@ -1,535 +1,562 @@ -#################### -#mono eglib files -#################### -SOURCES: -eglib/src/garray.c -eglib/src/gbytearray.c -eglib/src/gerror.c -eglib/src/gfile.c -eglib/src/ghashtable.c -eglib/src/giconv.c -eglib/src/glist.c -eglib/src/gmarkup.c -eglib/src/gmem.c -eglib/src/goutput.c -eglib/src/gpattern.c -eglib/src/gptrarray.c -eglib/src/gqsort.c -eglib/src/gqueue.c -eglib/src/gshell.c -eglib/src/gslist.c -eglib/src/gspawn.c -eglib/src/gpath.c -eglib/src/gstr.c -eglib/src/gstring.c -eglib/src/gunicode.c -eglib/src/gutf8.c -eglib/src/gmisc-unity.c -eglib/src/gfile-unity.c -eglib/src/gdate-unity.c -eglib/src/gpath-unity.c -eglib/src/gdir-unity.c -eglib/src/gunicode-win32.c -HEADERS: -eglib/src/glib.h -eglib/src/gmodule.h -eglib/src/sort.frag.h -eglib/src/eglib-remap.h -eglib/src/unicode-data.h -#################### -#mono utils files -#################### -SOURCES: -mono/utils/dlmalloc.c -mono/utils/hazard-pointer.c -mono/utils/json.c -mono/utils/lock-free-alloc.c -mono/utils/lock-free-array-queue.c -mono/utils/lock-free-queue.c -mono/utils/mach-support-amd64.c -mono/utils/mach-support-x86.c -mono/utils/mach-support.c -mono/utils/mono-codeman.c -mono/utils/mono-conc-hashtable.c -mono/utils/mono-context.c -mono/utils/mono-counters.c -mono/utils/mono-dl-unity.c -mono/utils/mono-dl-windows.c -mono/utils/mono-dl-darwin.c -mono/utils/mono-dl-posix.c -mono/utils/mono-dl.c -mono/utils/mono-error.c -mono/utils/mono-filemap.c -mono/utils/mono-internal-hash.c -mono/utils/mono-io-portability.c -mono/utils/mono-linked-list-set.c -mono/utils/mono-logger.c -mono/utils/mono-log-unity.c -mono/utils/mono-log-android.c -mono/utils/mono-log-windows.c -mono/utils/mono-log-darwin.c -mono/utils/mono-log-posix.c -mono/utils/mono-log-common.c -mono/utils/mono-math.c -mono/utils/mono-md5.c -mono/utils/mono-mmap.c -mono/utils/mono-mmap-windows.c -mono/utils/mono-networkinterfaces.c -mono/utils/mono-threads-state-machine.c -mono/utils/networking.c -mono/utils/networking-posix.c -mono/utils/networking-missing.c -mono/utils/networking-windows.c -mono/utils/networking-unity.c -mono/utils/mono-path.c -mono/utils/mono-poll.c -mono/utils/mono-proclib.c -mono/utils/mono-proclib-windows.c -mono/utils/mono-property-hash.c -mono/utils/mono-publib.c -mono/utils/mono-sha1.c -mono/utils/mono-stdlib.c -mono/utils/mono-threads-android.c -mono/utils/mono-threads-mach.c -mono/utils/mono-threads-mach-helper.c -mono/utils/mono-threads-posix.c -mono/utils/mono-threads-posix-signals.c -mono/utils/mono-threads-windows.c -mono/utils/mono-threads.c -mono/utils/mono-threads-coop.c -mono/utils/mono-threads-unity.c -mono/utils/mono-tls.c -mono/utils/mono-uri.c -mono/utils/mono-value-hash.c -mono/utils/monobitset.c -mono/utils/strenc.c -mono/utils/atomic.c -mono/utils/mono-hwcap.c -mono/utils/mono-hwcap-arm.c -mono/utils/mono-hwcap-x86.c -mono/utils/bsearch.c -mono/utils/memfuncs.c -mono/utils/parse.c -mono/utils/os-event-unity.c -mono/utils/os-event-win32.c -mono/utils/os-event-unix.c -mono/utils/unity-rand.c -mono/utils/unity-time.c -mono/utils/win64.asm -HEADERS: -mono/utils/checked-build.h -mono/utils/dlmalloc.h -mono/utils/dtrace.h -mono/utils/freebsd-dwarf.h -mono/utils/freebsd-elf32.h -mono/utils/freebsd-elf64.h -mono/utils/freebsd-elf_common.h -mono/utils/gc_wrapper.h -mono/utils/hazard-pointer.h -mono/utils/json.h -mono/utils/linux_magic.h -mono/utils/lock-free-alloc.h -mono/utils/lock-free-array-queue.h -mono/utils/lock-free-queue.h -mono/utils/mach-support.h -mono/utils/memcheck.h -mono/utils/mono-codeman.h -mono/utils/mono-compiler.h -mono/utils/mono-complex.h -mono/utils/mono-conc-hashtable.h -mono/utils/mono-context.h -mono/utils/mono-coop-mutex.h -mono/utils/mono-coop-semaphore.h -mono/utils/mono-counters.h -mono/utils/mono-digest.h -mono/utils/mono-dl-fallback.h -mono/utils/mono-dl-windows-internals.h -mono/utils/mono-dl.h -mono/utils/mono-embed.h -mono/utils/mono-error-internals.h -mono/utils/mono-error.h -mono/utils/mono-internal-hash.h -mono/utils/mono-io-portability.h -mono/utils/mono-lazy-init.h -mono/utils/mono-linked-list-set.h -mono/utils/mono-logger-internals.h -mono/utils/mono-logger.h -mono/utils/mono-machine.h -mono/utils/mono-math.h -mono/utils/mono-membar.h -mono/utils/mono-memory-model.h -mono/utils/mono-mmap-internals.h -mono/utils/mono-mmap-windows-internals.h -mono/utils/mono-mmap.h -mono/utils/mono-networkinterfaces.h -mono/utils/mono-once.h -mono/utils/mono-os-mutex.h -mono/utils/mono-os-semaphore.h -mono/utils/mono-path.h -mono/utils/mono-poll.h -mono/utils/mono-proclib.h -mono/utils/mono-property-hash.h -mono/utils/mono-publib.h -mono/utils/mono-rand.h -mono/utils/mono-sigcontext.h -mono/utils/mono-signal-handler.h -mono/utils/mono-stack-unwinding.h -mono/utils/mono-stdlib.h -mono/utils/mono-string.h -mono/utils/mono-threads.h -mono/utils/mono-threads-api.h -mono/utils/mono-threads-coop.h -mono/utils/mono-threads-debug.h -mono/utils/mono-time.h -mono/utils/mono-tls.h -mono/utils/mono-uri.h -mono/utils/mono-value-hash.h -mono/utils/monobitset.h -mono/utils/networking.h -mono/utils/refcount.h -mono/utils/strenc.h -mono/utils/valgrind.h -mono/utils/atomic.h -mono/utils/mono-hwcap-vars.h -mono/utils/mono-hwcap.h -mono/utils/bsearch.h -mono/utils/memfuncs.h -mono/utils/parse.h -mono/utils/os-event.h -mono/utils/w32api.h -#################### -#mono runtime files -#################### -SOURCES: -mono/metadata/appdomain.c -mono/metadata/assembly.c -mono/metadata/attach.c -mono/metadata/boehm-gc.c -mono/metadata/class.c -mono/metadata/class-accessors.c -mono/metadata/cominterop.c -mono/metadata/console-unity.c -mono/metadata/coree.c -mono/metadata/custom-attrs.c -mono/metadata/debug-helpers.c -mono/metadata/debug-mono-ppdb.c -mono/metadata/debug-mono-symfile.c -mono/metadata/decimal-ms.c -mono/metadata/domain.c -mono/metadata/dynamic-image.c -mono/metadata/dynamic-stream.c -mono/metadata/environment.c -mono/metadata/exception.c -mono/metadata/file-mmap-unity.c -mono/metadata/filewatcher.c -mono/metadata/gc-stats.c -mono/metadata/gc.c -mono/metadata/handle.c -mono/metadata/icall.c -mono/metadata/icall-windows.c -mono/metadata/image.c -mono/metadata/jit-info.c -mono/metadata/loader.c -mono/metadata/locales.c -mono/metadata/lock-tracer.c -mono/metadata/marshal.c -mono/metadata/marshal-windows.c -mono/metadata/mempool.c -mono/metadata/metadata-verify.c -mono/metadata/metadata.c -mono/metadata/metadata-cross-helpers.c -mono/metadata/method-builder.c -mono/metadata/monitor.c -mono/metadata/mono-basic-block.c -mono/metadata/mono-config.c -mono/metadata/mono-config-dirs.c -mono/metadata/mono-debug.c -mono/metadata/mono-endian.c -mono/metadata/mono-hash.c -mono/metadata/mono-mlist.c -mono/metadata/mono-perfcounters.c -mono/metadata/mono-route.c -mono/metadata/mono-security.c -mono/metadata/mono-security-windows.c -mono/metadata/nacl-stub.c -mono/metadata/null-gc.c -mono/metadata/number-ms.c -mono/metadata/object.c -mono/metadata/opcodes.c -mono/metadata/profiler.c -mono/metadata/property-bag.c -mono/metadata/rand.c -mono/metadata/reflection.c -mono/metadata/remoting.c -mono/metadata/runtime.c -mono/metadata/security-core-clr.c -mono/metadata/security-manager.c -mono/metadata/seq-points-data.c -mono/metadata/sgen-mono.c -mono/metadata/sgen-bridge.c -mono/metadata/sgen-new-bridge.c -mono/metadata/sgen-old-bridge.c -mono/metadata/sgen-tarjan-bridge.c -mono/metadata/sgen-toggleref.c -mono/metadata/sgen-stw.c -mono/metadata/sre.c -mono/metadata/sre-encode.c -mono/metadata/sre-save.c -mono/metadata/string-icalls.c -mono/metadata/sysmath.c -mono/metadata/threads.c -mono/metadata/threadpool.c -mono/metadata/threadpool-io.c -mono/metadata/threadpool-worker-default.c -mono/metadata/verify.c -mono/metadata/unity-liveness.c -mono/metadata/unity-utils.c -mono/metadata/w32error-unity.c -mono/metadata/w32error-win32.c -mono/metadata/w32error-unix.c -mono/metadata/w32event-unity.c -mono/metadata/w32file-unity.c -mono/metadata/w32file-unix-glob.c -mono/metadata/w32file.c -mono/metadata/w32handle-namespace.c -mono/metadata/w32handle.c -mono/metadata/w32mutex-unity.c -mono/metadata/w32process-unity.c -mono/metadata/w32process-unix-osx.c -mono/metadata/w32process-unix-default.c -mono/metadata/w32process-unix.c -mono/metadata/w32process-win32.c -mono/metadata/w32process.c -mono/metadata/w32semaphore-unity.c -mono/metadata/w32socket-unity.c -mono/metadata/w32socket-unix.c -mono/metadata/w32socket-win32.c -mono/metadata/w32socket.c -HEADERS: -mono/metadata/abi-details.h -mono/metadata/attrdefs.h -mono/metadata/appdomain.h -mono/metadata/appdomain-icalls.h -mono/metadata/assembly-internals.h -mono/metadata/assembly.h -mono/metadata/attach.h -mono/metadata/blob.h -mono/metadata/cil-coff.h -mono/metadata/class-inlines.h -mono/metadata/class-internals.h -mono/metadata/class.h -mono/metadata/cominterop-win32-internals.h -mono/metadata/cominterop.h -mono/metadata/console-io.h -mono/metadata/coree-internals.h -mono/metadata/coree.h -mono/metadata/culture-info-tables.h -mono/metadata/culture-info.h -mono/metadata/custom-attrs-internals.h -mono/metadata/debug-helpers.h -mono/metadata/debug-mono-ppdb.h -mono/metadata/debug-mono-symfile.h -mono/metadata/decimal-ms.h -mono/metadata/domain-internals.h -mono/metadata/dynamic-image-internals.h -mono/metadata/dynamic-stream-internals.h -mono/metadata/environment.h -mono/metadata/exception-internals.h -mono/metadata/exception.h -mono/metadata/filewatcher.h -mono/metadata/file-mmap.h -mono/metadata/gc-internals.h -mono/metadata/handle.h -mono/metadata/number-ms.h -mono/metadata/remoting.h -mono/metadata/row-indexes.h -mono/metadata/seq-points-data.h -mono/metadata/sgen-bridge-internals.h -mono/metadata/sgen-client-mono.h -mono/metadata/sgen-dynarray.h -mono/sgen/gc-internal-agnostic.h -mono/metadata/icall-def.h -mono/metadata/icall-internals.h -mono/metadata/icall-windows-internals.h -mono/metadata/il2cpp-compat-metadata.h -mono/metadata/image-internals.h -mono/metadata/image.h -mono/metadata/loader.h -mono/metadata/locales.h -mono/metadata/lock-tracer.h -mono/metadata/marshal-internals.h -mono/metadata/marshal-windows-internals.h -mono/metadata/marshal.h -mono/metadata/mempool-internals.h -mono/metadata/mempool.h -mono/metadata/metadata-internals.h -mono/metadata/metadata.h -mono/metadata/method-builder.h -mono/metadata/monitor.h -mono/metadata/mono-basic-block.h -mono/metadata/mono-config.h -mono/metadata/mono-config-dirs.h -mono/metadata/mono-debug-debugger.h -mono/metadata/mono-debug.h -mono/metadata/mono-endian.h -mono/metadata/mono-gc.h -mono/metadata/mono-hash.h -mono/metadata/mono-mlist.h -mono/metadata/mono-perfcounters-def.h -mono/metadata/mono-perfcounters.h -mono/metadata/mono-ptr-array.h -mono/metadata/mono-route.h -mono/metadata/mono-security-windows-internals.h -mono/metadata/normalization-tables.h -mono/metadata/number-formatter.h -mono/metadata/object-internals.h -mono/metadata/object-offsets.h -mono/metadata/object.h -mono/metadata/opcodes.h -mono/metadata/profiler-private.h -mono/metadata/profiler.h -mono/metadata/property-bag.h -mono/metadata/rand.h -mono/metadata/reflection.h -mono/metadata/reflection-cache.h -mono/metadata/reflection-internals.h -mono/metadata/runtime.h -mono/metadata/security-core-clr.h -mono/metadata/security-manager.h -mono/metadata/security.h -mono/metadata/sgen-bridge.h -mono/metadata/sgen-toggleref.h -mono/metadata/sre-internals.h -mono/metadata/string-icalls.h -mono/metadata/sysmath.h -mono/metadata/tabledefs.h -mono/metadata/threadpool.h -mono/metadata/threadpool-io.h -mono/metadata/threadpool-worker.h -mono/metadata/threads.h -mono/metadata/threads-types.h -mono/metadata/tokentype.h -mono/metadata/verify-internals.h -mono/metadata/verify.h -mono/metadata/unity-utils.h -mono/metadata/wrapper-types.h -mono/metadata/w32error.h -mono/metadata/w32event.h -mono/metadata/w32file-internals.h -mono/metadata/w32file-win32-internals.h -mono/metadata/w32file-unix-glob.h -mono/metadata/w32file.h -mono/metadata/w32handle-namespace.h -mono/metadata/w32handle.h -mono/metadata/w32mutex.h -mono/metadata/w32process-internals.h -mono/metadata/w32process-unix-internals.h -mono/metadata/w32process-win32-internals.h -mono/metadata/w32process.h -mono/metadata/w32semaphore.h -mono/metadata/w32socket.h -mono/metadata/w32socket-internals.h -PRIVATE: -mono/metadata/threadpool-io-epoll.c -mono/metadata/threadpool-io-kqueue.c -mono/metadata/threadpool-io-poll.c -#################### -#mono sgen files -#################### -SOURCES: -mono/sgen/sgen-alloc.c -mono/sgen/sgen-array-list.c -mono/sgen/sgen-cardtable.c -mono/sgen/sgen-debug.c -mono/sgen/sgen-descriptor.c -mono/sgen/sgen-gc.c -mono/sgen/sgen-gchandles.c -mono/sgen/sgen-gray.c -mono/sgen/sgen-hash-table.c -mono/sgen/sgen-internal.c -mono/sgen/sgen-los.c -mono/sgen/sgen-marksweep.c -mono/sgen/sgen-memory-governor.c -mono/sgen/sgen-nursery-allocator.c -mono/sgen/sgen-pinning-stats.c -mono/sgen/sgen-pinning.c -mono/sgen/sgen-pointer-queue.c -mono/sgen/sgen-protocol.c -mono/sgen/sgen-qsort.c -mono/sgen/sgen-simple-nursery.c -mono/sgen/sgen-split-nursery.c -mono/sgen/sgen-thread-pool.c -mono/sgen/sgen-workers.c -mono/sgen/sgen-fin-weak-hash.c -mono/sgen/sgen-layout-stats.c -HEADERS: -mono/sgen/gc-internal-agnostic.h -mono/sgen/sgen-archdep.h -mono/sgen/sgen-array-list.h -mono/sgen/sgen-cardtable.h -mono/sgen/sgen-client.h -mono/sgen/sgen-conf.h -mono/sgen/sgen-copy-object.h -mono/sgen/sgen-descriptor.h -mono/sgen/sgen-gc.h -mono/sgen/sgen-gray.h -mono/sgen/sgen-hash-table.h -mono/sgen/sgen-layout-stats.h -mono/sgen/sgen-major-copy-object.h -mono/sgen/sgen-marksweep-drain-gray-stack.h -mono/sgen/sgen-memory-governor.h -mono/sgen/sgen-minor-copy-object.h -mono/sgen/sgen-minor-scan-object.h -mono/sgen/sgen-pinning.h -mono/sgen/sgen-pointer-queue.h -mono/sgen/sgen-protocol-def.h -mono/sgen/sgen-protocol.h -mono/sgen/sgen-qsort.h -mono/sgen/sgen-scan-object.h -mono/sgen/sgen-tagged-pointer.h -mono/sgen/sgen-thread-pool.h -mono/sgen/sgen-workers.h -#################### -#mono cil files -#################### -METADATA: -mono/cil/opcode.def -mono/cil/tables.def -#################### -#mono arch files -#################### -HEADERS: -mono/arch/amd64/amd64-codegen.h -mono/arch/x86/x86-codegen.h -mono/arch/arm/arm-codegen.h -mono/arch/arm/arm_dpimacros.h -mono/arch/arm/arm-vfp-codegen.h -mono/arch/arm/arm_vfpmacros.h -#################### -#mono complex files -#################### -SOURCES: -support/libm/complex.c -HEADERS: -support/libm/complex.h -support/libm/math_private.h -#################### -#mono mini files -#################### -mono/mini/cfgdump.h -mono/mini/debugger-agent.c -mono/mini/debugger-agent.h -mono/mini/il2cpp-c-types.h -mono/mini/il2cpp-compat.h -mono/mini/il2cpp-stubs.cpp -mono/mini/jit.h -mono/mini/mini-amd64.h -mono/mini/mini-arch.h -mono/mini/mini-ops.h -mono/mini/mini-unwind.h -mono/mini/mini-x86.h -mono/mini/mini.h -mono/mini/optflags-def.h -mono/mini/patch-info.h -mono/mini/regalloc.h -mono/mini/seq-points.h +#################### +#mono eglib files +#################### +SOURCES: +mono/eglib/garray.c +mono/eglib/gbytearray.c +mono/eglib/gerror.c +mono/eglib/gfile.c +mono/eglib/ghashtable.c +mono/eglib/giconv.c +mono/eglib/glist.c +mono/eglib/gmarkup.c +mono/eglib/gmem.c +mono/eglib/goutput.c +mono/eglib/gpattern.c +mono/eglib/gptrarray.c +mono/eglib/gqsort.c +mono/eglib/gqueue.c +mono/eglib/gshell.c +mono/eglib/gslist.c +mono/eglib/gspawn.c +mono/eglib/gpath.c +mono/eglib/gstr.c +mono/eglib/gstring.c +mono/eglib/gunicode.c +mono/eglib/gutf8.c +mono/eglib/gmisc-unity.c +mono/eglib/gfile-unity.c +mono/eglib/gdate-unity.c +mono/eglib/gdir-unity.c +mono/eglib/gunicode-win32.c +HEADERS: +mono/eglib/glib.h +mono/eglib/gmodule.h +mono/eglib/sort.frag.h +mono/eglib/eglib-remap.h +mono/eglib/unicode-data.h +#################### +#mono utils files +#################### +SOURCES: +mono/utils/dlmalloc.c +mono/utils/hazard-pointer.c +mono/utils/json.c +mono/utils/lock-free-alloc.c +mono/utils/lock-free-array-queue.c +mono/utils/lock-free-queue.c +mono/utils/mach-support-amd64.c +mono/utils/mach-support-x86.c +mono/utils/mach-support.c +mono/utils/mono-codeman.c +mono/utils/mono-conc-hashtable.c +mono/utils/mono-context.c +mono/utils/mono-counters.c +mono/utils/mono-dl-unity.c +mono/utils/mono-dl-windows.c +mono/utils/mono-dl-darwin.c +mono/utils/mono-dl-posix.c +mono/utils/mono-dl.c +mono/utils/mono-error.c +mono/utils/mono-filemap.c +mono/utils/mono-internal-hash.c +mono/utils/mono-io-portability.c +mono/utils/mono-linked-list-set.c +mono/utils/mono-logger.c +mono/utils/mono-log-unity.c +mono/utils/mono-log-android.c +mono/utils/mono-log-windows.c +mono/utils/mono-log-darwin.c +mono/utils/mono-log-posix.c +mono/utils/mono-log-common.c +mono/utils/mono-math.c +mono/utils/mono-md5.c +mono/utils/mono-mmap.c +mono/utils/mono-mmap-windows.c +mono/utils/mono-os-mutex.c +mono/utils/mono-os-wait-win32.c +mono/utils/mono-os-wait-win32-uwp.c +mono/utils/mono-networkinterfaces.c +mono/utils/mono-threads-state-machine.c +mono/utils/networking.c +mono/utils/networking-posix.c +mono/utils/networking-missing.c +mono/utils/networking-windows.c +mono/utils/networking-unity.c +mono/utils/mono-path.c +mono/utils/mono-poll.c +mono/utils/mono-proclib.c +mono/utils/mono-proclib-windows.c +mono/utils/mono-property-hash.c +mono/utils/mono-publib.c +mono/utils/mono-sha1.c +mono/utils/mono-stdlib.c +mono/utils/mono-threads-android.c +mono/utils/mono-threads-mach.c +mono/utils/mono-threads-mach-helper.c +mono/utils/mono-threads-posix.c +mono/utils/mono-threads-posix-signals.c +mono/utils/mono-threads-windows.c +mono/utils/mono-threads.c +mono/utils/mono-threads-coop.c +mono/utils/mono-threads-unity.c +mono/utils/mono-tls.c +mono/utils/mono-uri.c +mono/utils/mono-value-hash.c +mono/utils/monobitset.c +mono/utils/strenc.c +mono/utils/atomic.c +mono/utils/mono-hwcap.c +mono/utils/mono-hwcap-arm.c +mono/utils/mono-hwcap-x86.c +mono/utils/bsearch.c +mono/utils/memfuncs.c +mono/utils/parse.c +mono/utils/os-event-unity.c +mono/utils/os-event-win32.c +mono/utils/os-event-unix.c +mono/utils/unity-rand.c +mono/utils/unity-time.c +mono/utils/win64.asm +HEADERS: +mono/utils/checked-build.h +mono/utils/dlmalloc.h +mono/utils/dtrace.h +mono/utils/freebsd-dwarf.h +mono/utils/freebsd-elf32.h +mono/utils/freebsd-elf64.h +mono/utils/freebsd-elf_common.h +mono/utils/gc_wrapper.h +mono/utils/hazard-pointer.h +mono/utils/json.h +mono/utils/linux_magic.h +mono/utils/lock-free-alloc.h +mono/utils/lock-free-array-queue.h +mono/utils/lock-free-queue.h +mono/utils/mach-support.h +mono/utils/memcheck.h +mono/utils/mono-codeman.h +mono/utils/mono-compiler.h +mono/utils/mono-complex.h +mono/utils/mono-conc-hashtable.h +mono/utils/mono-context.h +mono/utils/mono-coop-mutex.h +mono/utils/mono-coop-semaphore.h +mono/utils/mono-counters.h +mono/utils/mono-digest.h +mono/utils/mono-dl-fallback.h +mono/utils/mono-dl-windows-internals.h +mono/utils/mono-dl.h +mono/utils/mono-embed.h +mono/utils/mono-error-internals.h +mono/utils/mono-error.h +mono/utils/mono-internal-hash.h +mono/utils/mono-io-portability.h +mono/utils/mono-lazy-init.h +mono/utils/mono-linked-list-set.h +mono/utils/mono-logger-internals.h +mono/utils/mono-logger.h +mono/utils/mono-machine.h +mono/utils/mono-math.h +mono/utils/mono-membar.h +mono/utils/mono-memory-model.h +mono/utils/mono-mmap-internals.h +mono/utils/mono-mmap-windows-internals.h +mono/utils/mono-mmap.h +mono/utils/mono-networkinterfaces.h +mono/utils/mono-once.h +mono/utils/mono-os-mutex.h +mono/utils/mono-os-semaphore.h +mono/utils/mono-os-wait.h +mono/utils/mono-path.h +mono/utils/mono-poll.h +mono/utils/mono-proclib.h +mono/utils/mono-property-hash.h +mono/utils/mono-publib.h +mono/utils/mono-rand.h +mono/utils/mono-sigcontext.h +mono/utils/mono-signal-handler.h +mono/utils/mono-stack-unwinding.h +mono/utils/mono-stdlib.h +mono/utils/mono-string.h +mono/utils/mono-threads.h +mono/utils/mono-threads-api.h +mono/utils/mono-threads-coop.h +mono/utils/mono-threads-debug.h +mono/utils/mono-time.h +mono/utils/mono-tls.h +mono/utils/mono-uri.h +mono/utils/mono-value-hash.h +mono/utils/monobitset.h +mono/utils/networking.h +mono/utils/refcount.h +mono/utils/strenc.h +mono/utils/valgrind.h +mono/utils/atomic.h +mono/utils/mono-hwcap-vars.h +mono/utils/mono-hwcap.h +mono/utils/bsearch.h +mono/utils/memfuncs.h +mono/utils/parse.h +mono/utils/os-event.h +mono/utils/unlocked.h +mono/utils/w32api.h +mono/utils/ward.h +#################### +#mono runtime files +#################### +SOURCES: +mono/metadata/appdomain.c +mono/metadata/assembly.c +mono/metadata/attach.c +mono/metadata/boehm-gc.c +mono/metadata/class.c +mono/metadata/class-accessors.c +mono/metadata/cominterop.c +mono/metadata/console-unity.c +mono/metadata/console-unix.c +mono/metadata/console-win32.c +mono/metadata/coree.c +mono/metadata/custom-attrs.c +mono/metadata/debug-helpers.c +mono/metadata/debug-mono-ppdb.c +mono/metadata/debug-mono-symfile.c +mono/metadata/decimal-ms.c +mono/metadata/domain.c +mono/metadata/dynamic-image.c +mono/metadata/dynamic-stream.c +mono/metadata/environment.c +mono/metadata/exception.c +mono/metadata/fdhandle.c +mono/metadata/file-mmap-posix.c +mono/metadata/file-mmap-unity.c +mono/metadata/file-mmap-windows.c +mono/metadata/filewatcher.c +mono/metadata/gc-stats.c +mono/metadata/gc.c +mono/metadata/handle.c +mono/metadata/icall.c +mono/metadata/icall-windows.c +mono/metadata/image.c +mono/metadata/jit-info.c +mono/metadata/loader.c +mono/metadata/locales.c +mono/metadata/lock-tracer.c +mono/metadata/marshal.c +mono/metadata/marshal-windows.c +mono/metadata/mempool.c +mono/metadata/metadata-verify.c +mono/metadata/metadata.c +mono/metadata/metadata-cross-helpers.c +mono/metadata/method-builder.c +mono/metadata/monitor.c +mono/metadata/mono-basic-block.c +mono/metadata/mono-conc-hash.c +mono/metadata/mono-config.c +mono/metadata/mono-config-dirs.c +mono/metadata/mono-debug.c +mono/metadata/mono-endian.c +mono/metadata/mono-hash.c +mono/metadata/mono-mlist.c +mono/metadata/mono-perfcounters.c +mono/metadata/mono-route.c +mono/metadata/mono-security.c +mono/metadata/mono-security-windows.c +mono/metadata/null-gc.c +mono/metadata/null-gc-handles.h +mono/metadata/number-ms.c +mono/metadata/object.c +mono/metadata/opcodes.c +mono/metadata/profiler.c +mono/metadata/property-bag.c +mono/metadata/rand.c +mono/metadata/reflection.c +mono/metadata/remoting.c +mono/metadata/runtime.c +mono/metadata/security-core-clr.c +mono/metadata/security-manager.c +mono/metadata/seq-points-data.c +mono/metadata/sgen-mono.c +mono/metadata/sgen-bridge.c +mono/metadata/sgen-new-bridge.c +mono/metadata/sgen-old-bridge.c +mono/metadata/sgen-tarjan-bridge.c +mono/metadata/sgen-toggleref.c +mono/metadata/sgen-stw.c +mono/metadata/sre.c +mono/metadata/sre-encode.c +mono/metadata/sre-save.c +mono/metadata/string-icalls.c +mono/metadata/sysmath.c +mono/metadata/threads.c +mono/metadata/threadpool.c +mono/metadata/threadpool-io.c +mono/metadata/threadpool-worker-default.c +mono/metadata/verify.c +mono/metadata/unity-liveness.c +mono/metadata/unity-utils.c +mono/metadata/unity-icall.c +mono/metadata/w32error-unity.c +mono/metadata/w32error-win32.c +mono/metadata/w32error-unix.c +mono/metadata/w32event-unity.c +mono/metadata/w32event-unix.c +mono/metadata/w32event-win32.c +mono/metadata/w32file-unity.c +mono/metadata/w32file-unix.c +mono/metadata/w32file-win32.c +mono/metadata/w32file-unix-glob.c +mono/metadata/w32file.c +mono/metadata/w32handle-namespace.c +mono/metadata/w32handle.c +mono/metadata/w32mutex-unity.c +mono/metadata/w32mutex-unix.c +mono/metadata/w32mutex-win32.c +mono/metadata/w32process-unity.c +mono/metadata/w32process-unix-osx.c +mono/metadata/w32process-unix-default.c +mono/metadata/w32process-unix.c +mono/metadata/w32process-win32.c +mono/metadata/w32process.c +mono/metadata/w32semaphore-unity.c +mono/metadata/w32semaphore-unix.c +mono/metadata/w32semaphore-win32.c +mono/metadata/w32socket-unity.c +mono/metadata/w32socket-unix.c +mono/metadata/w32socket-win32.c +mono/metadata/w32socket.c +HEADERS: +mono/metadata/abi-details.h +mono/metadata/attrdefs.h +mono/metadata/appdomain.h +mono/metadata/appdomain-icalls.h +mono/metadata/assembly-internals.h +mono/metadata/assembly.h +mono/metadata/attach.h +mono/metadata/blob.h +mono/metadata/callspec.h +mono/metadata/cil-coff.h +mono/metadata/class-inlines.h +mono/metadata/class-internals.h +mono/metadata/class.h +mono/metadata/cominterop-win32-internals.h +mono/metadata/cominterop.h +mono/metadata/console-io.h +mono/metadata/coree-internals.h +mono/metadata/coree.h +mono/metadata/culture-info-tables.h +mono/metadata/culture-info.h +mono/metadata/custom-attrs-internals.h +mono/metadata/debug-helpers.h +mono/metadata/debug-internals.h +mono/metadata/debug-mono-ppdb.h +mono/metadata/debug-mono-symfile.h +mono/metadata/decimal-ms.h +mono/metadata/domain-internals.h +mono/metadata/dynamic-image-internals.h +mono/metadata/dynamic-stream-internals.h +mono/metadata/environment.h +mono/metadata/exception-internals.h +mono/metadata/exception.h +mono/metadata/fdhandle.h +mono/metadata/filewatcher.h +mono/metadata/file-mmap.h +mono/metadata/gc-internals.h +mono/metadata/handle.h +mono/metadata/number-ms.h +mono/metadata/remoting.h +mono/metadata/row-indexes.h +mono/metadata/seq-points-data.h +mono/metadata/sgen-bridge-internals.h +mono/metadata/sgen-client-mono.h +mono/metadata/sgen-dynarray.h +mono/sgen/gc-internal-agnostic.h +mono/metadata/icall-def.h +mono/metadata/icall-internals.h +mono/metadata/icall-windows-internals.h +mono/metadata/il2cpp-compat-metadata.h +mono/metadata/image-internals.h +mono/metadata/image.h +mono/metadata/loader.h +mono/metadata/locales.h +mono/metadata/lock-tracer.h +mono/metadata/marshal-internals.h +mono/metadata/marshal-windows-internals.h +mono/metadata/marshal.h +mono/metadata/mempool-internals.h +mono/metadata/mempool.h +mono/metadata/metadata-internals.h +mono/metadata/metadata.h +mono/metadata/method-builder.h +mono/metadata/monitor.h +mono/metadata/mono-basic-block.h +mono/metadata/mono-conc-hash.h +mono/metadata/mono-config.h +mono/metadata/mono-config-dirs.h +mono/metadata/mono-debug.h +mono/metadata/mono-endian.h +mono/metadata/mono-gc.h +mono/metadata/mono-hash.h +mono/metadata/mono-mlist.h +mono/metadata/mono-perfcounters-def.h +mono/metadata/mono-perfcounters.h +mono/metadata/mono-ptr-array.h +mono/metadata/mono-route.h +mono/metadata/mono-security-windows-internals.h +mono/metadata/normalization-tables.h +mono/metadata/number-formatter.h +mono/metadata/object-internals.h +mono/metadata/object-offsets.h +mono/metadata/object.h +mono/metadata/opcodes.h +mono/metadata/profiler-private.h +mono/metadata/profiler.h +mono/metadata/profiler-events.h +mono/metadata/property-bag.h +mono/metadata/rand.h +mono/metadata/reflection.h +mono/metadata/reflection-cache.h +mono/metadata/reflection-internals.h +mono/metadata/runtime.h +mono/metadata/security-core-clr.h +mono/metadata/security-manager.h +mono/metadata/security.h +mono/metadata/sgen-bridge.h +mono/metadata/sgen-toggleref.h +mono/metadata/sre-internals.h +mono/metadata/string-icalls.h +mono/metadata/sysmath.h +mono/metadata/tabledefs.h +mono/metadata/threadpool.h +mono/metadata/threadpool-io.h +mono/metadata/threadpool-worker.h +mono/metadata/threads.h +mono/metadata/threads-types.h +mono/metadata/tokentype.h +mono/metadata/verify-internals.h +mono/metadata/verify.h +mono/metadata/unity-utils.h +mono/metadata/wrapper-types.h +mono/metadata/w32error.h +mono/metadata/w32event.h +mono/metadata/w32file-internals.h +mono/metadata/w32file-win32-internals.h +mono/metadata/w32file-unix-glob.h +mono/metadata/w32file.h +mono/metadata/w32handle-namespace.h +mono/metadata/w32handle.h +mono/metadata/w32mutex.h +mono/metadata/w32process-internals.h +mono/metadata/w32process-unix-internals.h +mono/metadata/w32process-win32-internals.h +mono/metadata/w32process.h +mono/metadata/w32semaphore.h +mono/metadata/w32socket.h +mono/metadata/w32socket-internals.h +PRIVATE: +mono/metadata/threadpool-io-epoll.c +mono/metadata/threadpool-io-kqueue.c +mono/metadata/threadpool-io-poll.c +#################### +#mono sgen files +#################### +SOURCES: +mono/sgen/sgen-alloc.c +mono/sgen/sgen-array-list.c +mono/sgen/sgen-cardtable.c +mono/sgen/sgen-debug.c +mono/sgen/sgen-descriptor.c +mono/sgen/sgen-gc.c +mono/sgen/sgen-gchandles.c +mono/sgen/sgen-gray.c +mono/sgen/sgen-hash-table.c +mono/sgen/sgen-internal.c +mono/sgen/sgen-los.c +mono/sgen/sgen-marksweep.c +mono/sgen/sgen-memory-governor.c +mono/sgen/sgen-nursery-allocator.c +mono/sgen/sgen-pinning-stats.c +mono/sgen/sgen-pinning.c +mono/sgen/sgen-pointer-queue.c +mono/sgen/sgen-protocol.c +mono/sgen/sgen-qsort.c +mono/sgen/sgen-simple-nursery.c +mono/sgen/sgen-split-nursery.c +mono/sgen/sgen-thread-pool.c +mono/sgen/sgen-workers.c +mono/sgen/sgen-fin-weak-hash.c +mono/sgen/sgen-layout-stats.c +HEADERS: +mono/sgen/gc-internal-agnostic.h +mono/sgen/sgen-archdep.h +mono/sgen/sgen-array-list.h +mono/sgen/sgen-cardtable.h +mono/sgen/sgen-client.h +mono/sgen/sgen-conf.h +mono/sgen/sgen-copy-object.h +mono/sgen/sgen-descriptor.h +mono/sgen/sgen-gc.h +mono/sgen/sgen-gray.h +mono/sgen/sgen-hash-table.h +mono/sgen/sgen-layout-stats.h +mono/sgen/sgen-major-copy-object.h +mono/sgen/sgen-marksweep-drain-gray-stack.h +mono/sgen/sgen-memory-governor.h +mono/sgen/sgen-minor-copy-object.h +mono/sgen/sgen-minor-scan-object.h +mono/sgen/sgen-pinning.h +mono/sgen/sgen-pointer-queue.h +mono/sgen/sgen-protocol-def.h +mono/sgen/sgen-protocol.h +mono/sgen/sgen-qsort.h +mono/sgen/sgen-scan-object.h +mono/sgen/sgen-tagged-pointer.h +mono/sgen/sgen-thread-pool.h +mono/sgen/sgen-workers.h +#################### +#mono cil files +#################### +METADATA: +mono/cil/opcode.def +mono/cil/tables.def +#################### +#mono arch files +#################### +HEADERS: +mono/arch/amd64/amd64-codegen.h +mono/arch/x86/x86-codegen.h +mono/arch/arm/arm-codegen.h +mono/arch/arm/arm_dpimacros.h +mono/arch/arm/arm-vfp-codegen.h +mono/arch/arm/arm_vfpmacros.h +#################### +#mono complex files +#################### +SOURCES: +support/libm/complex.c +HEADERS: +support/libm/complex.h +support/libm/math_private.h +#################### +#mono mini files +#################### +mono/mini/aot-runtime.h +mono/mini/cfgdump.h +mono/mini/debugger-agent.c +mono/mini/debugger-agent.h +mono/mini/il2cpp-c-types.h +mono/mini/il2cpp-compat.h +mono/mini/il2cpp-stubs.cpp +mono/mini/jit.h +mono/mini/mini-amd64.h +mono/mini/mini-arch.h +mono/mini/mini-ops.h +mono/mini/mini-runtime.h +mono/mini/mini-unwind.h +mono/mini/mini-x86.h +mono/mini/mini.h +mono/mini/optflags-def.h +mono/mini/patch-info.h +mono/mini/regalloc.h +mono/mini/seq-points.h +mono/mini/interp/interp.h From 415dc87c10894f61580e179ffdde70bd46f7e99f Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Fri, 16 Feb 2018 10:59:01 -0500 Subject: [PATCH 148/582] Work around an Android C++ compiler bug The class library code in `GetErrorMessage` exposes a C++ compiler bug on Android in the r13b NDK. We can't easily update the NDK, so instead we will work around the bug by changing the class library code. We don't expect any change in behavior from this change. --- .../System/ReferenceSources/Win32Exception.cs | 1739 ++++++++++++++++- 1 file changed, 1738 insertions(+), 1 deletion(-) diff --git a/mcs/class/System/ReferenceSources/Win32Exception.cs b/mcs/class/System/ReferenceSources/Win32Exception.cs index a18b9fba8f69..c4ee090e8ef7 100644 --- a/mcs/class/System/ReferenceSources/Win32Exception.cs +++ b/mcs/class/System/ReferenceSources/Win32Exception.cs @@ -3,6 +3,9 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; +#if UNITY +using System.Collections.Generic; +#endif namespace System.ComponentModel { @@ -14,6 +17,11 @@ static extern int FormatMessage(int dwFlags, IntPtr lpSource, uint dwMessageId, [Out] StringBuilder lpBuffer, int nSize, IntPtr[] arguments); #endif +#if UNITY + static bool s_ErrorMessagesInitialized = false; + static Dictionary s_ErrorMessage = new Dictionary(); +#endif + internal static string GetErrorMessage (int error) { #if !MOBILE @@ -29,7 +37,14 @@ internal static string GetErrorMessage (int error) return sb.ToString (); } #endif - +#if UNITY + if (!s_ErrorMessagesInitialized) + InitializeErrorMessages(); + string message; + if (s_ErrorMessage.TryGetValue(error, out message)) + return message; + return string.Format ("mono-io-layer-error ({0})", error); +#else switch (error) { case 0: /* ERROR_SUCCESS */ return "Success"; case 2: /* ERROR_FILE_NOT_FOUND */ return "Cannot find the specified file"; @@ -1738,6 +1753,1728 @@ internal static string GetErrorMessage (int error) default: return string.Format ("mono-io-layer-error ({0})", error); } +#endif // UNITY + } + +#if UNITY + static void InitializeErrorMessages() + { + if (s_ErrorMessagesInitialized) + return; + + lock (s_ErrorMessage) + { + if (s_ErrorMessagesInitialized) + return; + + s_ErrorMessage.Add(0, "Success"); /* ERROR_SUCCESS */ + s_ErrorMessage.Add(2, "Cannot find the specified file"); /* ERROR_FILE_NOT_FOUND */ + s_ErrorMessage.Add(3, "Cannot find the specified file"); /* ERROR_PATH_NOT_FOUND */ + s_ErrorMessage.Add(4, "Too many open files"); /* ERROR_TOO_MANY_OPEN_FILES */ + s_ErrorMessage.Add(5, "Access denied"); /* ERROR_ACCESS_DENIED */ + s_ErrorMessage.Add(6, "Invalid handle"); /* ERROR_INVALID_HANDLE */ + s_ErrorMessage.Add(13, "Invalid data"); /* ERROR_INVALID_DATA */ + s_ErrorMessage.Add(14, "Out of memory"); /* ERROR_OUTOFMEMORY */ + s_ErrorMessage.Add(17, "Not same device"); /* ERROR_NOT_SAME_DEVICE */ + s_ErrorMessage.Add(18, "No more files"); /* ERROR_NO_MORE_FILES */ + s_ErrorMessage.Add(24, "Bad length"); /* ERROR_BAD_LENGTH */ + s_ErrorMessage.Add(31, "General failure"); /* ERROR_GEN_FAILURE */ + s_ErrorMessage.Add(32, "Sharing violation"); /* ERROR_SHARING_VIOLATION */ + s_ErrorMessage.Add(33, "Lock violation"); /* ERROR_LOCK_VIOLATION */ + s_ErrorMessage.Add(50, "Operation not supported"); /* ERROR_NOT_SUPPORTED */ + s_ErrorMessage.Add(55, "Device does not exist"); /* ERROR_DEV_NOT_EXIST */ + s_ErrorMessage.Add(87, "Invalid parameter"); /* ERROR_INVALID_PARAMETER */ + s_ErrorMessage.Add(120, "Call not implemented"); /* ERROR_CALL_NOT_IMPLEMENTED */ + s_ErrorMessage.Add(123, "Invalid name"); /* ERROR_INVALID_NAME */ + s_ErrorMessage.Add(127, "Process not found"); /* ERROR_PROC_NOT_FOUND */ + s_ErrorMessage.Add(183, "Already exists"); /* ERROR_ALREADY_EXISTS */ + s_ErrorMessage.Add(267, "Is a directory"); /* ERROR_DIRECTORY */ + s_ErrorMessage.Add(995, "Operation aborted"); /* ERROR_OPERATION_ABORTED */ + s_ErrorMessage.Add(6000, "Encryption failed"); /* ERROR_ENCRYPTION_FAILED */ + s_ErrorMessage.Add(10004, "interrupted"); /* WSAEINTR */ + s_ErrorMessage.Add(10009, "Bad file number"); /* WSAEBADF */ + s_ErrorMessage.Add(10013, "Access denied"); /* WSAEACCES */ + s_ErrorMessage.Add(10014, "Bad address"); /* WSAEFAULT */ + s_ErrorMessage.Add(10022, "Invalid arguments"); /* WSAEINVAL */ + s_ErrorMessage.Add(10024, "Too many open files"); /* WSAEMFILE */ + s_ErrorMessage.Add(10035, "Operation on non-blocking socket would block"); /* WSAEWOULDBLOCK */ + s_ErrorMessage.Add(10036, "Operation in progress"); /* WSAEINPROGRESS */ + s_ErrorMessage.Add(10037, "Operation already in progress"); /* WSAEALREADY */ + s_ErrorMessage.Add(10038, "The descriptor is not a socket"); /* WSAENOTSOCK */ + s_ErrorMessage.Add(10039, "Destination address required"); /* WSAEDESTADDRREQ */ + s_ErrorMessage.Add(10040, "Message too long"); /* WSAEMSGSIZE */ + s_ErrorMessage.Add(10041, "Protocol wrong type for socket"); /* WSAEPROTOTYPE */ + s_ErrorMessage.Add(10042, "Protocol option not supported"); /* WSAENOPROTOOPT */ + s_ErrorMessage.Add(10043, "Protocol not supported"); /* WSAEPROTONOSUPPORT */ + s_ErrorMessage.Add(10044, "Socket not supported"); /* WSAESOCKTNOSUPPORT */ + s_ErrorMessage.Add(10045, "Operation not supported"); /* WSAEOPNOTSUPP */ + s_ErrorMessage.Add(10046, "Protocol family not supported"); /* WSAEPFNOSUPPORT */ + s_ErrorMessage.Add(10047, "An address incompatible with the requested protocol was used"); /* WSAEAFNOSUPPORT */ + s_ErrorMessage.Add(10048, "Address already in use"); /* WSAEADDRINUSE */ + s_ErrorMessage.Add(10049, "The requested address is not valid in this context"); /* WSAEADDRNOTAVAIL */ + s_ErrorMessage.Add(10050, "Network subsystem is down"); /* WSAENETDOWN */ + s_ErrorMessage.Add(10051, "Network is unreachable"); /* WSAENETUNREACH */ + s_ErrorMessage.Add(10052, "Connection broken, keep-alive detected a problem"); /* WSAENETRESET */ + s_ErrorMessage.Add(10053, "An established connection was aborted in your host machine."); /* WSAECONNABORTED */ + s_ErrorMessage.Add(10054, "Connection reset by peer"); /* WSAECONNRESET */ + s_ErrorMessage.Add(10055, "Not enough buffer space is available"); /* WSAENOBUFS */ + s_ErrorMessage.Add(10056, "Socket is already connected"); /* WSAEISCONN */ + s_ErrorMessage.Add(10057, "The socket is not connected"); /* WSAENOTCONN */ + s_ErrorMessage.Add(10058, "The socket has been shut down"); /* WSAESHUTDOWN */ + s_ErrorMessage.Add(10059, "Too many references: cannot splice"); /* WSAETOOMANYREFS */ + s_ErrorMessage.Add(10060, "Connection timed out"); /* WSAETIMEDOUT */ + s_ErrorMessage.Add(10061, "Connection refused"); /* WSAECONNREFUSED */ + s_ErrorMessage.Add(10062, "Too many symbolic links encountered"); /* WSAELOOP */ + s_ErrorMessage.Add(10063, "File name too long"); /* WSAENAMETOOLONG */ + s_ErrorMessage.Add(10064, "Host is down"); /* WSAEHOSTDOWN */ + s_ErrorMessage.Add(10065, "No route to host"); /* WSAEHOSTUNREACH */ + s_ErrorMessage.Add(10066, "Directory not empty"); /* WSAENOTEMPTY */ + s_ErrorMessage.Add(10067, "EPROCLIM"); /* WSAEPROCLIM */ + s_ErrorMessage.Add(10068, "Too many users"); /* WSAEUSERS */ + s_ErrorMessage.Add(10069, "Quota exceeded"); /* WSAEDQUOT */ + s_ErrorMessage.Add(10070, "Stale NFS file handle"); /* WSAESTALE */ + s_ErrorMessage.Add(10071, "Object is remote"); /* WSAEREMOTE */ + s_ErrorMessage.Add(10091, "SYSNOTREADY"); /* WSASYSNOTREADY */ + s_ErrorMessage.Add(10092, "VERNOTSUPPORTED"); /* WSAVERNOTSUPPORTED */ + s_ErrorMessage.Add(10093, "Winsock not initialised"); /* WSANOTINITIALISED */ + s_ErrorMessage.Add(10101, "EDISCON"); /* WSAEDISCON */ + s_ErrorMessage.Add(10102, "ENOMORE"); /* WSAENOMORE */ + s_ErrorMessage.Add(10103, "Operation canceled"); /* WSAECANCELLED */ + s_ErrorMessage.Add(10104, "EINVALIDPROCTABLE"); /* WSAEINVALIDPROCTABLE */ + s_ErrorMessage.Add(10105, "EINVALIDPROVIDER"); /* WSAEINVALIDPROVIDER */ + s_ErrorMessage.Add(10106, "EPROVIDERFAILEDINIT"); /* WSAEPROVIDERFAILEDINIT */ + s_ErrorMessage.Add(10107, "System call failed"); /* WSASYSCALLFAILURE */ + s_ErrorMessage.Add(10108, "SERVICE_NOT_FOUND"); /* WSASERVICE_NOT_FOUND */ + s_ErrorMessage.Add(10109, "TYPE_NOT_FOUND"); /* WSATYPE_NOT_FOUND */ + s_ErrorMessage.Add(10112, "EREFUSED"); /* WSAEREFUSED */ + s_ErrorMessage.Add(11001, "No such host is known"); /* WSAHOST_NOT_FOUND */ + s_ErrorMessage.Add(11002, "A temporary error occurred on an authoritative name server. Try again later."); /* WSATRY_AGAIN */ + s_ErrorMessage.Add(11003, "No recovery"); /* WSANO_RECOVERY */ + s_ErrorMessage.Add(11004, "No data"); /* WSANO_DATA */ +#if !MOBILE + s_ErrorMessage.Add(1, "Invalid function"); /* ERROR_INVALID_FUNCTION */ + s_ErrorMessage.Add(7, "Arena trashed"); /* ERROR_ARENA_TRASHED */ + s_ErrorMessage.Add(8, "Not enough memory"); /* ERROR_NOT_ENOUGH_MEMORY */ + s_ErrorMessage.Add(9, "Invalid block"); /* ERROR_INVALID_BLOCK */ + s_ErrorMessage.Add(10, "Bad environment"); /* ERROR_BAD_ENVIRONMENT */ + s_ErrorMessage.Add(11, "Bad format"); /* ERROR_BAD_FORMAT */ + s_ErrorMessage.Add(12, "Invalid access"); /* ERROR_INVALID_ACCESS */ + s_ErrorMessage.Add(15, "Invalid drive"); /* ERROR_INVALID_DRIVE */ + s_ErrorMessage.Add(16, "Current directory"); /* ERROR_CURRENT_DIRECTORY */ + s_ErrorMessage.Add(19, "Write protect"); /* ERROR_WRITE_PROTECT */ + s_ErrorMessage.Add(20, "Bad unit"); /* ERROR_BAD_UNIT */ + s_ErrorMessage.Add(21, "Not ready"); /* ERROR_NOT_READY */ + s_ErrorMessage.Add(22, "Bad command"); /* ERROR_BAD_COMMAND */ + s_ErrorMessage.Add(23, "CRC"); /* ERROR_CRC */ + s_ErrorMessage.Add(25, "Seek"); /* ERROR_SEEK */ + s_ErrorMessage.Add(26, "Not DOS disk"); /* ERROR_NOT_DOS_DISK */ + s_ErrorMessage.Add(27, "Sector not found"); /* ERROR_SECTOR_NOT_FOUND */ + s_ErrorMessage.Add(28, "Out of paper"); /* ERROR_OUT_OF_PAPER */ + s_ErrorMessage.Add(29, "Write fault"); /* ERROR_WRITE_FAULT */ + s_ErrorMessage.Add(30, "Read fault"); /* ERROR_READ_FAULT */ + s_ErrorMessage.Add(34, "Wrong disk"); /* ERROR_WRONG_DISK */ + s_ErrorMessage.Add(36, "Sharing buffer exceeded"); /* ERROR_SHARING_BUFFER_EXCEEDED */ + s_ErrorMessage.Add(38, "Handle EOF"); /* ERROR_HANDLE_EOF */ + s_ErrorMessage.Add(39, "Handle disk full"); /* ERROR_HANDLE_DISK_FULL */ + s_ErrorMessage.Add(51, "Rem not list"); /* ERROR_REM_NOT_LIST */ + s_ErrorMessage.Add(52, "Duplicate name"); /* ERROR_DUP_NAME */ + s_ErrorMessage.Add(53, "Bad netpath"); /* ERROR_BAD_NETPATH */ + s_ErrorMessage.Add(54, "Network busy"); /* ERROR_NETWORK_BUSY */ + s_ErrorMessage.Add(56, "Too many commands"); /* ERROR_TOO_MANY_CMDS */ + s_ErrorMessage.Add(57, "ADAP HDW error"); /* ERROR_ADAP_HDW_ERR */ + s_ErrorMessage.Add(58, "Bad net response"); /* ERROR_BAD_NET_RESP */ + s_ErrorMessage.Add(59, "Unexpected net error"); /* ERROR_UNEXP_NET_ERR */ + s_ErrorMessage.Add(60, "Bad rem adap"); /* ERROR_BAD_REM_ADAP */ + s_ErrorMessage.Add(61, "Print queue full"); /* ERROR_PRINTQ_FULL */ + s_ErrorMessage.Add(62, "No spool space"); /* ERROR_NO_SPOOL_SPACE */ + s_ErrorMessage.Add(63, "Print cancelled"); /* ERROR_PRINT_CANCELLED */ + s_ErrorMessage.Add(64, "Netname deleted"); /* ERROR_NETNAME_DELETED */ + s_ErrorMessage.Add(65, "Network access denied"); /* ERROR_NETWORK_ACCESS_DENIED */ + s_ErrorMessage.Add(66, "Bad device type"); /* ERROR_BAD_DEV_TYPE */ + s_ErrorMessage.Add(67, "Bad net name"); /* ERROR_BAD_NET_NAME */ + s_ErrorMessage.Add(68, "Too many names"); /* ERROR_TOO_MANY_NAMES */ + s_ErrorMessage.Add(69, "Too many sessions"); /* ERROR_TOO_MANY_SESS */ + s_ErrorMessage.Add(70, "Sharing paused"); /* ERROR_SHARING_PAUSED */ + s_ErrorMessage.Add(71, "Req not accep"); /* ERROR_REQ_NOT_ACCEP */ + s_ErrorMessage.Add(72, "Redir paused"); /* ERROR_REDIR_PAUSED */ + s_ErrorMessage.Add(80, "File exists"); /* ERROR_FILE_EXISTS */ + s_ErrorMessage.Add(82, "Cannot make"); /* ERROR_CANNOT_MAKE */ + s_ErrorMessage.Add(83, "Fail i24"); /* ERROR_FAIL_I24 */ + s_ErrorMessage.Add(84, "Out of structures"); /* ERROR_OUT_OF_STRUCTURES */ + s_ErrorMessage.Add(85, "Already assigned"); /* ERROR_ALREADY_ASSIGNED */ + s_ErrorMessage.Add(86, "Invalid password"); /* ERROR_INVALID_PASSWORD */ + s_ErrorMessage.Add(88, "Net write fault"); /* ERROR_NET_WRITE_FAULT */ + s_ErrorMessage.Add(89, "No proc slots"); /* ERROR_NO_PROC_SLOTS */ + s_ErrorMessage.Add(100, "Too many semaphores"); /* ERROR_TOO_MANY_SEMAPHORES */ + s_ErrorMessage.Add(101, "Exclusive semaphore already owned"); /* ERROR_EXCL_SEM_ALREADY_OWNED */ + s_ErrorMessage.Add(102, "Semaphore is set"); /* ERROR_SEM_IS_SET */ + s_ErrorMessage.Add(103, "Too many semaphore requests"); /* ERROR_TOO_MANY_SEM_REQUESTS */ + s_ErrorMessage.Add(104, "Invalid at interrupt time"); /* ERROR_INVALID_AT_INTERRUPT_TIME */ + s_ErrorMessage.Add(105, "Semaphore owner died"); /* ERROR_SEM_OWNER_DIED */ + s_ErrorMessage.Add(106, "Semaphore user limit"); /* ERROR_SEM_USER_LIMIT */ + s_ErrorMessage.Add(107, "Disk change"); /* ERROR_DISK_CHANGE */ + s_ErrorMessage.Add(108, "Drive locked"); /* ERROR_DRIVE_LOCKED */ + s_ErrorMessage.Add(109, "Broken pipe"); /* ERROR_BROKEN_PIPE */ + s_ErrorMessage.Add(110, "Open failed"); /* ERROR_OPEN_FAILED */ + s_ErrorMessage.Add(111, "Buffer overflow"); /* ERROR_BUFFER_OVERFLOW */ + s_ErrorMessage.Add(112, "Disk full"); /* ERROR_DISK_FULL */ + s_ErrorMessage.Add(113, "No more search handles"); /* ERROR_NO_MORE_SEARCH_HANDLES */ + s_ErrorMessage.Add(114, "Invalid target handle"); /* ERROR_INVALID_TARGET_HANDLE */ + s_ErrorMessage.Add(117, "Invalid category"); /* ERROR_INVALID_CATEGORY */ + s_ErrorMessage.Add(118, "Invalid verify switch"); /* ERROR_INVALID_VERIFY_SWITCH */ + s_ErrorMessage.Add(119, "Bad driver level"); /* ERROR_BAD_DRIVER_LEVEL */ + s_ErrorMessage.Add(121, "Semaphore timeout"); /* ERROR_SEM_TIMEOUT */ + s_ErrorMessage.Add(122, "Insufficient buffer"); /* ERROR_INSUFFICIENT_BUFFER */ + s_ErrorMessage.Add(124, "Invalid level"); /* ERROR_INVALID_LEVEL */ + s_ErrorMessage.Add(125, "No volume label"); /* ERROR_NO_VOLUME_LABEL */ + s_ErrorMessage.Add(126, "Module not found"); /* ERROR_MOD_NOT_FOUND */ + s_ErrorMessage.Add(128, "Wait no children"); /* ERROR_WAIT_NO_CHILDREN */ + s_ErrorMessage.Add(129, "Child not complete"); /* ERROR_CHILD_NOT_COMPLETE */ + s_ErrorMessage.Add(130, "Direct access handle"); /* ERROR_DIRECT_ACCESS_HANDLE */ + s_ErrorMessage.Add(131, "Negative seek"); /* ERROR_NEGATIVE_SEEK */ + s_ErrorMessage.Add(132, "Seek on device"); /* ERROR_SEEK_ON_DEVICE */ + s_ErrorMessage.Add(133, "Is join target"); /* ERROR_IS_JOIN_TARGET */ + s_ErrorMessage.Add(134, "Is joined"); /* ERROR_IS_JOINED */ + s_ErrorMessage.Add(135, "Is substed"); /* ERROR_IS_SUBSTED */ + s_ErrorMessage.Add(136, "Not joined"); /* ERROR_NOT_JOINED */ + s_ErrorMessage.Add(137, "Not substed"); /* ERROR_NOT_SUBSTED */ + s_ErrorMessage.Add(138, "Join to join"); /* ERROR_JOIN_TO_JOIN */ + s_ErrorMessage.Add(139, "Subst to subst"); /* ERROR_SUBST_TO_SUBST */ + s_ErrorMessage.Add(140, "Join to subst"); /* ERROR_JOIN_TO_SUBST */ + s_ErrorMessage.Add(141, "Subst to join"); /* ERROR_SUBST_TO_JOIN */ + s_ErrorMessage.Add(142, "Busy drive"); /* ERROR_BUSY_DRIVE */ + s_ErrorMessage.Add(143, "Same drive"); /* ERROR_SAME_DRIVE */ + s_ErrorMessage.Add(144, "Directory not root"); /* ERROR_DIR_NOT_ROOT */ + s_ErrorMessage.Add(145, "Directory not empty"); /* ERROR_DIR_NOT_EMPTY */ + s_ErrorMessage.Add(146, "Is subst path"); /* ERROR_IS_SUBST_PATH */ + s_ErrorMessage.Add(147, "Is join path"); /* ERROR_IS_JOIN_PATH */ + s_ErrorMessage.Add(148, "Path busy"); /* ERROR_PATH_BUSY */ + s_ErrorMessage.Add(149, "Is subst target"); /* ERROR_IS_SUBST_TARGET */ + s_ErrorMessage.Add(150, "System trace"); /* ERROR_SYSTEM_TRACE */ + s_ErrorMessage.Add(151, "Invalid event count"); /* ERROR_INVALID_EVENT_COUNT */ + s_ErrorMessage.Add(152, "Too many muxwaiters"); /* ERROR_TOO_MANY_MUXWAITERS */ + s_ErrorMessage.Add(153, "Invalid list format"); /* ERROR_INVALID_LIST_FORMAT */ + s_ErrorMessage.Add(154, "Label too long"); /* ERROR_LABEL_TOO_LONG */ + s_ErrorMessage.Add(155, "Too many TCBs"); /* ERROR_TOO_MANY_TCBS */ + s_ErrorMessage.Add(156, "Signal refused"); /* ERROR_SIGNAL_REFUSED */ + s_ErrorMessage.Add(157, "Discarded"); /* ERROR_DISCARDED */ + s_ErrorMessage.Add(158, "Not locked"); /* ERROR_NOT_LOCKED */ + s_ErrorMessage.Add(159, "Bad thread ID addr"); /* ERROR_BAD_THREADID_ADDR */ + s_ErrorMessage.Add(160, "Bad arguments"); /* ERROR_BAD_ARGUMENTS */ + s_ErrorMessage.Add(161, "Bad pathname"); /* ERROR_BAD_PATHNAME */ + s_ErrorMessage.Add(162, "Signal pending"); /* ERROR_SIGNAL_PENDING */ + s_ErrorMessage.Add(164, "Max thrds reached"); /* ERROR_MAX_THRDS_REACHED */ + s_ErrorMessage.Add(167, "Lock failed"); /* ERROR_LOCK_FAILED */ + s_ErrorMessage.Add(170, "Busy"); /* ERROR_BUSY */ + s_ErrorMessage.Add(173, "Cancel violation"); /* ERROR_CANCEL_VIOLATION */ + s_ErrorMessage.Add(174, "Atomic locks not supported"); /* ERROR_ATOMIC_LOCKS_NOT_SUPPORTED */ + s_ErrorMessage.Add(180, "Invalid segment number"); /* ERROR_INVALID_SEGMENT_NUMBER */ + s_ErrorMessage.Add(182, "Invalid ordinal"); /* ERROR_INVALID_ORDINAL */ + s_ErrorMessage.Add(186, "Invalid flag number"); /* ERROR_INVALID_FLAG_NUMBER */ + s_ErrorMessage.Add(187, "Sem not found"); /* ERROR_SEM_NOT_FOUND */ + s_ErrorMessage.Add(188, "Invalid starting codeseg"); /* ERROR_INVALID_STARTING_CODESEG */ + s_ErrorMessage.Add(189, "Invalid stackseg"); /* ERROR_INVALID_STACKSEG */ + s_ErrorMessage.Add(190, "Invalid moduletype"); /* ERROR_INVALID_MODULETYPE */ + s_ErrorMessage.Add(191, "Invalid exe signature"); /* ERROR_INVALID_EXE_SIGNATURE */ + s_ErrorMessage.Add(192, "Exe marked invalid"); /* ERROR_EXE_MARKED_INVALID */ + s_ErrorMessage.Add(193, "Bad exe format"); /* ERROR_BAD_EXE_FORMAT */ + s_ErrorMessage.Add(194, "Iterated data exceeds 64k (and that should be enough for anybody!)"); /* ERROR_ITERATED_DATA_EXCEEDS_64k */ + s_ErrorMessage.Add(195, "Invalid minallocsize"); /* ERROR_INVALID_MINALLOCSIZE */ + s_ErrorMessage.Add(196, "Dynlink from invalid ring"); /* ERROR_DYNLINK_FROM_INVALID_RING */ + s_ErrorMessage.Add(197, "IOPL not enabled"); /* ERROR_IOPL_NOT_ENABLED */ + s_ErrorMessage.Add(198, "Invalid segdpl"); /* ERROR_INVALID_SEGDPL */ + s_ErrorMessage.Add(199, "Autodataseg exceeds 64k"); /* ERROR_AUTODATASEG_EXCEEDS_64k */ + s_ErrorMessage.Add(200, "Ring2seg must be movable"); /* ERROR_RING2SEG_MUST_BE_MOVABLE */ + s_ErrorMessage.Add(201, "Reloc chain exceeds seglim"); /* ERROR_RELOC_CHAIN_XEEDS_SEGLIM */ + s_ErrorMessage.Add(202, "Infloop in reloc chain"); /* ERROR_INFLOOP_IN_RELOC_CHAIN */ + s_ErrorMessage.Add(203, "Env var not found"); /* ERROR_ENVVAR_NOT_FOUND */ + s_ErrorMessage.Add(205, "No signal sent"); /* ERROR_NO_SIGNAL_SENT */ + s_ErrorMessage.Add(206, "Filename exceeds range"); /* ERROR_FILENAME_EXCED_RANGE */ + s_ErrorMessage.Add(207, "Ring2 stack in use"); /* ERROR_RING2_STACK_IN_USE */ + s_ErrorMessage.Add(208, "Meta expansion too long"); /* ERROR_META_EXPANSION_TOO_LONG */ + s_ErrorMessage.Add(209, "Invalid signal number"); /* ERROR_INVALID_SIGNAL_NUMBER */ + s_ErrorMessage.Add(210, "Thread 1 inactive"); /* ERROR_THREAD_1_INACTIVE */ + s_ErrorMessage.Add(212, "Locked"); /* ERROR_LOCKED */ + s_ErrorMessage.Add(214, "Too many modules"); /* ERROR_TOO_MANY_MODULES */ + s_ErrorMessage.Add(215, "Nesting not allowed"); /* ERROR_NESTING_NOT_ALLOWED */ + s_ErrorMessage.Add(216, "Exe machine type mismatch"); /* ERROR_EXE_MACHINE_TYPE_MISMATCH */ + s_ErrorMessage.Add(230, "Bad pipe"); /* ERROR_BAD_PIPE */ + s_ErrorMessage.Add(231, "Pipe busy"); /* ERROR_PIPE_BUSY */ + s_ErrorMessage.Add(232, "No data"); /* ERROR_NO_DATA */ + s_ErrorMessage.Add(233, "Pipe not connected"); /* ERROR_PIPE_NOT_CONNECTED */ + s_ErrorMessage.Add(234, "More data"); /* ERROR_MORE_DATA */ + s_ErrorMessage.Add(240, "VC disconnected"); /* ERROR_VC_DISCONNECTED */ + s_ErrorMessage.Add(254, "Invalid EA name"); /* ERROR_INVALID_EA_NAME */ + s_ErrorMessage.Add(255, "EA list inconsistent"); /* ERROR_EA_LIST_INCONSISTENT */ + s_ErrorMessage.Add(258, "Wait timeout"); /* WAIT_TIMEOUT */ + s_ErrorMessage.Add(259, "No more items"); /* ERROR_NO_MORE_ITEMS */ + s_ErrorMessage.Add(266, "Cannot copy"); /* ERROR_CANNOT_COPY */ + s_ErrorMessage.Add(275, "EAS didnt fit"); /* ERROR_EAS_DIDNT_FIT */ + s_ErrorMessage.Add(276, "EA file corrupt"); /* ERROR_EA_FILE_CORRUPT */ + s_ErrorMessage.Add(277, "EA table full"); /* ERROR_EA_TABLE_FULL */ + s_ErrorMessage.Add(278, "Invalid EA handle"); /* ERROR_INVALID_EA_HANDLE */ + s_ErrorMessage.Add(282, "EAs not supported"); /* ERROR_EAS_NOT_SUPPORTED */ + s_ErrorMessage.Add(288, "Not owner"); /* ERROR_NOT_OWNER */ + s_ErrorMessage.Add(298, "Too many posts"); /* ERROR_TOO_MANY_POSTS */ + s_ErrorMessage.Add(299, "Partial copy"); /* ERROR_PARTIAL_COPY */ + s_ErrorMessage.Add(300, "Oplock not granted"); /* ERROR_OPLOCK_NOT_GRANTED */ + s_ErrorMessage.Add(301, "Invalid oplock protocol"); /* ERROR_INVALID_OPLOCK_PROTOCOL */ + s_ErrorMessage.Add(302, "Disk too fragmented"); /* ERROR_DISK_TOO_FRAGMENTED */ + s_ErrorMessage.Add(303, "Delete pending"); /* ERROR_DELETE_PENDING */ + s_ErrorMessage.Add(317, "Mr Mid not found"); /* ERROR_MR_MID_NOT_FOUND */ + s_ErrorMessage.Add(487, "Invalid address"); /* ERROR_INVALID_ADDRESS */ + s_ErrorMessage.Add(534, "Arithmetic overflow"); /* ERROR_ARITHMETIC_OVERFLOW */ + s_ErrorMessage.Add(535, "Pipe connected"); /* ERROR_PIPE_CONNECTED */ + s_ErrorMessage.Add(536, "Pipe listening"); /* ERROR_PIPE_LISTENING */ + s_ErrorMessage.Add(994, "EA access denied"); /* ERROR_EA_ACCESS_DENIED */ + s_ErrorMessage.Add(996, "IO incomplete"); /* ERROR_IO_INCOMPLETE */ + s_ErrorMessage.Add(997, "IO pending"); /* ERROR_IO_PENDING */ + s_ErrorMessage.Add(998, "No access"); /* ERROR_NOACCESS */ + s_ErrorMessage.Add(999, "Swap error"); /* ERROR_SWAPERROR */ + s_ErrorMessage.Add(1001, "Stack overflow"); /* ERROR_STACK_OVERFLOW */ + s_ErrorMessage.Add(1002, "Invalid message"); /* ERROR_INVALID_MESSAGE */ + s_ErrorMessage.Add(1003, "Can not complete"); /* ERROR_CAN_NOT_COMPLETE */ + s_ErrorMessage.Add(1004, "Invalid flags"); /* ERROR_INVALID_FLAGS */ + s_ErrorMessage.Add(1005, "Unrecognised volume"); /* ERROR_UNRECOGNIZED_VOLUME */ + s_ErrorMessage.Add(1006, "File invalid"); /* ERROR_FILE_INVALID */ + s_ErrorMessage.Add(1007, "Full screen mode"); /* ERROR_FULLSCREEN_MODE */ + s_ErrorMessage.Add(1008, "No token"); /* ERROR_NO_TOKEN */ + s_ErrorMessage.Add(1009, "Bad DB"); /* ERROR_BADDB */ + s_ErrorMessage.Add(1010, "Bad key"); /* ERROR_BADKEY */ + s_ErrorMessage.Add(1011, "Can't open"); /* ERROR_CANTOPEN */ + s_ErrorMessage.Add(1012, "Can't read"); /* ERROR_CANTREAD */ + s_ErrorMessage.Add(1013, "Can't write"); /* ERROR_CANTWRITE */ + s_ErrorMessage.Add(1014, "Registry recovered"); /* ERROR_REGISTRY_RECOVERED */ + s_ErrorMessage.Add(1015, "Registry corrupt"); /* ERROR_REGISTRY_CORRUPT */ + s_ErrorMessage.Add(1016, "Registry IO failed"); /* ERROR_REGISTRY_IO_FAILED */ + s_ErrorMessage.Add(1017, "Not registry file"); /* ERROR_NOT_REGISTRY_FILE */ + s_ErrorMessage.Add(1018, "Key deleted"); /* ERROR_KEY_DELETED */ + s_ErrorMessage.Add(1019, "No log space"); /* ERROR_NO_LOG_SPACE */ + s_ErrorMessage.Add(1020, "Key has children"); /* ERROR_KEY_HAS_CHILDREN */ + s_ErrorMessage.Add(1021, "Child must be volatile"); /* ERROR_CHILD_MUST_BE_VOLATILE */ + s_ErrorMessage.Add(1022, "Notify enum dir"); /* ERROR_NOTIFY_ENUM_DIR */ + s_ErrorMessage.Add(1051, "Dependent services running"); /* ERROR_DEPENDENT_SERVICES_RUNNING */ + s_ErrorMessage.Add(1052, "Invalid service control"); /* ERROR_INVALID_SERVICE_CONTROL */ + s_ErrorMessage.Add(1053, "Service request timeout"); /* ERROR_SERVICE_REQUEST_TIMEOUT */ + s_ErrorMessage.Add(1054, "Service no thread"); /* ERROR_SERVICE_NO_THREAD */ + s_ErrorMessage.Add(1055, "Service database locked"); /* ERROR_SERVICE_DATABASE_LOCKED */ + s_ErrorMessage.Add(1056, "Service already running"); /* ERROR_SERVICE_ALREADY_RUNNING */ + s_ErrorMessage.Add(1057, "Invalid service account"); /* ERROR_INVALID_SERVICE_ACCOUNT */ + s_ErrorMessage.Add(1058, "Service disabled"); /* ERROR_SERVICE_DISABLED */ + s_ErrorMessage.Add(1059, "Circular dependency"); /* ERROR_CIRCULAR_DEPENDENCY */ + s_ErrorMessage.Add(1060, "Service does not exist"); /* ERROR_SERVICE_DOES_NOT_EXIST */ + s_ErrorMessage.Add(1061, "Service cannot accept ctrl"); /* ERROR_SERVICE_CANNOT_ACCEPT_CTRL */ + s_ErrorMessage.Add(1062, "Service not active"); /* ERROR_SERVICE_NOT_ACTIVE */ + s_ErrorMessage.Add(1063, "Failed service controller connect"); /* ERROR_FAILED_SERVICE_CONTROLLER_CONNECT */ + s_ErrorMessage.Add(1064, "Exception in service"); /* ERROR_EXCEPTION_IN_SERVICE */ + s_ErrorMessage.Add(1065, "Database does not exist"); /* ERROR_DATABASE_DOES_NOT_EXIST */ + s_ErrorMessage.Add(1066, "Service specific error"); /* ERROR_SERVICE_SPECIFIC_ERROR */ + s_ErrorMessage.Add(1067, "Process aborted"); /* ERROR_PROCESS_ABORTED */ + s_ErrorMessage.Add(1068, "Service dependency fail"); /* ERROR_SERVICE_DEPENDENCY_FAIL */ + s_ErrorMessage.Add(1069, "Service logon failed"); /* ERROR_SERVICE_LOGON_FAILED */ + s_ErrorMessage.Add(1070, "Service start hang"); /* ERROR_SERVICE_START_HANG */ + s_ErrorMessage.Add(1071, "Invalid service lock"); /* ERROR_INVALID_SERVICE_LOCK */ + s_ErrorMessage.Add(1072, "Service marked for delete"); /* ERROR_SERVICE_MARKED_FOR_DELETE */ + s_ErrorMessage.Add(1073, "Service exists"); /* ERROR_SERVICE_EXISTS */ + s_ErrorMessage.Add(1074, "Already running lkg"); /* ERROR_ALREADY_RUNNING_LKG */ + s_ErrorMessage.Add(1075, "Service dependency deleted"); /* ERROR_SERVICE_DEPENDENCY_DELETED */ + s_ErrorMessage.Add(1076, "Boot already accepted"); /* ERROR_BOOT_ALREADY_ACCEPTED */ + s_ErrorMessage.Add(1077, "Service never started"); /* ERROR_SERVICE_NEVER_STARTED */ + s_ErrorMessage.Add(1078, "Duplicate service name"); /* ERROR_DUPLICATE_SERVICE_NAME */ + s_ErrorMessage.Add(1079, "Different service account"); /* ERROR_DIFFERENT_SERVICE_ACCOUNT */ + s_ErrorMessage.Add(1080, "Cannot detect driver failure"); /* ERROR_CANNOT_DETECT_DRIVER_FAILURE */ + s_ErrorMessage.Add(1081, "Cannot detect process abort"); /* ERROR_CANNOT_DETECT_PROCESS_ABORT */ + s_ErrorMessage.Add(1082, "No recovery program"); /* ERROR_NO_RECOVERY_PROGRAM */ + s_ErrorMessage.Add(1083, "Service not in exe"); /* ERROR_SERVICE_NOT_IN_EXE */ + s_ErrorMessage.Add(1084, "Not safeboot service"); /* ERROR_NOT_SAFEBOOT_SERVICE */ + s_ErrorMessage.Add(1100, "End of media"); /* ERROR_END_OF_MEDIA */ + s_ErrorMessage.Add(1101, "Filemark detected"); /* ERROR_FILEMARK_DETECTED */ + s_ErrorMessage.Add(1102, "Beginning of media"); /* ERROR_BEGINNING_OF_MEDIA */ + s_ErrorMessage.Add(1103, "Setmark detected"); /* ERROR_SETMARK_DETECTED */ + s_ErrorMessage.Add(1104, "No data detected"); /* ERROR_NO_DATA_DETECTED */ + s_ErrorMessage.Add(1105, "Partition failure"); /* ERROR_PARTITION_FAILURE */ + s_ErrorMessage.Add(1106, "Invalid block length"); /* ERROR_INVALID_BLOCK_LENGTH */ + s_ErrorMessage.Add(1107, "Device not partitioned"); /* ERROR_DEVICE_NOT_PARTITIONED */ + s_ErrorMessage.Add(1108, "Unable to lock media"); /* ERROR_UNABLE_TO_LOCK_MEDIA */ + s_ErrorMessage.Add(1109, "Unable to unload media"); /* ERROR_UNABLE_TO_UNLOAD_MEDIA */ + s_ErrorMessage.Add(1110, "Media changed"); /* ERROR_MEDIA_CHANGED */ + s_ErrorMessage.Add(1111, "Bus reset"); /* ERROR_BUS_RESET */ + s_ErrorMessage.Add(1112, "No media in drive"); /* ERROR_NO_MEDIA_IN_DRIVE */ + s_ErrorMessage.Add(1113, "No unicode translation"); /* ERROR_NO_UNICODE_TRANSLATION */ + s_ErrorMessage.Add(1114, "DLL init failed"); /* ERROR_DLL_INIT_FAILED */ + s_ErrorMessage.Add(1115, "Shutdown in progress"); /* ERROR_SHUTDOWN_IN_PROGRESS */ + s_ErrorMessage.Add(1116, "No shutdown in progress"); /* ERROR_NO_SHUTDOWN_IN_PROGRESS */ + s_ErrorMessage.Add(1117, "IO device"); /* ERROR_IO_DEVICE */ + s_ErrorMessage.Add(1118, "Serial IO device"); /* ERROR_SERIAL_NO_DEVICE */ + s_ErrorMessage.Add(1119, "IRQ busy"); /* ERROR_IRQ_BUSY */ + s_ErrorMessage.Add(1120, "More writes"); /* ERROR_MORE_WRITES */ + s_ErrorMessage.Add(1121, "Counter timeout"); /* ERROR_COUNTER_TIMEOUT */ + s_ErrorMessage.Add(1122, "Floppy ID mark not found"); /* ERROR_FLOPPY_ID_MARK_NOT_FOUND */ + s_ErrorMessage.Add(1123, "Floppy wrong cylinder"); /* ERROR_FLOPPY_WRONG_CYLINDER */ + s_ErrorMessage.Add(1124, "Floppy unknown error"); /* ERROR_FLOPPY_UNKNOWN_ERROR */ + s_ErrorMessage.Add(1125, "Floppy bad registers"); /* ERROR_FLOPPY_BAD_REGISTERS */ + s_ErrorMessage.Add(1126, "Disk recalibrate failed"); /* ERROR_DISK_RECALIBRATE_FAILED */ + s_ErrorMessage.Add(1127, "Disk operation failed"); /* ERROR_DISK_OPERATION_FAILED */ + s_ErrorMessage.Add(1128, "Disk reset failed"); /* ERROR_DISK_RESET_FAILED */ + s_ErrorMessage.Add(1129, "EOM overflow"); /* ERROR_EOM_OVERFLOW */ + s_ErrorMessage.Add(1130, "Not enough server memory"); /* ERROR_NOT_ENOUGH_SERVER_MEMORY */ + s_ErrorMessage.Add(1131, "Possible deadlock"); /* ERROR_POSSIBLE_DEADLOCK */ + s_ErrorMessage.Add(1132, "Mapped alignment"); /* ERROR_MAPPED_ALIGNMENT */ + s_ErrorMessage.Add(1140, "Set power state vetoed"); /* ERROR_SET_POWER_STATE_VETOED */ + s_ErrorMessage.Add(1141, "Set power state failed"); /* ERROR_SET_POWER_STATE_FAILED */ + s_ErrorMessage.Add(1142, "Too many links"); /* ERROR_TOO_MANY_LINKS */ + s_ErrorMessage.Add(1150, "Old win version"); /* ERROR_OLD_WIN_VERSION */ + s_ErrorMessage.Add(1151, "App wrong OS"); /* ERROR_APP_WRONG_OS */ + s_ErrorMessage.Add(1152, "Single instance app"); /* ERROR_SINGLE_INSTANCE_APP */ + s_ErrorMessage.Add(1153, "Rmode app"); /* ERROR_RMODE_APP */ + s_ErrorMessage.Add(1154, "Invalid DLL"); /* ERROR_INVALID_DLL */ + s_ErrorMessage.Add(1155, "No association"); /* ERROR_NO_ASSOCIATION */ + s_ErrorMessage.Add(1156, "DDE fail"); /* ERROR_DDE_FAIL */ + s_ErrorMessage.Add(1157, "DLL not found"); /* ERROR_DLL_NOT_FOUND */ + s_ErrorMessage.Add(1158, "No more user handles"); /* ERROR_NO_MORE_USER_HANDLES */ + s_ErrorMessage.Add(1159, "Message sync only"); /* ERROR_MESSAGE_SYNC_ONLY */ + s_ErrorMessage.Add(1160, "Source element empty"); /* ERROR_SOURCE_ELEMENT_EMPTY */ + s_ErrorMessage.Add(1161, "Destination element full"); /* ERROR_DESTINATION_ELEMENT_FULL */ + s_ErrorMessage.Add(1162, "Illegal element address"); /* ERROR_ILLEGAL_ELEMENT_ADDRESS */ + s_ErrorMessage.Add(1163, "Magazine not present"); /* ERROR_MAGAZINE_NOT_PRESENT */ + s_ErrorMessage.Add(1164, "Device reinitialization needed"); /* ERROR_DEVICE_REINITIALIZATION_NEEDED */ + s_ErrorMessage.Add(1165, "Device requires cleaning"); /* ERROR_DEVICE_REQUIRES_CLEANING */ + s_ErrorMessage.Add(1166, "Device door open"); /* ERROR_DEVICE_DOOR_OPEN */ + s_ErrorMessage.Add(1167, "Device not connected"); /* ERROR_DEVICE_NOT_CONNECTED */ + s_ErrorMessage.Add(1168, "Not found"); /* ERROR_NOT_FOUND */ + s_ErrorMessage.Add(1169, "No match"); /* ERROR_NO_MATCH */ + s_ErrorMessage.Add(1170, "Set not found"); /* ERROR_SET_NOT_FOUND */ + s_ErrorMessage.Add(1171, "Point not found"); /* ERROR_POINT_NOT_FOUND */ + s_ErrorMessage.Add(1172, "No tracking service"); /* ERROR_NO_TRACKING_SERVICE */ + s_ErrorMessage.Add(1173, "No volume ID"); /* ERROR_NO_VOLUME_ID */ + s_ErrorMessage.Add(1175, "Unable to remove replaced"); /* ERROR_UNABLE_TO_REMOVE_REPLACED */ + s_ErrorMessage.Add(1176, "Unable to move replacement"); /* ERROR_UNABLE_TO_MOVE_REPLACEMENT */ + s_ErrorMessage.Add(1177, "Unable to move replacement 2"); /* ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 */ + s_ErrorMessage.Add(1178, "Journal delete in progress"); /* ERROR_JOURNAL_DELETE_IN_PROGRESS */ + s_ErrorMessage.Add(1179, "Journal not active"); /* ERROR_JOURNAL_NOT_ACTIVE */ + s_ErrorMessage.Add(1180, "Potential file found"); /* ERROR_POTENTIAL_FILE_FOUND */ + s_ErrorMessage.Add(1181, "Journal entry deleted"); /* ERROR_JOURNAL_ENTRY_DELETED */ + s_ErrorMessage.Add(1200, "Bad device"); /* ERROR_BAD_DEVICE */ + s_ErrorMessage.Add(1201, "Connection unavail"); /* ERROR_CONNECTION_UNAVAIL */ + s_ErrorMessage.Add(1202, "Device already remembered"); /* ERROR_DEVICE_ALREADY_REMEMBERED */ + s_ErrorMessage.Add(1203, "No net or bad path"); /* ERROR_NO_NET_OR_BAD_PATH */ + s_ErrorMessage.Add(1204, "Bad provider"); /* ERROR_BAD_PROVIDER */ + s_ErrorMessage.Add(1205, "Cannot open profile"); /* ERROR_CANNOT_OPEN_PROFILE */ + s_ErrorMessage.Add(1206, "Bad profile"); /* ERROR_BAD_PROFILE */ + s_ErrorMessage.Add(1207, "Not container"); /* ERROR_NOT_CONTAINER */ + s_ErrorMessage.Add(1208, "Extended error"); /* ERROR_EXTENDED_ERROR */ + s_ErrorMessage.Add(1209, "Invalid group name"); /* ERROR_INVALID_GROUPNAME */ + s_ErrorMessage.Add(1210, "Invalid computer name"); /* ERROR_INVALID_COMPUTERNAME */ + s_ErrorMessage.Add(1211, "Invalid event name"); /* ERROR_INVALID_EVENTNAME */ + s_ErrorMessage.Add(1212, "Invalid domain name"); /* ERROR_INVALID_DOMAINNAME */ + s_ErrorMessage.Add(1213, "Invalid service name"); /* ERROR_INVALID_SERVICENAME */ + s_ErrorMessage.Add(1214, "Invalid net name"); /* ERROR_INVALID_NETNAME */ + s_ErrorMessage.Add(1215, "Invalid share name"); /* ERROR_INVALID_SHARENAME */ + s_ErrorMessage.Add(1216, "Invalid password name"); /* ERROR_INVALID_PASSWORDNAME */ + s_ErrorMessage.Add(1217, "Invalid message name"); /* ERROR_INVALID_MESSAGENAME */ + s_ErrorMessage.Add(1218, "Invalid message dest"); /* ERROR_INVALID_MESSAGEDEST */ + s_ErrorMessage.Add(1219, "Session credential conflict"); /* ERROR_SESSION_CREDENTIAL_CONFLICT */ + s_ErrorMessage.Add(1220, "Remote session limit exceeded"); /* ERROR_REMOTE_SESSION_LIMIT_EXCEEDED */ + s_ErrorMessage.Add(1221, "Dup domain name"); /* ERROR_DUP_DOMAINNAME */ + s_ErrorMessage.Add(1222, "No network"); /* ERROR_NO_NETWORK */ + s_ErrorMessage.Add(1223, "Cancelled"); /* ERROR_CANCELLED */ + s_ErrorMessage.Add(1224, "User mapped file"); /* ERROR_USER_MAPPED_FILE */ + s_ErrorMessage.Add(1225, "Connection refused"); /* ERROR_CONNECTION_REFUSED */ + s_ErrorMessage.Add(1226, "Graceful disconnect"); /* ERROR_GRACEFUL_DISCONNECT */ + s_ErrorMessage.Add(1227, "Address already associated"); /* ERROR_ADDRESS_ALREADY_ASSOCIATED */ + s_ErrorMessage.Add(1228, "Address not associated"); /* ERROR_ADDRESS_NOT_ASSOCIATED */ + s_ErrorMessage.Add(1229, "Connected invalid"); /* ERROR_CONNECTION_INVALID */ + s_ErrorMessage.Add(1230, "Connection active"); /* ERROR_CONNECTION_ACTIVE */ + s_ErrorMessage.Add(1231, "Network unreachable"); /* ERROR_NETWORK_UNREACHABLE */ + s_ErrorMessage.Add(1232, "Host unreachable"); /* ERROR_HOST_UNREACHABLE */ + s_ErrorMessage.Add(1233, "Protocol unreachable"); /* ERROR_PROTOCOL_UNREACHABLE */ + s_ErrorMessage.Add(1234, "Port unreachable"); /* ERROR_PORT_UNREACHABLE */ + s_ErrorMessage.Add(1235, "Request aborted"); /* ERROR_REQUEST_ABORTED */ + s_ErrorMessage.Add(1236, "Connection aborted"); /* ERROR_CONNECTION_ABORTED */ + s_ErrorMessage.Add(1237, "Retry"); /* ERROR_RETRY */ + s_ErrorMessage.Add(1238, "Connection count limit"); /* ERROR_CONNECTION_COUNT_LIMIT */ + s_ErrorMessage.Add(1239, "Login time restriction"); /* ERROR_LOGIN_TIME_RESTRICTION */ + s_ErrorMessage.Add(1240, "Login wksta restriction"); /* ERROR_LOGIN_WKSTA_RESTRICTION */ + s_ErrorMessage.Add(1241, "Incorrect address"); /* ERROR_INCORRECT_ADDRESS */ + s_ErrorMessage.Add(1242, "Already registered"); /* ERROR_ALREADY_REGISTERED */ + s_ErrorMessage.Add(1243, "Service not found"); /* ERROR_SERVICE_NOT_FOUND */ + s_ErrorMessage.Add(1244, "Not authenticated"); /* ERROR_NOT_AUTHENTICATED */ + s_ErrorMessage.Add(1245, "Not logged on"); /* ERROR_NOT_LOGGED_ON */ + s_ErrorMessage.Add(1246, "Continue"); /* ERROR_CONTINUE */ + s_ErrorMessage.Add(1247, "Already initialised"); /* ERROR_ALREADY_INITIALIZED */ + s_ErrorMessage.Add(1248, "No more devices"); /* ERROR_NO_MORE_DEVICES */ + s_ErrorMessage.Add(1249, "No such site"); /* ERROR_NO_SUCH_SITE */ + s_ErrorMessage.Add(1250, "Domain controller exists"); /* ERROR_DOMAIN_CONTROLLER_EXISTS */ + s_ErrorMessage.Add(1251, "Only if connected"); /* ERROR_ONLY_IF_CONNECTED */ + s_ErrorMessage.Add(1252, "Override no changes"); /* ERROR_OVERRIDE_NOCHANGES */ + s_ErrorMessage.Add(1253, "Bad user profile"); /* ERROR_BAD_USER_PROFILE */ + s_ErrorMessage.Add(1254, "Not supported on SBS"); /* ERROR_NOT_SUPPORTED_ON_SBS */ + s_ErrorMessage.Add(1255, "Server shutdown in progress"); /* ERROR_SERVER_SHUTDOWN_IN_PROGRESS */ + s_ErrorMessage.Add(1256, "Host down"); /* ERROR_HOST_DOWN */ + s_ErrorMessage.Add(1257, "Non account sid"); /* ERROR_NON_ACCOUNT_SID */ + s_ErrorMessage.Add(1258, "Non domain sid"); /* ERROR_NON_DOMAIN_SID */ + s_ErrorMessage.Add(1259, "Apphelp block"); /* ERROR_APPHELP_BLOCK */ + s_ErrorMessage.Add(1260, "Access disabled by policy"); /* ERROR_ACCESS_DISABLED_BY_POLICY */ + s_ErrorMessage.Add(1261, "Reg nat consumption"); /* ERROR_REG_NAT_CONSUMPTION */ + s_ErrorMessage.Add(1262, "CSC share offline"); /* ERROR_CSCSHARE_OFFLINE */ + s_ErrorMessage.Add(1263, "PK init failure"); /* ERROR_PKINIT_FAILURE */ + s_ErrorMessage.Add(1264, "Smartcard subsystem failure"); /* ERROR_SMARTCARD_SUBSYSTEM_FAILURE */ + s_ErrorMessage.Add(1265, "Downgrade detected"); /* ERROR_DOWNGRADE_DETECTED */ + s_ErrorMessage.Add(1266, "Smartcard cert revoked"); /* SEC_E_SMARTCARD_CERT_REVOKED */ + s_ErrorMessage.Add(1267, "Issuing CA untrusted"); /* SEC_E_ISSUING_CA_UNTRUSTED */ + s_ErrorMessage.Add(1268, "Revocation offline"); /* SEC_E_REVOCATION_OFFLINE_C */ + s_ErrorMessage.Add(1269, "PK init client failure"); /* SEC_E_PKINIT_CLIENT_FAILUR */ + s_ErrorMessage.Add(1270, "Smartcard cert expired"); /* SEC_E_SMARTCARD_CERT_EXPIRED */ + s_ErrorMessage.Add(1271, "Machine locked"); /* ERROR_MACHINE_LOCKED */ + s_ErrorMessage.Add(1273, "Callback supplied invalid data"); /* ERROR_CALLBACK_SUPPLIED_INVALID_DATA */ + s_ErrorMessage.Add(1274, "Sync foreground refresh required"); /* ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED */ + s_ErrorMessage.Add(1275, "Driver blocked"); /* ERROR_DRIVER_BLOCKED */ + s_ErrorMessage.Add(1276, "Invalid import of non DLL"); /* ERROR_INVALID_IMPORT_OF_NON_DLL */ + s_ErrorMessage.Add(1300, "Not all assigned"); /* ERROR_NOT_ALL_ASSIGNED */ + s_ErrorMessage.Add(1301, "Some not mapped"); /* ERROR_SOME_NOT_MAPPED */ + s_ErrorMessage.Add(1302, "No quotas for account"); /* ERROR_NO_QUOTAS_FOR_ACCOUNT */ + s_ErrorMessage.Add(1303, "Local user session key"); /* ERROR_LOCAL_USER_SESSION_KEY */ + s_ErrorMessage.Add(1304, "Null LM password"); /* ERROR_NULL_LM_PASSWORD */ + s_ErrorMessage.Add(1305, "Unknown revision"); /* ERROR_UNKNOWN_REVISION */ + s_ErrorMessage.Add(1306, "Revision mismatch"); /* ERROR_REVISION_MISMATCH */ + s_ErrorMessage.Add(1307, "Invalid owner"); /* ERROR_INVALID_OWNER */ + s_ErrorMessage.Add(1308, "Invalid primary group"); /* ERROR_INVALID_PRIMARY_GROUP */ + s_ErrorMessage.Add(1309, "No impersonation token"); /* ERROR_NO_IMPERSONATION_TOKEN */ + s_ErrorMessage.Add(1310, "Can't disable mandatory"); /* ERROR_CANT_DISABLE_MANDATORY */ + s_ErrorMessage.Add(1311, "No logon servers"); /* ERROR_NO_LOGON_SERVERS */ + s_ErrorMessage.Add(1312, "No such logon session"); /* ERROR_NO_SUCH_LOGON_SESSION */ + s_ErrorMessage.Add(1313, "No such privilege"); /* ERROR_NO_SUCH_PRIVILEGE */ + s_ErrorMessage.Add(1314, "Privilege not held"); /* ERROR_PRIVILEGE_NOT_HELD */ + s_ErrorMessage.Add(1315, "Invalid account name"); /* ERROR_INVALID_ACCOUNT_NAME */ + s_ErrorMessage.Add(1316, "User exists"); /* ERROR_USER_EXISTS */ + s_ErrorMessage.Add(1317, "No such user"); /* ERROR_NO_SUCH_USER */ + s_ErrorMessage.Add(1318, "Group exists"); /* ERROR_GROUP_EXISTS */ + s_ErrorMessage.Add(1319, "No such group"); /* ERROR_NO_SUCH_GROUP */ + s_ErrorMessage.Add(1320, "Member in group"); /* ERROR_MEMBER_IN_GROUP */ + s_ErrorMessage.Add(1321, "Member not in group"); /* ERROR_MEMBER_NOT_IN_GROUP */ + s_ErrorMessage.Add(1322, "Last admin"); /* ERROR_LAST_ADMIN */ + s_ErrorMessage.Add(1323, "Wrong password"); /* ERROR_WRONG_PASSWORD */ + s_ErrorMessage.Add(1324, "Ill formed password"); /* ERROR_ILL_FORMED_PASSWORD */ + s_ErrorMessage.Add(1325, "Password restriction"); /* ERROR_PASSWORD_RESTRICTION */ + s_ErrorMessage.Add(1326, "Logon failure"); /* ERROR_LOGON_FAILURE */ + s_ErrorMessage.Add(1327, "Account restriction"); /* ERROR_ACCOUNT_RESTRICTION */ + s_ErrorMessage.Add(1328, "Invalid logon hours"); /* ERROR_INVALID_LOGON_HOURS */ + s_ErrorMessage.Add(1329, "Invalid workstation"); /* ERROR_INVALID_WORKSTATION */ + s_ErrorMessage.Add(1330, "Password expired"); /* ERROR_PASSWORD_EXPIRED */ + s_ErrorMessage.Add(1331, "Account disabled"); /* ERROR_ACCOUNT_DISABLED */ + s_ErrorMessage.Add(1332, "None mapped"); /* ERROR_NONE_MAPPED */ + s_ErrorMessage.Add(1333, "Too many LUIDs requested"); /* ERROR_TOO_MANY_LUIDS_REQUESTED */ + s_ErrorMessage.Add(1334, "LUIDs exhausted"); /* ERROR_LUIDS_EXHAUSTED */ + s_ErrorMessage.Add(1335, "Invalid sub authority"); /* ERROR_INVALID_SUB_AUTHORITY */ + s_ErrorMessage.Add(1336, "Invalid ACL"); /* ERROR_INVALID_ACL */ + s_ErrorMessage.Add(1337, "Invalid SID"); /* ERROR_INVALID_SID */ + s_ErrorMessage.Add(1338, "Invalid security descr"); /* ERROR_INVALID_SECURITY_DESCR */ + s_ErrorMessage.Add(1340, "Bad inheritance ACL"); /* ERROR_BAD_INHERITANCE_ACL */ + s_ErrorMessage.Add(1341, "Server disabled"); /* ERROR_SERVER_DISABLED */ + s_ErrorMessage.Add(1342, "Server not disabled"); /* ERROR_SERVER_NOT_DISABLED */ + s_ErrorMessage.Add(1343, "Invalid ID authority"); /* ERROR_INVALID_ID_AUTHORITY */ + s_ErrorMessage.Add(1344, "Allotted space exceeded"); /* ERROR_ALLOTTED_SPACE_EXCEEDED */ + s_ErrorMessage.Add(1345, "Invalid group attributes"); /* ERROR_INVALID_GROUP_ATTRIBUTES */ + s_ErrorMessage.Add(1346, "Bad impersonation level"); /* ERROR_BAD_IMPERSONATION_LEVEL */ + s_ErrorMessage.Add(1347, "Can't open anonymous"); /* ERROR_CANT_OPEN_ANONYMOUS */ + s_ErrorMessage.Add(1348, "Bad validation class"); /* ERROR_BAD_VALIDATION_CLASS */ + s_ErrorMessage.Add(1349, "Bad token type"); /* ERROR_BAD_TOKEN_TYPE */ + s_ErrorMessage.Add(1350, "No security on object"); /* ERROR_NO_SECURITY_ON_OBJECT */ + s_ErrorMessage.Add(1351, "Can't access domain info"); /* ERROR_CANT_ACCESS_DOMAIN_INFO */ + s_ErrorMessage.Add(1352, "Invalid server state"); /* ERROR_INVALID_SERVER_STATE */ + s_ErrorMessage.Add(1353, "Invalid domain state"); /* ERROR_INVALID_DOMAIN_STATE */ + s_ErrorMessage.Add(1354, "Invalid domain role"); /* ERROR_INVALID_DOMAIN_ROLE */ + s_ErrorMessage.Add(1355, "No such domain"); /* ERROR_NO_SUCH_DOMAIN */ + s_ErrorMessage.Add(1356, "Domain exists"); /* ERROR_DOMAIN_EXISTS */ + s_ErrorMessage.Add(1357, "Domain limit exceeded"); /* ERROR_DOMAIN_LIMIT_EXCEEDED */ + s_ErrorMessage.Add(1358, "Internal DB corruption"); /* ERROR_INTERNAL_DB_CORRUPTION */ + s_ErrorMessage.Add(1359, "Internal error"); /* ERROR_INTERNAL_ERROR */ + s_ErrorMessage.Add(1360, "Generic not mapped"); /* ERROR_GENERIC_NOT_MAPPED */ + s_ErrorMessage.Add(1361, "Bad descriptor format"); /* ERROR_BAD_DESCRIPTOR_FORMAT */ + s_ErrorMessage.Add(1362, "Not logon process"); /* ERROR_NOT_LOGON_PROCESS */ + s_ErrorMessage.Add(1363, "Logon session exists"); /* ERROR_LOGON_SESSION_EXISTS */ + s_ErrorMessage.Add(1364, "No such package"); /* ERROR_NO_SUCH_PACKAGE */ + s_ErrorMessage.Add(1365, "Bad logon session state"); /* ERROR_BAD_LOGON_SESSION_STATE */ + s_ErrorMessage.Add(1366, "Logon session collision"); /* ERROR_LOGON_SESSION_COLLISION */ + s_ErrorMessage.Add(1367, "Invalid logon type"); /* ERROR_INVALID_LOGON_TYPE */ + s_ErrorMessage.Add(1368, "Cannot impersonate"); /* ERROR_CANNOT_IMPERSONATE */ + s_ErrorMessage.Add(1369, "Rxact invalid state"); /* ERROR_RXACT_INVALID_STATE */ + s_ErrorMessage.Add(1370, "Rxact commit failure"); /* ERROR_RXACT_COMMIT_FAILURE */ + s_ErrorMessage.Add(1371, "Special account"); /* ERROR_SPECIAL_ACCOUNT */ + s_ErrorMessage.Add(1372, "Special group"); /* ERROR_SPECIAL_GROUP */ + s_ErrorMessage.Add(1373, "Special user"); /* ERROR_SPECIAL_USER */ + s_ErrorMessage.Add(1374, "Members primary group"); /* ERROR_MEMBERS_PRIMARY_GROUP */ + s_ErrorMessage.Add(1375, "Token already in use"); /* ERROR_TOKEN_ALREADY_IN_USE */ + s_ErrorMessage.Add(1376, "No such alias"); /* ERROR_NO_SUCH_ALIAS */ + s_ErrorMessage.Add(1377, "Member not in alias"); /* ERROR_MEMBER_NOT_IN_ALIAS */ + s_ErrorMessage.Add(1378, "Member in alias"); /* ERROR_MEMBER_IN_ALIAS */ + s_ErrorMessage.Add(1379, "Alias exists"); /* ERROR_ALIAS_EXISTS */ + s_ErrorMessage.Add(1380, "Logon not granted"); /* ERROR_LOGON_NOT_GRANTED */ + s_ErrorMessage.Add(1381, "Too many secrets"); /* ERROR_TOO_MANY_SECRETS */ + s_ErrorMessage.Add(1382, "Secret too long"); /* ERROR_SECRET_TOO_LONG */ + s_ErrorMessage.Add(1383, "Internal DB error"); /* ERROR_INTERNAL_DB_ERROR */ + s_ErrorMessage.Add(1384, "Too many context IDs"); /* ERROR_TOO_MANY_CONTEXT_IDS */ + s_ErrorMessage.Add(1385, "Logon type not granted"); /* ERROR_LOGON_TYPE_NOT_GRANTED */ + s_ErrorMessage.Add(1386, "NT cross encryption required"); /* ERROR_NT_CROSS_ENCRYPTION_REQUIRED */ + s_ErrorMessage.Add(1387, "No such member"); /* ERROR_NO_SUCH_MEMBER */ + s_ErrorMessage.Add(1388, "Invalid member"); /* ERROR_INVALID_MEMBER */ + s_ErrorMessage.Add(1389, "Too many SIDs"); /* ERROR_TOO_MANY_SIDS */ + s_ErrorMessage.Add(1390, "LM cross encryption required"); /* ERROR_LM_CROSS_ENCRYPTION_REQUIRED */ + s_ErrorMessage.Add(1391, "No inheritance"); /* ERROR_NO_INHERITANCE */ + s_ErrorMessage.Add(1392, "File corrupt"); /* ERROR_FILE_CORRUPT */ + s_ErrorMessage.Add(1393, "Disk corrupt"); /* ERROR_DISK_CORRUPT */ + s_ErrorMessage.Add(1394, "No user session key"); /* ERROR_NO_USER_SESSION_KEY */ + s_ErrorMessage.Add(1395, "Licence quota exceeded"); /* ERROR_LICENSE_QUOTA_EXCEEDED */ + s_ErrorMessage.Add(1396, "Wrong target name"); /* ERROR_WRONG_TARGET_NAME */ + s_ErrorMessage.Add(1397, "Mutual auth failed"); /* ERROR_MUTUAL_AUTH_FAILED */ + s_ErrorMessage.Add(1398, "Time skew"); /* ERROR_TIME_SKEW */ + s_ErrorMessage.Add(1399, "Current domain not allowed"); /* ERROR_CURRENT_DOMAIN_NOT_ALLOWED */ + s_ErrorMessage.Add(1400, "Invalid window handle"); /* ERROR_INVALID_WINDOW_HANDLE */ + s_ErrorMessage.Add(1401, "Invalid menu handle"); /* ERROR_INVALID_MENU_HANDLE */ + s_ErrorMessage.Add(1402, "Invalid cursor handle"); /* ERROR_INVALID_CURSOR_HANDLE */ + s_ErrorMessage.Add(1403, "Invalid accel handle"); /* ERROR_INVALID_ACCEL_HANDLE */ + s_ErrorMessage.Add(1404, "Invalid hook handle"); /* ERROR_INVALID_HOOK_HANDLE */ + s_ErrorMessage.Add(1405, "Invalid DWP handle"); /* ERROR_INVALID_DWP_HANDLE */ + s_ErrorMessage.Add(1406, "TLW with wschild"); /* ERROR_TLW_WITH_WSCHILD */ + s_ErrorMessage.Add(1407, "Cannot find WND class"); /* ERROR_CANNOT_FIND_WND_CLASS */ + s_ErrorMessage.Add(1408, "Window of other thread"); /* ERROR_WINDOW_OF_OTHER_THREAD */ + s_ErrorMessage.Add(1409, "Hotkey already registered"); /* ERROR_HOTKEY_ALREADY_REGISTERED */ + s_ErrorMessage.Add(1410, "Class already exists"); /* ERROR_CLASS_ALREADY_EXISTS */ + s_ErrorMessage.Add(1411, "Class does not exist"); /* ERROR_CLASS_DOES_NOT_EXIST */ + s_ErrorMessage.Add(1412, "Class has windows"); /* ERROR_CLASS_HAS_WINDOWS */ + s_ErrorMessage.Add(1413, "Invalid index"); /* ERROR_INVALID_INDEX */ + s_ErrorMessage.Add(1414, "Invalid icon handle"); /* ERROR_INVALID_ICON_HANDLE */ + s_ErrorMessage.Add(1415, "Private dialog index"); /* ERROR_PRIVATE_DIALOG_INDEX */ + s_ErrorMessage.Add(1416, "Listbox ID not found"); /* ERROR_LISTBOX_ID_NOT_FOUND */ + s_ErrorMessage.Add(1417, "No wildcard characters"); /* ERROR_NO_WILDCARD_CHARACTERS */ + s_ErrorMessage.Add(1418, "Clipboard not open"); /* ERROR_CLIPBOARD_NOT_OPEN */ + s_ErrorMessage.Add(1419, "Hotkey not registered"); /* ERROR_HOTKEY_NOT_REGISTERED */ + s_ErrorMessage.Add(1420, "Window not dialog"); /* ERROR_WINDOW_NOT_DIALOG */ + s_ErrorMessage.Add(1421, "Control ID not found"); /* ERROR_CONTROL_ID_NOT_FOUND */ + s_ErrorMessage.Add(1422, "Invalid combobox message"); /* ERROR_INVALID_COMBOBOX_MESSAGE */ + s_ErrorMessage.Add(1423, "Window not combobox"); /* ERROR_WINDOW_NOT_COMBOBOX */ + s_ErrorMessage.Add(1424, "Invalid edit height"); /* ERROR_INVALID_EDIT_HEIGHT */ + s_ErrorMessage.Add(1425, "DC not found"); /* ERROR_DC_NOT_FOUND */ + s_ErrorMessage.Add(1426, "Invalid hook filter"); /* ERROR_INVALID_HOOK_FILTER */ + s_ErrorMessage.Add(1427, "Invalid filter proc"); /* ERROR_INVALID_FILTER_PROC */ + s_ErrorMessage.Add(1428, "Hook needs HMOD"); /* ERROR_HOOK_NEEDS_HMOD */ + s_ErrorMessage.Add(1429, "Global only hook"); /* ERROR_GLOBAL_ONLY_HOOK */ + s_ErrorMessage.Add(1430, "Journal hook set"); /* ERROR_JOURNAL_HOOK_SET */ + s_ErrorMessage.Add(1431, "Hook not installed"); /* ERROR_HOOK_NOT_INSTALLED */ + s_ErrorMessage.Add(1432, "Invalid LB message"); /* ERROR_INVALID_LB_MESSAGE */ + s_ErrorMessage.Add(1433, "Setcount on bad LB"); /* ERROR_SETCOUNT_ON_BAD_LB */ + s_ErrorMessage.Add(1434, "LB without tabstops"); /* ERROR_LB_WITHOUT_TABSTOPS */ + s_ErrorMessage.Add(1435, "Destroy object of other thread"); /* ERROR_DESTROY_OBJECT_OF_OTHER_THREAD */ + s_ErrorMessage.Add(1436, "Child window menu"); /* ERROR_CHILD_WINDOW_MENU */ + s_ErrorMessage.Add(1437, "No system menu"); /* ERROR_NO_SYSTEM_MENU */ + s_ErrorMessage.Add(1438, "Invalid msgbox style"); /* ERROR_INVALID_MSGBOX_STYLE */ + s_ErrorMessage.Add(1439, "Invalid SPI value"); /* ERROR_INVALID_SPI_VALUE */ + s_ErrorMessage.Add(1440, "Screen already locked"); /* ERROR_SCREEN_ALREADY_LOCKED */ + s_ErrorMessage.Add(1441, "HWNDs have different parent"); /* ERROR_HWNDS_HAVE_DIFF_PARENT */ + s_ErrorMessage.Add(1442, "Not child window"); /* ERROR_NOT_CHILD_WINDOW */ + s_ErrorMessage.Add(1443, "Invalid GW command"); /* ERROR_INVALID_GW_COMMAND */ + s_ErrorMessage.Add(1444, "Invalid thread ID"); /* ERROR_INVALID_THREAD_ID */ + s_ErrorMessage.Add(1445, "Non MDI child window"); /* ERROR_NON_MDICHILD_WINDOW */ + s_ErrorMessage.Add(1446, "Popup already active"); /* ERROR_POPUP_ALREADY_ACTIVE */ + s_ErrorMessage.Add(1447, "No scrollbars"); /* ERROR_NO_SCROLLBARS */ + s_ErrorMessage.Add(1448, "Invalid scrollbar range"); /* ERROR_INVALID_SCROLLBAR_RANGE */ + s_ErrorMessage.Add(1449, "Invalid showwin command"); /* ERROR_INVALID_SHOWWIN_COMMAND */ + s_ErrorMessage.Add(1450, "No system resources"); /* ERROR_NO_SYSTEM_RESOURCES */ + s_ErrorMessage.Add(1451, "Nonpaged system resources"); /* ERROR_NONPAGED_SYSTEM_RESOURCES */ + s_ErrorMessage.Add(1452, "Paged system resources"); /* ERROR_PAGED_SYSTEM_RESOURCES */ + s_ErrorMessage.Add(1453, "Working set quota"); /* ERROR_WORKING_SET_QUOTA */ + s_ErrorMessage.Add(1454, "Pagefile quota"); /* ERROR_PAGEFILE_QUOTA */ + s_ErrorMessage.Add(1455, "Commitment limit"); /* ERROR_COMMITMENT_LIMIT */ + s_ErrorMessage.Add(1456, "Menu item not found"); /* ERROR_MENU_ITEM_NOT_FOUND */ + s_ErrorMessage.Add(1457, "Invalid keyboard handle"); /* ERROR_INVALID_KEYBOARD_HANDLE */ + s_ErrorMessage.Add(1458, "Hook type not allowed"); /* ERROR_HOOK_TYPE_NOT_ALLOWED */ + s_ErrorMessage.Add(1459, "Requires interactive windowstation"); /* ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION */ + s_ErrorMessage.Add(1460, "Timeout"); /* ERROR_TIMEOUT */ + s_ErrorMessage.Add(1461, "Invalid monitor handle"); /* ERROR_INVALID_MONITOR_HANDLE */ + s_ErrorMessage.Add(1500, "Eventlog file corrupt"); /* ERROR_EVENTLOG_FILE_CORRUPT */ + s_ErrorMessage.Add(1501, "Eventlog can't start"); /* ERROR_EVENTLOG_CANT_START */ + s_ErrorMessage.Add(1502, "Log file full"); /* ERROR_LOG_FILE_FULL */ + s_ErrorMessage.Add(1503, "Eventlog file changed"); /* ERROR_EVENTLOG_FILE_CHANGED */ + s_ErrorMessage.Add(1601, "Install service failure"); /* ERROR_INSTALL_SERVICE_FAILURE */ + s_ErrorMessage.Add(1602, "Install userexit"); /* ERROR_INSTALL_USEREXIT */ + s_ErrorMessage.Add(1603, "Install failure"); /* ERROR_INSTALL_FAILURE */ + s_ErrorMessage.Add(1604, "Install suspend"); /* ERROR_INSTALL_SUSPEND */ + s_ErrorMessage.Add(1605, "Unknown product"); /* ERROR_UNKNOWN_PRODUCT */ + s_ErrorMessage.Add(1606, "Unknown feature"); /* ERROR_UNKNOWN_FEATURE */ + s_ErrorMessage.Add(1607, "Unknown component"); /* ERROR_UNKNOWN_COMPONENT */ + s_ErrorMessage.Add(1608, "Unknown property"); /* ERROR_UNKNOWN_PROPERTY */ + s_ErrorMessage.Add(1609, "Invalid handle state"); /* ERROR_INVALID_HANDLE_STATE */ + s_ErrorMessage.Add(1610, "Bad configuration"); /* ERROR_BAD_CONFIGURATION */ + s_ErrorMessage.Add(1611, "Index absent"); /* ERROR_INDEX_ABSENT */ + s_ErrorMessage.Add(1612, "Install source absent"); /* ERROR_INSTALL_SOURCE_ABSENT */ + s_ErrorMessage.Add(1613, "Install package version"); /* ERROR_INSTALL_PACKAGE_VERSION */ + s_ErrorMessage.Add(1614, "Product uninstalled"); /* ERROR_PRODUCT_UNINSTALLED */ + s_ErrorMessage.Add(1615, "Bad query syntax"); /* ERROR_BAD_QUERY_SYNTAX */ + s_ErrorMessage.Add(1616, "Invalid field"); /* ERROR_INVALID_FIELD */ + s_ErrorMessage.Add(1617, "Device removed"); /* ERROR_DEVICE_REMOVED */ + s_ErrorMessage.Add(1618, "Install already running"); /* ERROR_INSTALL_ALREADY_RUNNING */ + s_ErrorMessage.Add(1619, "Install package open failed"); /* ERROR_INSTALL_PACKAGE_OPEN_FAILED */ + s_ErrorMessage.Add(1620, "Install package invalid"); /* ERROR_INSTALL_PACKAGE_INVALID */ + s_ErrorMessage.Add(1621, "Install UI failure"); /* ERROR_INSTALL_UI_FAILURE */ + s_ErrorMessage.Add(1622, "Install log failure"); /* ERROR_INSTALL_LOG_FAILURE */ + s_ErrorMessage.Add(1623, "Install language unsupported"); /* ERROR_INSTALL_LANGUAGE_UNSUPPORTED */ + s_ErrorMessage.Add(1624, "Install transform failure"); /* ERROR_INSTALL_TRANSFORM_FAILURE */ + s_ErrorMessage.Add(1625, "Install package rejected"); /* ERROR_INSTALL_PACKAGE_REJECTED */ + s_ErrorMessage.Add(1626, "Function not called"); /* ERROR_FUNCTION_NOT_CALLED */ + s_ErrorMessage.Add(1627, "Function failed"); /* ERROR_FUNCTION_FAILED */ + s_ErrorMessage.Add(1628, "Invalid table"); /* ERROR_INVALID_TABLE */ + s_ErrorMessage.Add(1629, "Datatype mismatch"); /* ERROR_DATATYPE_MISMATCH */ + s_ErrorMessage.Add(1630, "Unsupported type"); /* ERROR_UNSUPPORTED_TYPE */ + s_ErrorMessage.Add(1631, "Create failed"); /* ERROR_CREATE_FAILED */ + s_ErrorMessage.Add(1632, "Install temp unwritable"); /* ERROR_INSTALL_TEMP_UNWRITABLE */ + s_ErrorMessage.Add(1633, "Install platform unsupported"); /* ERROR_INSTALL_PLATFORM_UNSUPPORTED */ + s_ErrorMessage.Add(1634, "Install notused"); /* ERROR_INSTALL_NOTUSED */ + s_ErrorMessage.Add(1635, "Patch package open failed"); /* ERROR_PATCH_PACKAGE_OPEN_FAILED */ + s_ErrorMessage.Add(1636, "Patch package invalid"); /* ERROR_PATCH_PACKAGE_INVALID */ + s_ErrorMessage.Add(1637, "Patch package unsupported"); /* ERROR_PATCH_PACKAGE_UNSUPPORTED */ + s_ErrorMessage.Add(1638, "Product version"); /* ERROR_PRODUCT_VERSION */ + s_ErrorMessage.Add(1639, "Invalid command line"); /* ERROR_INVALID_COMMAND_LINE */ + s_ErrorMessage.Add(1640, "Install remote disallowed"); /* ERROR_INSTALL_REMOTE_DISALLOWED */ + s_ErrorMessage.Add(1641, "Success reboot initiated"); /* ERROR_SUCCESS_REBOOT_INITIATED */ + s_ErrorMessage.Add(1642, "Patch target not found"); /* ERROR_PATCH_TARGET_NOT_FOUND */ + s_ErrorMessage.Add(1643, "Patch package rejected"); /* ERROR_PATCH_PACKAGE_REJECTED */ + s_ErrorMessage.Add(1644, "Install transform rejected"); /* ERROR_INSTALL_TRANSFORM_REJECTED */ + s_ErrorMessage.Add(1700, "RPC S Invalid string binding"); /* RPC_S_INVALID_STRING_BINDING */ + s_ErrorMessage.Add(1701, "RPC S Wrong kind of binding"); /* RPC_S_WRONG_KIND_OF_BINDING */ + s_ErrorMessage.Add(1702, "RPC S Invalid binding"); /* RPC_S_INVALID_BINDING */ + s_ErrorMessage.Add(1703, "RPC S Protseq not supported"); /* RPC_S_PROTSEQ_NOT_SUPPORTED */ + s_ErrorMessage.Add(1704, "RPC S Invalid RPC protseq"); /* RPC_S_INVALID_RPC_PROTSEQ */ + s_ErrorMessage.Add(1705, "RPC S Invalid string UUID"); /* RPC_S_INVALID_STRING_UUID */ + s_ErrorMessage.Add(1706, "RPC S Invalid endpoint format"); /* RPC_S_INVALID_ENDPOINT_FORMAT */ + s_ErrorMessage.Add(1707, "RPC S Invalid net addr"); /* RPC_S_INVALID_NET_ADDR */ + s_ErrorMessage.Add(1708, "RPC S No endpoint found"); /* RPC_S_NO_ENDPOINT_FOUND */ + s_ErrorMessage.Add(1709, "RPC S Invalid timeout"); /* RPC_S_INVALID_TIMEOUT */ + s_ErrorMessage.Add(1710, "RPC S Object not found"); /* RPC_S_OBJECT_NOT_FOUND */ + s_ErrorMessage.Add(1711, "RPC S Already registered"); /* RPC_S_ALREADY_REGISTERED */ + s_ErrorMessage.Add(1712, "RPC S Type already registered"); /* RPC_S_TYPE_ALREADY_REGISTERED */ + s_ErrorMessage.Add(1713, "RPC S Already listening"); /* RPC_S_ALREADY_LISTENING */ + s_ErrorMessage.Add(1714, "RPC S Not protseqs registered"); /* RPC_S_NO_PROTSEQS_REGISTERED */ + s_ErrorMessage.Add(1715, "RPC S Not listening"); /* RPC_S_NOT_LISTENING */ + s_ErrorMessage.Add(1716, "RPC S Unknown mgr type"); /* RPC_S_UNKNOWN_MGR_TYPE */ + s_ErrorMessage.Add(1717, "RPC S Unknown IF"); /* RPC_S_UNKNOWN_IF */ + s_ErrorMessage.Add(1718, "RPC S No bindings"); /* RPC_S_NO_BINDINGS */ + s_ErrorMessage.Add(1719, "RPC S Not protseqs"); /* RPC_S_NO_PROTSEQS */ + s_ErrorMessage.Add(1720, "RPC S Can't create endpoint"); /* RPC_S_CANT_CREATE_ENDPOINT */ + s_ErrorMessage.Add(1721, "RPC S Out of resources"); /* RPC_S_OUT_OF_RESOURCES */ + s_ErrorMessage.Add(1722, "RPC S Server unavailable"); /* RPC_S_SERVER_UNAVAILABLE */ + s_ErrorMessage.Add(1723, "RPC S Server too busy"); /* RPC_S_SERVER_TOO_BUSY */ + s_ErrorMessage.Add(1724, "RPC S Invalid network options"); /* RPC_S_INVALID_NETWORK_OPTIONS */ + s_ErrorMessage.Add(1725, "RPC S No call active"); /* RPC_S_NO_CALL_ACTIVE */ + s_ErrorMessage.Add(1726, "RPC S Call failed"); /* RPC_S_CALL_FAILED */ + s_ErrorMessage.Add(1727, "RPC S Call failed DNE"); /* RPC_S_CALL_FAILED_DNE */ + s_ErrorMessage.Add(1728, "RPC S Protocol error"); /* RPC_S_PROTOCOL_ERROR */ + s_ErrorMessage.Add(1730, "RPC S Unsupported trans syn"); /* RPC_S_UNSUPPORTED_TRANS_SYN */ + s_ErrorMessage.Add(1732, "RPC S Unsupported type"); /* RPC_S_UNSUPPORTED_TYPE */ + s_ErrorMessage.Add(1733, "RPC S Invalid tag"); /* RPC_S_INVALID_TAG */ + s_ErrorMessage.Add(1734, "RPC S Invalid bound"); /* RPC_S_INVALID_BOUND */ + s_ErrorMessage.Add(1735, "RPC S No entry name"); /* RPC_S_NO_ENTRY_NAME */ + s_ErrorMessage.Add(1736, "RPC S Invalid name syntax"); /* RPC_S_INVALID_NAME_SYNTAX */ + s_ErrorMessage.Add(1737, "RPC S Unsupported name syntax"); /* RPC_S_UNSUPPORTED_NAME_SYNTAX */ + s_ErrorMessage.Add(1739, "RPC S UUID no address"); /* RPC_S_UUID_NO_ADDRESS */ + s_ErrorMessage.Add(1740, "RPC S Duplicate endpoint"); /* RPC_S_DUPLICATE_ENDPOINT */ + s_ErrorMessage.Add(1741, "RPC S Unknown authn type"); /* RPC_S_UNKNOWN_AUTHN_TYPE */ + s_ErrorMessage.Add(1742, "RPC S Max calls too small"); /* RPC_S_MAX_CALLS_TOO_SMALL */ + s_ErrorMessage.Add(1743, "RPC S String too long"); /* RPC_S_STRING_TOO_LONG */ + s_ErrorMessage.Add(1744, "RPC S Protseq not found"); /* RPC_S_PROTSEQ_NOT_FOUND */ + s_ErrorMessage.Add(1745, "RPC S Procnum out of range"); /* RPC_S_PROCNUM_OUT_OF_RANGE */ + s_ErrorMessage.Add(1746, "RPC S Binding has no auth"); /* RPC_S_BINDING_HAS_NO_AUTH */ + s_ErrorMessage.Add(1747, "RPC S Unknown authn service"); /* RPC_S_UNKNOWN_AUTHN_SERVICE */ + s_ErrorMessage.Add(1748, "RPC S Unknown authn level"); /* RPC_S_UNKNOWN_AUTHN_LEVEL */ + s_ErrorMessage.Add(1749, "RPC S Invalid auth identity"); /* RPC_S_INVALID_AUTH_IDENTITY */ + s_ErrorMessage.Add(1750, "RPC S Unknown authz service"); /* RPC_S_UNKNOWN_AUTHZ_SERVICE */ + s_ErrorMessage.Add(1751, "EPT S Invalid entry"); /* EPT_S_INVALID_ENTRY */ + s_ErrorMessage.Add(1752, "EPT S Can't perform op"); /* EPT_S_CANT_PERFORM_OP */ + s_ErrorMessage.Add(1753, "EPT S Not registered"); /* EPT_S_NOT_REGISTERED */ + s_ErrorMessage.Add(1754, "RPC S Nothing to export"); /* RPC_S_NOTHING_TO_EXPORT */ + s_ErrorMessage.Add(1755, "RPC S Incomplete name"); /* RPC_S_INCOMPLETE_NAME */ + s_ErrorMessage.Add(1756, "RPC S Invalid vers option"); /* RPC_S_INVALID_VERS_OPTION */ + s_ErrorMessage.Add(1757, "RPC S No more members"); /* RPC_S_NO_MORE_MEMBERS */ + s_ErrorMessage.Add(1758, "RPC S Not all objs unexported"); /* RPC_S_NOT_ALL_OBJS_UNEXPORTED */ + s_ErrorMessage.Add(1759, "RPC S Interface not found"); /* RPC_S_INTERFACE_NOT_FOUND */ + s_ErrorMessage.Add(1760, "RPC S Entry already exists"); /* RPC_S_ENTRY_ALREADY_EXISTS */ + s_ErrorMessage.Add(1761, "RPC S Entry not found"); /* RPC_S_ENTRY_NOT_FOUND */ + s_ErrorMessage.Add(1762, "RPC S Name service unavailable"); /* RPC_S_NAME_SERVICE_UNAVAILABLE */ + s_ErrorMessage.Add(1763, "RPC S Invalid naf ID"); /* RPC_S_INVALID_NAF_ID */ + s_ErrorMessage.Add(1764, "RPC S Cannot support"); /* RPC_S_CANNOT_SUPPORT */ + s_ErrorMessage.Add(1765, "RPC S No context available"); /* RPC_S_NO_CONTEXT_AVAILABLE */ + s_ErrorMessage.Add(1766, "RPC S Internal error"); /* RPC_S_INTERNAL_ERROR */ + s_ErrorMessage.Add(1767, "RPC S Zero divide"); /* RPC_S_ZERO_DIVIDE */ + s_ErrorMessage.Add(1768, "RPC S Address error"); /* RPC_S_ADDRESS_ERROR */ + s_ErrorMessage.Add(1769, "RPC S FP div zero"); /* RPC_S_FP_DIV_ZERO */ + s_ErrorMessage.Add(1770, "RPC S FP Underflow"); /* RPC_S_FP_UNDERFLOW */ + s_ErrorMessage.Add(1771, "RPC S Overflow"); /* RPC_S_FP_OVERFLOW */ + s_ErrorMessage.Add(1772, "RPC X No more entries"); /* RPC_X_NO_MORE_ENTRIES */ + s_ErrorMessage.Add(1773, "RPC X SS char trans open fail"); /* RPC_X_SS_CHAR_TRANS_OPEN_FAIL */ + s_ErrorMessage.Add(1774, "RPC X SS char trans short file"); /* RPC_X_SS_CHAR_TRANS_SHORT_FILE */ + s_ErrorMessage.Add(1775, "RPC S SS in null context"); /* RPC_X_SS_IN_NULL_CONTEXT */ + s_ErrorMessage.Add(1777, "RPC X SS context damaged"); /* RPC_X_SS_CONTEXT_DAMAGED */ + s_ErrorMessage.Add(1778, "RPC X SS handles mismatch"); /* RPC_X_SS_HANDLES_MISMATCH */ + s_ErrorMessage.Add(1779, "RPC X SS cannot get call handle"); /* RPC_X_SS_CANNOT_GET_CALL_HANDLE */ + s_ErrorMessage.Add(1780, "RPC X Null ref pointer"); /* RPC_X_NULL_REF_POINTER */ + s_ErrorMessage.Add(1781, "RPC X enum value out of range"); /* RPC_X_ENUM_VALUE_OUT_OF_RANGE */ + s_ErrorMessage.Add(1782, "RPC X byte count too small"); /* RPC_X_BYTE_COUNT_TOO_SMALL */ + s_ErrorMessage.Add(1783, "RPC X bad stub data"); /* RPC_X_BAD_STUB_DATA */ + s_ErrorMessage.Add(1784, "Invalid user buffer"); /* ERROR_INVALID_USER_BUFFER */ + s_ErrorMessage.Add(1785, "Unrecognised media"); /* ERROR_UNRECOGNIZED_MEDIA */ + s_ErrorMessage.Add(1786, "No trust lsa secret"); /* ERROR_NO_TRUST_LSA_SECRET */ + s_ErrorMessage.Add(1787, "No trust sam account"); /* ERROR_NO_TRUST_SAM_ACCOUNT */ + s_ErrorMessage.Add(1788, "Trusted domain failure"); /* ERROR_TRUSTED_DOMAIN_FAILURE */ + s_ErrorMessage.Add(1789, "Trusted relationship failure"); /* ERROR_TRUSTED_RELATIONSHIP_FAILURE */ + s_ErrorMessage.Add(1790, "Trust failure"); /* ERROR_TRUST_FAILURE */ + s_ErrorMessage.Add(1791, "RPC S call in progress"); /* RPC_S_CALL_IN_PROGRESS */ + s_ErrorMessage.Add(1792, "Error netlogon not started"); /* ERROR_NETLOGON_NOT_STARTED */ + s_ErrorMessage.Add(1793, "Account expired"); /* ERROR_ACCOUNT_EXPIRED */ + s_ErrorMessage.Add(1794, "Redirector has open handles"); /* ERROR_REDIRECTOR_HAS_OPEN_HANDLES */ + s_ErrorMessage.Add(1795, "Printer driver already installed"); /* ERROR_PRINTER_DRIVER_ALREADY_INSTALLED */ + s_ErrorMessage.Add(1796, "Unknown port"); /* ERROR_UNKNOWN_PORT */ + s_ErrorMessage.Add(1797, "Unknown printer driver"); /* ERROR_UNKNOWN_PRINTER_DRIVER */ + s_ErrorMessage.Add(1798, "Unknown printprocessor"); /* ERROR_UNKNOWN_PRINTPROCESSOR */ + s_ErrorMessage.Add(1799, "Invalid separator file"); /* ERROR_INVALID_SEPARATOR_FILE */ + s_ErrorMessage.Add(1800, "Invalid priority"); /* ERROR_INVALID_PRIORITY */ + s_ErrorMessage.Add(1801, "Invalid printer name"); /* ERROR_INVALID_PRINTER_NAME */ + s_ErrorMessage.Add(1802, "Printer already exists"); /* ERROR_PRINTER_ALREADY_EXISTS */ + s_ErrorMessage.Add(1803, "Invalid printer command"); /* ERROR_INVALID_PRINTER_COMMAND */ + s_ErrorMessage.Add(1804, "Invalid datatype"); /* ERROR_INVALID_DATATYPE */ + s_ErrorMessage.Add(1805, "Invalid environment"); /* ERROR_INVALID_ENVIRONMENT */ + s_ErrorMessage.Add(1806, "RPC S no more bindings"); /* RPC_S_NO_MORE_BINDINGS */ + s_ErrorMessage.Add(1807, "Nologon interdomain trust account"); /* ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT */ + s_ErrorMessage.Add(1808, "Nologon workstation trust account"); /* ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT */ + s_ErrorMessage.Add(1809, "Nologon server trust account"); /* ERROR_NOLOGON_SERVER_TRUST_ACCOUNT */ + s_ErrorMessage.Add(1810, "Domain trust inconsistent"); /* ERROR_DOMAIN_TRUST_INCONSISTENT */ + s_ErrorMessage.Add(1811, "Server has open handles"); /* ERROR_SERVER_HAS_OPEN_HANDLES */ + s_ErrorMessage.Add(1812, "Resource data not found"); /* ERROR_RESOURCE_DATA_NOT_FOUND */ + s_ErrorMessage.Add(1813, "Resource type not found"); /* ERROR_RESOURCE_TYPE_NOT_FOUND */ + s_ErrorMessage.Add(1814, "Resource name not found"); /* ERROR_RESOURCE_NAME_NOT_FOUND */ + s_ErrorMessage.Add(1815, "Resource lang not found"); /* ERROR_RESOURCE_LANG_NOT_FOUND */ + s_ErrorMessage.Add(1816, "Not enough quota"); /* ERROR_NOT_ENOUGH_QUOTA */ + s_ErrorMessage.Add(1817, "RPC S no interfaces"); /* RPC_S_NO_INTERFACES */ + s_ErrorMessage.Add(1818, "RPC S Call cancelled"); /* RPC_S_CALL_CANCELLED */ + s_ErrorMessage.Add(1819, "RPC S Binding incomplete"); /* RPC_S_BINDING_INCOMPLETE */ + s_ErrorMessage.Add(1820, "RPC S Comm failure"); /* RPC_S_COMM_FAILURE */ + s_ErrorMessage.Add(1821, "RPC S Unsupported authn level"); /* RPC_S_UNSUPPORTED_AUTHN_LEVEL */ + s_ErrorMessage.Add(1822, "RPC S No princ name"); /* RPC_S_NO_PRINC_NAME */ + s_ErrorMessage.Add(1823, "RPC S Not RPC error"); /* RPC_S_NOT_RPC_ERROR */ + s_ErrorMessage.Add(1824, "RPC U UUID local only"); /* RPC_S_UUID_LOCAL_ONLY */ + s_ErrorMessage.Add(1825, "RPC S Sec pkg error"); /* RPC_S_SEC_PKG_ERROR */ + s_ErrorMessage.Add(1826, "RPC S Not cancelled"); /* RPC_S_NOT_CANCELLED */ + s_ErrorMessage.Add(1827, "RPC X Invalid ES action"); /* RPC_X_INVALID_ES_ACTION */ + s_ErrorMessage.Add(1828, "RPC X Wrong ES version"); /* RPC_X_WRONG_ES_VERSION */ + s_ErrorMessage.Add(1829, "RPC X Wrong stub version"); /* RPC_X_WRONG_STUB_VERSION */ + s_ErrorMessage.Add(1830, "RPC X Invalid pipe object"); /* RPC_X_INVALID_PIPE_OBJECT */ + s_ErrorMessage.Add(1831, "RPC X Wrong pipe order"); /* RPC_X_WRONG_PIPE_ORDER */ + s_ErrorMessage.Add(1832, "RPC X Wrong pipe version"); /* RPC_X_WRONG_PIPE_VERSION */ + s_ErrorMessage.Add(1898, "RPC S group member not found"); /* RPC_S_GROUP_MEMBER_NOT_FOUND */ + s_ErrorMessage.Add(1899, "EPT S Can't create"); /* EPT_S_CANT_CREATE */ + s_ErrorMessage.Add(1900, "RPC S Invalid object"); /* RPC_S_INVALID_OBJECT */ + s_ErrorMessage.Add(1901, "Invalid time"); /* ERROR_INVALID_TIME */ + s_ErrorMessage.Add(1902, "Invalid form name"); /* ERROR_INVALID_FORM_NAME */ + s_ErrorMessage.Add(1903, "Invalid form size"); /* ERROR_INVALID_FORM_SIZE */ + s_ErrorMessage.Add(1904, "Already waiting"); /* ERROR_ALREADY_WAITING */ + s_ErrorMessage.Add(1905, "Printer deleted"); /* ERROR_PRINTER_DELETED */ + s_ErrorMessage.Add(1906, "Invalid printer state"); /* ERROR_INVALID_PRINTER_STATE */ + s_ErrorMessage.Add(1907, "Password must change"); /* ERROR_PASSWORD_MUST_CHANGE */ + s_ErrorMessage.Add(1908, "Domain controller not found"); /* ERROR_DOMAIN_CONTROLLER_NOT_FOUND */ + s_ErrorMessage.Add(1909, "Account locked out"); /* ERROR_ACCOUNT_LOCKED_OUT */ + s_ErrorMessage.Add(1910, "OR Invalid OXID"); /* OR_INVALID_OXID */ + s_ErrorMessage.Add(1911, "OR Invalid OID"); /* OR_INVALID_OID */ + s_ErrorMessage.Add(1912, "OR Invalid set"); /* OR_INVALID_SET */ + s_ErrorMessage.Add(1913, "RPC S Send incomplete"); /* RPC_S_SEND_INCOMPLETE */ + s_ErrorMessage.Add(1914, "RPC S Invalid async handle"); /* RPC_S_INVALID_ASYNC_HANDLE */ + s_ErrorMessage.Add(1915, "RPC S Invalid async call"); /* RPC_S_INVALID_ASYNC_CALL */ + s_ErrorMessage.Add(1916, "RPC X Pipe closed"); /* RPC_X_PIPE_CLOSED */ + s_ErrorMessage.Add(1917, "RPC X Pipe discipline error"); /* RPC_X_PIPE_DISCIPLINE_ERROR */ + s_ErrorMessage.Add(1918, "RPC X Pipe empty"); /* RPC_X_PIPE_EMPTY */ + s_ErrorMessage.Add(1919, "No sitename"); /* ERROR_NO_SITENAME */ + s_ErrorMessage.Add(1920, "Can't access file"); /* ERROR_CANT_ACCESS_FILE */ + s_ErrorMessage.Add(1921, "Can't resolve filename"); /* ERROR_CANT_RESOLVE_FILENAME */ + s_ErrorMessage.Add(1922, "RPC S Entry type mismatch"); /* RPC_S_ENTRY_TYPE_MISMATCH */ + s_ErrorMessage.Add(1923, "RPC S Not all objs exported"); /* RPC_S_NOT_ALL_OBJS_EXPORTED */ + s_ErrorMessage.Add(1924, "RPC S Interface not exported"); /* RPC_S_INTERFACE_NOT_EXPORTED */ + s_ErrorMessage.Add(1925, "RPC S Profile not added"); /* RPC_S_PROFILE_NOT_ADDED */ + s_ErrorMessage.Add(1926, "RPC S PRF ELT not added"); /* RPC_S_PRF_ELT_NOT_ADDED */ + s_ErrorMessage.Add(1927, "RPC S PRF ELT not removed"); /* RPC_S_PRF_ELT_NOT_REMOVED */ + s_ErrorMessage.Add(1928, "RPC S GRP ELT not added"); /* RPC_S_GRP_ELT_NOT_ADDED */ + s_ErrorMessage.Add(1929, "RPC S GRP ELT not removed"); /* RPC_S_GRP_ELT_NOT_REMOVED */ + s_ErrorMessage.Add(1930, "KM driver blocked"); /* ERROR_KM_DRIVER_BLOCKED */ + s_ErrorMessage.Add(1931, "Context expired"); /* ERROR_CONTEXT_EXPIRED */ + s_ErrorMessage.Add(2000, "Invalid pixel format"); /* ERROR_INVALID_PIXEL_FORMAT */ + s_ErrorMessage.Add(2001, "Bad driver"); /* ERROR_BAD_DRIVER */ + s_ErrorMessage.Add(2002, "Invalid window style"); /* ERROR_INVALID_WINDOW_STYLE */ + s_ErrorMessage.Add(2003, "Metafile not supported"); /* ERROR_METAFILE_NOT_SUPPORTED */ + s_ErrorMessage.Add(2004, "Transform not supported"); /* ERROR_TRANSFORM_NOT_SUPPORTED */ + s_ErrorMessage.Add(2005, "Clipping not supported"); /* ERROR_CLIPPING_NOT_SUPPORTED */ + s_ErrorMessage.Add(2010, "Invalid CMM"); /* ERROR_INVALID_CMM */ + s_ErrorMessage.Add(2011, "Invalid profile"); /* ERROR_INVALID_PROFILE */ + s_ErrorMessage.Add(2012, "Tag not found"); /* ERROR_TAG_NOT_FOUND */ + s_ErrorMessage.Add(2013, "Tag not present"); /* ERROR_TAG_NOT_PRESENT */ + s_ErrorMessage.Add(2014, "Duplicate tag"); /* ERROR_DUPLICATE_TAG */ + s_ErrorMessage.Add(2015, "Profile not associated with device"); /* ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE */ + s_ErrorMessage.Add(2016, "Profile not found"); /* ERROR_PROFILE_NOT_FOUND */ + s_ErrorMessage.Add(2017, "Invalid colorspace"); /* ERROR_INVALID_COLORSPACE */ + s_ErrorMessage.Add(2018, "ICM not enabled"); /* ERROR_ICM_NOT_ENABLED */ + s_ErrorMessage.Add(2019, "Deleting ICM xform"); /* ERROR_DELETING_ICM_XFORM */ + s_ErrorMessage.Add(2020, "Invalid transform"); /* ERROR_INVALID_TRANSFORM */ + s_ErrorMessage.Add(2021, "Colorspace mismatch"); /* ERROR_COLORSPACE_MISMATCH */ + s_ErrorMessage.Add(2022, "Invalid colorindex"); /* ERROR_INVALID_COLORINDEX */ + s_ErrorMessage.Add(2108, "Connected other password"); /* ERROR_CONNECTED_OTHER_PASSWORD */ + s_ErrorMessage.Add(2109, "Connected other password default"); /* ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT */ + s_ErrorMessage.Add(2202, "Bad username"); /* ERROR_BAD_USERNAME */ + s_ErrorMessage.Add(2250, "Not connected"); /* ERROR_NOT_CONNECTED */ + s_ErrorMessage.Add(2401, "Open files"); /* ERROR_OPEN_FILES */ + s_ErrorMessage.Add(2402, "Active connections"); /* ERROR_ACTIVE_CONNECTIONS */ + s_ErrorMessage.Add(2404, "Device in use"); /* ERROR_DEVICE_IN_USE */ + s_ErrorMessage.Add(3000, "Unknown print monitor"); /* ERROR_UNKNOWN_PRINT_MONITOR */ + s_ErrorMessage.Add(3001, "Printer driver in use"); /* ERROR_PRINTER_DRIVER_IN_USE */ + s_ErrorMessage.Add(3002, "Spool file not found"); /* ERROR_SPOOL_FILE_NOT_FOUND */ + s_ErrorMessage.Add(3003, "SPL no startdoc"); /* ERROR_SPL_NO_STARTDOC */ + s_ErrorMessage.Add(3004, "SPL no addjob"); /* ERROR_SPL_NO_ADDJOB */ + s_ErrorMessage.Add(3005, "Print processor already installed"); /* ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED */ + s_ErrorMessage.Add(3006, "Print monitor already installed"); /* ERROR_PRINT_MONITOR_ALREADY_INSTALLED */ + s_ErrorMessage.Add(3007, "Invalid print monitor"); /* ERROR_INVALID_PRINT_MONITOR */ + s_ErrorMessage.Add(3008, "Print monitor in use"); /* ERROR_PRINT_MONITOR_IN_USE */ + s_ErrorMessage.Add(3009, "Printer has jobs queued"); /* ERROR_PRINTER_HAS_JOBS_QUEUED */ + s_ErrorMessage.Add(3010, "Success reboot required"); /* ERROR_SUCCESS_REBOOT_REQUIRED */ + s_ErrorMessage.Add(3011, "Success restart required"); /* ERROR_SUCCESS_RESTART_REQUIRED */ + s_ErrorMessage.Add(3012, "Printer not found"); /* ERROR_PRINTER_NOT_FOUND */ + s_ErrorMessage.Add(3013, "Printer driver warned"); /* ERROR_PRINTER_DRIVER_WARNED */ + s_ErrorMessage.Add(3014, "Printer driver blocked"); /* ERROR_PRINTER_DRIVER_BLOCKED */ + s_ErrorMessage.Add(4000, "Wins internal"); /* ERROR_WINS_INTERNAL */ + s_ErrorMessage.Add(4001, "Can not del local wins"); /* ERROR_CAN_NOT_DEL_LOCAL_WINS */ + s_ErrorMessage.Add(4002, "Static init"); /* ERROR_STATIC_INIT */ + s_ErrorMessage.Add(4003, "Inc backup"); /* ERROR_INC_BACKUP */ + s_ErrorMessage.Add(4004, "Full backup"); /* ERROR_FULL_BACKUP */ + s_ErrorMessage.Add(4005, "Rec not existent"); /* ERROR_REC_NON_EXISTENT */ + s_ErrorMessage.Add(4006, "RPL not allowed"); /* ERROR_RPL_NOT_ALLOWED */ + s_ErrorMessage.Add(4100, "DHCP address conflict"); /* ERROR_DHCP_ADDRESS_CONFLICT */ + s_ErrorMessage.Add(4200, "WMU GUID not found"); /* ERROR_WMI_GUID_NOT_FOUND */ + s_ErrorMessage.Add(4201, "WMI instance not found"); /* ERROR_WMI_INSTANCE_NOT_FOUND */ + s_ErrorMessage.Add(4202, "WMI ItemID not found"); /* ERROR_WMI_ITEMID_NOT_FOUND */ + s_ErrorMessage.Add(4203, "WMI try again"); /* ERROR_WMI_TRY_AGAIN */ + s_ErrorMessage.Add(4204, "WMI DP not found"); /* ERROR_WMI_DP_NOT_FOUND */ + s_ErrorMessage.Add(4205, "WMI unresolved instance ref"); /* ERROR_WMI_UNRESOLVED_INSTANCE_REF */ + s_ErrorMessage.Add(4206, "WMU already enabled"); /* ERROR_WMI_ALREADY_ENABLED */ + s_ErrorMessage.Add(4207, "WMU GUID disconnected"); /* ERROR_WMI_GUID_DISCONNECTED */ + s_ErrorMessage.Add(4208, "WMI server unavailable"); /* ERROR_WMI_SERVER_UNAVAILABLE */ + s_ErrorMessage.Add(4209, "WMI DP failed"); /* ERROR_WMI_DP_FAILED */ + s_ErrorMessage.Add(4210, "WMI invalid MOF"); /* ERROR_WMI_INVALID_MOF */ + s_ErrorMessage.Add(4211, "WMI invalid reginfo"); /* ERROR_WMI_INVALID_REGINFO */ + s_ErrorMessage.Add(4212, "WMI already disabled"); /* ERROR_WMI_ALREADY_DISABLED */ + s_ErrorMessage.Add(4213, "WMI read only"); /* ERROR_WMI_READ_ONLY */ + s_ErrorMessage.Add(4214, "WMI set failure"); /* ERROR_WMI_SET_FAILURE */ + s_ErrorMessage.Add(4300, "Invalid media"); /* ERROR_INVALID_MEDIA */ + s_ErrorMessage.Add(4301, "Invalid library"); /* ERROR_INVALID_LIBRARY */ + s_ErrorMessage.Add(4302, "Invalid media pool"); /* ERROR_INVALID_MEDIA_POOL */ + s_ErrorMessage.Add(4303, "Drive media mismatch"); /* ERROR_DRIVE_MEDIA_MISMATCH */ + s_ErrorMessage.Add(4304, "Media offline"); /* ERROR_MEDIA_OFFLINE */ + s_ErrorMessage.Add(4305, "Library offline"); /* ERROR_LIBRARY_OFFLINE */ + s_ErrorMessage.Add(4306, "Empty"); /* ERROR_EMPTY */ + s_ErrorMessage.Add(4307, "Not empty"); /* ERROR_NOT_EMPTY */ + s_ErrorMessage.Add(4308, "Media unavailable"); /* ERROR_MEDIA_UNAVAILABLE */ + s_ErrorMessage.Add(4309, "Resource disabled"); /* ERROR_RESOURCE_DISABLED */ + s_ErrorMessage.Add(4310, "Invalid cleaner"); /* ERROR_INVALID_CLEANER */ + s_ErrorMessage.Add(4311, "Unable to clean"); /* ERROR_UNABLE_TO_CLEAN */ + s_ErrorMessage.Add(4312, "Object not found"); /* ERROR_OBJECT_NOT_FOUND */ + s_ErrorMessage.Add(4313, "Database failure"); /* ERROR_DATABASE_FAILURE */ + s_ErrorMessage.Add(4314, "Database full"); /* ERROR_DATABASE_FULL */ + s_ErrorMessage.Add(4315, "Media incompatible"); /* ERROR_MEDIA_INCOMPATIBLE */ + s_ErrorMessage.Add(4316, "Resource not present"); /* ERROR_RESOURCE_NOT_PRESENT */ + s_ErrorMessage.Add(4317, "Invalid operation"); /* ERROR_INVALID_OPERATION */ + s_ErrorMessage.Add(4318, "Media not available"); /* ERROR_MEDIA_NOT_AVAILABLE */ + s_ErrorMessage.Add(4319, "Device not available"); /* ERROR_DEVICE_NOT_AVAILABLE */ + s_ErrorMessage.Add(4320, "Request refused"); /* ERROR_REQUEST_REFUSED */ + s_ErrorMessage.Add(4321, "Invalid drive object"); /* ERROR_INVALID_DRIVE_OBJECT */ + s_ErrorMessage.Add(4322, "Library full"); /* ERROR_LIBRARY_FULL */ + s_ErrorMessage.Add(4323, "Medium not accessible"); /* ERROR_MEDIUM_NOT_ACCESSIBLE */ + s_ErrorMessage.Add(4324, "Unable to load medium"); /* ERROR_UNABLE_TO_LOAD_MEDIUM */ + s_ErrorMessage.Add(4325, "Unable to inventory drive"); /* ERROR_UNABLE_TO_INVENTORY_DRIVE */ + s_ErrorMessage.Add(4326, "Unable to inventory slot"); /* ERROR_UNABLE_TO_INVENTORY_SLOT */ + s_ErrorMessage.Add(4327, "Unable to inventory transport"); /* ERROR_UNABLE_TO_INVENTORY_TRANSPORT */ + s_ErrorMessage.Add(4328, "Transport full"); /* ERROR_TRANSPORT_FULL */ + s_ErrorMessage.Add(4329, "Controlling ieport"); /* ERROR_CONTROLLING_IEPORT */ + s_ErrorMessage.Add(4330, "Unable to eject mounted media"); /* ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA */ + s_ErrorMessage.Add(4331, "Cleaner slot set"); /* ERROR_CLEANER_SLOT_SET */ + s_ErrorMessage.Add(4332, "Cleaner slot not set"); /* ERROR_CLEANER_SLOT_NOT_SET */ + s_ErrorMessage.Add(4333, "Cleaner cartridge spent"); /* ERROR_CLEANER_CARTRIDGE_SPENT */ + s_ErrorMessage.Add(4334, "Unexpected omid"); /* ERROR_UNEXPECTED_OMID */ + s_ErrorMessage.Add(4335, "Can't delete last item"); /* ERROR_CANT_DELETE_LAST_ITEM */ + s_ErrorMessage.Add(4336, "Message exceeds max size"); /* ERROR_MESSAGE_EXCEEDS_MAX_SIZE */ + s_ErrorMessage.Add(4337, "Volume contains sys files"); /* ERROR_VOLUME_CONTAINS_SYS_FILES */ + s_ErrorMessage.Add(4338, "Indigenous type"); /* ERROR_INDIGENOUS_TYPE */ + s_ErrorMessage.Add(4339, "No supporting drives"); /* ERROR_NO_SUPPORTING_DRIVES */ + s_ErrorMessage.Add(4340, "Cleaner cartridge installed"); /* ERROR_CLEANER_CARTRIDGE_INSTALLED */ + s_ErrorMessage.Add(4350, "Fill offline"); /* ERROR_FILE_OFFLINE */ + s_ErrorMessage.Add(4351, "Remote storage not active"); /* ERROR_REMOTE_STORAGE_NOT_ACTIVE */ + s_ErrorMessage.Add(4352, "Remote storage media error"); /* ERROR_REMOTE_STORAGE_MEDIA_ERROR */ + s_ErrorMessage.Add(4390, "Not a reparse point"); /* ERROR_NOT_A_REPARSE_POINT */ + s_ErrorMessage.Add(4391, "Reparse attribute conflict"); /* ERROR_REPARSE_ATTRIBUTE_CONFLICT */ + s_ErrorMessage.Add(4392, "Invalid reparse data"); /* ERROR_INVALID_REPARSE_DATA */ + s_ErrorMessage.Add(4393, "Reparse tag invalid"); /* ERROR_REPARSE_TAG_INVALID */ + s_ErrorMessage.Add(4394, "Reparse tag mismatch"); /* ERROR_REPARSE_TAG_MISMATCH */ + s_ErrorMessage.Add(4500, "Volume not sis enabled"); /* ERROR_VOLUME_NOT_SIS_ENABLED */ + s_ErrorMessage.Add(5001, "Dependent resource exists"); /* ERROR_DEPENDENT_RESOURCE_EXISTS */ + s_ErrorMessage.Add(5002, "Dependency not found"); /* ERROR_DEPENDENCY_NOT_FOUND */ + s_ErrorMessage.Add(5003, "Dependency already exists"); /* ERROR_DEPENDENCY_ALREADY_EXISTS */ + s_ErrorMessage.Add(5004, "Resource not online"); /* ERROR_RESOURCE_NOT_ONLINE */ + s_ErrorMessage.Add(5005, "Host node not available"); /* ERROR_HOST_NODE_NOT_AVAILABLE */ + s_ErrorMessage.Add(5006, "Resource not available"); /* ERROR_RESOURCE_NOT_AVAILABLE */ + s_ErrorMessage.Add(5007, "Resource not found"); /* ERROR_RESOURCE_NOT_FOUND */ + s_ErrorMessage.Add(5008, "Shutdown cluster"); /* ERROR_SHUTDOWN_CLUSTER */ + s_ErrorMessage.Add(5009, "Can't evict active node"); /* ERROR_CANT_EVICT_ACTIVE_NODE */ + s_ErrorMessage.Add(5010, "Object already exists"); /* ERROR_OBJECT_ALREADY_EXISTS */ + s_ErrorMessage.Add(5011, "Object in list"); /* ERROR_OBJECT_IN_LIST */ + s_ErrorMessage.Add(5012, "Group not available"); /* ERROR_GROUP_NOT_AVAILABLE */ + s_ErrorMessage.Add(5013, "Group not found"); /* ERROR_GROUP_NOT_FOUND */ + s_ErrorMessage.Add(5014, "Group not online"); /* ERROR_GROUP_NOT_ONLINE */ + s_ErrorMessage.Add(5015, "Host node not resource owner"); /* ERROR_HOST_NODE_NOT_RESOURCE_OWNER */ + s_ErrorMessage.Add(5016, "Host node not group owner"); /* ERROR_HOST_NODE_NOT_GROUP_OWNER */ + s_ErrorMessage.Add(5017, "Resmon create failed"); /* ERROR_RESMON_CREATE_FAILED */ + s_ErrorMessage.Add(5018, "Resmon online failed"); /* ERROR_RESMON_ONLINE_FAILED */ + s_ErrorMessage.Add(5019, "Resource online"); /* ERROR_RESOURCE_ONLINE */ + s_ErrorMessage.Add(5020, "Quorum resource"); /* ERROR_QUORUM_RESOURCE */ + s_ErrorMessage.Add(5021, "Not quorum capable"); /* ERROR_NOT_QUORUM_CAPABLE */ + s_ErrorMessage.Add(5022, "Cluster shutting down"); /* ERROR_CLUSTER_SHUTTING_DOWN */ + s_ErrorMessage.Add(5023, "Invalid state"); /* ERROR_INVALID_STATE */ + s_ErrorMessage.Add(5024, "Resource properties stored"); /* ERROR_RESOURCE_PROPERTIES_STORED */ + s_ErrorMessage.Add(5025, "Not quorum class"); /* ERROR_NOT_QUORUM_CLASS */ + s_ErrorMessage.Add(5026, "Core resource"); /* ERROR_CORE_RESOURCE */ + s_ErrorMessage.Add(5027, "Quorum resource online failed"); /* ERROR_QUORUM_RESOURCE_ONLINE_FAILED */ + s_ErrorMessage.Add(5028, "Quorumlog open failed"); /* ERROR_QUORUMLOG_OPEN_FAILED */ + s_ErrorMessage.Add(5029, "Clusterlog corrupt"); /* ERROR_CLUSTERLOG_CORRUPT */ + s_ErrorMessage.Add(5030, "Clusterlog record exceeds maxsize"); /* ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE */ + s_ErrorMessage.Add(5031, "Clusterlog exceeds maxsize"); /* ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE */ + s_ErrorMessage.Add(5032, "Clusterlog chkpoint not found"); /* ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND */ + s_ErrorMessage.Add(5033, "Clusterlog not enough space"); /* ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE */ + s_ErrorMessage.Add(5034, "Quorum owner alive"); /* ERROR_QUORUM_OWNER_ALIVE */ + s_ErrorMessage.Add(5035, "Network not available"); /* ERROR_NETWORK_NOT_AVAILABLE */ + s_ErrorMessage.Add(5036, "Node not available"); /* ERROR_NODE_NOT_AVAILABLE */ + s_ErrorMessage.Add(5037, "All nodes not available"); /* ERROR_ALL_NODES_NOT_AVAILABLE */ + s_ErrorMessage.Add(5038, "Resource failed"); /* ERROR_RESOURCE_FAILED */ + s_ErrorMessage.Add(5039, "Cluster invalid node"); /* ERROR_CLUSTER_INVALID_NODE */ + s_ErrorMessage.Add(5040, "Cluster node exists"); /* ERROR_CLUSTER_NODE_EXISTS */ + s_ErrorMessage.Add(5041, "Cluster join in progress"); /* ERROR_CLUSTER_JOIN_IN_PROGRESS */ + s_ErrorMessage.Add(5042, "Cluster node not found"); /* ERROR_CLUSTER_NODE_NOT_FOUND */ + s_ErrorMessage.Add(5043, "Cluster local node not found"); /* ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND */ + s_ErrorMessage.Add(5044, "Cluster network exists"); /* ERROR_CLUSTER_NETWORK_EXISTS */ + s_ErrorMessage.Add(5045, "Cluster network not found"); /* ERROR_CLUSTER_NETWORK_NOT_FOUND */ + s_ErrorMessage.Add(5046, "Cluster netinterface exists"); /* ERROR_CLUSTER_NETINTERFACE_EXISTS */ + s_ErrorMessage.Add(5047, "Cluster netinterface not found"); /* ERROR_CLUSTER_NETINTERFACE_NOT_FOUND */ + s_ErrorMessage.Add(5048, "Cluster invalid request"); /* ERROR_CLUSTER_INVALID_REQUEST */ + s_ErrorMessage.Add(5049, "Cluster invalid network provider"); /* ERROR_CLUSTER_INVALID_NETWORK_PROVIDER */ + s_ErrorMessage.Add(5050, "Cluster node down"); /* ERROR_CLUSTER_NODE_DOWN */ + s_ErrorMessage.Add(5051, "Cluster node unreachable"); /* ERROR_CLUSTER_NODE_UNREACHABLE */ + s_ErrorMessage.Add(5052, "Cluster node not member"); /* ERROR_CLUSTER_NODE_NOT_MEMBER */ + s_ErrorMessage.Add(5053, "Cluster join not in progress"); /* ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS */ + s_ErrorMessage.Add(5054, "Cluster invalid network"); /* ERROR_CLUSTER_INVALID_NETWORK */ + s_ErrorMessage.Add(5056, "Cluster node up"); /* ERROR_CLUSTER_NODE_UP */ + s_ErrorMessage.Add(5057, "Cluster ipaddr in use"); /* ERROR_CLUSTER_IPADDR_IN_USE */ + s_ErrorMessage.Add(5058, "Cluster node not paused"); /* ERROR_CLUSTER_NODE_NOT_PAUSED */ + s_ErrorMessage.Add(5059, "Cluster no security context"); /* ERROR_CLUSTER_NO_SECURITY_CONTEXT */ + s_ErrorMessage.Add(5060, "Cluster network not internal"); /* ERROR_CLUSTER_NETWORK_NOT_INTERNAL */ + s_ErrorMessage.Add(5061, "Cluster node already up"); /* ERROR_CLUSTER_NODE_ALREADY_UP */ + s_ErrorMessage.Add(5062, "Cluster node already down"); /* ERROR_CLUSTER_NODE_ALREADY_DOWN */ + s_ErrorMessage.Add(5063, "Cluster network already online"); /* ERROR_CLUSTER_NETWORK_ALREADY_ONLINE */ + s_ErrorMessage.Add(5064, "Cluster network already offline"); /* ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE */ + s_ErrorMessage.Add(5065, "Cluster node already member"); /* ERROR_CLUSTER_NODE_ALREADY_MEMBER */ + s_ErrorMessage.Add(5066, "Cluster last internal network"); /* ERROR_CLUSTER_LAST_INTERNAL_NETWORK */ + s_ErrorMessage.Add(5067, "Cluster network has dependents"); /* ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS */ + s_ErrorMessage.Add(5068, "Invalid operation on quorum"); /* ERROR_INVALID_OPERATION_ON_QUORUM */ + s_ErrorMessage.Add(5069, "Dependency not allowed"); /* ERROR_DEPENDENCY_NOT_ALLOWED */ + s_ErrorMessage.Add(5070, "Cluster node paused"); /* ERROR_CLUSTER_NODE_PAUSED */ + s_ErrorMessage.Add(5071, "Node can't host resource"); /* ERROR_NODE_CANT_HOST_RESOURCE */ + s_ErrorMessage.Add(5072, "Cluster node not ready"); /* ERROR_CLUSTER_NODE_NOT_READY */ + s_ErrorMessage.Add(5073, "Cluster node shutting down"); /* ERROR_CLUSTER_NODE_SHUTTING_DOWN */ + s_ErrorMessage.Add(5074, "Cluster join aborted"); /* ERROR_CLUSTER_JOIN_ABORTED */ + s_ErrorMessage.Add(5075, "Cluster incompatible versions"); /* ERROR_CLUSTER_INCOMPATIBLE_VERSIONS */ + s_ErrorMessage.Add(5076, "Cluster maxnum of resources exceeded"); /* ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED */ + s_ErrorMessage.Add(5077, "Cluster system config changed"); /* ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED */ + s_ErrorMessage.Add(5078, "Cluster resource type not found"); /* ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND */ + s_ErrorMessage.Add(5079, "Cluster restype not supported"); /* ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED */ + s_ErrorMessage.Add(5080, "Cluster resname not found"); /* ERROR_CLUSTER_RESNAME_NOT_FOUND */ + s_ErrorMessage.Add(5081, "Cluster no RPC packages registered"); /* ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED */ + s_ErrorMessage.Add(5082, "Cluster owner not in preflist"); /* ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST */ + s_ErrorMessage.Add(5083, "Cluster database seqmismatch"); /* ERROR_CLUSTER_DATABASE_SEQMISMATCH */ + s_ErrorMessage.Add(5084, "Resmon invalid state"); /* ERROR_RESMON_INVALID_STATE */ + s_ErrorMessage.Add(5085, "Cluster gum not locker"); /* ERROR_CLUSTER_GUM_NOT_LOCKER */ + s_ErrorMessage.Add(5086, "Quorum disk not found"); /* ERROR_QUORUM_DISK_NOT_FOUND */ + s_ErrorMessage.Add(5087, "Database backup corrupt"); /* ERROR_DATABASE_BACKUP_CORRUPT */ + s_ErrorMessage.Add(5088, "Cluster node already has DFS root"); /* ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT */ + s_ErrorMessage.Add(5089, "Resource property unchangeable"); /* ERROR_RESOURCE_PROPERTY_UNCHANGEABLE */ + s_ErrorMessage.Add(5890, "Cluster membership invalid state"); /* ERROR_CLUSTER_MEMBERSHIP_INVALID_STATE */ + s_ErrorMessage.Add(5891, "Cluster quorumlog not found"); /* ERROR_CLUSTER_QUORUMLOG_NOT_FOUND */ + s_ErrorMessage.Add(5892, "Cluster membership halt"); /* ERROR_CLUSTER_MEMBERSHIP_HALT */ + s_ErrorMessage.Add(5893, "Cluster instance ID mismatch"); /* ERROR_CLUSTER_INSTANCE_ID_MISMATCH */ + s_ErrorMessage.Add(5894, "Cluster network not found for IP"); /* ERROR_CLUSTER_NETWORK_NOT_FOUND_FOR_IP */ + s_ErrorMessage.Add(5895, "Cluster property data type mismatch"); /* ERROR_CLUSTER_PROPERTY_DATA_TYPE_MISMATCH */ + s_ErrorMessage.Add(5896, "Cluster evict without cleanup"); /* ERROR_CLUSTER_EVICT_WITHOUT_CLEANUP */ + s_ErrorMessage.Add(5897, "Cluster parameter mismatch"); /* ERROR_CLUSTER_PARAMETER_MISMATCH */ + s_ErrorMessage.Add(5898, "Node cannot be clustered"); /* ERROR_NODE_CANNOT_BE_CLUSTERED */ + s_ErrorMessage.Add(5899, "Cluster wrong OS version"); /* ERROR_CLUSTER_WRONG_OS_VERSION */ + s_ErrorMessage.Add(5900, "Cluster can't create dup cluster name"); /* ERROR_CLUSTER_CANT_CREATE_DUP_CLUSTER_NAME */ + s_ErrorMessage.Add(6001, "Decryption failed"); /* ERROR_DECRYPTION_FAILED */ + s_ErrorMessage.Add(6002, "File encrypted"); /* ERROR_FILE_ENCRYPTED */ + s_ErrorMessage.Add(6003, "No recovery policy"); /* ERROR_NO_RECOVERY_POLICY */ + s_ErrorMessage.Add(6004, "No EFS"); /* ERROR_NO_EFS */ + s_ErrorMessage.Add(6005, "Wrong EFS"); /* ERROR_WRONG_EFS */ + s_ErrorMessage.Add(6006, "No user keys"); /* ERROR_NO_USER_KEYS */ + s_ErrorMessage.Add(6007, "File not encryped"); /* ERROR_FILE_NOT_ENCRYPTED */ + s_ErrorMessage.Add(6008, "Not export format"); /* ERROR_NOT_EXPORT_FORMAT */ + s_ErrorMessage.Add(6009, "File read only"); /* ERROR_FILE_READ_ONLY */ + s_ErrorMessage.Add(6010, "Dir EFS disallowed"); /* ERROR_DIR_EFS_DISALLOWED */ + s_ErrorMessage.Add(6011, "EFS server not trusted"); /* ERROR_EFS_SERVER_NOT_TRUSTED */ + s_ErrorMessage.Add(6012, "Bad recovery policy"); /* ERROR_BAD_RECOVERY_POLICY */ + s_ErrorMessage.Add(6013, "ETS alg blob too big"); /* ERROR_EFS_ALG_BLOB_TOO_BIG */ + s_ErrorMessage.Add(6014, "Volume not support EFS"); /* ERROR_VOLUME_NOT_SUPPORT_EFS */ + s_ErrorMessage.Add(6015, "EFS disabled"); /* ERROR_EFS_DISABLED */ + s_ErrorMessage.Add(6016, "EFS version not support"); /* ERROR_EFS_VERSION_NOT_SUPPORT */ + s_ErrorMessage.Add(6118, "No browser servers found"); /* ERROR_NO_BROWSER_SERVERS_FOUND */ + s_ErrorMessage.Add(6200, "Sched E service not localsystem"); /* SCHED_E_SERVICE_NOT_LOCALSYSTEM */ + s_ErrorMessage.Add(7001, "Ctx winstation name invalid"); /* ERROR_CTX_WINSTATION_NAME_INVALID */ + s_ErrorMessage.Add(7002, "Ctx invalid PD"); /* ERROR_CTX_INVALID_PD */ + s_ErrorMessage.Add(7003, "Ctx PD not found"); /* ERROR_CTX_PD_NOT_FOUND */ + s_ErrorMessage.Add(7004, "Ctx WD not found"); /* ERROR_CTX_WD_NOT_FOUND */ + s_ErrorMessage.Add(7005, "Ctx cannot make eventlog entry"); /* ERROR_CTX_CANNOT_MAKE_EVENTLOG_ENTRY */ + s_ErrorMessage.Add(7006, "Ctx service name collision"); /* ERROR_CTX_SERVICE_NAME_COLLISION */ + s_ErrorMessage.Add(7007, "Ctx close pending"); /* ERROR_CTX_CLOSE_PENDING */ + s_ErrorMessage.Add(7008, "Ctx no outbuf"); /* ERROR_CTX_NO_OUTBUF */ + s_ErrorMessage.Add(7009, "Ctx modem inf not found"); /* ERROR_CTX_MODEM_INF_NOT_FOUND */ + s_ErrorMessage.Add(7010, "Ctx invalid modemname"); /* ERROR_CTX_INVALID_MODEMNAME */ + s_ErrorMessage.Add(7011, "Ctx modem response error"); /* ERROR_CTX_MODEM_RESPONSE_ERROR */ + s_ErrorMessage.Add(7012, "Ctx modem response timeout"); /* ERROR_CTX_MODEM_RESPONSE_TIMEOUT */ + s_ErrorMessage.Add(7013, "Ctx modem response no carrier"); /* ERROR_CTX_MODEM_RESPONSE_NO_CARRIER */ + s_ErrorMessage.Add(7014, "Ctx modem response no dial tone"); /* ERROR_CTX_MODEM_RESPONSE_NO_DIALTONE */ + s_ErrorMessage.Add(7015, "Ctx modem response busy"); /* ERROR_CTX_MODEM_RESPONSE_BUSY */ + s_ErrorMessage.Add(7016, "Ctx modem response voice"); /* ERROR_CTX_MODEM_RESPONSE_VOICE */ + s_ErrorMessage.Add(7017, "Ctx TD error"); /* ERROR_CTX_TD_ERROR */ + s_ErrorMessage.Add(7022, "Ctx winstation not found"); /* ERROR_CTX_WINSTATION_NOT_FOUND */ + s_ErrorMessage.Add(7023, "Ctx winstation already exists"); /* ERROR_CTX_WINSTATION_ALREADY_EXISTS */ + s_ErrorMessage.Add(7024, "Ctx winstation busy"); /* ERROR_CTX_WINSTATION_BUSY */ + s_ErrorMessage.Add(7025, "Ctx bad video mode"); /* ERROR_CTX_BAD_VIDEO_MODE */ + s_ErrorMessage.Add(7035, "Ctx graphics invalid"); /* ERROR_CTX_GRAPHICS_INVALID */ + s_ErrorMessage.Add(7037, "Ctx logon disabled"); /* ERROR_CTX_LOGON_DISABLED */ + s_ErrorMessage.Add(7038, "Ctx not console"); /* ERROR_CTX_NOT_CONSOLE */ + s_ErrorMessage.Add(7040, "Ctx client query timeout"); /* ERROR_CTX_CLIENT_QUERY_TIMEOUT */ + s_ErrorMessage.Add(7041, "Ctx console disconnect"); /* ERROR_CTX_CONSOLE_DISCONNECT */ + s_ErrorMessage.Add(7042, "Ctx console connect"); /* ERROR_CTX_CONSOLE_CONNECT */ + s_ErrorMessage.Add(7044, "Ctx shadow denied"); /* ERROR_CTX_SHADOW_DENIED */ + s_ErrorMessage.Add(7045, "Ctx winstation access denied"); /* ERROR_CTX_WINSTATION_ACCESS_DENIED */ + s_ErrorMessage.Add(7049, "Ctx invalid WD"); /* ERROR_CTX_INVALID_WD */ + s_ErrorMessage.Add(7050, "Ctx shadow invalid"); /* ERROR_CTX_SHADOW_INVALID */ + s_ErrorMessage.Add(7051, "Ctx shadow disabled"); /* ERROR_CTX_SHADOW_DISABLED */ + s_ErrorMessage.Add(7052, "Ctx client licence in use"); /* ERROR_CTX_CLIENT_LICENSE_IN_USE */ + s_ErrorMessage.Add(7053, "Ctx client licence not set"); /* ERROR_CTX_CLIENT_LICENSE_NOT_SET */ + s_ErrorMessage.Add(7054, "Ctx licence not available"); /* ERROR_CTX_LICENSE_NOT_AVAILABLE */ + s_ErrorMessage.Add(7055, "Ctx licence client invalid"); /* ERROR_CTX_LICENSE_CLIENT_INVALID */ + s_ErrorMessage.Add(7056, "Ctx licence expired"); /* ERROR_CTX_LICENSE_EXPIRED */ + s_ErrorMessage.Add(7057, "Ctx shadow not running"); /* ERROR_CTX_SHADOW_NOT_RUNNING */ + s_ErrorMessage.Add(7058, "Ctx shadow ended by mode change"); /* ERROR_CTX_SHADOW_ENDED_BY_MODE_CHANGE */ + s_ErrorMessage.Add(8001, "FRS err invalid API sequence"); /* FRS_ERR_INVALID_API_SEQUENCE */ + s_ErrorMessage.Add(8002, "FRS err starting service"); /* FRS_ERR_STARTING_SERVICE */ + s_ErrorMessage.Add(8003, "FRS err stopping service"); /* FRS_ERR_STOPPING_SERVICE */ + s_ErrorMessage.Add(8004, "FRS err internal API"); /* FRS_ERR_INTERNAL_API */ + s_ErrorMessage.Add(8005, "FRS err internal"); /* FRS_ERR_INTERNAL */ + s_ErrorMessage.Add(8006, "FRS err service comm"); /* FRS_ERR_SERVICE_COMM */ + s_ErrorMessage.Add(8007, "FRS err insufficient priv"); /* FRS_ERR_INSUFFICIENT_PRIV */ + s_ErrorMessage.Add(8008, "FRS err authentication"); /* FRS_ERR_AUTHENTICATION */ + s_ErrorMessage.Add(8009, "FRS err parent insufficient priv"); /* FRS_ERR_PARENT_INSUFFICIENT_PRIV */ + s_ErrorMessage.Add(8010, "FRS err parent authentication"); /* FRS_ERR_PARENT_AUTHENTICATION */ + s_ErrorMessage.Add(8011, "FRS err child to parent comm"); /* FRS_ERR_CHILD_TO_PARENT_COMM */ + s_ErrorMessage.Add(8012, "FRS err parent to child comm"); /* FRS_ERR_PARENT_TO_CHILD_COMM */ + s_ErrorMessage.Add(8013, "FRS err sysvol populate"); /* FRS_ERR_SYSVOL_POPULATE */ + s_ErrorMessage.Add(8014, "FRS err sysvol populate timeout"); /* FRS_ERR_SYSVOL_POPULATE_TIMEOUT */ + s_ErrorMessage.Add(8015, "FRS err sysvol is busy"); /* FRS_ERR_SYSVOL_IS_BUSY */ + s_ErrorMessage.Add(8016, "FRS err sysvol demote"); /* FRS_ERR_SYSVOL_DEMOTE */ + s_ErrorMessage.Add(8017, "FRS err invalid service parameter"); /* FRS_ERR_INVALID_SERVICE_PARAMETER */ + s_ErrorMessage.Add(8200, "DS not installed"); /* ERROR_DS_NOT_INSTALLED */ + s_ErrorMessage.Add(8201, "DS membership evaluated locally"); /* ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY */ + s_ErrorMessage.Add(8202, "DS no attribute or value"); /* ERROR_DS_NO_ATTRIBUTE_OR_VALUE */ + s_ErrorMessage.Add(8203, "DS invalid attribute syntax"); /* ERROR_DS_INVALID_ATTRIBUTE_SYNTAX */ + s_ErrorMessage.Add(8204, "DS attribute type undefined"); /* ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED */ + s_ErrorMessage.Add(8205, "DS attribute or value exists"); /* ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS */ + s_ErrorMessage.Add(8206, "DS busy"); /* ERROR_DS_BUSY */ + s_ErrorMessage.Add(8207, "DS unavailable"); /* ERROR_DS_UNAVAILABLE */ + s_ErrorMessage.Add(8208, "DS no rids allocated"); /* ERROR_DS_NO_RIDS_ALLOCATED */ + s_ErrorMessage.Add(8209, "DS no more rids"); /* ERROR_DS_NO_MORE_RIDS */ + s_ErrorMessage.Add(8210, "DS incorrect role owner"); /* ERROR_DS_INCORRECT_ROLE_OWNER */ + s_ErrorMessage.Add(8211, "DS ridmgr init error"); /* ERROR_DS_RIDMGR_INIT_ERROR */ + s_ErrorMessage.Add(8212, "DS obj class violation"); /* ERROR_DS_OBJ_CLASS_VIOLATION */ + s_ErrorMessage.Add(8213, "DS can't on non leaf"); /* ERROR_DS_CANT_ON_NON_LEAF */ + s_ErrorMessage.Add(8214, "DS can't on rnd"); /* ERROR_DS_CANT_ON_RDN */ + s_ErrorMessage.Add(8215, "DS can't mod obj class"); /* ERROR_DS_CANT_MOD_OBJ_CLASS */ + s_ErrorMessage.Add(8216, "DS cross dom move error"); /* ERROR_DS_CROSS_DOM_MOVE_ERROR */ + s_ErrorMessage.Add(8217, "DS GC not available"); /* ERROR_DS_GC_NOT_AVAILABLE */ + s_ErrorMessage.Add(8218, "Shared policy"); /* ERROR_SHARED_POLICY */ + s_ErrorMessage.Add(8219, "Policy object not found"); /* ERROR_POLICY_OBJECT_NOT_FOUND */ + s_ErrorMessage.Add(8220, "Policy only in DS"); /* ERROR_POLICY_ONLY_IN_DS */ + s_ErrorMessage.Add(8221, "Promotion active"); /* ERROR_PROMOTION_ACTIVE */ + s_ErrorMessage.Add(8222, "No promotion active"); /* ERROR_NO_PROMOTION_ACTIVE */ + s_ErrorMessage.Add(8224, "DS operations error"); /* ERROR_DS_OPERATIONS_ERROR */ + s_ErrorMessage.Add(8225, "DS protocol error"); /* ERROR_DS_PROTOCOL_ERROR */ + s_ErrorMessage.Add(8226, "DS timelimit exceeded"); /* ERROR_DS_TIMELIMIT_EXCEEDED */ + s_ErrorMessage.Add(8227, "DS sizelimit exceeded"); /* ERROR_DS_SIZELIMIT_EXCEEDED */ + s_ErrorMessage.Add(8228, "DS admin limit exceeded"); /* ERROR_DS_ADMIN_LIMIT_EXCEEDED */ + s_ErrorMessage.Add(8229, "DS compare false"); /* ERROR_DS_COMPARE_FALSE */ + s_ErrorMessage.Add(8230, "DS compare true"); /* ERROR_DS_COMPARE_TRUE */ + s_ErrorMessage.Add(8231, "DS auth method not supported"); /* ERROR_DS_AUTH_METHOD_NOT_SUPPORTED */ + s_ErrorMessage.Add(8232, "DS strong auth required"); /* ERROR_DS_STRONG_AUTH_REQUIRED */ + s_ErrorMessage.Add(8233, "DS inappropriate auth"); /* ERROR_DS_INAPPROPRIATE_AUTH */ + s_ErrorMessage.Add(8234, "DS auth unknown"); /* ERROR_DS_AUTH_UNKNOWN */ + s_ErrorMessage.Add(8235, "DS referral"); /* ERROR_DS_REFERRAL */ + s_ErrorMessage.Add(8236, "DS unavailable crit extension"); /* ERROR_DS_UNAVAILABLE_CRIT_EXTENSION */ + s_ErrorMessage.Add(8237, "DS confidentiality required"); /* ERROR_DS_CONFIDENTIALITY_REQUIRED */ + s_ErrorMessage.Add(8238, "DS inappropriate matching"); /* ERROR_DS_INAPPROPRIATE_MATCHING */ + s_ErrorMessage.Add(8239, "DS constraint violation"); /* ERROR_DS_CONSTRAINT_VIOLATION */ + s_ErrorMessage.Add(8240, "DS no such object"); /* ERROR_DS_NO_SUCH_OBJECT */ + s_ErrorMessage.Add(8241, "DS alias problem"); /* ERROR_DS_ALIAS_PROBLEM */ + s_ErrorMessage.Add(8242, "DS invalid dn syntax"); /* ERROR_DS_INVALID_DN_SYNTAX */ + s_ErrorMessage.Add(8243, "DS is leaf"); /* ERROR_DS_IS_LEAF */ + s_ErrorMessage.Add(8244, "DS alias deref problem"); /* ERROR_DS_ALIAS_DEREF_PROBLEM */ + s_ErrorMessage.Add(8245, "DS unwilling to perform"); /* ERROR_DS_UNWILLING_TO_PERFORM */ + s_ErrorMessage.Add(8246, "DS loop detect"); /* ERROR_DS_LOOP_DETECT */ + s_ErrorMessage.Add(8247, "DS naming violation"); /* ERROR_DS_NAMING_VIOLATION */ + s_ErrorMessage.Add(8248, "DS object results too large"); /* ERROR_DS_OBJECT_RESULTS_TOO_LARGE */ + s_ErrorMessage.Add(8249, "DS affects multiple dsas"); /* ERROR_DS_AFFECTS_MULTIPLE_DSAS */ + s_ErrorMessage.Add(8250, "DS server down"); /* ERROR_DS_SERVER_DOWN */ + s_ErrorMessage.Add(8251, "DS local error"); /* ERROR_DS_LOCAL_ERROR */ + s_ErrorMessage.Add(8252, "DS encoding error"); /* ERROR_DS_ENCODING_ERROR */ + s_ErrorMessage.Add(8253, "DS decoding error"); /* ERROR_DS_DECODING_ERROR */ + s_ErrorMessage.Add(8254, "DS filter unknown"); /* ERROR_DS_FILTER_UNKNOWN */ + s_ErrorMessage.Add(8255, "DS param error"); /* ERROR_DS_PARAM_ERROR */ + s_ErrorMessage.Add(8256, "DS not supported"); /* ERROR_DS_NOT_SUPPORTED */ + s_ErrorMessage.Add(8257, "DS no results returned"); /* ERROR_DS_NO_RESULTS_RETURNED */ + s_ErrorMessage.Add(8258, "DS control not found"); /* ERROR_DS_CONTROL_NOT_FOUND */ + s_ErrorMessage.Add(8259, "DS client loop"); /* ERROR_DS_CLIENT_LOOP */ + s_ErrorMessage.Add(8260, "DS referral limit exceeded"); /* ERROR_DS_REFERRAL_LIMIT_EXCEEDED */ + s_ErrorMessage.Add(8261, "DS sort control missing"); /* ERROR_DS_SORT_CONTROL_MISSING */ + s_ErrorMessage.Add(8262, "DS offset range error"); /* ERROR_DS_OFFSET_RANGE_ERROR */ + s_ErrorMessage.Add(8301, "DS root must be nc"); /* ERROR_DS_ROOT_MUST_BE_NC */ + s_ErrorMessage.Add(8302, "DS and replica inhibited"); /* ERROR_DS_ADD_REPLICA_INHIBITED */ + s_ErrorMessage.Add(8303, "DS att not def in schema"); /* ERROR_DS_ATT_NOT_DEF_IN_SCHEMA */ + s_ErrorMessage.Add(8304, "DS max obj size exceeded"); /* ERROR_DS_MAX_OBJ_SIZE_EXCEEDED */ + s_ErrorMessage.Add(8305, "DS obj string name exists"); /* ERROR_DS_OBJ_STRING_NAME_EXISTS */ + s_ErrorMessage.Add(8306, "DS no rdn defined in schema"); /* ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA */ + s_ErrorMessage.Add(8307, "DS rdn doesn't match schema"); /* ERROR_DS_RDN_DOESNT_MATCH_SCHEMA */ + s_ErrorMessage.Add(8308, "DS no requested atts found"); /* ERROR_DS_NO_REQUESTED_ATTS_FOUND */ + s_ErrorMessage.Add(8309, "DS user buffer too small"); /* ERROR_DS_USER_BUFFER_TO_SMALL */ + s_ErrorMessage.Add(8310, "DS att is not on obj"); /* ERROR_DS_ATT_IS_NOT_ON_OBJ */ + s_ErrorMessage.Add(8311, "DS illegal mod operation"); /* ERROR_DS_ILLEGAL_MOD_OPERATION */ + s_ErrorMessage.Add(8312, "DS obj too large"); /* ERROR_DS_OBJ_TOO_LARGE */ + s_ErrorMessage.Add(8313, "DS bad instance type"); /* ERROR_DS_BAD_INSTANCE_TYPE */ + s_ErrorMessage.Add(8314, "DS masterdsa required"); /* ERROR_DS_MASTERDSA_REQUIRED */ + s_ErrorMessage.Add(8315, "DS object class required"); /* ERROR_DS_OBJECT_CLASS_REQUIRED */ + s_ErrorMessage.Add(8316, "DS missing required att"); /* ERROR_DS_MISSING_REQUIRED_ATT */ + s_ErrorMessage.Add(8317, "DS att not def for class"); /* ERROR_DS_ATT_NOT_DEF_FOR_CLASS */ + s_ErrorMessage.Add(8318, "DS att already exists"); /* ERROR_DS_ATT_ALREADY_EXISTS */ + s_ErrorMessage.Add(8320, "DS can't add att values"); /* ERROR_DS_CANT_ADD_ATT_VALUES */ + s_ErrorMessage.Add(8321, "DS single value constraint"); /* ERROR_DS_SINGLE_VALUE_CONSTRAINT */ + s_ErrorMessage.Add(8322, "DS range constraint"); /* ERROR_DS_RANGE_CONSTRAINT */ + s_ErrorMessage.Add(8323, "DS att val already exists"); /* ERROR_DS_ATT_VAL_ALREADY_EXISTS */ + s_ErrorMessage.Add(8324, "DS can't rem missing att"); /* ERROR_DS_CANT_REM_MISSING_ATT */ + s_ErrorMessage.Add(8325, "DS can't rem missing att val"); /* ERROR_DS_CANT_REM_MISSING_ATT_VAL */ + s_ErrorMessage.Add(8326, "DS root can't be subref"); /* ERROR_DS_ROOT_CANT_BE_SUBREF */ + s_ErrorMessage.Add(8327, "DS no chaining"); /* ERROR_DS_NO_CHAINING */ + s_ErrorMessage.Add(8328, "DS no chained eval"); /* ERROR_DS_NO_CHAINED_EVAL */ + s_ErrorMessage.Add(8329, "DS no parent object"); /* ERROR_DS_NO_PARENT_OBJECT */ + s_ErrorMessage.Add(8330, "DS parent is an alias"); /* ERROR_DS_PARENT_IS_AN_ALIAS */ + s_ErrorMessage.Add(8331, "DS can't mix master and reps"); /* ERROR_DS_CANT_MIX_MASTER_AND_REPS */ + s_ErrorMessage.Add(8332, "DS children exist"); /* ERROR_DS_CHILDREN_EXIST */ + s_ErrorMessage.Add(8333, "DS obj not found"); /* ERROR_DS_OBJ_NOT_FOUND */ + s_ErrorMessage.Add(8334, "DS aliased obj missing"); /* ERROR_DS_ALIASED_OBJ_MISSING */ + s_ErrorMessage.Add(8335, "DS bad name syntax"); /* ERROR_DS_BAD_NAME_SYNTAX */ + s_ErrorMessage.Add(8336, "DS alias points to alias"); /* ERROR_DS_ALIAS_POINTS_TO_ALIAS */ + s_ErrorMessage.Add(8337, "DS can't redef alias"); /* ERROR_DS_CANT_DEREF_ALIAS */ + s_ErrorMessage.Add(8338, "DS out of scope"); /* ERROR_DS_OUT_OF_SCOPE */ + s_ErrorMessage.Add(8339, "DS object being removed"); /* ERROR_DS_OBJECT_BEING_REMOVED */ + s_ErrorMessage.Add(8340, "DS can't delete dsa obj"); /* ERROR_DS_CANT_DELETE_DSA_OBJ */ + s_ErrorMessage.Add(8341, "DS generic error"); /* ERROR_DS_GENERIC_ERROR */ + s_ErrorMessage.Add(8342, "DS dsa must be int master"); /* ERROR_DS_DSA_MUST_BE_INT_MASTER */ + s_ErrorMessage.Add(8343, "DS class not dsa"); /* ERROR_DS_CLASS_NOT_DSA */ + s_ErrorMessage.Add(8344, "DS insuff access rights"); /* ERROR_DS_INSUFF_ACCESS_RIGHTS */ + s_ErrorMessage.Add(8345, "DS illegal superior"); /* ERROR_DS_ILLEGAL_SUPERIOR */ + s_ErrorMessage.Add(8346, "DS attribute owned by sam"); /* ERROR_DS_ATTRIBUTE_OWNED_BY_SAM */ + s_ErrorMessage.Add(8347, "DS name too many parts"); /* ERROR_DS_NAME_TOO_MANY_PARTS */ + s_ErrorMessage.Add(8348, "DS name too long"); /* ERROR_DS_NAME_TOO_LONG */ + s_ErrorMessage.Add(8349, "DS name value too long"); /* ERROR_DS_NAME_VALUE_TOO_LONG */ + s_ErrorMessage.Add(8350, "DS name unparseable"); /* ERROR_DS_NAME_UNPARSEABLE */ + s_ErrorMessage.Add(8351, "DS name type unknown"); /* ERROR_DS_NAME_TYPE_UNKNOWN */ + s_ErrorMessage.Add(8352, "DS not an object"); /* ERROR_DS_NOT_AN_OBJECT */ + s_ErrorMessage.Add(8353, "DS sec desc too short"); /* ERROR_DS_SEC_DESC_TOO_SHORT */ + s_ErrorMessage.Add(8354, "DS sec desc invalid"); /* ERROR_DS_SEC_DESC_INVALID */ + s_ErrorMessage.Add(8355, "DS no deleted name"); /* ERROR_DS_NO_DELETED_NAME */ + s_ErrorMessage.Add(8356, "DS subref must have parent"); /* ERROR_DS_SUBREF_MUST_HAVE_PARENT */ + s_ErrorMessage.Add(8357, "DS ncname must be nc"); /* ERROR_DS_NCNAME_MUST_BE_NC */ + s_ErrorMessage.Add(8358, "DS can't add system only"); /* ERROR_DS_CANT_ADD_SYSTEM_ONLY */ + s_ErrorMessage.Add(8359, "DS class must be concrete"); /* ERROR_DS_CLASS_MUST_BE_CONCRETE */ + s_ErrorMessage.Add(8360, "DS invalid dmd"); /* ERROR_DS_INVALID_DMD */ + s_ErrorMessage.Add(8361, "DS obj GUID exists"); /* ERROR_DS_OBJ_GUID_EXISTS */ + s_ErrorMessage.Add(8362, "DS not on backlink"); /* ERROR_DS_NOT_ON_BACKLINK */ + s_ErrorMessage.Add(8363, "DS no crossref for nc"); /* ERROR_DS_NO_CROSSREF_FOR_NC */ + s_ErrorMessage.Add(8364, "DS shutting down"); /* ERROR_DS_SHUTTING_DOWN */ + s_ErrorMessage.Add(8365, "DS unknown operation"); /* ERROR_DS_UNKNOWN_OPERATION */ + s_ErrorMessage.Add(8366, "DS invalid role owner"); /* ERROR_DS_INVALID_ROLE_OWNER */ + s_ErrorMessage.Add(8367, "DS couldn't contact fsmo"); /* ERROR_DS_COULDNT_CONTACT_FSMO */ + s_ErrorMessage.Add(8368, "DS cross nc dn rename"); /* ERROR_DS_CROSS_NC_DN_RENAME */ + s_ErrorMessage.Add(8369, "DS can't mod system only"); /* ERROR_DS_CANT_MOD_SYSTEM_ONLY */ + s_ErrorMessage.Add(8370, "DS replicator only"); /* ERROR_DS_REPLICATOR_ONLY */ + s_ErrorMessage.Add(8371, "DS obj class not defined"); /* ERROR_DS_OBJ_CLASS_NOT_DEFINED */ + s_ErrorMessage.Add(8372, "DS obj class not subclass"); /* ERROR_DS_OBJ_CLASS_NOT_SUBCLASS */ + s_ErrorMessage.Add(8373, "DS name reference invalid"); /* ERROR_DS_NAME_REFERENCE_INVALID */ + s_ErrorMessage.Add(8374, "DS cross ref exists"); /* ERROR_DS_CROSS_REF_EXISTS */ + s_ErrorMessage.Add(8375, "DS can't del master crossref"); /* ERROR_DS_CANT_DEL_MASTER_CROSSREF */ + s_ErrorMessage.Add(8376, "DS subtree notify not nc head"); /* ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD */ + s_ErrorMessage.Add(8377, "DS notify filter too complex"); /* ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX */ + s_ErrorMessage.Add(8378, "DS dup rdn"); /* ERROR_DS_DUP_RDN */ + s_ErrorMessage.Add(8379, "DS dup oid"); /* ERROR_DS_DUP_OID */ + s_ErrorMessage.Add(8380, "DS dup mapi ID"); /* ERROR_DS_DUP_MAPI_ID */ + s_ErrorMessage.Add(8381, "DS dup schema ID GUID"); /* ERROR_DS_DUP_SCHEMA_ID_GUID */ + s_ErrorMessage.Add(8382, "DS dup LDAP display name"); /* ERROR_DS_DUP_LDAP_DISPLAY_NAME */ + s_ErrorMessage.Add(8383, "DS semantic att test"); /* ERROR_DS_SEMANTIC_ATT_TEST */ + s_ErrorMessage.Add(8384, "DS syntax mismatch"); /* ERROR_DS_SYNTAX_MISMATCH */ + s_ErrorMessage.Add(8385, "DS exists in must have"); /* ERROR_DS_EXISTS_IN_MUST_HAVE */ + s_ErrorMessage.Add(8386, "DS exists in may have"); /* ERROR_DS_EXISTS_IN_MAY_HAVE */ + s_ErrorMessage.Add(8387, "DS nonexistent may have"); /* ERROR_DS_NONEXISTENT_MAY_HAVE */ + s_ErrorMessage.Add(8388, "DS nonexistent must have"); /* ERROR_DS_NONEXISTENT_MUST_HAVE */ + s_ErrorMessage.Add(8389, "DS aux cls test fail"); /* ERROR_DS_AUX_CLS_TEST_FAIL */ + s_ErrorMessage.Add(8390, "DS nonexistent poss sup"); /* ERROR_DS_NONEXISTENT_POSS_SUP */ + s_ErrorMessage.Add(8391, "DS sub cls test fail"); /* ERROR_DS_SUB_CLS_TEST_FAIL */ + s_ErrorMessage.Add(8392, "DS bad rdn att ID syntax"); /* ERROR_DS_BAD_RDN_ATT_ID_SYNTAX */ + s_ErrorMessage.Add(8393, "DS exists in aux cls"); /* ERROR_DS_EXISTS_IN_AUX_CLS */ + s_ErrorMessage.Add(8394, "DS exists in sub cls"); /* ERROR_DS_EXISTS_IN_SUB_CLS */ + s_ErrorMessage.Add(8395, "DS exists in poss sup"); /* ERROR_DS_EXISTS_IN_POSS_SUP */ + s_ErrorMessage.Add(8396, "DS recalcschema failed"); /* ERROR_DS_RECALCSCHEMA_FAILED */ + s_ErrorMessage.Add(8397, "DS tree delete not finished"); /* ERROR_DS_TREE_DELETE_NOT_FINISHED */ + s_ErrorMessage.Add(8398, "DS can't delete"); /* ERROR_DS_CANT_DELETE */ + s_ErrorMessage.Add(8399, "DS att schema req ID"); /* ERROR_DS_ATT_SCHEMA_REQ_ID */ + s_ErrorMessage.Add(8400, "DS bad att schema syntax"); /* ERROR_DS_BAD_ATT_SCHEMA_SYNTAX */ + s_ErrorMessage.Add(8401, "DS can't cache att"); /* ERROR_DS_CANT_CACHE_ATT */ + s_ErrorMessage.Add(8402, "DS can't cache class"); /* ERROR_DS_CANT_CACHE_CLASS */ + s_ErrorMessage.Add(8403, "DS can't remove att cache"); /* ERROR_DS_CANT_REMOVE_ATT_CACHE */ + s_ErrorMessage.Add(8404, "DS can't remove class cache"); /* ERROR_DS_CANT_REMOVE_CLASS_CACHE */ + s_ErrorMessage.Add(8405, "DS can't retrieve DN"); /* ERROR_DS_CANT_RETRIEVE_DN */ + s_ErrorMessage.Add(8406, "DS missing supref"); /* ERROR_DS_MISSING_SUPREF */ + s_ErrorMessage.Add(8407, "DS can't retrieve instance"); /* ERROR_DS_CANT_RETRIEVE_INSTANCE */ + s_ErrorMessage.Add(8408, "DS code inconsistency"); /* ERROR_DS_CODE_INCONSISTENCY */ + s_ErrorMessage.Add(8409, "DS database error"); /* ERROR_DS_DATABASE_ERROR */ + s_ErrorMessage.Add(8410, "DS governsid missing"); /* ERROR_DS_GOVERNSID_MISSING */ + s_ErrorMessage.Add(8411, "DS missing expected att"); /* ERROR_DS_MISSING_EXPECTED_ATT */ + s_ErrorMessage.Add(8412, "DS ncname missing cr ref"); /* ERROR_DS_NCNAME_MISSING_CR_REF */ + s_ErrorMessage.Add(8413, "DS security checking error"); /* ERROR_DS_SECURITY_CHECKING_ERROR */ + s_ErrorMessage.Add(8414, "DS schema not loaded"); /* ERROR_DS_SCHEMA_NOT_LOADED */ + s_ErrorMessage.Add(8415, "DS schema alloc failed"); /* ERROR_DS_SCHEMA_ALLOC_FAILED */ + s_ErrorMessage.Add(8416, "DS att schema req syntax"); /* ERROR_DS_ATT_SCHEMA_REQ_SYNTAX */ + s_ErrorMessage.Add(8417, "DS gcverify error"); /* ERROR_DS_GCVERIFY_ERROR */ + s_ErrorMessage.Add(8418, "DS dra schema mismatch"); /* ERROR_DS_DRA_SCHEMA_MISMATCH */ + s_ErrorMessage.Add(8419, "DS can't find dsa obj"); /* ERROR_DS_CANT_FIND_DSA_OBJ */ + s_ErrorMessage.Add(8420, "DS can't find expected nc"); /* ERROR_DS_CANT_FIND_EXPECTED_NC */ + s_ErrorMessage.Add(8421, "DS can't find nc in cache"); /* ERROR_DS_CANT_FIND_NC_IN_CACHE */ + s_ErrorMessage.Add(8422, "DS can't retrieve child"); /* ERROR_DS_CANT_RETRIEVE_CHILD */ + s_ErrorMessage.Add(8423, "DS security illegal modify"); /* ERROR_DS_SECURITY_ILLEGAL_MODIFY */ + s_ErrorMessage.Add(8424, "DS can't replace hidden rec"); /* ERROR_DS_CANT_REPLACE_HIDDEN_REC */ + s_ErrorMessage.Add(8425, "DS bad hierarchy file"); /* ERROR_DS_BAD_HIERARCHY_FILE */ + s_ErrorMessage.Add(8426, "DS build hierarchy table failed"); /* ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED */ + s_ErrorMessage.Add(8427, "DS config param missing"); /* ERROR_DS_CONFIG_PARAM_MISSING */ + s_ErrorMessage.Add(8428, "DS counting ab indices failed"); /* ERROR_DS_COUNTING_AB_INDICES_FAILED */ + s_ErrorMessage.Add(8429, "DS hierarchy table malloc failed"); /* ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED */ + s_ErrorMessage.Add(8430, "DS internal failure"); /* ERROR_DS_INTERNAL_FAILURE */ + s_ErrorMessage.Add(8431, "DS unknown error"); /* ERROR_DS_UNKNOWN_ERROR */ + s_ErrorMessage.Add(8432, "DS root requires class top"); /* ERROR_DS_ROOT_REQUIRES_CLASS_TOP */ + s_ErrorMessage.Add(8433, "DS refusing fmso roles"); /* ERROR_DS_REFUSING_FSMO_ROLES */ + s_ErrorMessage.Add(8434, "DS missing fmso settings"); /* ERROR_DS_MISSING_FSMO_SETTINGS */ + s_ErrorMessage.Add(8435, "DS unable to surrender roles"); /* ERROR_DS_UNABLE_TO_SURRENDER_ROLES */ + s_ErrorMessage.Add(8436, "DS dra generic"); /* ERROR_DS_DRA_GENERIC */ + s_ErrorMessage.Add(8437, "DS dra invalid parameter"); /* ERROR_DS_DRA_INVALID_PARAMETER */ + s_ErrorMessage.Add(8438, "DS dra busy"); /* ERROR_DS_DRA_BUSY */ + s_ErrorMessage.Add(8439, "DS dra bad dn"); /* ERROR_DS_DRA_BAD_DN */ + s_ErrorMessage.Add(8440, "DS dra bad nc"); /* ERROR_DS_DRA_BAD_NC */ + s_ErrorMessage.Add(8441, "DS dra dn exists"); /* ERROR_DS_DRA_DN_EXISTS */ + s_ErrorMessage.Add(8442, "DS dra internal error"); /* ERROR_DS_DRA_INTERNAL_ERROR */ + s_ErrorMessage.Add(8443, "DS dra inconsistent dit"); /* ERROR_DS_DRA_INCONSISTENT_DIT */ + s_ErrorMessage.Add(8444, "DS dra connection failed"); /* ERROR_DS_DRA_CONNECTION_FAILED */ + s_ErrorMessage.Add(8445, "DS dra bad instance type"); /* ERROR_DS_DRA_BAD_INSTANCE_TYPE */ + s_ErrorMessage.Add(8446, "DS dra out of mem"); /* ERROR_DS_DRA_OUT_OF_MEM */ + s_ErrorMessage.Add(8447, "DS dra mail problem"); /* ERROR_DS_DRA_MAIL_PROBLEM */ + s_ErrorMessage.Add(8448, "DS dra ref already exists"); /* ERROR_DS_DRA_REF_ALREADY_EXISTS */ + s_ErrorMessage.Add(8449, "DS dra ref not found"); /* ERROR_DS_DRA_REF_NOT_FOUND */ + s_ErrorMessage.Add(8450, "DS dra obj is rep source"); /* ERROR_DS_DRA_OBJ_IS_REP_SOURCE */ + s_ErrorMessage.Add(8451, "DS dra db error"); /* ERROR_DS_DRA_DB_ERROR */ + s_ErrorMessage.Add(8452, "DS dra no replica"); /* ERROR_DS_DRA_NO_REPLICA */ + s_ErrorMessage.Add(8453, "DS dra access denied"); /* ERROR_DS_DRA_ACCESS_DENIED */ + s_ErrorMessage.Add(8454, "DS dra not supported"); /* ERROR_DS_DRA_NOT_SUPPORTED */ + s_ErrorMessage.Add(8455, "DS dra RPC cancelled"); /* ERROR_DS_DRA_RPC_CANCELLED */ + s_ErrorMessage.Add(8456, "DS dra source disabled"); /* ERROR_DS_DRA_SOURCE_DISABLED */ + s_ErrorMessage.Add(8457, "DS dra sink disabled"); /* ERROR_DS_DRA_SINK_DISABLED */ + s_ErrorMessage.Add(8458, "DS dra name collision"); /* ERROR_DS_DRA_NAME_COLLISION */ + s_ErrorMessage.Add(8459, "DS dra source reinstalled"); /* ERROR_DS_DRA_SOURCE_REINSTALLED */ + s_ErrorMessage.Add(8460, "DS dra missing parent"); /* ERROR_DS_DRA_MISSING_PARENT */ + s_ErrorMessage.Add(8461, "DS dra preempted"); /* ERROR_DS_DRA_PREEMPTED */ + s_ErrorMessage.Add(8462, "DS dra abandon sync"); /* ERROR_DS_DRA_ABANDON_SYNC */ + s_ErrorMessage.Add(8463, "DS dra shutdown"); /* ERROR_DS_DRA_SHUTDOWN */ + s_ErrorMessage.Add(8464, "DS dra incompatible partial set"); /* ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET */ + s_ErrorMessage.Add(8465, "DS dra source is partial replica"); /* ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA */ + s_ErrorMessage.Add(8466, "DS dra extn connection failed"); /* ERROR_DS_DRA_EXTN_CONNECTION_FAILED */ + s_ErrorMessage.Add(8467, "DS install schema mismatch"); /* ERROR_DS_INSTALL_SCHEMA_MISMATCH */ + s_ErrorMessage.Add(8468, "DS dup link ID"); /* ERROR_DS_DUP_LINK_ID */ + s_ErrorMessage.Add(8469, "DS name error resolving"); /* ERROR_DS_NAME_ERROR_RESOLVING */ + s_ErrorMessage.Add(8470, "DS name error not found"); /* ERROR_DS_NAME_ERROR_NOT_FOUND */ + s_ErrorMessage.Add(8471, "DS name error not unique"); /* ERROR_DS_NAME_ERROR_NOT_UNIQUE */ + s_ErrorMessage.Add(8472, "DS name error no mapping"); /* ERROR_DS_NAME_ERROR_NO_MAPPING */ + s_ErrorMessage.Add(8473, "DS name error domain only"); /* ERROR_DS_NAME_ERROR_DOMAIN_ONLY */ + s_ErrorMessage.Add(8474, "DS name error no syntactical mapping"); /* ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING */ + s_ErrorMessage.Add(8475, "DS constructed att mod"); /* ERROR_DS_CONSTRUCTED_ATT_MOD */ + s_ErrorMessage.Add(8476, "DS wrong om obj class"); /* ERROR_DS_WRONG_OM_OBJ_CLASS */ + s_ErrorMessage.Add(8477, "DS dra repl pending"); /* ERROR_DS_DRA_REPL_PENDING */ + s_ErrorMessage.Add(8478, "DS ds required"); /* ERROR_DS_DS_REQUIRED */ + s_ErrorMessage.Add(8479, "DS invalid LDAP display name"); /* ERROR_DS_INVALID_LDAP_DISPLAY_NAME */ + s_ErrorMessage.Add(8480, "DS non base search"); /* ERROR_DS_NON_BASE_SEARCH */ + s_ErrorMessage.Add(8481, "DS can't retrieve atts"); /* ERROR_DS_CANT_RETRIEVE_ATTS */ + s_ErrorMessage.Add(8482, "DS backlink without link"); /* ERROR_DS_BACKLINK_WITHOUT_LINK */ + s_ErrorMessage.Add(8483, "DS epoch mismatch"); /* ERROR_DS_EPOCH_MISMATCH */ + s_ErrorMessage.Add(8484, "DS src name mismatch"); /* ERROR_DS_SRC_NAME_MISMATCH */ + s_ErrorMessage.Add(8485, "DS src and dst nc identical"); /* ERROR_DS_SRC_AND_DST_NC_IDENTICAL */ + s_ErrorMessage.Add(8486, "DS dst nc mismatch"); /* ERROR_DS_DST_NC_MISMATCH */ + s_ErrorMessage.Add(8487, "DS not authoritive for dst nc"); /* ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC */ + s_ErrorMessage.Add(8488, "DS src GUID mismatch"); /* ERROR_DS_SRC_GUID_MISMATCH */ + s_ErrorMessage.Add(8489, "DS can't move deleted object"); /* ERROR_DS_CANT_MOVE_DELETED_OBJECT */ + s_ErrorMessage.Add(8490, "DS pdc operation in progress"); /* ERROR_DS_PDC_OPERATION_IN_PROGRESS */ + s_ErrorMessage.Add(8491, "DS cross domain cleanup reqd"); /* ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD */ + s_ErrorMessage.Add(8492, "DS illegal xdom move operation"); /* ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION */ + s_ErrorMessage.Add(8493, "DS can't with acct group membershps"); /* ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS */ + s_ErrorMessage.Add(8494, "DS nc must have nc parent"); /* ERROR_DS_NC_MUST_HAVE_NC_PARENT */ + s_ErrorMessage.Add(8496, "DS dst domain not native"); /* ERROR_DS_DST_DOMAIN_NOT_NATIVE */ + s_ErrorMessage.Add(8497, "DS missing infrastructure container"); /* ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER */ + s_ErrorMessage.Add(8498, "DS can't move account group"); /* ERROR_DS_CANT_MOVE_ACCOUNT_GROUP */ + s_ErrorMessage.Add(8499, "DS can't move resource group"); /* ERROR_DS_CANT_MOVE_RESOURCE_GROUP */ + s_ErrorMessage.Add(8500, "DS invalid search flag"); /* ERROR_DS_INVALID_SEARCH_FLAG */ + s_ErrorMessage.Add(8501, "DS no tree delete above nc"); /* ERROR_DS_NO_TREE_DELETE_ABOVE_NC */ + s_ErrorMessage.Add(8502, "DS couldn't lock tree for delete"); /* ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE */ + s_ErrorMessage.Add(8503, "DS couldn't identify objects for tree delete"); /* ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE */ + s_ErrorMessage.Add(8504, "DS sam init failure"); /* ERROR_DS_SAM_INIT_FAILURE */ + s_ErrorMessage.Add(8505, "DS sensitive group violation"); /* ERROR_DS_SENSITIVE_GROUP_VIOLATION */ + s_ErrorMessage.Add(8506, "DS can't mod primarygroupid"); /* ERROR_DS_CANT_MOD_PRIMARYGROUPID */ + s_ErrorMessage.Add(8507, "DS illegal base schema mod"); /* ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD */ + s_ErrorMessage.Add(8508, "DS nonsafe schema change"); /* ERROR_DS_NONSAFE_SCHEMA_CHANGE */ + s_ErrorMessage.Add(8509, "DS schema update disallowed"); /* ERROR_DS_SCHEMA_UPDATE_DISALLOWED */ + s_ErrorMessage.Add(8510, "DS can't create under schema"); /* ERROR_DS_CANT_CREATE_UNDER_SCHEMA */ + s_ErrorMessage.Add(8511, "DS install no src sch version"); /* ERROR_DS_INSTALL_NO_SRC_SCH_VERSION */ + s_ErrorMessage.Add(8512, "DS install no sch version in inifile"); /* ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE */ + s_ErrorMessage.Add(8513, "DS invalid group type"); /* ERROR_DS_INVALID_GROUP_TYPE */ + s_ErrorMessage.Add(8514, "DS no nest globalgroup in mixeddomain"); /* ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN */ + s_ErrorMessage.Add(8515, "DS no nest localgroup in mixeddomain"); /* ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN */ + s_ErrorMessage.Add(8516, "DS global can't have local member"); /* ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER */ + s_ErrorMessage.Add(8517, "DS global can't have universal member"); /* ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER */ + s_ErrorMessage.Add(8518, "DS universal can't have local member"); /* ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER */ + s_ErrorMessage.Add(8519, "DS global can't have crossdomain member"); /* ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER */ + s_ErrorMessage.Add(8520, "DS local can't have crossdomain local member"); /* ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER */ + s_ErrorMessage.Add(8521, "DS have primary members"); /* ERROR_DS_HAVE_PRIMARY_MEMBERS */ + s_ErrorMessage.Add(8522, "DS string sd conversion failed"); /* ERROR_DS_STRING_SD_CONVERSION_FAILED */ + s_ErrorMessage.Add(8523, "DS naming master gc"); /* ERROR_DS_NAMING_MASTER_GC */ + s_ErrorMessage.Add(8524, "DS lookup failure"); /* ERROR_DS_LOOKUP_FAILURE */ + s_ErrorMessage.Add(8525, "DS couldn't update spns"); /* ERROR_DS_COULDNT_UPDATE_SPNS */ + s_ErrorMessage.Add(8526, "DS can't retrieve sd"); /* ERROR_DS_CANT_RETRIEVE_SD */ + s_ErrorMessage.Add(8527, "DS key not unique"); /* ERROR_DS_KEY_NOT_UNIQUE */ + s_ErrorMessage.Add(8528, "DS wrong linked att syntax"); /* ERROR_DS_WRONG_LINKED_ATT_SYNTAX */ + s_ErrorMessage.Add(8529, "DS sam need bootkey password"); /* ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD */ + s_ErrorMessage.Add(8530, "DS sam need bootkey floppy"); /* ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY */ + s_ErrorMessage.Add(8531, "DS can't start"); /* ERROR_DS_CANT_START */ + s_ErrorMessage.Add(8532, "DS init failure"); /* ERROR_DS_INIT_FAILURE */ + s_ErrorMessage.Add(8533, "DS no pkt privacy on connection"); /* ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION */ + s_ErrorMessage.Add(8534, "DS source domain in forest"); /* ERROR_DS_SOURCE_DOMAIN_IN_FOREST */ + s_ErrorMessage.Add(8535, "DS destination domain not in forest"); /* ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST */ + s_ErrorMessage.Add(8536, "DS destination auditing not enabled"); /* ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED */ + s_ErrorMessage.Add(8537, "DS can't find dc for src domain"); /* ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN */ + s_ErrorMessage.Add(8538, "DS src obj not group or user"); /* ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER */ + s_ErrorMessage.Add(8539, "DS src sid exists in forest"); /* ERROR_DS_SRC_SID_EXISTS_IN_FOREST */ + s_ErrorMessage.Add(8540, "DS src and dst object class mismatch"); /* ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH */ + s_ErrorMessage.Add(8541, "Sam init failure"); /* ERROR_SAM_INIT_FAILURE */ + s_ErrorMessage.Add(8542, "DS dra schema info ship"); /* ERROR_DS_DRA_SCHEMA_INFO_SHIP */ + s_ErrorMessage.Add(8543, "DS dra schema conflict"); /* ERROR_DS_DRA_SCHEMA_CONFLICT */ + s_ErrorMessage.Add(8544, "DS dra earlier schema conflict"); /* ERROR_DS_DRA_EARLIER_SCHEMA_CONLICT */ + s_ErrorMessage.Add(8545, "DS dra obj nc mismatch"); /* ERROR_DS_DRA_OBJ_NC_MISMATCH */ + s_ErrorMessage.Add(8546, "DS nc still has dsas"); /* ERROR_DS_NC_STILL_HAS_DSAS */ + s_ErrorMessage.Add(8547, "DS gc required"); /* ERROR_DS_GC_REQUIRED */ + s_ErrorMessage.Add(8548, "DS local member of local only"); /* ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY */ + s_ErrorMessage.Add(8549, "DS no fpo in universal groups"); /* ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS */ + s_ErrorMessage.Add(8550, "DS can't add to gc"); /* ERROR_DS_CANT_ADD_TO_GC */ + s_ErrorMessage.Add(8551, "DS no checkpoint with pdc"); /* ERROR_DS_NO_CHECKPOINT_WITH_PDC */ + s_ErrorMessage.Add(8552, "DS source auditing not enabled"); /* ERROR_DS_SOURCE_AUDITING_NOT_ENABLED */ + s_ErrorMessage.Add(8553, "DS can't create in nondomain nc"); /* ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC */ + s_ErrorMessage.Add(8554, "DS invalid name for spn"); /* ERROR_DS_INVALID_NAME_FOR_SPN */ + s_ErrorMessage.Add(8555, "DS filter uses constructed attrs"); /* ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS */ + s_ErrorMessage.Add(8556, "DS unicodepwd not in quotes"); /* ERROR_DS_UNICODEPWD_NOT_IN_QUOTES */ + s_ErrorMessage.Add(8557, "DS machine account quota exceeded"); /* ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED */ + s_ErrorMessage.Add(8558, "DS must be run on dst dc"); /* ERROR_DS_MUST_BE_RUN_ON_DST_DC */ + s_ErrorMessage.Add(8559, "DS src dc must be sp4 or greater"); /* ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER */ + s_ErrorMessage.Add(8560, "DS can't tree delete critical obj"); /* ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ */ + s_ErrorMessage.Add(8561, "DS init failure console"); /* ERROR_DS_INIT_FAILURE_CONSOLE */ + s_ErrorMessage.Add(8562, "DS sam init failure console"); /* ERROR_DS_SAM_INIT_FAILURE_CONSOLE */ + s_ErrorMessage.Add(8563, "DS forest version too high"); /* ERROR_DS_FOREST_VERSION_TOO_HIGH */ + s_ErrorMessage.Add(8564, "DS domain version too high"); /* ERROR_DS_DOMAIN_VERSION_TOO_HIGH */ + s_ErrorMessage.Add(8565, "DS forest version too low"); /* ERROR_DS_FOREST_VERSION_TOO_LOW */ + s_ErrorMessage.Add(8566, "DS domain version too low"); /* ERROR_DS_DOMAIN_VERSION_TOO_LOW */ + s_ErrorMessage.Add(8567, "DS incompatible version"); /* ERROR_DS_INCOMPATIBLE_VERSION */ + s_ErrorMessage.Add(8568, "DS low dsa version"); /* ERROR_DS_LOW_DSA_VERSION */ + s_ErrorMessage.Add(8569, "DS no behaviour version in mixeddomain"); /* ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN */ + s_ErrorMessage.Add(8570, "DS not supported sort order"); /* ERROR_DS_NOT_SUPPORTED_SORT_ORDER */ + s_ErrorMessage.Add(8571, "DS name not unique"); /* ERROR_DS_NAME_NOT_UNIQUE */ + s_ErrorMessage.Add(8572, "DS machine account created prent4"); /* ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4 */ + s_ErrorMessage.Add(8573, "DS out of version store"); /* ERROR_DS_OUT_OF_VERSION_STORE */ + s_ErrorMessage.Add(8574, "DS incompatible controls used"); /* ERROR_DS_INCOMPATIBLE_CONTROLS_USED */ + s_ErrorMessage.Add(8575, "DS no ref domain"); /* ERROR_DS_NO_REF_DOMAIN */ + s_ErrorMessage.Add(8576, "DS reserved link ID"); /* ERROR_DS_RESERVED_LINK_ID */ + s_ErrorMessage.Add(8577, "DS link ID not available"); /* ERROR_DS_LINK_ID_NOT_AVAILABLE */ + s_ErrorMessage.Add(8578, "DS ag can't have universal member"); /* ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER */ + s_ErrorMessage.Add(8579, "DS modifydn disallowed by instance type"); /* ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE */ + s_ErrorMessage.Add(8580, "DS no object move in schema nc"); /* ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC */ + s_ErrorMessage.Add(8581, "DS modifydn disallowed by flag"); /* ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG */ + s_ErrorMessage.Add(8582, "DS modifydn wrong grandparent"); /* ERROR_DS_MODIFYDN_WRONG_GRANDPARENT */ + s_ErrorMessage.Add(8583, "DS name error trust referral"); /* ERROR_DS_NAME_ERROR_TRUST_REFERRAL */ + s_ErrorMessage.Add(8584, "Not supported on standard server"); /* ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER */ + s_ErrorMessage.Add(8585, "DS can't access remote part of ad"); /* ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD */ + s_ErrorMessage.Add(8586, "DS cr impossible to validate"); /* ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE */ + s_ErrorMessage.Add(8587, "DS thread limit exceeded"); /* ERROR_DS_THREAD_LIMIT_EXCEEDED */ + s_ErrorMessage.Add(8588, "DS not closest"); /* ERROR_DS_NOT_CLOSEST */ + s_ErrorMessage.Add(8589, "DS can't derive spn without server ref"); /* ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF */ + s_ErrorMessage.Add(8590, "DS single user mode failed"); /* ERROR_DS_SINGLE_USER_MODE_FAILED */ + s_ErrorMessage.Add(8591, "DS ntdscript syntax error"); /* ERROR_DS_NTDSCRIPT_SYNTAX_ERROR */ + s_ErrorMessage.Add(8592, "DS ntdscript process error"); /* ERROR_DS_NTDSCRIPT_PROCESS_ERROR */ + s_ErrorMessage.Add(8593, "DS different repl epochs"); /* ERROR_DS_DIFFERENT_REPL_EPOCHS */ + s_ErrorMessage.Add(8594, "DS drs extensions changed"); /* ERROR_DS_DRS_EXTENSIONS_CHANGED */ + s_ErrorMessage.Add(8595, "DS replica set change not allowed on disabled cr"); /* ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR */ + s_ErrorMessage.Add(8596, "DS no msds intid"); /* ERROR_DS_NO_MSDS_INTID */ + s_ErrorMessage.Add(8597, "DS dup msds intid"); /* ERROR_DS_DUP_MSDS_INTID */ + s_ErrorMessage.Add(8598, "DS exists in rdnattid"); /* ERROR_DS_EXISTS_IN_RDNATTID */ + s_ErrorMessage.Add(8599, "DS authorisation failed"); /* ERROR_DS_AUTHORIZATION_FAILED */ + s_ErrorMessage.Add(8600, "DS invalid script"); /* ERROR_DS_INVALID_SCRIPT */ + s_ErrorMessage.Add(8601, "DS remote crossref op failed"); /* ERROR_DS_REMOTE_CROSSREF_OP_FAILED */ + s_ErrorMessage.Add(9001, "DNS error rcode format error"); /* DNS_ERROR_RCODE_FORMAT_ERROR */ + s_ErrorMessage.Add(9002, "DNS error rcode server failure"); /* DNS_ERROR_RCODE_SERVER_FAILURE */ + s_ErrorMessage.Add(9003, "DNS error rcode name error"); /* DNS_ERROR_RCODE_NAME_ERROR */ + s_ErrorMessage.Add(9004, "DNS error rcode not implemented"); /* DNS_ERROR_RCODE_NOT_IMPLEMENTED */ + s_ErrorMessage.Add(9005, "DNS error rcode refused"); /* DNS_ERROR_RCODE_REFUSED */ + s_ErrorMessage.Add(9006, "DNS error rcode yxdomain"); /* DNS_ERROR_RCODE_YXDOMAIN */ + s_ErrorMessage.Add(9007, "DNS error rcode yxrrset"); /* DNS_ERROR_RCODE_YXRRSET */ + s_ErrorMessage.Add(9008, "DNS error rcode nxrrset"); /* DNS_ERROR_RCODE_NXRRSET */ + s_ErrorMessage.Add(9009, "DNS error rcode notauth"); /* DNS_ERROR_RCODE_NOTAUTH */ + s_ErrorMessage.Add(9010, "DNS error rcode notzone"); /* DNS_ERROR_RCODE_NOTZONE */ + s_ErrorMessage.Add(9016, "DNS error rcode badsig"); /* DNS_ERROR_RCODE_BADSIG */ + s_ErrorMessage.Add(9017, "DNS error rcode badkey"); /* DNS_ERROR_RCODE_BADKEY */ + s_ErrorMessage.Add(9018, "DNS error rcode badtime"); /* DNS_ERROR_RCODE_BADTIME */ + s_ErrorMessage.Add(9501, "DNS info no records"); /* DNS_INFO_NO_RECORDS */ + s_ErrorMessage.Add(9502, "DNS error bad packet"); /* DNS_ERROR_BAD_PACKET */ + s_ErrorMessage.Add(9503, "DNS error no packet"); /* DNS_ERROR_NO_PACKET */ + s_ErrorMessage.Add(9504, "DNS error rcode"); /* DNS_ERROR_RCODE */ + s_ErrorMessage.Add(9505, "DNS error unsecure packet"); /* DNS_ERROR_UNSECURE_PACKET */ + s_ErrorMessage.Add(9551, "DNS error invalid type"); /* DNS_ERROR_INVALID_TYPE */ + s_ErrorMessage.Add(9552, "DNS error invalid IP address"); /* DNS_ERROR_INVALID_IP_ADDRESS */ + s_ErrorMessage.Add(9553, "DNS error invalid property"); /* DNS_ERROR_INVALID_PROPERTY */ + s_ErrorMessage.Add(9554, "DNS error try again later"); /* DNS_ERROR_TRY_AGAIN_LATER */ + s_ErrorMessage.Add(9555, "DNS error not unique"); /* DNS_ERROR_NOT_UNIQUE */ + s_ErrorMessage.Add(9556, "DNS error non RFC name"); /* DNS_ERROR_NON_RFC_NAME */ + s_ErrorMessage.Add(9557, "DNS status FQDN"); /* DNS_STATUS_FQDN */ + s_ErrorMessage.Add(9558, "DNS status dotted name"); /* DNS_STATUS_DOTTED_NAME */ + s_ErrorMessage.Add(9559, "DNS status single part name"); /* DNS_STATUS_SINGLE_PART_NAME */ + s_ErrorMessage.Add(9560, "DNS error invalid name char"); /* DNS_ERROR_INVALID_NAME_CHAR */ + s_ErrorMessage.Add(9561, "DNS error numeric name"); /* DNS_ERROR_NUMERIC_NAME */ + s_ErrorMessage.Add(9562, "DNS error not allowed on root server"); /* DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER */ + s_ErrorMessage.Add(9601, "DNS error zone does not exist"); /* DNS_ERROR_ZONE_DOES_NOT_EXIST */ + s_ErrorMessage.Add(9602, "DNS error not zone info"); /* DNS_ERROR_NO_ZONE_INFO */ + s_ErrorMessage.Add(9603, "DNS error invalid zone operation"); /* DNS_ERROR_INVALID_ZONE_OPERATION */ + s_ErrorMessage.Add(9604, "DNS error zone configuration error"); /* DNS_ERROR_ZONE_CONFIGURATION_ERROR */ + s_ErrorMessage.Add(9605, "DNS error zone has not SOA record"); /* DNS_ERROR_ZONE_HAS_NO_SOA_RECORD */ + s_ErrorMessage.Add(9606, "DNS error zone has no NS records"); /* DNS_ERROR_ZONE_HAS_NO_NS_RECORDS */ + s_ErrorMessage.Add(9607, "DNS error zone locked"); /* DNS_ERROR_ZONE_LOCKED */ + s_ErrorMessage.Add(9608, "DNS error zone creation failed"); /* DNS_ERROR_ZONE_CREATION_FAILED */ + s_ErrorMessage.Add(9609, "DNS error zone already exists"); /* DNS_ERROR_ZONE_ALREADY_EXISTS */ + s_ErrorMessage.Add(9610, "DNS error autozone already exists"); /* DNS_ERROR_AUTOZONE_ALREADY_EXISTS */ + s_ErrorMessage.Add(9611, "DNS error invalid zone type"); /* DNS_ERROR_INVALID_ZONE_TYPE */ + s_ErrorMessage.Add(9612, "DNS error secondary requires master IP"); /* DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP */ + s_ErrorMessage.Add(9613, "DNS error zone not secondary"); /* DNS_ERROR_ZONE_NOT_SECONDARY */ + s_ErrorMessage.Add(9614, "DNS error need secondary addresses"); /* DNS_ERROR_NEED_SECONDARY_ADDRESSES */ + s_ErrorMessage.Add(9615, "DNS error wins init failed"); /* DNS_ERROR_WINS_INIT_FAILED */ + s_ErrorMessage.Add(9616, "DNS error need wins servers"); /* DNS_ERROR_NEED_WINS_SERVERS */ + s_ErrorMessage.Add(9617, "DNS error nbstat init failed"); /* DNS_ERROR_NBSTAT_INIT_FAILED */ + s_ErrorMessage.Add(9618, "DNS error SOA delete invalid"); /* DNS_ERROR_SOA_DELETE_INVALID */ + s_ErrorMessage.Add(9619, "DNS error forwarder already exists"); /* DNS_ERROR_FORWARDER_ALREADY_EXISTS */ + s_ErrorMessage.Add(9620, "DNS error zone requires master IP"); /* DNS_ERROR_ZONE_REQUIRES_MASTER_IP */ + s_ErrorMessage.Add(9621, "DNS error zone is shutdown"); /* DNS_ERROR_ZONE_IS_SHUTDOWN */ + s_ErrorMessage.Add(9651, "DNS error primary requires datafile"); /* DNS_ERROR_PRIMARY_REQUIRES_DATAFILE */ + s_ErrorMessage.Add(9652, "DNS error invalid datafile name"); /* DNS_ERROR_INVALID_DATAFILE_NAME */ + s_ErrorMessage.Add(9653, "DNS error datafile open failure"); /* DNS_ERROR_DATAFILE_OPEN_FAILURE */ + s_ErrorMessage.Add(9654, "DNS error file writeback failed"); /* DNS_ERROR_FILE_WRITEBACK_FAILED */ + s_ErrorMessage.Add(9655, "DNS error datafile parsing"); /* DNS_ERROR_DATAFILE_PARSING */ + s_ErrorMessage.Add(9701, "DNS error record does not exist"); /* DNS_ERROR_RECORD_DOES_NOT_EXIST */ + s_ErrorMessage.Add(9702, "DNS error record format"); /* DNS_ERROR_RECORD_FORMAT */ + s_ErrorMessage.Add(9703, "DNS error node creation failed"); /* DNS_ERROR_NODE_CREATION_FAILED */ + s_ErrorMessage.Add(9704, "DNS error unknown record type"); /* DNS_ERROR_UNKNOWN_RECORD_TYPE */ + s_ErrorMessage.Add(9705, "DNS error record timed out"); /* DNS_ERROR_RECORD_TIMED_OUT */ + s_ErrorMessage.Add(9706, "DNS error name not in zone"); /* DNS_ERROR_NAME_NOT_IN_ZONE */ + s_ErrorMessage.Add(9707, "DNS error CNAME loop"); /* DNS_ERROR_CNAME_LOOP */ + s_ErrorMessage.Add(9708, "DNS error node is CNAME"); /* DNS_ERROR_NODE_IS_CNAME */ + s_ErrorMessage.Add(9709, "DNS error CNAME collision"); /* DNS_ERROR_CNAME_COLLISION */ + s_ErrorMessage.Add(9710, "DNS error record only at zone root"); /* DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT */ + s_ErrorMessage.Add(9711, "DNS error record already exists"); /* DNS_ERROR_RECORD_ALREADY_EXISTS */ + s_ErrorMessage.Add(9712, "DNS error secondary data"); /* DNS_ERROR_SECONDARY_DATA */ + s_ErrorMessage.Add(9713, "DNS error no create cache data"); /* DNS_ERROR_NO_CREATE_CACHE_DATA */ + s_ErrorMessage.Add(9714, "DNS error name does not exist"); /* DNS_ERROR_NAME_DOES_NOT_EXIST */ + s_ErrorMessage.Add(9715, "DNS warning PTR create failed"); /* DNS_WARNING_PTR_CREATE_FAILED */ + s_ErrorMessage.Add(9716, "DNS warning domain undeleted"); /* DNS_WARNING_DOMAIN_UNDELETED */ + s_ErrorMessage.Add(9717, "DNS error ds unavailable"); /* DNS_ERROR_DS_UNAVAILABLE */ + s_ErrorMessage.Add(9718, "DNS error ds zone already exists"); /* DNS_ERROR_DS_ZONE_ALREADY_EXISTS */ + s_ErrorMessage.Add(9719, "DNS error no bootfile if ds zone"); /* DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE */ + s_ErrorMessage.Add(9751, "DNS info AXFR complete"); /* DNS_INFO_AXFR_COMPLETE */ + s_ErrorMessage.Add(9752, "DNS error AXFR"); /* DNS_ERROR_AXFR */ + s_ErrorMessage.Add(9753, "DNS info added local wins"); /* DNS_INFO_ADDED_LOCAL_WINS */ + s_ErrorMessage.Add(9801, "DNS status continue needed"); /* DNS_STATUS_CONTINUE_NEEDED */ + s_ErrorMessage.Add(9851, "DNS error no TCPIP"); /* DNS_ERROR_NO_TCPIP */ + s_ErrorMessage.Add(9852, "DNS error no DNS servers"); /* DNS_ERROR_NO_DNS_SERVERS */ + s_ErrorMessage.Add(9901, "DNS error dp does not exist"); /* DNS_ERROR_DP_DOES_NOT_EXIST */ + s_ErrorMessage.Add(9902, "DNS error dp already exists"); /* DNS_ERROR_DP_ALREADY_EXISTS */ + s_ErrorMessage.Add(9903, "DNS error dp not enlisted"); /* DNS_ERROR_DP_NOT_ENLISTED */ + s_ErrorMessage.Add(9904, "DNS error dp already enlisted"); /* DNS_ERROR_DP_ALREADY_ENLISTED */ + s_ErrorMessage.Add(10110, "E_NO_MORE"); /* WSA_E_NO_MORE */ + s_ErrorMessage.Add(10111, "E_CANCELLED"); /* WSA_E_CANCELLED */ + s_ErrorMessage.Add(11005, "QOS receivers"); /* WSA_QOS_RECEIVERS */ + s_ErrorMessage.Add(11006, "QOS senders"); /* WSA_QOS_SENDERS */ + s_ErrorMessage.Add(11007, "QOS no senders"); /* WSA_QOS_NO_SENDERS */ + s_ErrorMessage.Add(11008, "QOS no receivers"); /* WSA_QOS_NO_RECEIVERS */ + s_ErrorMessage.Add(11009, "QOS request confirmed"); /* WSA_QOS_REQUEST_CONFIRMED */ + s_ErrorMessage.Add(11010, "QOS admission failure"); /* WSA_QOS_ADMISSION_FAILURE */ + s_ErrorMessage.Add(11011, "QOS policy failure"); /* WSA_QOS_POLICY_FAILURE */ + s_ErrorMessage.Add(11012, "QOS bad style"); /* WSA_QOS_BAD_STYLE */ + s_ErrorMessage.Add(11013, "QOS bad object"); /* WSA_QOS_BAD_OBJECT */ + s_ErrorMessage.Add(11014, "QOS traffic ctrl error"); /* WSA_QOS_TRAFFIC_CTRL_ERROR */ + s_ErrorMessage.Add(11015, "QOS generic error"); /* WSA_QOS_GENERIC_ERROR */ + s_ErrorMessage.Add(11016, "QOS eservicetype"); /* WSA_QOS_ESERVICETYPE */ + s_ErrorMessage.Add(11017, "QOS eflowspec"); /* WSA_QOS_EFLOWSPEC */ + s_ErrorMessage.Add(11018, "QOS eprovspecbuf"); /* WSA_QOS_EPROVSPECBUF */ + s_ErrorMessage.Add(11019, "QOS efilterstyle"); /* WSA_QOS_EFILTERSTYLE */ + s_ErrorMessage.Add(11020, "QOS efiltertype"); /* WSA_QOS_EFILTERTYPE */ + s_ErrorMessage.Add(11021, "QOS efiltercount"); /* WSA_QOS_EFILTERCOUNT */ + s_ErrorMessage.Add(11022, "QOS eobjlength"); /* WSA_QOS_EOBJLENGTH */ + s_ErrorMessage.Add(11023, "QOS eflowcount"); /* WSA_QOS_EFLOWCOUNT */ + s_ErrorMessage.Add(11024, "QOS eunknownpsobj"); /* WSA_QOS_EUNKNOWNPSOBJ */ + s_ErrorMessage.Add(11025, "QOS epolicyobj"); /* WSA_QOS_EPOLICYOBJ */ + s_ErrorMessage.Add(11026, "QOS eflowdesc"); /* WSA_QOS_EFLOWDESC */ + s_ErrorMessage.Add(11027, "QOS epsflowspec"); /* WSA_QOS_EPSFLOWSPEC */ + s_ErrorMessage.Add(11028, "QOS epsfilterspec"); /* WSA_QOS_EPSFILTERSPEC */ + s_ErrorMessage.Add(11029, "QOS esdmodeobj"); /* WSA_QOS_ESDMODEOBJ */ + s_ErrorMessage.Add(11030, "QOS eshaperateobj"); /* WSA_QOS_ESHAPERATEOBJ */ + s_ErrorMessage.Add(11031, "QOS reserved petype"); /* WSA_QOS_RESERVED_PETYPE */ + s_ErrorMessage.Add(13000, "IPSEC qm policy exists"); /* ERROR_IPSEC_QM_POLICY_EXISTS */ + s_ErrorMessage.Add(13001, "IPSEC qm policy not found"); /* ERROR_IPSEC_QM_POLICY_NOT_FOUND */ + s_ErrorMessage.Add(13002, "IPSEC qm policy in use"); /* ERROR_IPSEC_QM_POLICY_IN_USE */ + s_ErrorMessage.Add(13003, "IPSEC mm policy exists"); /* ERROR_IPSEC_MM_POLICY_EXISTS */ + s_ErrorMessage.Add(13004, "IPSEC mm policy not found"); /* ERROR_IPSEC_MM_POLICY_NOT_FOUND */ + s_ErrorMessage.Add(13005, "IPSEC mm policy in use"); /* ERROR_IPSEC_MM_POLICY_IN_USE */ + s_ErrorMessage.Add(13006, "IPSEC mm filter exists"); /* ERROR_IPSEC_MM_FILTER_EXISTS */ + s_ErrorMessage.Add(13007, "IPSEC mm filter not found"); /* ERROR_IPSEC_MM_FILTER_NOT_FOUND */ + s_ErrorMessage.Add(13008, "IPSEC transport filter exists"); /* ERROR_IPSEC_TRANSPORT_FILTER_EXISTS */ + s_ErrorMessage.Add(13009, "IPSEC transport filter not found"); /* ERROR_IPSEC_TRANSPORT_FILTER_NOT_FOUND */ + s_ErrorMessage.Add(13010, "IPSEC mm auth exists"); /* ERROR_IPSEC_MM_AUTH_EXISTS */ + s_ErrorMessage.Add(13011, "IPSEC mm auth not found"); /* ERROR_IPSEC_MM_AUTH_NOT_FOUND */ + s_ErrorMessage.Add(13012, "IPSEC mm auth in use"); /* ERROR_IPSEC_MM_AUTH_IN_USE */ + s_ErrorMessage.Add(13013, "IPSEC default mm policy not found"); /* ERROR_IPSEC_DEFAULT_MM_POLICY_NOT_FOUND */ + s_ErrorMessage.Add(13014, "IPSEC default mm auth not found"); /* ERROR_IPSEC_DEFAULT_MM_AUTH_NOT_FOUND */ + s_ErrorMessage.Add(13015, "IPSEC default qm policy not found"); /* ERROR_IPSEC_DEFAULT_QM_POLICY_NOT_FOUND */ + s_ErrorMessage.Add(13016, "IPSEC tunnel filter exists"); /* ERROR_IPSEC_TUNNEL_FILTER_EXISTS */ + s_ErrorMessage.Add(13017, "IPSEC tunnel filter not found"); /* ERROR_IPSEC_TUNNEL_FILTER_NOT_FOUND */ + s_ErrorMessage.Add(13018, "IPSEC mm filter pending deletion"); /* ERROR_IPSEC_MM_FILTER_PENDING_DELETION */ + s_ErrorMessage.Add(13019, "IPSEC transport filter pending deletion"); /* ERROR_IPSEC_TRANSPORT_FILTER_PENDING_DELETION */ + s_ErrorMessage.Add(13020, "IPSEC tunnel filter pending deletion"); /* ERROR_IPSEC_TUNNEL_FILTER_PENDING_DELETION */ + s_ErrorMessage.Add(13021, "IPSEC mm policy pending deletion"); /* ERROR_IPSEC_MM_POLICY_PENDING_DELETION */ + s_ErrorMessage.Add(13022, "IPSEC mm auth pending deletion"); /* ERROR_IPSEC_MM_AUTH_PENDING_DELETION */ + s_ErrorMessage.Add(13023, "IPSEC qm policy pending deletion"); /* ERROR_IPSEC_QM_POLICY_PENDING_DELETION */ + s_ErrorMessage.Add(13801, "IPSEC IKE auth fail"); /* ERROR_IPSEC_IKE_AUTH_FAIL */ + s_ErrorMessage.Add(13802, "IPSEC IKE attrib fail"); /* ERROR_IPSEC_IKE_ATTRIB_FAIL */ + s_ErrorMessage.Add(13803, "IPSEC IKE negotiation pending"); /* ERROR_IPSEC_IKE_NEGOTIATION_PENDING */ + s_ErrorMessage.Add(13804, "IPSEC IKE general processing error"); /* ERROR_IPSEC_IKE_GENERAL_PROCESSING_ERROR */ + s_ErrorMessage.Add(13805, "IPSEC IKE timed out"); /* ERROR_IPSEC_IKE_TIMED_OUT */ + s_ErrorMessage.Add(13806, "IPSEC IKE no cert"); /* ERROR_IPSEC_IKE_NO_CERT */ + s_ErrorMessage.Add(13807, "IPSEC IKE sa deleted"); /* ERROR_IPSEC_IKE_SA_DELETED */ + s_ErrorMessage.Add(13808, "IPSEC IKE sa reaped"); /* ERROR_IPSEC_IKE_SA_REAPED */ + s_ErrorMessage.Add(13809, "IPSEC IKE mm acquire drop"); /* ERROR_IPSEC_IKE_MM_ACQUIRE_DROP */ + s_ErrorMessage.Add(13810, "IPSEC IKE qm acquire drop"); /* ERROR_IPSEC_IKE_QM_ACQUIRE_DROP */ + s_ErrorMessage.Add(13811, "IPSEC IKE queue drop mm"); /* ERROR_IPSEC_IKE_QUEUE_DROP_MM */ + s_ErrorMessage.Add(13812, "IPSEC IKE queue drop no mm"); /* ERROR_IPSEC_IKE_QUEUE_DROP_NO_MM */ + s_ErrorMessage.Add(13813, "IPSEC IKE drop no response"); /* ERROR_IPSEC_IKE_DROP_NO_RESPONSE */ + s_ErrorMessage.Add(13814, "IPSEC IKE mm delay drop"); /* ERROR_IPSEC_IKE_MM_DELAY_DROP */ + s_ErrorMessage.Add(13815, "IPSEC IKE qm delay drop"); /* ERROR_IPSEC_IKE_QM_DELAY_DROP */ + s_ErrorMessage.Add(13816, "IPSEC IKE error"); /* ERROR_IPSEC_IKE_ERROR */ + s_ErrorMessage.Add(13817, "IPSEC IKE crl failed"); /* ERROR_IPSEC_IKE_CRL_FAILED */ + s_ErrorMessage.Add(13818, "IPSEC IKE invalid key usage"); /* ERROR_IPSEC_IKE_INVALID_KEY_USAGE */ + s_ErrorMessage.Add(13819, "IPSEC IKE invalid cert type"); /* ERROR_IPSEC_IKE_INVALID_CERT_TYPE */ + s_ErrorMessage.Add(13820, "IPSEC IKE no private key"); /* ERROR_IPSEC_IKE_NO_PRIVATE_KEY */ + s_ErrorMessage.Add(13822, "IPSEC IKE dh fail"); /* ERROR_IPSEC_IKE_DH_FAIL */ + s_ErrorMessage.Add(13824, "IPSEC IKE invalid header"); /* ERROR_IPSEC_IKE_INVALID_HEADER */ + s_ErrorMessage.Add(13825, "IPSEC IKE no policy"); /* ERROR_IPSEC_IKE_NO_POLICY */ + s_ErrorMessage.Add(13826, "IPSEC IKE invalid signature"); /* ERROR_IPSEC_IKE_INVALID_SIGNATURE */ + s_ErrorMessage.Add(13827, "IPSEC IKE kerberos error"); /* ERROR_IPSEC_IKE_KERBEROS_ERROR */ + s_ErrorMessage.Add(13828, "IPSEC IKE no public key"); /* ERROR_IPSEC_IKE_NO_PUBLIC_KEY */ + s_ErrorMessage.Add(13829, "IPSEC IKE process err"); /* ERROR_IPSEC_IKE_PROCESS_ERR */ + s_ErrorMessage.Add(13830, "IPSEC IKE process err sa"); /* ERROR_IPSEC_IKE_PROCESS_ERR_SA */ + s_ErrorMessage.Add(13831, "IPSEC IKE process err prop"); /* ERROR_IPSEC_IKE_PROCESS_ERR_PROP */ + s_ErrorMessage.Add(13832, "IPSEC IKE process err trans"); /* ERROR_IPSEC_IKE_PROCESS_ERR_TRANS */ + s_ErrorMessage.Add(13833, "IPSEC IKE process err ke"); /* ERROR_IPSEC_IKE_PROCESS_ERR_KE */ + s_ErrorMessage.Add(13834, "IPSEC IKE process err ID"); /* ERROR_IPSEC_IKE_PROCESS_ERR_ID */ + s_ErrorMessage.Add(13835, "IPSEC IKE process err cert"); /* ERROR_IPSEC_IKE_PROCESS_ERR_CERT */ + s_ErrorMessage.Add(13836, "IPSEC IKE process err cert req"); /* ERROR_IPSEC_IKE_PROCESS_ERR_CERT_REQ */ + s_ErrorMessage.Add(13837, "IPSEC IKE process err hash"); /* ERROR_IPSEC_IKE_PROCESS_ERR_HASH */ + s_ErrorMessage.Add(13838, "IPSEC IKE process err sig"); /* ERROR_IPSEC_IKE_PROCESS_ERR_SIG */ + s_ErrorMessage.Add(13839, "IPSEC IKE process err nonce"); /* ERROR_IPSEC_IKE_PROCESS_ERR_NONCE */ + s_ErrorMessage.Add(13840, "IPSEC IKE process err notify"); /* ERROR_IPSEC_IKE_PROCESS_ERR_NOTIFY */ + s_ErrorMessage.Add(13841, "IPSEC IKE process err delete"); /* ERROR_IPSEC_IKE_PROCESS_ERR_DELETE */ + s_ErrorMessage.Add(13842, "IPSEC IKE process err vendor"); /* ERROR_IPSEC_IKE_PROCESS_ERR_VENDOR */ + s_ErrorMessage.Add(13843, "IPSEC IKE invalid payload"); /* ERROR_IPSEC_IKE_INVALID_PAYLOAD */ + s_ErrorMessage.Add(13844, "IPSEC IKE load soft sa"); /* ERROR_IPSEC_IKE_LOAD_SOFT_SA */ + s_ErrorMessage.Add(13845, "IPSEC IKE soft sa torn down"); /* ERROR_IPSEC_IKE_SOFT_SA_TORN_DOWN */ + s_ErrorMessage.Add(13846, "IPSEC IKE invalid cookie"); /* ERROR_IPSEC_IKE_INVALID_COOKIE */ + s_ErrorMessage.Add(13847, "IPSEC IKE no peer cert"); /* ERROR_IPSEC_IKE_NO_PEER_CERT */ + s_ErrorMessage.Add(13848, "IPSEC IKE peer CRL failed"); /* ERROR_IPSEC_IKE_PEER_CRL_FAILED */ + s_ErrorMessage.Add(13849, "IPSEC IKE policy change"); /* ERROR_IPSEC_IKE_POLICY_CHANGE */ + s_ErrorMessage.Add(13850, "IPSEC IKE no mm policy"); /* ERROR_IPSEC_IKE_NO_MM_POLICY */ + s_ErrorMessage.Add(13851, "IPSEC IKE notcbpriv"); /* ERROR_IPSEC_IKE_NOTCBPRIV */ + s_ErrorMessage.Add(13852, "IPSEC IKE secloadfail"); /* ERROR_IPSEC_IKE_SECLOADFAIL */ + s_ErrorMessage.Add(13853, "IPSEC IKE failsspinit"); /* ERROR_IPSEC_IKE_FAILSSPINIT */ + s_ErrorMessage.Add(13854, "IPSEC IKE failqueryssp"); /* ERROR_IPSEC_IKE_FAILQUERYSSP */ + s_ErrorMessage.Add(13855, "IPSEC IKE srvacqfail"); /* ERROR_IPSEC_IKE_SRVACQFAIL */ + s_ErrorMessage.Add(13856, "IPSEC IKE srvquerycred"); /* ERROR_IPSEC_IKE_SRVQUERYCRED */ + s_ErrorMessage.Add(13857, "IPSEC IKE getspifail"); /* ERROR_IPSEC_IKE_GETSPIFAIL */ + s_ErrorMessage.Add(13858, "IPSEC IKE invalid filter"); /* ERROR_IPSEC_IKE_INVALID_FILTER */ + s_ErrorMessage.Add(13859, "IPSEC IKE out of memory"); /* ERROR_IPSEC_IKE_OUT_OF_MEMORY */ + s_ErrorMessage.Add(13860, "IPSEC IKE add update key failed"); /* ERROR_IPSEC_IKE_ADD_UPDATE_KEY_FAILED */ + s_ErrorMessage.Add(13861, "IPSEC IKE invalid policy"); /* ERROR_IPSEC_IKE_INVALID_POLICY */ + s_ErrorMessage.Add(13862, "IPSEC IKE unknown doi"); /* ERROR_IPSEC_IKE_UNKNOWN_DOI */ + s_ErrorMessage.Add(13863, "IPSEC IKE invalid situation"); /* ERROR_IPSEC_IKE_INVALID_SITUATION */ + s_ErrorMessage.Add(13864, "IPSEC IKE dh failure"); /* ERROR_IPSEC_IKE_DH_FAILURE */ + s_ErrorMessage.Add(13865, "IPSEC IKE invalid group"); /* ERROR_IPSEC_IKE_INVALID_GROUP */ + s_ErrorMessage.Add(13866, "IPSEC IKE encrypt"); /* ERROR_IPSEC_IKE_ENCRYPT */ + s_ErrorMessage.Add(13867, "IPSEC IKE decrypt"); /* ERROR_IPSEC_IKE_DECRYPT */ + s_ErrorMessage.Add(13868, "IPSEC IKE policy match"); /* ERROR_IPSEC_IKE_POLICY_MATCH */ + s_ErrorMessage.Add(13869, "IPSEC IKE unsupported ID"); /* ERROR_IPSEC_IKE_UNSUPPORTED_ID */ + s_ErrorMessage.Add(13870, "IPSEC IKE invalid hash"); /* ERROR_IPSEC_IKE_INVALID_HASH */ + s_ErrorMessage.Add(13871, "IPSEC IKE invalid hash alg"); /* ERROR_IPSEC_IKE_INVALID_HASH_ALG */ + s_ErrorMessage.Add(13872, "IPSEC IKE invalid hash size"); /* ERROR_IPSEC_IKE_INVALID_HASH_SIZE */ + s_ErrorMessage.Add(13873, "IPSEC IKE invalid encrypt alg"); /* ERROR_IPSEC_IKE_INVALID_ENCRYPT_ALG */ + s_ErrorMessage.Add(13874, "IPSEC IKE invalid auth alg"); /* ERROR_IPSEC_IKE_INVALID_AUTH_ALG */ + s_ErrorMessage.Add(13875, "IPSEC IKE invalid sig"); /* ERROR_IPSEC_IKE_INVALID_SIG */ + s_ErrorMessage.Add(13876, "IPSEC IKE load failed"); /* ERROR_IPSEC_IKE_LOAD_FAILED */ + s_ErrorMessage.Add(13877, "IPSEC IKE rpc delete"); /* ERROR_IPSEC_IKE_RPC_DELETE */ + s_ErrorMessage.Add(13878, "IPSEC IKE benign reinit"); /* ERROR_IPSEC_IKE_BENIGN_REINIT */ + s_ErrorMessage.Add(13879, "IPSEC IKE invalid responder lifetime notify"); /* ERROR_IPSEC_IKE_INVALID_RESPONDER_LIFETIME_NOTIFY */ + s_ErrorMessage.Add(13881, "IPSEC IKE invalid cert keylen"); /* ERROR_IPSEC_IKE_INVALID_CERT_KEYLEN */ + s_ErrorMessage.Add(13882, "IPSEC IKE mm limit"); /* ERROR_IPSEC_IKE_MM_LIMIT */ + s_ErrorMessage.Add(13883, "IPSEC IKE negotiation disabled"); /* ERROR_IPSEC_IKE_NEGOTIATION_DISABLED */ + s_ErrorMessage.Add(13884, "IPSEC IKE neg status end"); /* ERROR_IPSEC_IKE_NEG_STATUS_END */ + s_ErrorMessage.Add(100001, "Device not configured"); /* WSAENXIO */ +#endif // MOBILE + s_ErrorMessagesInitialized = true; + } + } +#endif // UNITY } } \ No newline at end of file From 4ff5d1ea7a7a1c7e2061d128c7e7c5d98a328adc Mon Sep 17 00:00:00 2001 From: Brian Raderman Date: Tue, 20 Feb 2018 10:19:28 -0500 Subject: [PATCH 149/582] Removing unneeded files from the IL2CPP external/mono/mono/mini directory. The extra files were causing compilation errors on Android due to pre-existing platform support that we weren't using. Stubbing out types and re-defining a few things to support these changes. --- external/buildscripts/sources.txt | 15 --------------- mono/mini/debugger-agent.c | 22 ++++++++++++++++++++-- mono/mini/debugger-agent.h | 3 +++ mono/mini/il2cpp-c-types.h | 17 ++++++++++++++++- mono/mini/il2cpp-compat.h | 5 +++++ mono/mini/il2cpp-stubs.cpp | 7 +++---- 6 files changed, 47 insertions(+), 22 deletions(-) diff --git a/external/buildscripts/sources.txt b/external/buildscripts/sources.txt index 09d977c41f3b..884a7456ec75 100644 --- a/external/buildscripts/sources.txt +++ b/external/buildscripts/sources.txt @@ -540,23 +540,8 @@ support/libm/math_private.h #################### #mono mini files #################### -mono/mini/aot-runtime.h -mono/mini/cfgdump.h mono/mini/debugger-agent.c mono/mini/debugger-agent.h mono/mini/il2cpp-c-types.h mono/mini/il2cpp-compat.h mono/mini/il2cpp-stubs.cpp -mono/mini/jit.h -mono/mini/mini-amd64.h -mono/mini/mini-arch.h -mono/mini/mini-ops.h -mono/mini/mini-runtime.h -mono/mini/mini-unwind.h -mono/mini/mini-x86.h -mono/mini/mini.h -mono/mini/optflags-def.h -mono/mini/patch-info.h -mono/mini/regalloc.h -mono/mini/seq-points.h -mono/mini/interp/interp.h diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index c22799d01345..8039880adf9c 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -78,11 +78,21 @@ #include #include #include + +#ifndef RUNTIME_IL2CPP #include "mini.h" #include "seq-points.h" #include "aot-runtime.h" #include "mini-runtime.h" #include "interp/interp.h" +#endif + +#ifdef RUNTIME_IL2CPP +#include +#include +#include +#define MONO_ARCH_SOFT_DEBUG_SUPPORTED +#endif /* * On iOS we can't use System.Environment.Exit () as it will do the wrong @@ -2267,6 +2277,7 @@ void mono_debugger_il2cpp_init (const Il2CppDebuggerMetadataRegistration *data) { s_jit_info_hashtable = g_hash_table_new_full(mono_aligned_addr_hash, NULL, NULL, NULL); g_il2cpp_metadata = data; + debug_options.native_debugger_break = FALSE; } static gpointer @@ -4475,6 +4486,8 @@ breakpoints_init (void) * Insert the breakpoint described by BP into the method described by * JI. */ +#ifndef RUNTIME_IL2CPP + static void insert_breakpoint (MonoSeqPointInfo *seq_points, MonoDomain *domain, MonoJitInfo *ji, MonoBreakpoint *bp, MonoError *error) { @@ -4564,7 +4577,6 @@ insert_breakpoint (MonoSeqPointInfo *seq_points, MonoDomain *domain, MonoJitInfo DEBUG_PRINTF (1, "[dbg] Inserted breakpoint at %s:[il=0x%x,native=0x%x] [%p](%d).\n", mono_method_full_name (jinfo_get_method (ji), TRUE), (int)it.seq_point.il_offset, (int)it.seq_point.native_offset, inst->ip, count); } -#ifndef RUNTIME_IL2CPP static void remove_breakpoint (BreakpointInstance *inst) @@ -4694,6 +4706,8 @@ add_pending_breakpoints (MonoMethod *method, MonoJitInfo *ji) #endif } +#ifndef RUNTIME_IL2CPP + static void set_bp_in_method (MonoDomain *domain, MonoMethod *method, MonoSeqPointInfo *seq_points, MonoBreakpoint *bp, MonoError *error) { @@ -4723,6 +4737,8 @@ set_bp_in_method (MonoDomain *domain, MonoMethod *method, MonoSeqPointInfo *seq_ insert_breakpoint (seq_points, domain, ji, bp, error); } +#endif + static void clear_breakpoint (MonoBreakpoint *bp); @@ -8124,8 +8140,10 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 MonoObject *this_arg, *res, *exc = NULL; MonoDomain *domain; guint8 *this_buf; -#ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED +#ifndef RUNTIME_IL2CPP +#ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED MonoLMFExt ext; +#endif #endif MonoStopwatch watch; diff --git a/mono/mini/debugger-agent.h b/mono/mini/debugger-agent.h index 1cef217a04dc..581579c21c82 100644 --- a/mono/mini/debugger-agent.h +++ b/mono/mini/debugger-agent.h @@ -5,7 +5,10 @@ #ifndef __MONO_DEBUGGER_AGENT_H__ #define __MONO_DEBUGGER_AGENT_H__ +#ifndef RUNTIME_IL2CPP #include "mini.h" +#endif + #include "il2cpp-compat.h" #include diff --git a/mono/mini/il2cpp-c-types.h b/mono/mini/il2cpp-c-types.h index ecf664d0a3e9..53f8a17e8b6a 100644 --- a/mono/mini/il2cpp-c-types.h +++ b/mono/mini/il2cpp-c-types.h @@ -52,6 +52,11 @@ typedef struct _Il2CppMonoMethodSignature Il2CppMonoMethodSignature; typedef struct _Il2CppMonoRuntimeExceptionHandlingCallbacks Il2CppMonoRuntimeExceptionHandlingCallbacks; typedef struct Il2CppDefaults Il2CppMonoDefaults; typedef struct _Il2CppMonoTypeNameParse Il2CppMonoTypeNameParse; +typedef struct _Il2CppMonoDebugOptions Il2CppMonoDebugOptions; +typedef struct _Il2CppEmptyStruct Il2CppMonoLMF; + +typedef MonoStackFrameInfo StackFrameInfo; +typedef gpointer MonoInterpFrameHandle; typedef gboolean (*Il2CppMonoInternalStackWalk) (MonoStackFrameInfo *frame, MonoContext *ctx, gpointer data); @@ -76,10 +81,20 @@ struct _Il2CppMonoTypeNameParse void *il2cppTypeNameParseInfo; }; +struct _Il2CppMonoDebugOptions +{ + gboolean native_debugger_break; +}; + +struct _Il2CppEmptyStruct +{ + int dummy; +}; + TYPED_HANDLE_DECL (MonoObject); TYPED_HANDLE_DECL (MonoReflectionAssembly); Il2CppMonoDefaults il2cpp_mono_defaults; -MonoDebugOptions il2cpp_mono_debug_options; +Il2CppMonoDebugOptions il2cpp_mono_debug_options; typedef void (*Il2CppMonoProfileFunc) (MonoProfiler *prof); typedef void (*Il2CppMonoProfileAppDomainFunc) (MonoProfiler *prof, MonoDomain *domain); diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index ed71752c12d1..393adef62961 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -50,6 +50,8 @@ #define MonoRuntimeExceptionHandlingCallbacks Il2CppMonoRuntimeExceptionHandlingCallbacks #define debug_options il2cpp_mono_debug_options #define MonoTypeNameParse Il2CppMonoTypeNameParse +#define MonoDebugOptions Il2CppMonoDebugOptions +#define MonoLMF Il2CppMonoLMF #define mono_image_get_entry_point il2cpp_mono_image_get_entry_point #define mono_image_get_filename il2cpp_mono_image_get_filename @@ -258,6 +260,9 @@ #define mono_get_string_class il2cpp_mono_get_string_class +#define MONO_MAX_IREGS 1 +#define NOT_IMPLEMENTED do { g_assert_not_reached (); } while (0) + MonoMethod* il2cpp_mono_image_get_entry_point (MonoImage *image); const char* il2cpp_mono_image_get_filename (MonoImage *image); const char* il2cpp_mono_image_get_guid (MonoImage *image); diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index e8ae454f227b..ba54dc9bb9e2 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -40,7 +40,6 @@ extern "C" { #include #include #include -#include #include #include "il2cpp-c-types.h" #include @@ -970,7 +969,7 @@ MonoMethod* il2cpp_mono_marshal_method_from_wrapper(MonoMethod* wrapper) return NULL; } -MonoDebugOptions* il2cpp_mini_get_debug_options() +Il2CppMonoDebugOptions* il2cpp_mini_get_debug_options() { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; @@ -982,13 +981,13 @@ gpointer il2cpp_mono_jit_find_compiled_method_with_jit_info(MonoDomain* domain, return 0; } -MonoLMF** il2cpp_mono_get_lmf_addr() +Il2CppMonoLMF** il2cpp_mono_get_lmf_addr() { IL2CPP_ASSERT(0 && "This method is not yet implemented"); return NULL; } -void il2cpp_mono_set_lmf(MonoLMF* lmf) +void il2cpp_mono_set_lmf(Il2CppMonoLMF* lmf) { IL2CPP_ASSERT(0 && "This method is not yet implemented"); } From 3aa9801bfcadb522dfcb5a222974133f5416baa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tautvydas=20=C5=BDilys?= Date: Fri, 23 Feb 2018 13:21:50 -0800 Subject: [PATCH 150/582] Poke various parts of Mono until libil2cpp with debugger compiles on UWP and Xbox One. --- mono/eglib/glib.h | 4 +++ mono/eglib/gpath.c | 8 +++-- mono/eglib/gunicode-win32-uwp.c | 4 +-- mono/eglib/gunicode-win32.c | 4 +-- mono/metadata/threads.c | 9 ++++++ mono/mini/debugger-agent.c | 6 ++-- mono/mini/il2cpp-compat.h | 4 +++ mono/utils/atomic.h | 2 +- mono/utils/dlmalloc.c | 2 ++ mono/utils/mono-context.c | 22 +++++++++++++ mono/utils/mono-dl-windows-uwp.c | 6 ++-- mono/utils/mono-dl-windows.c | 8 +++++ mono/utils/mono-filemap.c | 2 +- mono/utils/mono-hwcap-arm.c | 25 +++++++++++++++ mono/utils/mono-os-wait-win32-uwp.c | 6 ++-- mono/utils/mono-os-wait-win32.c | 5 +++ mono/utils/mono-stdlib.c | 11 ++++++- mono/utils/mono-threads-debug.h | 8 +++++ mono/utils/mono-threads-windows.c | 48 +++++++++++++++++------------ mono/utils/mono-threads.h | 2 +- mono/utils/mono-tls.h | 13 ++++++++ mono/utils/w32api.h | 2 +- 22 files changed, 162 insertions(+), 39 deletions(-) diff --git a/mono/eglib/glib.h b/mono/eglib/glib.h index 9e3c61fe8b39..c7a8b972cef6 100644 --- a/mono/eglib/glib.h +++ b/mono/eglib/glib.h @@ -889,7 +889,11 @@ gboolean g_file_test (const gchar *filename, GFileTest test); #define g_open open #define g_rename rename #define g_stat stat +#ifdef G_OS_WIN32 +#define g_unlink _unlink +#else #define g_unlink unlink +#endif #define g_fopen fopen #define g_lstat lstat #define g_rmdir rmdir diff --git a/mono/eglib/gpath.c b/mono/eglib/gpath.c index 6448b0bac18d..01113ee0ce69 100644 --- a/mono/eglib/gpath.c +++ b/mono/eglib/gpath.c @@ -252,7 +252,11 @@ g_find_program_in_path (const gchar *program) x = NULL; probe_path = g_build_path (G_DIR_SEPARATOR_S, l, program, NULL); #if !defined(NO_HAVE_ACCESS) - if (access (probe_path, X_OK) == 0){ /* FIXME: on windows this is just a read permissions test */ +#ifdef G_OS_WIN32 + if (_access (probe_path, X_OK) == 0){ /* FIXME: on windows this is just a read permissions test */ +#else + if (access(probe_path, X_OK) == 0) { +#endif g_free (curdir); g_free (p); return probe_path; @@ -268,7 +272,7 @@ g_find_program_in_path (const gchar *program) program_exe = g_strjoin(NULL,program,suffix_list[listx],NULL); probe_path = g_build_path (G_DIR_SEPARATOR_S, l, program_exe, NULL); #if !defined(NO_HAVE_ACCESS) - if (access (probe_path, X_OK) == 0){ /* FIXME: on windows this is just a read permissions test */ + if (_access (probe_path, X_OK) == 0){ /* FIXME: on windows this is just a read permissions test */ g_free (curdir); g_free (p); g_free (program_exe); diff --git a/mono/eglib/gunicode-win32-uwp.c b/mono/eglib/gunicode-win32-uwp.c index ef36ffc17f51..359ed2458431 100644 --- a/mono/eglib/gunicode-win32-uwp.c +++ b/mono/eglib/gunicode-win32-uwp.c @@ -19,9 +19,9 @@ g_get_charset (G_CONST_RETURN char **charset) { if (my_charset == NULL) { static char buf [14]; - CPINFOEXA cp_info; + CPINFOEXW cp_info; - GetCPInfoExA (CP_ACP, 0, &cp_info); + GetCPInfoExW (CP_ACP, 0, &cp_info); sprintf (buf, "CP%u", cp_info.CodePage); my_charset = buf; is_utf8 = FALSE; diff --git a/mono/eglib/gunicode-win32.c b/mono/eglib/gunicode-win32.c index a35cfcd48c12..993583629ca3 100644 --- a/mono/eglib/gunicode-win32.c +++ b/mono/eglib/gunicode-win32.c @@ -7,7 +7,7 @@ #include #include -#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_XBOXONE_WINAPI_SUPPORT) #define CODESET 1 #include @@ -30,7 +30,7 @@ g_get_charset (G_CONST_RETURN char **charset) return is_utf8; } -#else /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */ +#else /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_XBOXONE_WINAPI_SUPPORT) */ #ifdef _MSC_VER // Quiet Visual Studio linker warning, LNK4221, in cases when this source file intentional ends up empty. diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index 9f77e1e7a25e..367fb67fc560 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -1986,6 +1986,13 @@ ves_icall_System_Threading_WaitHandle_Wait_internal (gpointer *handles, gint32 n return map_native_wait_result_to_managed (ret, numhandles); } +/* + * UWP doesn't support SignalObjectAndWait until SDK version 15063. Our minspec currently is 10240. + * Since we don't care about running Mono runtime for now, let's just disable this icall and reevaluate + * in some months when we have to get libmono with IL2CPP up & running + */ +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) + gint32 ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (gpointer toSignal, gpointer toWait, gint32 ms, MonoError *error) { @@ -2013,6 +2020,8 @@ ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (gpointer toSignal, return map_native_wait_result_to_managed (ret, 1); } +#endif + gint32 ves_icall_System_Threading_Interlocked_Increment_Int (gint32 *location) { return mono_atomic_inc_i32 (location); diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 8039880adf9c..8f7ec4fc6aa1 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -636,8 +636,6 @@ typedef struct ReplyPacket { Buffer *data; } ReplyPacket; -#define DEBUG(level,s) do { if (G_UNLIKELY ((level) <= log_level)) { s; fflush (log_file); } } while (0) - #ifdef HOST_ANDROID #define DEBUG_PRINTF(level, ...) do { if (G_UNLIKELY ((level) <= log_level)) { g_print (__VA_ARGS__); } } while (0) #else @@ -1465,7 +1463,11 @@ socket_transport_connect (const char *address) break; /* Success */ MONO_ENTER_GC_SAFE; +#ifdef HOST_WIN32 + closesocket (sfd); +#else close (sfd); +#endif MONO_EXIT_GC_SAFE; } diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index 393adef62961..98a748f6cdef 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -239,6 +239,7 @@ #define mono_method_get_class il2cpp_method_get_class #define mono_class_get_image il2cpp_class_get_image #define mono_class_get_interfaces il2cpp_class_get_interfaces +#undef MONO_CLASS_IS_INTERFACE #define MONO_CLASS_IS_INTERFACE il2cpp_class_is_interface #define mono_image_get_assembly il2cpp_image_get_assembly #define mono_image_get_name il2cpp_image_get_name @@ -252,10 +253,13 @@ #define mono_method_get_token il2cpp_method_get_token #define mono_method_is_generic il2cpp_method_is_generic #define mono_method_is_inflated il2cpp_method_is_inflated +#undef mono_field_is_deleted #define mono_field_is_deleted il2cpp_field_is_deleted #define mono_domain_get_assemblies_iter il2cpp_domain_get_assemblies_iter +#undef mono_domain_assemblies_lock #define mono_domain_assemblies_lock +#undef mono_domain_assemblies_unlock #define mono_domain_assemblies_unlock #define mono_get_string_class il2cpp_mono_get_string_class diff --git a/mono/utils/atomic.h b/mono/utils/atomic.h index bbf79ebea4ab..c26f65b5e938 100755 --- a/mono/utils/atomic.h +++ b/mono/utils/atomic.h @@ -167,7 +167,7 @@ static inline void mono_atomic_store_i8 (volatile gint8 *dst, gint8 val) { #if (_MSC_VER >= 1600) - InterlockedExchange8 ((CHAR volatile *)dst, (CHAR)val); + _InterlockedExchange8 ((CHAR volatile *)dst, (CHAR)val); #else *dst = val; mono_memory_barrier (); diff --git a/mono/utils/dlmalloc.c b/mono/utils/dlmalloc.c index 2f14c9e6a76d..39850671934f 100644 --- a/mono/utils/dlmalloc.c +++ b/mono/utils/dlmalloc.c @@ -461,7 +461,9 @@ DEFAULT_MMAP_THRESHOLD default: 256K #endif /* _WIN32 */ #endif /* WIN32 */ #ifdef WIN32 +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN +#endif #include #define HAVE_MMAP 1 #define HAVE_MORECORE 0 diff --git a/mono/utils/mono-context.c b/mono/utils/mono-context.c index 4dfbbb34163e..f4266854876f 100644 --- a/mono/utils/mono-context.c +++ b/mono/utils/mono-context.c @@ -395,11 +395,24 @@ mono_monoctx_to_sigctx (MonoContext *mctx, void *ctx) #include #include +#ifdef HOST_WIN32 +#include +#endif + void mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx) { #ifdef MONO_CROSS_COMPILE g_assert_not_reached (); +#elif defined(HOST_WIN32) + CONTEXT *context = (CONTEXT*)sigctx; + + mctx->pc = context->Pc; + mctx->cpsr = context->Cpsr; + memcpy (&mctx->regs, &context->R0, sizeof (DWORD) * 16); + + /* Why are we only copying 16 registers?! There are 32! */ + memcpy (&mctx->fregs, &context->D, sizeof (double) * 16); #else arm_ucontext *my_uc = sigctx; @@ -418,6 +431,15 @@ mono_monoctx_to_sigctx (MonoContext *mctx, void *ctx) { #ifdef MONO_CROSS_COMPILE g_assert_not_reached (); +#elif defined(HOST_WIN32) + CONTEXT *context = (CONTEXT*)ctx; + + context->Pc = mctx->pc; + context->Cpsr = mctx->cpsr; + memcpy (&context->R0, &mctx->regs, sizeof (DWORD) * 16); + + /* Why are we only copying 16 registers?! There are 32! */ + memcpy (&context->D, &mctx->fregs, sizeof (double) * 16); #else arm_ucontext *my_uc = ctx; diff --git a/mono/utils/mono-dl-windows-uwp.c b/mono/utils/mono-dl-windows-uwp.c index e3e5ddf7b6ad..f88b81c5ce5d 100644 --- a/mono/utils/mono-dl-windows-uwp.c +++ b/mono/utils/mono-dl-windows-uwp.c @@ -9,7 +9,7 @@ #include #include "mono/utils/mono-compiler.h" -#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) +#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT | HAVE_XBOXONE_WINAPI_SUPPORT) #include #include "mono/utils/mono-dl-windows-internals.h" @@ -37,7 +37,7 @@ mono_dl_current_error_string (void) return ret; } -#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */ +#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT | HAVE_XBOXONE_WINAPI_SUPPORT) */ MONO_EMPTY_SOURCE_FILE (mono_dl_windows_uwp); -#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */ +#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT | HAVE_XBOXONE_WINAPI_SUPPORT) */ diff --git a/mono/utils/mono-dl-windows.c b/mono/utils/mono-dl-windows.c index ab26660fed43..9ebb14b8bf70 100644 --- a/mono/utils/mono-dl-windows.c +++ b/mono/utils/mono-dl-windows.c @@ -55,7 +55,11 @@ mono_dl_open_file (const char *file, int flags) #endif guint32 last_error = 0; +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_XBOXONE_WINAPI_SUPPORT) hModule = LoadLibrary (file_utf16); +#else + hModule = LoadPackagedLibrary (file_utf16, NULL); +#endif if (!hModule) last_error = GetLastError (); @@ -68,7 +72,11 @@ mono_dl_open_file (const char *file, int flags) if (!hModule) SetLastError (last_error); } else { +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) hModule = GetModuleHandle (NULL); +#else + g_assert(0 && "Not supported"); +#endif } return hModule; } diff --git a/mono/utils/mono-filemap.c b/mono/utils/mono-filemap.c index f03a0c263f0d..d96ae877869d 100644 --- a/mono/utils/mono-filemap.c +++ b/mono/utils/mono-filemap.c @@ -80,7 +80,7 @@ mono_file_map_fd (MonoFileMap *fmap) { if (file_fd_func) return file_fd_func(fmap); #ifdef WIN32 - return fileno ((FILE*)fmap); + return _fileno ((FILE*)fmap); #else return (int)(size_t)fmap; #endif diff --git a/mono/utils/mono-hwcap-arm.c b/mono/utils/mono-hwcap-arm.c index a44f43ac9e74..7b34c8502e0c 100644 --- a/mono/utils/mono-hwcap-arm.c +++ b/mono/utils/mono-hwcap-arm.c @@ -94,6 +94,31 @@ mono_hwcap_arch_init (void) } /* TODO: Find a way to detect features like Thumb and VFP. */ +#elif defined (_WIN32) + /* From MSDN: + * Windows on ARM presumes that it is running on an ARMv7 architecture at all times. + * Floating-point support in the form of VFPv3-D32 or later must be present in hardware. + * The VFP must support both single-precision and double-precision floating-point in hardware. + * + * The Windows runtime does not support emulation of floating-point to enable running on non-VFP hardware. + * Advanced SIMD Extensions (NEON) support—this includes both integer and floating-point operations—must also be present in hardware. + * No run-time support for emulation is provided. + * + * Integer divide support (UDIV/SDIV) is strongly recommended but not required. + * Platforms that lack integer divide support may incur a performance penalty because + * these operations have to be trapped and possibly patched. + * + * The instruction set for Windows on ARM is strictly limited to Thumb-2. + * All code executed on this platform is expected to start and remain in Thumb mode at all times. + */ + mono_hwcap_arm_is_v5 = TRUE; + mono_hwcap_arm_is_v6 = TRUE; + mono_hwcap_arm_is_v7 = TRUE; + mono_hwcap_arm_has_vfp = TRUE; + mono_hwcap_arm_has_vfp3 = TRUE; + mono_hwcap_arm_has_vfp3_d16 = TRUE; + mono_hwcap_arm_has_thumb = TRUE; + mono_hwcap_arm_has_thumb2 = TRUE; #else /* We can't use the auxiliary vector on Android due to * permissions, so fall back to /proc/cpuinfo. We also diff --git a/mono/utils/mono-os-wait-win32-uwp.c b/mono/utils/mono-os-wait-win32-uwp.c index bb8260003a37..d17d9ed559c4 100644 --- a/mono/utils/mono-os-wait-win32-uwp.c +++ b/mono/utils/mono-os-wait-win32-uwp.c @@ -9,7 +9,7 @@ #include #include "mono/utils/mono-compiler.h" -#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) +#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT | HAVE_XBOXONE_WINAPI_SUPPORT) #include DWORD @@ -21,7 +21,7 @@ mono_win32_msg_wait_for_multiple_objects_ex (DWORD count, CONST HANDLE *handles, return WAIT_FAILED; } -#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */ +#else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT | HAVE_XBOXONE_WINAPI_SUPPORT) */ MONO_EMPTY_SOURCE_FILE (mono_os_wait_win32_uwp); -#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */ +#endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT | HAVE_XBOXONE_WINAPI_SUPPORT) */ diff --git a/mono/utils/mono-os-wait-win32.c b/mono/utils/mono-os-wait-win32.c index 43ca85e3f5c8..9f84a34da905 100644 --- a/mono/utils/mono-os-wait-win32.c +++ b/mono/utils/mono-os-wait-win32.c @@ -152,6 +152,9 @@ mono_win32_wait_for_multiple_objects_ex (DWORD count, CONST HANDLE *handles, BOO return result; } +/* See comment above ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal */ +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) + DWORD mono_win32_signal_object_and_wait (HANDLE toSignal, HANDLE toWait, DWORD timeout, BOOL alertable) { @@ -173,6 +176,8 @@ mono_win32_signal_object_and_wait (HANDLE toSignal, HANDLE toWait, DWORD timeout return result; } +#endif + #if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) DWORD mono_win32_msg_wait_for_multiple_objects_ex (DWORD count, CONST HANDLE *handles, DWORD timeout, DWORD wakeMask, DWORD flags) diff --git a/mono/utils/mono-stdlib.c b/mono/utils/mono-stdlib.c index 3685dcb996d4..e65f9645982f 100644 --- a/mono/utils/mono-stdlib.c +++ b/mono/utils/mono-stdlib.c @@ -35,7 +35,12 @@ mono_mkstemp (char *templ) len = strlen (templ); do { +#if HOST_WIN32 + t = _mktemp (templ); +#else t = mktemp (templ); +#endif + if (t == NULL) { errno = EINVAL; return -1; @@ -45,7 +50,11 @@ mono_mkstemp (char *templ) return -1; } - ret = open (templ, O_RDWR | O_BINARY | O_CREAT | O_EXCL, 0600); +#if HOST_WIN32 + ret = _open (templ, O_RDWR | O_BINARY | O_CREAT | O_EXCL, 0600); +#else + ret = open(templ, O_RDWR | O_BINARY | O_CREAT | O_EXCL, 0600); +#endif if (ret == -1) { if (errno != EEXIST) return -1; diff --git a/mono/utils/mono-threads-debug.h b/mono/utils/mono-threads-debug.h index c14acab00e84..36742b3db9b6 100644 --- a/mono/utils/mono-threads-debug.h +++ b/mono/utils/mono-threads-debug.h @@ -6,11 +6,19 @@ #define __MONO_UTILS_MONO_THREADS_DEBUG_H__ /* Logging - enable them below if you need specific logging for the category you need */ +#ifdef HOST_WIN32 +#define MOSTLY_ASYNC_SAFE_PRINTF(...) do { \ + char __buff[1024]; __buff [0] = '\0'; \ + g_snprintf (__buff, sizeof (__buff), __VA_ARGS__); \ + _write (1, __buff, (guint32)strlen (__buff)); \ +} while (0) +#else #define MOSTLY_ASYNC_SAFE_PRINTF(...) do { \ char __buff[1024]; __buff [0] = '\0'; \ g_snprintf (__buff, sizeof (__buff), __VA_ARGS__); \ write (1, __buff, (guint32)strlen (__buff)); \ } while (0) +#endif #if 1 #define THREADS_DEBUG(...) diff --git a/mono/utils/mono-threads-windows.c b/mono/utils/mono-threads-windows.c index 5a55af20570b..18e83f545c76 100644 --- a/mono/utils/mono-threads-windows.c +++ b/mono/utils/mono-threads-windows.c @@ -29,13 +29,12 @@ mono_threads_suspend_begin_async_suspend (MonoThreadInfo *info, gboolean interru HANDLE handle; DWORD result; - handle = OpenThread (THREAD_ALL_ACCESS, FALSE, id); + handle = info->native_handle; g_assert (handle); result = SuspendThread (handle); THREADS_SUSPEND_DEBUG ("SUSPEND %p -> %d\n", (void*)id, ret); if (result == (DWORD)-1) { - CloseHandle (handle); return FALSE; } @@ -48,7 +47,6 @@ mono_threads_suspend_begin_async_suspend (MonoThreadInfo *info, gboolean interru CONTEXT context; context.ContextFlags = CONTEXT_INTEGER | CONTEXT_CONTROL; if (!GetThreadContext (handle, &context)) { - CloseHandle (handle); return FALSE; } @@ -57,7 +55,6 @@ mono_threads_suspend_begin_async_suspend (MonoThreadInfo *info, gboolean interru mono_threads_add_to_pending_operation_set (info); result = ResumeThread (handle); g_assert (result == 1); - CloseHandle (handle); THREADS_SUSPEND_DEBUG ("FAILSAFE RESUME/1 %p -> %d\n", (void*)id, 0); //XXX interrupt_kernel doesn't make sense in this case as the target is not in a syscall return TRUE; @@ -71,7 +68,6 @@ mono_threads_suspend_begin_async_suspend (MonoThreadInfo *info, gboolean interru THREADS_SUSPEND_DEBUG ("FAILSAFE RESUME/2 %p -> %d\n", (void*)info->native_handle, 0); } - CloseHandle (handle); return TRUE; } @@ -86,15 +82,9 @@ mono_threads_suspend_check_suspend_result (MonoThreadInfo *info) void mono_threads_suspend_abort_syscall (MonoThreadInfo *info) { - DWORD id = mono_thread_info_get_tid (info); - HANDLE handle; - - handle = OpenThread (THREAD_ALL_ACCESS, FALSE, id); - g_assert (handle); - - mono_win32_abort_wait (info, handle, id); - - CloseHandle (handle); + DWORD id = mono_thread_info_get_tid(info); + g_assert (info->native_handle); + mono_win32_abort_wait (info, info->native_handle, id); } gboolean @@ -104,9 +94,10 @@ mono_threads_suspend_begin_async_resume (MonoThreadInfo *info) HANDLE handle; DWORD result; - handle = OpenThread (THREAD_ALL_ACCESS, FALSE, id); + handle = info->native_handle; g_assert (handle); - + +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) if (info->async_target) { MonoContext ctx; CONTEXT context; @@ -119,7 +110,6 @@ mono_threads_suspend_begin_async_resume (MonoThreadInfo *info) context.ContextFlags = CONTEXT_INTEGER | CONTEXT_CONTROL; if (!GetThreadContext (handle, &context)) { - CloseHandle (handle); return FALSE; } @@ -131,13 +121,14 @@ mono_threads_suspend_begin_async_resume (MonoThreadInfo *info) context.ContextFlags = CONTEXT_INTEGER | CONTEXT_CONTROL; res = SetThreadContext (handle, &context); if (!res) { - CloseHandle (handle); return FALSE; } } +#else + g_assert(0 && "Not implemented due to lack of SetThreadContext"); +#endif result = ResumeThread (handle); - CloseHandle (handle); return result != (DWORD)-1; } @@ -146,11 +137,20 @@ mono_threads_suspend_begin_async_resume (MonoThreadInfo *info) void mono_threads_suspend_register (MonoThreadInfo *info) { + BOOL success; + HANDLE currentThreadHandle = NULL; + + success = DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), ¤tThreadHandle, 0, FALSE, DUPLICATE_SAME_ACCESS); + g_assert(success && "Failed to duplicate current thread handle"); + + info->native_handle = currentThreadHandle; } void mono_threads_suspend_free (MonoThreadInfo *info) { + CloseHandle(info->native_handle); + info->native_handle = NULL; } void @@ -242,6 +242,12 @@ mono_native_thread_join_handle (HANDLE thread_handle, gboolean close_handle) return res != WAIT_FAILED; } +/* + * Can't OpenThread on UWP until SDK 15063 (our minspec today is 10240), + * but this function doesn't seem to be used on Windows anyway + */ +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) + gboolean mono_native_thread_join (MonoNativeThreadId tid) { @@ -253,6 +259,8 @@ mono_native_thread_join (MonoNativeThreadId tid) return mono_native_thread_join_handle (handle, TRUE); } +#endif + #if HAVE_DECL___READFSDWORD==0 static MONO_ALWAYS_INLINE unsigned long long __readfsdword (unsigned long offset) @@ -269,7 +277,7 @@ void mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize) { MEMORY_BASIC_INFORMATION meminfo; -#ifdef _WIN64 +#if defined(_WIN64) || defined(_M_ARM) /* win7 apis */ NT_TIB* tib = (NT_TIB*)NtCurrentTeb(); guint8 *stackTop = (guint8*)tib->StackBase; diff --git a/mono/utils/mono-threads.h b/mono/utils/mono-threads.h index 2cc3d54ff4fd..a25973253512 100644 --- a/mono/utils/mono-threads.h +++ b/mono/utils/mono-threads.h @@ -151,7 +151,7 @@ typedef struct _MonoThreadInfoInterruptToken MonoThreadInfoInterruptToken; typedef struct { MonoLinkedListSetNode node; guint32 small_id; /*Used by hazard pointers */ - MonoNativeThreadHandle native_handle; /* Valid on mach and android */ + MonoNativeThreadHandle native_handle; /* Valid on mach, android and Windows */ int thread_state; /*Tells if this thread was created by the runtime or not.*/ diff --git a/mono/utils/mono-tls.h b/mono/utils/mono-tls.h index b87ede880ba5..a7950d8f5b2a 100644 --- a/mono/utils/mono-tls.h +++ b/mono/utils/mono-tls.h @@ -36,6 +36,19 @@ typedef enum { #include +/* +* These APIs were added back in Windows SDK 14393. Let's redirect them to +* Fls* APIs on older SDKs just like Windows 8.1 headers do +*/ +#if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) +#if WINDOWS_SDK_BUILD_VERSION < 14393 +#define TlsAlloc() FlsAlloc(NULL) +#define TlsGetValue FlsGetValue +#define TlsSetValue FlsSetValue +#define TlsFree FlsFree +#endif +#endif + #define MonoNativeTlsKey DWORD #define mono_native_tls_alloc(key,destructor) ((*(key) = TlsAlloc ()) != TLS_OUT_OF_INDEXES && destructor == NULL) #define mono_native_tls_free TlsFree diff --git a/mono/utils/w32api.h b/mono/utils/w32api.h index 1d582fb945f8..45544c78fcdd 100644 --- a/mono/utils/w32api.h +++ b/mono/utils/w32api.h @@ -51,7 +51,7 @@ typedef struct pollfd { } WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD; #endif -#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) +#if G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT | HAVE_UWP_WINAPI_SUPPORT) #include #endif From 58faedf7d7fd1baa244e6c805d5ace19c1c503ac Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Fri, 23 Feb 2018 14:06:49 -0500 Subject: [PATCH 151/582] Use the Unity PAL for the IL2CPP debugger Change the IL2CPP manager debugger to use the Unity PAL, so the debugger can work on all platforms that IL2CPP supports. --- mono/metadata/w32process-unity.c | 10 +++- mono/metadata/w32socket-unity.c | 15 +++++- mono/mini/il2cpp-c-types.h | 2 +- mono/utils/mono-threads-unity.c | 8 ++-- mono/utils/networking-unity.c | 80 ++++++++++++++++++++++++++++++-- 5 files changed, 104 insertions(+), 11 deletions(-) diff --git a/mono/metadata/w32process-unity.c b/mono/metadata/w32process-unity.c index fdc276faa29e..0b79fe252865 100644 --- a/mono/metadata/w32process-unity.c +++ b/mono/metadata/w32process-unity.c @@ -3,6 +3,14 @@ #if defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS) +#ifdef HOST_WIN32 +typedef struct { + gpointer lpBaseOfDll; + guint32 SizeOfImage; + gpointer EntryPoint; +} MODULEINFO; +#endif + void mono_w32process_init (void) { @@ -108,7 +116,7 @@ ves_icall_Microsoft_Win32_NativeMethods_GetCurrentProcess (void) } gboolean -mono_w32process_get_fileversion_info (gunichar2 *filename, guint32 handle, guint32 len, gpointer data) +mono_w32process_get_fileversion_info (gunichar2 *filename, gpointer* data) { g_assert(0 && "This function is not yet implemented for the Unity platform."); return FALSE; diff --git a/mono/metadata/w32socket-unity.c b/mono/metadata/w32socket-unity.c index 636710383552..38729c773d95 100644 --- a/mono/metadata/w32socket-unity.c +++ b/mono/metadata/w32socket-unity.c @@ -3,15 +3,26 @@ #if defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS) +#ifdef NO_HAVE_TRANSMIT_FILE_BUFFERS + +typedef struct { + gpointer Head; + guint32 HeadLength; + gpointer Tail; + guint32 TailLength; +} TRANSMIT_FILE_BUFFERS; + +#endif + gboolean -ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto) +ves_icall_System_Net_Sockets_Socket_SupportPortReuse (MonoProtocolType proto, MonoError* error) { g_assert(0 && "This function is not yet implemented for the Unity platform."); return FALSE; } MonoBoolean -ves_icall_System_Net_Dns_GetHostByName_internal (MonoString *host, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list, gint32 hint) +ves_icall_System_Net_Dns_GetHostByName_internal (MonoStringHandle host, MonoStringHandleOut h_name, MonoArrayHandleOut h_aliases, MonoArrayHandleOut h_addr_list, gint32 hint, MonoError *error) { g_assert(0 && "This function is not yet implemented for the Unity platform."); return FALSE; diff --git a/mono/mini/il2cpp-c-types.h b/mono/mini/il2cpp-c-types.h index 53f8a17e8b6a..627d0cc8366d 100644 --- a/mono/mini/il2cpp-c-types.h +++ b/mono/mini/il2cpp-c-types.h @@ -117,4 +117,4 @@ void* il2cpp_gc_alloc_fixed(size_t size); void il2cpp_gc_free_fixed(void* address); const char* il2cpp_domain_get_name(MonoDomain* domain); -#endif \ No newline at end of file +#endif diff --git a/mono/utils/mono-threads-unity.c b/mono/utils/mono-threads-unity.c index b2bacccc251a..89ef83535cbb 100644 --- a/mono/utils/mono-threads-unity.c +++ b/mono/utils/mono-threads-unity.c @@ -2,6 +2,8 @@ #if defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS) +#include "Thread-c-api.h" + void mono_threads_suspend_init (void) { @@ -99,15 +101,13 @@ mono_threads_platform_create_thread (MonoThreadStart thread_fn, gpointer thread_ MonoNativeThreadId mono_native_thread_id_get (void) { - g_assert(0 && "This function is not yet implemented for the Unity platform."); - return 0; + return (MonoNativeThreadId)UnityPalGetCurrentThreadId(); } gboolean mono_native_thread_id_equals (MonoNativeThreadId id1, MonoNativeThreadId id2) { - g_assert(0 && "This function is not yet implemented for the Unity platform."); - return FALSE; + return id1 == id2; } gboolean diff --git a/mono/utils/networking-unity.c b/mono/utils/networking-unity.c index f37b3d662090..105868779981 100644 --- a/mono/utils/networking-unity.c +++ b/mono/utils/networking-unity.c @@ -1,12 +1,86 @@ +#include +#include + + #include #if defined(PLATFORM_UNITY) && defined(UNITY_USE_PLATFORM_STUBS) +#include "Socket-c-api.h" + +static void +add_hostent(MonoAddressInfo *info, int flags, const char* name, gint family, char** aliases, void** addresses, int32_t addressSize) +{ + MonoAddressEntry *cur, *prev = info->entries; + int idx = 0; + int address_length = 0; + + if (!info->aliases) + info->aliases = g_strdupv(aliases); + + while (addresses[idx]) { + cur = g_new0(MonoAddressEntry, 1); + if (prev) + prev->next = cur; + else + info->entries = cur; + + if (flags & MONO_HINT_CANONICAL_NAME && name) + cur->canonical_name = g_strdup(name); + + cur->family = family; + cur->socktype = SOCK_STREAM; + cur->protocol = 0; /* Zero means the default stream protocol */ + address_length = addressSize; + cur->address_len = address_length; + memcpy(&cur->address, addresses[idx], address_length); + + prev = cur; + ++idx; + } +} + +static void free_null_terminated_array (void** array) +{ + if (array != NULL) + { + int i = 0; + while (array[i] != NULL) + { + g_free(array[i]); + i++; + } + } + g_free(array); +} + int -mono_get_address_info (const char *hostname, int port, int flags, MonoAddressInfo **result) +mono_get_address_info(const char *hostname, int port, int flags, MonoAddressInfo **result) { - g_assert(0 && "This function is not yet implemented for the Unity platform."); - return 0; + MonoAddressInfo *addr_info; + addr_info = g_new0(MonoAddressInfo, 1); + + char* name; + gint family; + char** aliases; + void** addresses; + int32_t addressSize; + + if (UnityPalGetHostByName(hostname, &name, &family, &aliases, &addresses, &addressSize) == kWaitStatusSuccess) + add_hostent(addr_info, flags, name, family, aliases, addresses, addressSize); + + g_free(name); + free_null_terminated_array(aliases); + free_null_terminated_array(addresses); + + if (!addr_info->entries) { + *result = NULL; + mono_free_address_info(addr_info); + return 1; + } + + *result = addr_info; + return 0; } void * From 24b257efcfd04e62b99cc7264e04a2e5bd4560e3 Mon Sep 17 00:00:00 2001 From: Eneko Osia Date: Wed, 28 Feb 2018 15:58:43 +0100 Subject: [PATCH 152/582] [metadata] expose mono type attrs --- mono/metadata/metadata.c | 12 ++++++++++++ mono/metadata/metadata.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/mono/metadata/metadata.c b/mono/metadata/metadata.c index 378ceb4dc139..b18ba6cfa2f8 100644 --- a/mono/metadata/metadata.c +++ b/mono/metadata/metadata.c @@ -6607,6 +6607,18 @@ mono_type_is_byref (MonoType *type) return type->byref; } +/** + * mono_type_get_attrs: + * @type: the MonoType operated on + * + * Returns: the param attributes. + */ +uint16_t +mono_type_get_attrs (MonoType *type) +{ + return type->attrs; +} + /** * mono_type_get_type: * \param type the \c MonoType operated on diff --git a/mono/metadata/metadata.h b/mono/metadata/metadata.h index 874852c9b076..ee07f991e9c9 100644 --- a/mono/metadata/metadata.h +++ b/mono/metadata/metadata.h @@ -335,6 +335,9 @@ typedef enum { MONO_API mono_bool mono_type_is_byref (MonoType *type); +MONO_API uint32_t +mono_type_get_attrs (MonoType *type); + MONO_API int mono_type_get_type (MonoType *type); From 14bc7f50f17dba68b094e0134b57c5bd7fc78026 Mon Sep 17 00:00:00 2001 From: Eneko Osia Date: Wed, 28 Feb 2018 16:25:51 +0100 Subject: [PATCH 153/582] [metadata] change return type in mono_type_get_attrs function --- mono/metadata/metadata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mono/metadata/metadata.h b/mono/metadata/metadata.h index ee07f991e9c9..236028f4ba9a 100644 --- a/mono/metadata/metadata.h +++ b/mono/metadata/metadata.h @@ -335,7 +335,7 @@ typedef enum { MONO_API mono_bool mono_type_is_byref (MonoType *type); -MONO_API uint32_t +MONO_API uint16_t mono_type_get_attrs (MonoType *type); MONO_API int From 2c936e019375f0fa0d836fa92d32db76e201a3f4 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 20 Feb 2018 16:10:55 -0500 Subject: [PATCH 154/582] Use proper sized integer for ioctlsocket on Win32 (case 990979) Windows expects a 32-bit unsigned long in this API. Previously we passed a 64-bit value and the actual amount was stored in the wrong bits. --- mono/metadata/w32socket-win32.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mono/metadata/w32socket-win32.c b/mono/metadata/w32socket-win32.c index 07ca648260c2..ff89617d270d 100644 --- a/mono/metadata/w32socket-win32.c +++ b/mono/metadata/w32socket-win32.c @@ -330,8 +330,10 @@ gint mono_w32socket_get_available (SOCKET sock, guint64 *amount) { gint ret; + u_long amount_long = 0; MONO_ENTER_GC_SAFE; - ret = ioctlsocket (sock, FIONREAD, (int*) amount); + ret = ioctlsocket (sock, FIONREAD, &amount_long); + *amount = amount_long; MONO_EXIT_GC_SAFE; return ret; } From 3d4bb3945d186405c9bbb0d38434474bde72f1c1 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Sun, 17 Dec 2017 09:44:12 -0500 Subject: [PATCH 155/582] [bcl] Allow conversion from enums and their basetypes in both directions with Delegate.CreateDelegate (). Fixes https://github.com/mono/mono/issues/6255. (case 977917) --- mcs/class/corlib/System/Delegate.cs | 2 ++ mcs/class/corlib/Test/System/DelegateTest.cs | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/mcs/class/corlib/System/Delegate.cs b/mcs/class/corlib/System/Delegate.cs index 48d78605147f..958b70ce816e 100644 --- a/mcs/class/corlib/System/Delegate.cs +++ b/mcs/class/corlib/System/Delegate.cs @@ -134,6 +134,8 @@ private static bool arg_type_match (Type delArgType, Type argType) { if (!match) { if (delArgType.IsEnum && Enum.GetUnderlyingType (delArgType) == argType) match = true; + else if (argType.IsEnum && Enum.GetUnderlyingType (argType) == delArgType) + match = true; } return match; diff --git a/mcs/class/corlib/Test/System/DelegateTest.cs b/mcs/class/corlib/Test/System/DelegateTest.cs index 26c449615b30..19a4bd894dc3 100644 --- a/mcs/class/corlib/Test/System/DelegateTest.cs +++ b/mcs/class/corlib/Test/System/DelegateTest.cs @@ -1395,6 +1395,23 @@ public void EnumBaseTypeConversion () { Assert.IsTrue (d (0, 0)); } + [Test] + public void EnumBaseTypeConversion2 () { + Func dm = EnumArg; + var d = (Func)Delegate.CreateDelegate (typeof (Func), dm.Method); + Assert.AreEqual (1, d (1)); + } + + public enum Enum22 { + none, + one, + two + } + + public static int EnumArg (Enum22 e) { + return (int)e; + } + #if !MONOTOUCH && !FULL_AOT_RUNTIME public static void DynInvokeWithClosedFirstArg (object a, object b) { From bc0ff2fa7d809ce91852b7afb5b72aaf8a5ec56d Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Fri, 22 Dec 2017 00:49:48 +0100 Subject: [PATCH 156/582] [mcs] Support implicit user conversion from nullable type without unwrapping. Fixes #60900 (case 970493) --- mcs/errors/cs0151-4.cs | 3 ++- mcs/errors/known-issues-net_4_x | 3 +++ mcs/mcs/convert.cs | 7 +++++++ mcs/tests/gtest-647.cs | 34 +++++++++++++++++++++++++++++++++ mcs/tests/ver-il-net_4_x.xml | 19 ++++++++++++++++-- 5 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 mcs/tests/gtest-647.cs diff --git a/mcs/errors/cs0151-4.cs b/mcs/errors/cs0151-4.cs index 0e45b1a9049d..c9e05589e4dd 100644 --- a/mcs/errors/cs0151-4.cs +++ b/mcs/errors/cs0151-4.cs @@ -1,5 +1,6 @@ // CS0151: A switch expression of type `S1?' cannot be converted to an integral type, bool, char, string, enum or nullable type -// Line: 24 +// Line: 25 +// Compiler options: -langversion:5 using System; diff --git a/mcs/errors/known-issues-net_4_x b/mcs/errors/known-issues-net_4_x index c9ed9317350d..54902e03e7be 100644 --- a/mcs/errors/known-issues-net_4_x +++ b/mcs/errors/known-issues-net_4_x @@ -14,6 +14,9 @@ # Parser problems cs0080.cs +# Undocumented switch governing rules +cs0151-4.cs NO ERROR + # Operators cs0457-2.cs cs0457.cs diff --git a/mcs/mcs/convert.cs b/mcs/mcs/convert.cs index f4012fbd2223..2fd5bcc55859 100644 --- a/mcs/mcs/convert.cs +++ b/mcs/mcs/convert.cs @@ -1232,6 +1232,13 @@ public static Expression UserDefinedConversion (ResolveContext rc, Expression so FindApplicableUserDefinedConversionOperators (rc, operators, source_type_expr, target_type, restr, ref candidates); } + if (source_type_expr == source && source_type.IsNullableType) { + operators = MemberCache.GetUserOperator (source_type.TypeArguments [0], Operator.OpType.Implicit, declared_only); + if (operators != null) { + FindApplicableUserDefinedConversionOperators (rc, operators, source_type_expr, target_type, restr, ref candidates); + } + } + if (!implicitOnly) { operators = MemberCache.GetUserOperator (source_type, Operator.OpType.Explicit, declared_only); if (operators != null) { diff --git a/mcs/tests/gtest-647.cs b/mcs/tests/gtest-647.cs new file mode 100644 index 000000000000..4aae641f85f2 --- /dev/null +++ b/mcs/tests/gtest-647.cs @@ -0,0 +1,34 @@ +using System; + +public class Program +{ + public static int Main () + { + int B = default (MyStruct?); + if (MyStruct.counter != 1) + return 1; + + switch (default (MyStruct?)) { + case 0: + break; + default: + return 2; + } + + if (MyStruct.counter != 2) + return 4; + + return 0; + } + + public struct MyStruct + { + public static int counter; + + public static implicit operator int (MyStruct? s) + { + ++counter; + return 0; + } + } +} \ No newline at end of file diff --git a/mcs/tests/ver-il-net_4_x.xml b/mcs/tests/ver-il-net_4_x.xml index 3d4d271f3db2..4180824c10d5 100644 --- a/mcs/tests/ver-il-net_4_x.xml +++ b/mcs/tests/ver-il-net_4_x.xml @@ -11064,7 +11064,7 @@ - 72 + 60 62 @@ -19505,7 +19505,7 @@ - 267 + 255 7 @@ -20144,6 +20144,21 @@ + + + + 99 + + + 7 + + + + + 22 + + + From ecef34cc4e69ab10ee3774060273fdc856c3b9f7 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Wed, 7 Feb 2018 17:43:29 +0100 Subject: [PATCH 157/582] Add PointerValue.Value to dereference and access pointer value. --- .../Mono.Debugger.Soft/Connection.cs | 47 ++++++++++--- .../Mono.Debugger.Soft/PointerValue.cs | 10 +++ .../Mono.Debugger.Soft/TypeMirror.cs | 5 ++ .../Mono.Debugger.Soft/VirtualMachine.cs | 10 ++- .../Mono.Debugger.Soft/Test/dtest-app.cs | 19 ++++++ mcs/class/Mono.Debugger.Soft/Test/dtest.cs | 38 ++++++++++- mono/mini/debugger-agent.c | 66 +++++++++++++++++-- 7 files changed, 178 insertions(+), 17 deletions(-) diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs index 602c827091de..e480555252ed 100644 --- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs +++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/Connection.cs @@ -420,7 +420,7 @@ public abstract class Connection * with newer runtimes, and vice versa. */ internal const int MAJOR_VERSION = 2; - internal const int MINOR_VERSION = 45; + internal const int MINOR_VERSION = 46; enum WPSuspendPolicy { NONE = 0, @@ -442,7 +442,8 @@ enum CommandSet { TYPE = 23, MODULE = 24, FIELD = 25, - EVENT = 64 + EVENT = 64, + POINTER = 65 } enum EventKind { @@ -574,7 +575,8 @@ enum CmdType { GET_INTERFACES = 16, GET_INTERFACE_MAP = 17, IS_INITIALIZED = 18, - CREATE_INSTANCE = 19 + CREATE_INSTANCE = 19, + GET_VALUE_SIZE = 20 } enum CmdField { @@ -606,6 +608,10 @@ enum CmdStringRef { GET_CHARS = 3 } + enum CmdPointer { + GET_VALUE = 1 + } + enum CmdObjectRef { GET_TYPE = 1, GET_VALUES = 2, @@ -730,10 +736,12 @@ internal static byte[] EncodePacket (int id, int commandSet, int command, byte[] } class PacketReader { + Connection connection; byte[] packet; int offset; - public PacketReader (byte[] packet) { + public PacketReader (Connection connection, byte[] packet) { + this.connection = connection; this.packet = packet; // For event packets @@ -845,9 +853,16 @@ public ValueImpl ReadValue () { return new ValueImpl { Type = etype, Value = ReadDouble () }; case ElementType.I: case ElementType.U: - case ElementType.Ptr: // FIXME: The client and the debuggee might have different word sizes return new ValueImpl { Type = etype, Value = ReadLong () }; + case ElementType.Ptr: + long value = ReadLong (); + if (connection.Version.AtLeast (2, 46)) { + long pointerClass = ReadId (); + return new ValueImpl { Type = etype, Klass = pointerClass, Value = value }; + } else { + return new ValueImpl { Type = etype, Value = value }; + } case ElementType.String: case ElementType.SzArray: case ElementType.Class: @@ -1283,7 +1298,7 @@ bool ReceivePacket () { if (cb != null) cb.Invoke (id, packet); } else { - PacketReader r = new PacketReader (packet); + PacketReader r = new PacketReader (this, packet); if (r.CommandSet == CommandSet.EVENT && r.Command == (int)CmdEvent.COMPOSITE) { int spolicy = r.ReadByte (); @@ -1502,7 +1517,7 @@ int Send (CommandSet command_set, int command, PacketWriter packet, Action parent_vtypes) { - if (v.Value != null) + if (v.Value != null) { + if (Version.AtLeast (2, 46) && v.Type == ElementType.Ptr) + return new PointerValue(this, GetType(v.Klass), (long)v.Value); return new PrimitiveValue (this, v.Value); + } switch (v.Type) { case ElementType.Void: @@ -682,8 +685,11 @@ internal ValueImpl EncodeValue (Value v, List duplicates = null) { duplicates.Add (v); return new ValueImpl { Type = ElementType.ValueType, Klass = (v as StructMirror).Type.Id, Fields = EncodeValues ((v as StructMirror).Fields, duplicates) }; + } else if (v is PointerValue) { + PointerValue val = (PointerValue)v; + return new ValueImpl { Type = ElementType.Ptr, Klass = val.Type.Id, Value = val.Address }; } else { - throw new NotSupportedException (); + throw new NotSupportedException ("Value of type " + v.GetType()); } } diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs index 82efc79e51d8..20df95287288 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs @@ -145,6 +145,12 @@ public override string ToString () { } } + +public struct BlittableStruct { + public int i; + public double d; +} + public class GClass { public T field; public static T static_field; @@ -343,6 +349,7 @@ public static int Main (String[] args) { gc_suspend (); set_ip (); step_filters (); + pointers (); if (args.Length > 0 && args [0] == "local-reflect") local_reflect (); if (args.Length > 0 && args [0] == "domain-test") @@ -1720,6 +1727,18 @@ public void attach () { attach_break (); } } + + public static unsafe void pointer_arguments (int* a, BlittableStruct* s) { + *a = 0; + } + + [MethodImplAttribute (MethodImplOptions.NoInlining)] + public static unsafe void pointers () { + int[] a = new [] {1,2,3}; + BlittableStruct s = new BlittableStruct () { i = 2, d = 3.0 }; + fixed (int* pa = a) + pointer_arguments (pa, &s); + } } public class SentinelClass : MarshalByRefObject { diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs index ccd3b6b7602e..7d5c0fdbe660 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs @@ -324,6 +324,8 @@ void AssertValue (object expected, object val) { Assert.AreEqual (expected, (val as StringMirror).Value); } else if (val is StructMirror && (val as StructMirror).Type.Name == "IntPtr") { AssertValue (expected, (val as StructMirror).Fields [0]); + } else if (val is PointerValue) { + Assert.AreEqual (expected, (val as PointerValue).Address); } else { Assert.IsTrue (val is PrimitiveValue); Assert.AreEqual (expected, (val as PrimitiveValue).Value); @@ -4361,6 +4363,38 @@ public void Hash () } } -} + [Test] + public void Pointer_GetValue () { + var e = run_until ("pointer_arguments"); + var frame = e.Thread.GetFrames () [0]; + + var param = frame.Method.GetParameters()[0]; + Assert.AreEqual("Int32*", param.ParameterType.Name); + + var pointerValue = frame.GetValue(param) as PointerValue; + Assert.AreEqual("Int32*", pointerValue.Type.Name); + + AssertValue(1, pointerValue.Value); + + var pointerValue2 = new PointerValue (pointerValue.VirtualMachine, pointerValue.Type, pointerValue.Address + pointerValue.Type.GetElementType().GetValueSize()); + + AssertValue(2, pointerValue2.Value); -} + + param = frame.Method.GetParameters()[1]; + Assert.AreEqual("BlittableStruct*", param.ParameterType.Name); + + pointerValue = frame.GetValue(param) as PointerValue; + Assert.AreEqual("BlittableStruct*", pointerValue.Type.Name); + + var structValue = pointerValue.Value as StructMirror; + Assert.AreEqual("BlittableStruct", structValue.Type.Name); + + object f = structValue.Fields[0]; + AssertValue (2, f); + f = structValue.Fields[1]; + AssertValue (3.0, f); + + } +} // class DebuggerTests +} // namespace diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 8f7ec4fc6aa1..3713c38c5ecf 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -306,7 +306,7 @@ typedef struct { #define HEADER_LENGTH 11 #define MAJOR_VERSION 2 -#define MINOR_VERSION 45 +#define MINOR_VERSION 46 typedef enum { CMD_SET_VM = 1, @@ -322,7 +322,8 @@ typedef enum { CMD_SET_TYPE = 23, CMD_SET_MODULE = 24, CMD_SET_FIELD = 25, - CMD_SET_EVENT = 64 + CMD_SET_EVENT = 64, + CMD_SET_POINTER = 65 } CommandSet; typedef enum { @@ -527,7 +528,8 @@ typedef enum { CMD_TYPE_GET_INTERFACES = 16, CMD_TYPE_GET_INTERFACE_MAP = 17, CMD_TYPE_IS_INITIALIZED = 18, - CMD_TYPE_CREATE_INSTANCE = 19 + CMD_TYPE_CREATE_INSTANCE = 19, + CMD_TYPE_GET_VALUE_SIZE = 20 } CmdType; typedef enum { @@ -550,6 +552,10 @@ typedef enum { CMD_STRING_REF_GET_CHARS = 3 } CmdString; +typedef enum { + CMD_POINTER_GET_VALUE = 1 +} CmdPointer; + typedef enum { CMD_OBJECT_REF_GET_TYPE = 1, CMD_OBJECT_REF_GET_VALUES = 2, @@ -7162,6 +7168,8 @@ static void buffer_add_value_full (Buffer *buf, MonoType *t, void *addr, MonoDom buffer_add_byte (buf, t->type); buffer_add_long (buf, val); + if (CHECK_PROTOCOL_VERSION(2, 46)) + buffer_add_typeid (buf, domain, mono_class_from_mono_type (t)); break; } handle_ref: @@ -10132,6 +10140,13 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint buffer_add_objid (buf, obj); break; } + case CMD_TYPE_GET_VALUE_SIZE: { + int32_t value_size; + + value_size = mono_class_value_size (klass, NULL); + buffer_add_int (buf, value_size); + break; + } default: return ERR_NOT_IMPLEMENTED; } @@ -11448,6 +11463,34 @@ string_commands (int command, guint8 *p, guint8 *end, Buffer *buf) return ERR_NONE; } +static ErrorCode +pointer_commands (int command, guint8 *p, guint8 *end, Buffer *buf) +{ + ErrorCode err; + gint64 addr; + MonoClass* klass; + MonoDomain* domain = NULL; + + switch (command) { + case CMD_POINTER_GET_VALUE: + addr = decode_long (p, &p, end); + klass = decode_typeid (p, &p, end, &domain, &err); + if (err != ERR_NONE) + return err; + + if (klass->byval_arg.type != MONO_TYPE_PTR) + return ERR_INVALID_ARGUMENT; + + buffer_add_value (buf, &klass->element_class->byval_arg, (gpointer)addr, domain); + + break; + default: + return ERR_NOT_IMPLEMENTED; + } + + return ERR_NONE; +} + static ErrorCode object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) { @@ -11646,6 +11689,8 @@ command_set_to_string (CommandSet command_set) return "FIELD"; case CMD_SET_EVENT: return "EVENT"; + case CMD_SET_POINTER: + return "POINTER"; default: return ""; } @@ -11742,7 +11787,9 @@ static const char* type_cmds_str[] = { "GET_METHODS_BY_NAME_FLAGS", "GET_INTERFACES", "GET_INTERFACE_MAP", - "IS_INITIALIZED" + "IS_INITIALIZED", + "CREATE_INSTANCE", + "GET_VALUE_SIZE" }; static const char* stack_frame_cmds_str[] = { @@ -11765,6 +11812,10 @@ static const char* string_cmds_str[] = { "GET_CHARS" }; +static const char* pointer_cmds_str[] = { + "GET_VALUE" +}; + static const char* object_cmds_str[] = { "GET_TYPE", "GET_VALUES", @@ -11838,6 +11889,10 @@ cmd_to_string (CommandSet set, int command) cmds = event_cmds_str; cmds_len = G_N_ELEMENTS (event_cmds_str); break; + case CMD_SET_POINTER: + cmds = pointer_cmds_str; + cmds_len = G_N_ELEMENTS (pointer_cmds_str); + break; default: return NULL; } @@ -12031,6 +12086,9 @@ debugger_thread (void *arg) case CMD_SET_STRING_REF: err = string_commands (command, p, end, &buf); break; + case CMD_SET_POINTER: + err = pointer_commands (command, p, end, &buf); + break; case CMD_SET_OBJECT_REF: err = object_commands (command, p, end, &buf); break; From e15b660bf61d716aabf9956995024d510409e01b Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Thu, 1 Mar 2018 14:50:46 -0500 Subject: [PATCH 158/582] change first supported time to 1971 for ps4 --- mcs/class/corlib/System/TimeZoneInfo.Unity.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mcs/class/corlib/System/TimeZoneInfo.Unity.cs b/mcs/class/corlib/System/TimeZoneInfo.Unity.cs index 7f10ac91be9b..9100a328670d 100644 --- a/mcs/class/corlib/System/TimeZoneInfo.Unity.cs +++ b/mcs/class/corlib/System/TimeZoneInfo.Unity.cs @@ -85,7 +85,7 @@ static TimeZoneInfo CreateLocalUnity () if(!disableDaylightSavings) { //the icall only supports years from 1970 through 2037. - int firstSupportedDate = 1970; + int firstSupportedDate = 1971; int lastSupportedDate = 2037; //first, generate rules from the current year until the last year mktime is guaranteed to supports From 73fae33c2750da10ee89cb8b199a98e1f3861796 Mon Sep 17 00:00:00 2001 From: Eneko Osia Date: Mon, 5 Mar 2018 14:36:40 +0100 Subject: [PATCH 159/582] [metadata] add new function define into il2cpp-compat file --- mono/mini/il2cpp-compat.h | 1 + 1 file changed, 1 insertion(+) diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index 98a748f6cdef..1258544f6dba 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -248,6 +248,7 @@ #define mono_class_get_element_class il2cpp_class_get_element_class #define mono_class_get_type_token il2cpp_class_get_type_token #define mono_type_is_byref il2cpp_type_is_byref +#define mono_type_get_attrs il2cpp_type_get_attrs #define mono_class_is_enum il2cpp_class_is_enum #define mono_method_get_flags il2cpp_method_get_flags #define mono_method_get_token il2cpp_method_get_token From 14342b1046b9d8c59446a22941c7c35abb260a9e Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Wed, 7 Mar 2018 09:04:25 -0500 Subject: [PATCH 160/582] Remove the machine.config check for IPv6 support We want the .NET 4.x and the .NET Standard 2.0 profiles to work the same with respect to IPv6. Previously, the .NET 4.x profile checked the machine.config file for IPv6 support. This change removes the code which checks the machine.config file, and instead always returns true. Later, we will use the Unity PAL to get the proper value for each platform. For now, we want consistency. --- mcs/class/System/ReferenceSources/SettingsSectionInternal.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mcs/class/System/ReferenceSources/SettingsSectionInternal.cs b/mcs/class/System/ReferenceSources/SettingsSectionInternal.cs index e7719c1afaad..c3bda137bfa7 100644 --- a/mcs/class/System/ReferenceSources/SettingsSectionInternal.cs +++ b/mcs/class/System/ReferenceSources/SettingsSectionInternal.cs @@ -30,6 +30,7 @@ internal static SettingsSectionInternal Section { internal bool Ipv6Enabled { get { +#if !UNITY #if CONFIGURATION_DEP && !MOBILE try { var config = (SettingsSection) System.Configuration.ConfigurationManager.GetSection ("system.net/settings"); @@ -37,6 +38,7 @@ internal bool Ipv6Enabled { return config.Ipv6.Enabled; } catch { } +#endif #endif return true; From fdd29baabe6e213e94cf9598934d5bc32a407330 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Thu, 8 Mar 2018 08:18:39 -0500 Subject: [PATCH 161/582] Set the frame ID for the debugger This code is a bit odd. It depends on the `i` variable value after the `for` loop. If that `for` loop does not execute (even if the loop body does nothing), the code won't set the frame ID properly. This causes locals to be reported for the wrong frame in the `GET_FRAME_INFO` command. On a side note, maybe we should implement something for IL2CPP in the body of for loop, but that is a different issue. This syncs with the debugger code in the IL2CPP repo. --- mono/mini/debugger-agent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 3713c38c5ecf..894e2b794f13 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -3453,18 +3453,18 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) for (tmp = user_data.frames; tmp; tmp = tmp->next) { f = (StackFrame *)tmp->data; -#ifndef RUNTIME_IL2CPP /* * Reuse the id for already existing stack frames, so invokes don't invalidate * the still valid stack frames. */ for (i = 0; i < tls->frame_count; ++i) { +#ifndef RUNTIME_IL2CPP if (MONO_CONTEXT_GET_SP (&tls->frames [i]->ctx) == MONO_CONTEXT_GET_SP (&f->ctx)) { f->id = tls->frames [i]->id; break; } - } #endif // !RUNTIME_IL2CPP + } if (i >= tls->frame_count) f->id = mono_atomic_inc_i32 (&frame_id); From af9f98c2393ad63a8be0c97ab052339b0c1a704d Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Thu, 8 Mar 2018 12:16:22 -0500 Subject: [PATCH 162/582] Support pointer fields in ValueType Equals & GetHashCode (case 1005597) --- mono/metadata/icall.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c index 1741e78cf38e..3537675aabcf 100644 --- a/mono/metadata/icall.c +++ b/mono/metadata/icall.c @@ -1096,6 +1096,9 @@ ves_icall_System_ValueType_InternalGetHashCode (MonoObject *this_obj, MonoArray case MONO_TYPE_I4: result ^= *(gint32*)((guint8*)this_obj + field->offset); break; + case MONO_TYPE_PTR: + result ^= mono_aligned_addr_hash (*(gpointer*)((guint8*)this_obj + field->offset)); + break; case MONO_TYPE_STRING: { MonoString *s; s = *(MonoString**)((guint8*)this_obj + field->offset); @@ -1195,6 +1198,10 @@ ves_icall_System_ValueType_Equals (MonoObject *this_obj, MonoObject *that, MonoA if (*(double*)((guint8*)this_obj + field->offset) != *(double*)((guint8*)that + field->offset)) return FALSE; break; + case MONO_TYPE_PTR: + if (*(gpointer*)((guint8*)this_obj + field->offset) != *(gpointer*)((guint8*)that + field->offset)) + return FALSE; + break; case MONO_TYPE_STRING: { From 3bb0be9b4ac6c6179bf47e82f158708b1f46f55b Mon Sep 17 00:00:00 2001 From: Konstantin Khitrykh Date: Thu, 8 Mar 2018 05:58:59 +0700 Subject: [PATCH 163/582] [corlib] Fix Type.GetInterface() to find implemented interface when "ignoreCase: true" is used (#7464) Fixes #6579 --- mcs/class/corlib/Test/System/TypeTest.cs | 24 +++++++++++++++++++ .../referencesource/mscorlib/system/rttype.cs | 7 ++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/mcs/class/corlib/Test/System/TypeTest.cs b/mcs/class/corlib/Test/System/TypeTest.cs index 6608ef9cc430..2c9bd2728afd 100644 --- a/mcs/class/corlib/Test/System/TypeTest.cs +++ b/mcs/class/corlib/Test/System/TypeTest.cs @@ -4886,6 +4886,30 @@ public void NullFullNameForSpecificGenericTypes() } } + // https://github.com/mono/mono/issues/6579 + [Test] + public void GetInterfaceCaseInsensitiveTest() + { + var type = typeof(Dictionary); + + Assert.NotNull ( + type.GetInterface ("System.Collections.IDictionary", false), + "strict named interface must be found (ignoreCase = false)" + ); + Assert.NotNull ( + type.GetInterface ("System.Collections.IDictionary", true), + "strict named interface must be found (ignoreCase = true)" + ); + Assert.Null ( + type.GetInterface ("System.Collections.Idictionary", false), + "interface, named in mixed case, must not be found (ignoreCase = false)" + ); + Assert.NotNull ( + type.GetInterface ("System.Collections.Idictionary", true), + "interface, named in mixed case, must be found (ignoreCase = true)" + ); + } + interface Bug59738Interface { } diff --git a/mcs/class/referencesource/mscorlib/system/rttype.cs b/mcs/class/referencesource/mscorlib/system/rttype.cs index 61b46433b342..42a445bc5cf5 100644 --- a/mcs/class/referencesource/mscorlib/system/rttype.cs +++ b/mcs/class/referencesource/mscorlib/system/rttype.cs @@ -3413,9 +3413,12 @@ public override Type GetInterface(String fullname, bool ignoreCase) #if MONO List list = null; + var nameComparison = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; foreach (RuntimeType t in GetInterfaces ()) { - if (t.Name != name) - continue; + + if (!String.Equals(t.Name, name, nameComparison)) { + continue; + } if (list == null) list = new List (2); From 5c9428b3b3f25d91b2649b74f860920609b14761 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 9 Mar 2018 16:34:19 -0500 Subject: [PATCH 164/582] Swap bytes for port number (case 1006506) --- .../System.Net.NetworkInformation/IPGlobalProperties.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs b/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs index b93b53ae0a28..7246735678d0 100644 --- a/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs +++ b/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs @@ -622,6 +622,9 @@ public override NetBiosNodeType NodeType { [DllImport ("iphlpapi.dll")] static extern int GetIpStatisticsEx (out Win32_MIB_IPSTATS pStats, int dwFamily); + [DllImport ("Ws2_32.dll")] + static extern ushort ntohs (ushort netshort); + // Win32 structures [StructLayout (LayoutKind.Explicit)] @@ -682,10 +685,10 @@ public TcpConnectionInformation TcpInfo { class Win32_MIB_UDPROW { public uint LocalAddr; - public int LocalPort; + public uint LocalPort; public IPEndPoint LocalEndPoint { - get { return new IPEndPoint (LocalAddr, LocalPort); } + get { return new IPEndPoint (LocalAddr, ntohs((ushort)LocalPort)); } } } From cb33cc6c0f3830b357ed75aeff99e91af293ed79 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 9 Mar 2018 16:57:40 -0500 Subject: [PATCH 165/582] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 440e4c4026f4..917e18a22345 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ Branches for released Unity versions are of the form unity-\\[-mbe\][- * [unity-trunk (PR to this branch for Mono)](https://github.com/Unity-Technologies/mono/tree/unity-trunk) * [unity-master (PR to this branch for MonoBleedingEdge)](https://github.com/Unity-Technologies/mono/tree/unity-master) +#### 2018.1 +* [unity-2018.1](https://github.com/Unity-Technologies/mono/tree/unity-2018.1) +* [unity-2018.1-mbe](https://github.com/Unity-Technologies/mono/tree/unity-2018.1-mbe) + #### 2017.3 * [unity-2017.3](https://github.com/Unity-Technologies/mono/tree/unity-2017.3) * [unity-2017.3-mbe](https://github.com/Unity-Technologies/mono/tree/unity-2017.3-mbe) From 002915a0419adf44a9d4ebd077db1ad93279ac3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Sat, 10 Mar 2018 04:08:53 +0100 Subject: [PATCH 166/582] [Facades] Add missing Facades that exist in .NET 4.7.1 (#7541) Some of them we had on mobile only, others were missing completely. Fixes https://github.com/mono/mono/issues/7536 --- .../System.Net.Http.Rtc/AssemblyInfo.cs | 35 +++++++++++++++++++ .../Facades/System.Net.Http.Rtc/Makefile | 21 +++++++++++ .../System.Net.Http.Rtc.dll.sources | 2 ++ .../System.Net.Http.Rtc/TypeForwarders.cs | 25 +++++++++++++ .../System.Resources.Reader/AssemblyInfo.cs | 35 +++++++++++++++++++ .../Facades/System.Resources.Reader/Makefile | 23 ++++++++++++ .../System.Resources.Reader.dll.sources | 3 ++ .../System.Resources.Reader/TypeForwarders.cs | 25 +++++++++++++ .../System.Resources.Writer/AssemblyInfo.cs | 35 +++++++++++++++++++ .../Facades/System.Resources.Writer/Makefile | 23 ++++++++++++ .../System.Resources.Writer.dll.sources | 3 ++ .../System.Resources.Writer/TypeForwarders.cs | 25 +++++++++++++ mcs/class/Facades/subdirs.make | 5 +-- 13 files changed, 258 insertions(+), 2 deletions(-) create mode 100644 mcs/class/Facades/System.Net.Http.Rtc/AssemblyInfo.cs create mode 100644 mcs/class/Facades/System.Net.Http.Rtc/Makefile create mode 100644 mcs/class/Facades/System.Net.Http.Rtc/System.Net.Http.Rtc.dll.sources create mode 100644 mcs/class/Facades/System.Net.Http.Rtc/TypeForwarders.cs create mode 100644 mcs/class/Facades/System.Resources.Reader/AssemblyInfo.cs create mode 100644 mcs/class/Facades/System.Resources.Reader/Makefile create mode 100644 mcs/class/Facades/System.Resources.Reader/System.Resources.Reader.dll.sources create mode 100644 mcs/class/Facades/System.Resources.Reader/TypeForwarders.cs create mode 100644 mcs/class/Facades/System.Resources.Writer/AssemblyInfo.cs create mode 100644 mcs/class/Facades/System.Resources.Writer/Makefile create mode 100644 mcs/class/Facades/System.Resources.Writer/System.Resources.Writer.dll.sources create mode 100644 mcs/class/Facades/System.Resources.Writer/TypeForwarders.cs diff --git a/mcs/class/Facades/System.Net.Http.Rtc/AssemblyInfo.cs b/mcs/class/Facades/System.Net.Http.Rtc/AssemblyInfo.cs new file mode 100644 index 000000000000..19cd3907a866 --- /dev/null +++ b/mcs/class/Facades/System.Net.Http.Rtc/AssemblyInfo.cs @@ -0,0 +1,35 @@ +// +// Copyright (c) 2013 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle ("System.Net.Http.Rtc")] +[assembly: AssemblyDescription ("System.Net.Http.Rtc")] +[assembly: AssemblyDefaultAlias ("System.Net.Http.Rtc")] +[assembly: AssemblyCompany ("Mono development team")] +[assembly: AssemblyProduct ("Mono Common Language Infrastructure")] +[assembly: AssemblyCopyright ("(c) Various Mono authors")] +[assembly: AssemblyVersion ("4.0.0.0")] +[assembly: AssemblyInformationalVersion ("4.0.0.0")] +[assembly: AssemblyFileVersion ("4.0.0.0")] diff --git a/mcs/class/Facades/System.Net.Http.Rtc/Makefile b/mcs/class/Facades/System.Net.Http.Rtc/Makefile new file mode 100644 index 000000000000..f730763a925e --- /dev/null +++ b/mcs/class/Facades/System.Net.Http.Rtc/Makefile @@ -0,0 +1,21 @@ +MCS_BUILD_DIR = ../../../build + +thisdir = class/Facades/System.Net.Http.Rtc +SUBDIRS = +include $(MCS_BUILD_DIR)/rules.make + +LIBRARY_SUBDIR = Facades +LIBRARY_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION)/Facades + +LIBRARY = System.Net.Http.Rtc.dll + +KEYFILE = ../../msfinal.pub +SIGN_FLAGS = /delaysign /nowarn:1616,1699 +LIB_REFS = System +LIB_MCS_FLAGS = $(SIGN_FLAGS) + +PLATFORM_DEBUG_FLAGS = + +NO_TEST = yes + +include $(MCS_BUILD_DIR)/library.make diff --git a/mcs/class/Facades/System.Net.Http.Rtc/System.Net.Http.Rtc.dll.sources b/mcs/class/Facades/System.Net.Http.Rtc/System.Net.Http.Rtc.dll.sources new file mode 100644 index 000000000000..719628dc7c61 --- /dev/null +++ b/mcs/class/Facades/System.Net.Http.Rtc/System.Net.Http.Rtc.dll.sources @@ -0,0 +1,2 @@ +TypeForwarders.cs +AssemblyInfo.cs diff --git a/mcs/class/Facades/System.Net.Http.Rtc/TypeForwarders.cs b/mcs/class/Facades/System.Net.Http.Rtc/TypeForwarders.cs new file mode 100644 index 000000000000..b8c87d21f333 --- /dev/null +++ b/mcs/class/Facades/System.Net.Http.Rtc/TypeForwarders.cs @@ -0,0 +1,25 @@ +// +// Copyright (c) 2016 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +#if false // it is forwarded to System.Net.Http.WebRequest.dll but doesn't actually exist there in the .NET 4.7.1 reference assemblies ... +[assembly:System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Net.Http.RtcRequestFactory))] +#endif diff --git a/mcs/class/Facades/System.Resources.Reader/AssemblyInfo.cs b/mcs/class/Facades/System.Resources.Reader/AssemblyInfo.cs new file mode 100644 index 000000000000..fe58b174b957 --- /dev/null +++ b/mcs/class/Facades/System.Resources.Reader/AssemblyInfo.cs @@ -0,0 +1,35 @@ +// +// Copyright (c) 2015 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle ("System.Resources.Reader")] +[assembly: AssemblyDescription ("System.Resources.Reader")] +[assembly: AssemblyDefaultAlias ("System.Resources.Reader")] +[assembly: AssemblyCompany ("Mono development team")] +[assembly: AssemblyProduct ("Mono Common Language Infrastructure")] +[assembly: AssemblyCopyright ("(c) Various Mono authors")] +[assembly: AssemblyVersion ("4.0.2.0")] +[assembly: AssemblyInformationalVersion ("4.0.0.0")] +[assembly: AssemblyFileVersion ("4.0.0.0")] diff --git a/mcs/class/Facades/System.Resources.Reader/Makefile b/mcs/class/Facades/System.Resources.Reader/Makefile new file mode 100644 index 000000000000..b16ae43ee303 --- /dev/null +++ b/mcs/class/Facades/System.Resources.Reader/Makefile @@ -0,0 +1,23 @@ +MCS_BUILD_DIR = ../../../build + +thisdir = class/Facades/System.Resources.Reader +SUBDIRS = +include $(MCS_BUILD_DIR)/rules.make + +LIBRARY_SUBDIR = Facades +LIBRARY_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION)/Facades + +LIBRARY = System.Resources.Reader.dll + +KEYFILE = ../../msfinal.pub +SIGN_FLAGS = /delaysign /nowarn:1616,1699 +LIB_REFS = System +LIB_MCS_FLAGS = $(SIGN_FLAGS) + +PLATFORM_DEBUG_FLAGS = + +NO_TEST = yes + +include $(MCS_BUILD_DIR)/library.make + + diff --git a/mcs/class/Facades/System.Resources.Reader/System.Resources.Reader.dll.sources b/mcs/class/Facades/System.Resources.Reader/System.Resources.Reader.dll.sources new file mode 100644 index 000000000000..8e33d4ddeae9 --- /dev/null +++ b/mcs/class/Facades/System.Resources.Reader/System.Resources.Reader.dll.sources @@ -0,0 +1,3 @@ +TypeForwarders.cs +AssemblyInfo.cs + diff --git a/mcs/class/Facades/System.Resources.Reader/TypeForwarders.cs b/mcs/class/Facades/System.Resources.Reader/TypeForwarders.cs new file mode 100644 index 000000000000..310362270c75 --- /dev/null +++ b/mcs/class/Facades/System.Resources.Reader/TypeForwarders.cs @@ -0,0 +1,25 @@ +// +// Copyright (c) 2015 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Resources.ResourceReader))] + + diff --git a/mcs/class/Facades/System.Resources.Writer/AssemblyInfo.cs b/mcs/class/Facades/System.Resources.Writer/AssemblyInfo.cs new file mode 100644 index 000000000000..71222db9e31e --- /dev/null +++ b/mcs/class/Facades/System.Resources.Writer/AssemblyInfo.cs @@ -0,0 +1,35 @@ +// +// Copyright (c) 2015 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +using System; +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle ("System.Resources.Writer")] +[assembly: AssemblyDescription ("System.Resources.Writer")] +[assembly: AssemblyDefaultAlias ("System.Resources.Writer")] +[assembly: AssemblyCompany ("Mono development team")] +[assembly: AssemblyProduct ("Mono Common Language Infrastructure")] +[assembly: AssemblyCopyright ("(c) Various Mono authors")] +[assembly: AssemblyVersion ("4.0.2.0")] +[assembly: AssemblyInformationalVersion ("4.0.0.0")] +[assembly: AssemblyFileVersion ("4.0.0.0")] diff --git a/mcs/class/Facades/System.Resources.Writer/Makefile b/mcs/class/Facades/System.Resources.Writer/Makefile new file mode 100644 index 000000000000..f2f622eb1bf0 --- /dev/null +++ b/mcs/class/Facades/System.Resources.Writer/Makefile @@ -0,0 +1,23 @@ +MCS_BUILD_DIR = ../../../build + +thisdir = class/Facades/System.Resources.Writer +SUBDIRS = +include $(MCS_BUILD_DIR)/rules.make + +LIBRARY_SUBDIR = Facades +LIBRARY_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION)/Facades + +LIBRARY = System.Resources.Writer.dll + +KEYFILE = ../../msfinal.pub +SIGN_FLAGS = /delaysign /nowarn:1616,1699 +LIB_REFS = System +LIB_MCS_FLAGS = $(SIGN_FLAGS) + +PLATFORM_DEBUG_FLAGS = + +NO_TEST = yes + +include $(MCS_BUILD_DIR)/library.make + + diff --git a/mcs/class/Facades/System.Resources.Writer/System.Resources.Writer.dll.sources b/mcs/class/Facades/System.Resources.Writer/System.Resources.Writer.dll.sources new file mode 100644 index 000000000000..8e33d4ddeae9 --- /dev/null +++ b/mcs/class/Facades/System.Resources.Writer/System.Resources.Writer.dll.sources @@ -0,0 +1,3 @@ +TypeForwarders.cs +AssemblyInfo.cs + diff --git a/mcs/class/Facades/System.Resources.Writer/TypeForwarders.cs b/mcs/class/Facades/System.Resources.Writer/TypeForwarders.cs new file mode 100644 index 000000000000..e82cdb0ad509 --- /dev/null +++ b/mcs/class/Facades/System.Resources.Writer/TypeForwarders.cs @@ -0,0 +1,25 @@ +// +// Copyright (c) 2015 Xamarin Inc. (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Resources.ResourceWriter))] + + diff --git a/mcs/class/Facades/subdirs.make b/mcs/class/Facades/subdirs.make index 141d754f38fa..3901ea16eeb2 100644 --- a/mcs/class/Facades/subdirs.make +++ b/mcs/class/Facades/subdirs.make @@ -27,7 +27,8 @@ System.Xml.XPath System.Xml.XmlDocument System.Xml.Xsl.Primitives Microsoft.Win3 System.IO.FileSystem.AccessControl System.Reflection.TypeExtensions System.Reflection.Emit.Lightweight System.Reflection.Emit.ILGeneration System.Reflection.Emit \ System.Threading.AccessControl System.ValueTuple \ System.Security.Cryptography.Primitives System.Text.Encoding.CodePages System.IO.FileSystem.Watcher \ -System.Security.Cryptography.ProtectedData System.ServiceProcess.ServiceController System.IO.Pipes +System.Security.Cryptography.ProtectedData System.ServiceProcess.ServiceController System.IO.Pipes \ +System.Net.Http.Rtc System.Net.Ping System.Resources.Reader System.Resources.Writer System.Runtime.Serialization.Formatters System.Security.Cryptography.Csp # common_SUBDIRS dependencies common_DEPS_SUBDIRS = System.Security.Cryptography.X509Certificates System.ServiceModel.Primitives System.Runtime.Serialization.Primitives \ @@ -95,7 +96,7 @@ unreal_PARALLEL_SUBDIRS = $(common_SUBDIRS) $(mobile_only_SUBDIRS) wasm_SUBDIRS = $(common_DEPS_SUBDIRS) $(netstandard_drawing_SUBDIRS) $(mobile_only_DEPS_SUBDIRS) wasm_PARALLEL_SUBDIRS = $(common_SUBDIRS) $(mobile_only_SUBDIRS) -mobile_only_SUBDIRS = System.Net.Ping System.Runtime.Serialization.Formatters System.Security.Cryptography.Csp System.Security.Cryptography.Pkcs \ +mobile_only_SUBDIRS = System.Security.Cryptography.Pkcs \ System.Security.Cryptography.Cng System.Runtime.Loader System.Xml.XPath.XmlDocument System.Reflection.DispatchProxy mobile_only_DEPS_SUBDIRS = System.Security.Cryptography.OpenSsl From b6daf2015bb978d69ffd5d4aea0bfd4454824476 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Mon, 12 Mar 2018 10:31:01 -0400 Subject: [PATCH 167/582] Sync changes from IL2CPP 85698322c225ff1be2bc71c65a00b64d67d71a24 Added a building test for building with the debugger code generation enabled but the debugger turned "off" via the IL2CPP_MONO_DEBUGGER preprocessor define. --- mono/metadata/il2cpp-compat-metadata.h | 4 ++-- mono/mini/il2cpp-stubs.cpp | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mono/metadata/il2cpp-compat-metadata.h b/mono/metadata/il2cpp-compat-metadata.h index 8e8cc6aaf19c..62d1500e5d3b 100644 --- a/mono/metadata/il2cpp-compat-metadata.h +++ b/mono/metadata/il2cpp-compat-metadata.h @@ -1,6 +1,6 @@ #pragma once -#ifdef IL2CPP_MONO_DEBUGGER +#ifdef RUNTIME_IL2CPP #include #include @@ -33,4 +33,4 @@ void* il2cpp_mono_gc_invoke_with_gc_lock (MonoGCLockedCallbackFunc func, void *d int il2cpp_mono_gc_pthread_create (pthread_t *new_thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg); #endif -#endif \ No newline at end of file +#endif diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index ba54dc9bb9e2..060d8b68b3e0 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -1505,7 +1505,11 @@ char* il2cpp_assembly_get_full_name(MonoAssembly *assembly) const MonoMethod* il2cpp_get_seq_point_method(Il2CppSequencePoint *seqPoint) { +#if IL2CPP_MONO_DEBUGGER return il2cpp::utils::Debugger::GetSequencePointMethod(seqPoint); +#else + return NULL; +#endif } const MonoClass* il2cpp_get_class_from_index(int index) From 374a1526e87384cb1916f64cf9bb44a1eba89b5e Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Mon, 12 Mar 2018 10:32:24 -0400 Subject: [PATCH 168/582] Sync changes from IL2CPP 7071db69fe79c82b32c928e94c61b8af145e7697 Fix for case 1011160: Step Out from an Update function behaves incorrectly. If we are stepping out of the only managed frame in the call stack, cancel creating the step request and just continue. --- mono/mini/debugger-agent.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 894e2b794f13..e08e23f7b89e 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -9134,6 +9134,21 @@ event_commands (int command, guint8 *p, guint8 *end, Buffer *buf) return err; } +#if RUNTIME_IL2CPP + { + DebuggerTlsData* tls; + mono_loader_lock(); + tls = (DebuggerTlsData *)mono_g_hash_table_lookup(thread_to_tls, THREAD_TO_INTERNAL(step_thread)); + mono_loader_unlock(); + + if (tls->il2cpp_context.frameCount == 1 && depth == STEP_DEPTH_OUT) + { + g_free(req); + return ERR_NONE; + } + } +#endif + err = ss_create (THREAD_TO_INTERNAL (step_thread), size, depth, filter, req); if (err != ERR_NONE) { g_free (req); From 70ff1501a30cc3ad648b6f45ca6560486cb5e366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tautvydas=20=C5=BDilys?= Date: Mon, 12 Mar 2018 13:03:15 -0700 Subject: [PATCH 169/582] Don't fail constructing WebProxyData if retrieving proxy data from the registry fails with DllNotFoundException. We don't construct it on Unity AOT profile anyway, and it's better for it to work without proxy support than not work at all. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Release notes: • Universal Windows Platform: Fixed HttpWebRequest throwing DllNotFoundException on IL2CPP scripting backend (case 989588). --- .../ReferenceSources/AutoWebProxyScriptEngine.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/mcs/class/System/ReferenceSources/AutoWebProxyScriptEngine.cs b/mcs/class/System/ReferenceSources/AutoWebProxyScriptEngine.cs index f3b840e8f7f5..b667bdc9792b 100644 --- a/mcs/class/System/ReferenceSources/AutoWebProxyScriptEngine.cs +++ b/mcs/class/System/ReferenceSources/AutoWebProxyScriptEngine.cs @@ -46,14 +46,22 @@ public WebProxyData GetWebProxyData () WebProxyData data; // TODO: Could re-use some pieces from _AutoWebProxyScriptEngine.cs - if (IsWindows ()) { - data = InitializeRegistryGlobalProxy (); + try { + if (IsWindows ()) { + data = InitializeRegistryGlobalProxy (); + if (data != null) + return data; + } + + data = ReadEnvVariables (); if (data != null) return data; } + catch (DllNotFoundException) { + // This path will be hit on UWP since we're not allowed to read from registry + } - data = ReadEnvVariables (); - return data ?? new WebProxyData (); + return new WebProxyData (); } WebProxyData ReadEnvVariables () From 96c5d1526b3a2114dde3dddbe71a34549653932b Mon Sep 17 00:00:00 2001 From: andreasr Date: Tue, 13 Mar 2018 13:10:03 +0100 Subject: [PATCH 170/582] Fixed calling conventions for unitytls callbacks (for calls native -> managed) --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index 54771af296d2..6b4112da46c4 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -112,6 +112,7 @@ public enum unitytls_x509verify_result : UInt32 UNITYTLS_X509VERIFY_FLAG_UNKNOWN_ERROR = 0x08000000, } + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate unitytls_x509verify_result unitytls_x509verify_callback(void* userData, unitytls_x509_ref cert, unitytls_x509verify_result result, unitytls_errorstate* errorState); // ------------------------------------ @@ -144,10 +145,15 @@ public struct unitytls_tlsctx_protocolrange public unitytls_protocol max; }; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate size_t unitytls_tlsctx_write_callback(void* userData, UInt8* data, size_t bufferLen, unitytls_errorstate* errorState); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate size_t unitytls_tlsctx_read_callback(void* userData, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void unitytls_tlsctx_trace_callback(void* userData, unitytls_tlsctx* ctx, Int8* traceMessage, size_t traceMessageLen); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void unitytls_tlsctx_certificate_callback(void* userData, unitytls_tlsctx* ctx, Int8* cn, size_t cnLen, unitytls_x509name* caList, size_t caListLen, unitytls_x509list_ref* chain, unitytls_key_ref* key, unitytls_errorstate* errorState); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate unitytls_x509verify_result unitytls_tlsctx_x509verify_callback(void* userData, unitytls_x509list_ref chain, unitytls_errorstate* errorState); [StructLayout (LayoutKind.Sequential)] From 2b3f8a56f590d7ce1fc286aa5879bbacca0c2b95 Mon Sep 17 00:00:00 2001 From: andreasr Date: Tue, 13 Mar 2018 13:29:05 +0100 Subject: [PATCH 171/582] Set calling convention to cdecl for all delegates in unitytls_interface_struct --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index 6b4112da46c4..22adb9efdaf8 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -178,72 +178,103 @@ public class unitytls_interface_struct public readonly UInt64 UNITYTLS_INVALID_HANDLE; public readonly unitytls_tlsctx_protocolrange UNITYTLS_TLSCTX_PROTOCOLRANGE_DEFAULT; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate unitytls_errorstate unitytls_errorstate_create_t(); public unitytls_errorstate_create_t unitytls_errorstate_create; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void unitytls_errorstate_raise_error_t(unitytls_errorstate* errorState, unitytls_error_code errorCode); public unitytls_errorstate_raise_error_t unitytls_errorstate_raise_error; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate unitytls_key_ref unitytls_key_get_ref_t(unitytls_key* key, unitytls_errorstate* errorState); public unitytls_key_get_ref_t unitytls_key_get_ref; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate unitytls_key* unitytls_key_parse_der_t(UInt8* buffer, size_t bufferLen, Int8* password, size_t passwordLen, unitytls_errorstate* errorState); public unitytls_key_parse_der_t unitytls_key_parse_der; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate unitytls_key* unitytls_key_parse_pem_t(Int8* buffer, size_t bufferLen, Int8* password, size_t passwordLen, unitytls_errorstate* errorState); public unitytls_key_parse_pem_t unitytls_key_parse_pem; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void unitytls_key_free_t(unitytls_key* key); public unitytls_key_free_t unitytls_key_free; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate size_t unitytls_x509_export_der_t(unitytls_x509_ref cert, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); public unitytls_x509_export_der_t unitytls_x509_export_der; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate unitytls_x509list_ref unitytls_x509list_get_ref_t(unitytls_x509list* list, unitytls_errorstate* errorState); public unitytls_x509list_get_ref_t unitytls_x509list_get_ref; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate unitytls_x509_ref unitytls_x509list_get_x509_t(unitytls_x509list_ref list, size_t index, unitytls_errorstate* errorState); public unitytls_x509list_get_x509_t unitytls_x509list_get_x509; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate unitytls_x509list* unitytls_x509list_create_t(unitytls_errorstate* errorState); public unitytls_x509list_create_t unitytls_x509list_create; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void unitytls_x509list_append_t(unitytls_x509list* list, unitytls_x509_ref cert, unitytls_errorstate* errorState); public unitytls_x509list_append_t unitytls_x509list_append; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void unitytls_x509list_append_der_t(unitytls_x509list* list, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); public unitytls_x509list_append_der_t unitytls_x509list_append_der; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void unitytls_x509list_append_pem_t(unitytls_x509list* list, Int8* buffer, size_t bufferLen, unitytls_errorstate* errorState); public unitytls_x509list_append_der_t unitytls_x509list_append_pem; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void unitytls_x509list_free_t(unitytls_x509list* list); public unitytls_x509list_free_t unitytls_x509list_free; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate unitytls_x509verify_result unitytls_x509verify_default_ca_t(unitytls_x509list_ref chain, Int8* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); public unitytls_x509verify_default_ca_t unitytls_x509verify_default_ca; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate unitytls_x509verify_result unitytls_x509verify_explicit_ca_t(unitytls_x509list_ref chain, unitytls_x509list_ref trustCA, Int8* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); public unitytls_x509verify_explicit_ca_t unitytls_x509verify_explicit_ca; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate unitytls_tlsctx* unitytls_tlsctx_create_server_t(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, unitytls_x509list_ref certChain, unitytls_key_ref leafCertificateKey, unitytls_errorstate* errorState); public unitytls_tlsctx_create_server_t unitytls_tlsctx_create_server; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate unitytls_tlsctx* unitytls_tlsctx_create_client_t(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, Int8* cn, size_t cnLen, unitytls_errorstate* errorState); public unitytls_tlsctx_create_client_t unitytls_tlsctx_create_client; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void unitytls_tlsctx_server_require_client_authentication_t(unitytls_tlsctx* ctx, unitytls_x509list_ref clientAuthCAList, unitytls_errorstate* errorState); public unitytls_tlsctx_server_require_client_authentication_t unitytls_tlsctx_server_require_client_authentication; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void unitytls_tlsctx_set_certificate_callback_t(unitytls_tlsctx* ctx, unitytls_tlsctx_certificate_callback cb, void* userData, unitytls_errorstate* errorState); public unitytls_tlsctx_set_certificate_callback_t unitytls_tlsctx_set_certificate_callback; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void unitytls_tlsctx_set_trace_callback_t(unitytls_tlsctx* ctx, unitytls_tlsctx_trace_callback cb, void* userData, unitytls_errorstate* errorState); public unitytls_tlsctx_set_trace_callback_t unitytls_tlsctx_set_trace_callback; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void unitytls_tlsctx_set_x509verify_callback_t(unitytls_tlsctx* ctx, unitytls_tlsctx_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); public unitytls_tlsctx_set_x509verify_callback_t unitytls_tlsctx_set_x509verify_callback; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void unitytls_tlsctx_set_supported_ciphersuites_t(unitytls_tlsctx* ctx, unitytls_ciphersuite* supportedCiphersuites, size_t supportedCiphersuitesLen, unitytls_errorstate* errorState); public unitytls_tlsctx_set_supported_ciphersuites_t unitytls_tlsctx_set_supported_ciphersuites; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate unitytls_ciphersuite unitytls_tlsctx_get_ciphersuite_t(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); public unitytls_tlsctx_get_ciphersuite_t unitytls_tlsctx_get_ciphersuite; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate unitytls_protocol unitytls_tlsctx_get_protocol_t(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); public unitytls_tlsctx_get_protocol_t unitytls_tlsctx_get_protocol; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate unitytls_x509verify_result unitytls_tlsctx_process_handshake_t(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); public unitytls_tlsctx_process_handshake_t unitytls_tlsctx_process_handshake; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate size_t unitytls_tlsctx_read_t(unitytls_tlsctx* ctx, UInt8* buffer, size_t bufferLen, unitytls_errorstate* errorState); public unitytls_tlsctx_read_t unitytls_tlsctx_read; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate size_t unitytls_tlsctx_write_t(unitytls_tlsctx* ctx, UInt8* data, size_t bufferLen, unitytls_errorstate* errorState); public unitytls_tlsctx_write_t unitytls_tlsctx_write; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void unitytls_tlsctx_notify_close_t(unitytls_tlsctx* ctx, unitytls_errorstate* errorState); public unitytls_tlsctx_notify_close_t unitytls_tlsctx_notify_close; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void unitytls_tlsctx_free_t(unitytls_tlsctx* ctx); public unitytls_tlsctx_free_t unitytls_tlsctx_free; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void unitytls_random_generate_bytes_t(UInt8 * buffer, size_t bufferLen, unitytls_errorstate * errorState); public unitytls_random_generate_bytes_t unitytls_random_generate_bytes; } From 2d68de174d076f3835d90c6eb1d86d19364a46e7 Mon Sep 17 00:00:00 2001 From: andreasr Date: Wed, 14 Mar 2018 22:33:52 +0100 Subject: [PATCH 172/582] [unitytls] Workaround for crash on Android when calling unitytls_tlsctx_create_server_t --- mcs/class/System/Mono.UnityTls/UnityTls.cs | 4 +++- mcs/class/System/Mono.UnityTls/UnityTlsContext.cs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index 22adb9efdaf8..a7cd4b5b5860 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -231,8 +231,10 @@ public class unitytls_interface_struct public delegate unitytls_x509verify_result unitytls_x509verify_explicit_ca_t(unitytls_x509list_ref chain, unitytls_x509list_ref trustCA, Int8* cn, size_t cnLen, unitytls_x509verify_callback cb, void* userData, unitytls_errorstate* errorState); public unitytls_x509verify_explicit_ca_t unitytls_x509verify_explicit_ca; + // Note that we take UInt64 here instead of handles! + // This a workaround for an android specific crash, caused by a bug in Mono's implementation of native calls through the arm ABI. [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate unitytls_tlsctx* unitytls_tlsctx_create_server_t(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, unitytls_x509list_ref certChain, unitytls_key_ref leafCertificateKey, unitytls_errorstate* errorState); + public delegate unitytls_tlsctx* unitytls_tlsctx_create_server_t(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, UInt64 certChain, UInt64 leafCertificateKey, unitytls_errorstate* errorState); public unitytls_tlsctx_create_server_t unitytls_tlsctx_create_server; [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate unitytls_tlsctx* unitytls_tlsctx_create_client_t(unitytls_tlsctx_protocolrange supportedProtocols, unitytls_tlsctx_callbacks callbacks, Int8* cn, size_t cnLen, unitytls_errorstate* errorState); diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index 314215e59b3b..f54c82cac81a 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -80,7 +80,7 @@ public UnityTlsContext ( var serverKeyRef = UnityTls.NativeInterface.unitytls_key_get_ref (serverPrivateKey, &errorState); Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to parse server key/certificate"); - tlsContext = UnityTls.NativeInterface.unitytls_tlsctx_create_server (protocolRange, callbacks, serverCertsRef, serverKeyRef, &errorState); + tlsContext = UnityTls.NativeInterface.unitytls_tlsctx_create_server (protocolRange, callbacks, serverCertsRef.handle, serverKeyRef.handle, &errorState); if (askForClientCert) { UnityTls.unitytls_x509list* clientAuthCAList = null; From f517be783b39894282e786f6c40f5532b8c070e5 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 9 Mar 2018 16:35:39 -0500 Subject: [PATCH 173/582] Remove mono specific reference assemblies --- mcs/class/reference-assemblies/Makefile | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mcs/class/reference-assemblies/Makefile b/mcs/class/reference-assemblies/Makefile index d8f99734d2f0..798799a3d7d6 100644 --- a/mcs/class/reference-assemblies/Makefile +++ b/mcs/class/reference-assemblies/Makefile @@ -50,16 +50,17 @@ install-local: $(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.7/Facades/*.dll $(PROFILE_DIR)/4.7-api/Facades $(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.7.1/Facades/*.dll $(PROFILE_DIR)/4.7.1-api/Facades + # Unity: these are mono extensions to .NET we don't want to support going forward $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/2.0-api - $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.0-api - $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.5-api - $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.5.1-api - $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.5.2-api - $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.6-api - $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.6.1-api - $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.6.2-api - $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.7-api - $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.7.1-api + #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.0-api + #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.5-api + #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.5.1-api + #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.5.2-api + #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.6-api + #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.6.1-api + #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.6.2-api + #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.7-api + #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.7.1-api # Unfortunately, a few programs (most notably NUnit and FSharp) have hardcoded checks for /lib/mono/4.0/mscorlib.dll or Mono.Posix.dll, # so we need to place something there or those tools break. We decided to symlink to the reference assembly for now. From 13ef9d12d70e5e24276c3a2b23e64d160219621b Mon Sep 17 00:00:00 2001 From: Johan Lorensson Date: Fri, 16 Mar 2018 01:02:06 +0100 Subject: [PATCH 174/582] Fix issue #7596 on Windows x64. (#7625) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix error in vcxproj filter causing load error in Visual Studio. * Fixes issue #7596 on Windows x64. Passing value types in Windows x64 not fitting into register will be passed by reference (ArgValuetypeAddrInIReg or ArgValuetypeAddrOnStack ) using a local variable allocated in caller’s frame. Current implementation sized and marshaled the native struct correctly when using pinvoke, but it sized the final local passed as reference to the native method using the managed stack size instead of the native. This caused the final copy into the local to overwrite other locals on stack if managed and native struct stack sizes differed. The fix is to flag the local variable used as stack parameter with its pinvoke state. This makes sure the stack allocation size will be correct when using value types passed on the stacks in pinvokes. When running other unit tests with sequence points I hit a similar issue with empty structs as return parameters (using [StructLayout (LayoutKind.Sequential, Size = 0)]. This commit includes a fix to ignore the return value if it’s an empty struct on Windows x64. --- mono/mini/mini-amd64.c | 5 +++-- msvc/libmonoruntime-common.targets.filters | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mono/mini/mini-amd64.c b/mono/mini/mini-amd64.c index 4b7a7cc77507..309dcd95c2ff 100644 --- a/mono/mini/mini-amd64.c +++ b/mono/mini/mini-amd64.c @@ -606,7 +606,7 @@ add_valuetype_win64 (MonoMethodSignature *signature, ArgInfo *arg_info, MonoType get_valuetype_size_win64 (klass, signature->pinvoke, arg_info, type, &arg_class, &arg_size); /* Only drop value type if its not an empty struct as input that must be represented in call */ - if ((arg_size == 0 && !arg_info->pass_empty_struct) || (arg_size == 0 && arg_info->pass_empty_struct && is_return)) { + if ((arg_size == 0 && !arg_info->pass_empty_struct) || (arg_info->pass_empty_struct && is_return)) { arg_info->storage = ArgValuetypeInReg; arg_info->pair_storage [0] = arg_info->pair_storage [1] = ArgNone; } else { @@ -2228,7 +2228,8 @@ mono_arch_emit_outarg_vt (MonoCompile *cfg, MonoInst *ins, MonoInst *src) g_assert (ainfo->storage == ArgValuetypeAddrInIReg || (ainfo->storage == ArgValuetypeAddrOnStack && ainfo->pair_storage [0] == ArgNone)); vtaddr = mono_compile_create_var (cfg, &ins->klass->byval_arg, OP_LOCAL); - + vtaddr->backend.is_pinvoke = call->signature->pinvoke; + MONO_INST_NEW (cfg, load, OP_LDADDR); cfg->has_indirection = TRUE; load->inst_p0 = vtaddr; diff --git a/msvc/libmonoruntime-common.targets.filters b/msvc/libmonoruntime-common.targets.filters index a3ac56434536..76fd6bc7ae46 100644 --- a/msvc/libmonoruntime-common.targets.filters +++ b/msvc/libmonoruntime-common.targets.filters @@ -112,6 +112,12 @@ Source Files$(MonoRuntimeFilterSubFolder)\common + + Source Files$(MonoRuntimeFilterSubFolder)\common + + + Header Files$(MonoRuntimeFilterSubFolder)\common + Header Files$(MonoRuntimeFilterSubFolder)\common From c41badcae08ee292d68a3a2f0b1040bc15ce3cd5 Mon Sep 17 00:00:00 2001 From: Lukasz Paczkowski Date: Mon, 19 Mar 2018 14:30:53 +0100 Subject: [PATCH 175/582] Implement mono_unity_capture_memory_snapshot and mono_unity_free_captured_memory_snapshot. Based upon the implementation in Unity .NET 3.5 Mono: https://github.com/Unity-Technologies/mono/blob/unity-trunk/unity/unity_memory_info.c --- mono/metadata/boehm-gc.c | 24 ++ mono/metadata/gc-internals.h | 2 + mono/metadata/mempool.c | 18 ++ mono/metadata/mempool.h | 5 + mono/metadata/metadata.c | 38 +++ mono/metadata/metadata.h | 3 + mono/metadata/unity-memory-info.c | 441 ++++++++++++++++++++++++++++++ 7 files changed, 531 insertions(+) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index 260a09842a69..0a428ce00233 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -2058,6 +2058,30 @@ mono_gc_register_obj_with_weak_fields (void *obj) g_error ("Weak fields not supported by boehm gc"); } +void +mono_gc_strong_handle_foreach(GFunc func, gpointer user_data) +{ + int gcHandleTypeIndex; + uint32_t i; + + lock_handles(handles); + + for (gcHandleTypeIndex = HANDLE_NORMAL; gcHandleTypeIndex <= HANDLE_PINNED; gcHandleTypeIndex++) + { + HandleData* handles = &gc_handles[gcHandleTypeIndex]; + + for (i = 0; i < handles->size; i++) + { + if (!slot_occupied(handles, i)) + continue; + if (handles->entries[i] != NULL) + func(handles->entries[i], user_data); + } + } + + unlock_handles(handles); +} + #else MONO_EMPTY_SOURCE_FILE (boehm_gc); diff --git a/mono/metadata/gc-internals.h b/mono/metadata/gc-internals.h index c40fbae71fc0..22f556eafee9 100644 --- a/mono/metadata/gc-internals.h +++ b/mono/metadata/gc-internals.h @@ -140,6 +140,8 @@ MonoGCDescriptor mono_gc_make_descr_for_string (gsize *bitmap, int numbits); void mono_gc_register_obj_with_weak_fields (void *obj); +void mono_gc_strong_handle_foreach(GFunc func, gpointer user_data); + void mono_gc_register_for_finalization (MonoObject *obj, void *user_data); void mono_gc_add_memory_pressure (gint64 value); MONO_API int mono_gc_register_root (char *start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, void *key, const char *msg); diff --git a/mono/metadata/mempool.c b/mono/metadata/mempool.c index be5af1083f22..154b0213738f 100644 --- a/mono/metadata/mempool.c +++ b/mono/metadata/mempool.c @@ -434,3 +434,21 @@ mono_mempool_get_bytes_allocated (void) { return UnlockedRead64 (&total_bytes_allocated); } + +void +mono_mempool_foreach_block(MonoMemPool* pool, mono_mempool_block_proc callback, void* user_data) +{ + MonoMemPool *current = pool; + + while (current) + { + gpointer start = (guint8*)current + SIZEOF_MEM_POOL; + gpointer end = (guint8*)start + current->size; + + callback(start, end, user_data); + current = current->next; + } +} + + + diff --git a/mono/metadata/mempool.h b/mono/metadata/mempool.h index 1abc25cc406e..7e75cd138cab 100644 --- a/mono/metadata/mempool.h +++ b/mono/metadata/mempool.h @@ -41,6 +41,11 @@ mono_mempool_strdup (MonoMemPool *pool, const char *s); MONO_API uint32_t mono_mempool_get_allocated (MonoMemPool *pool); +typedef void(*mono_mempool_block_proc)(void* start, void* end, void* user_data); + +MONO_API void +mono_mempool_foreach_block(MonoMemPool* pool, mono_mempool_block_proc callback, void* user_data); + MONO_END_DECLS #endif diff --git a/mono/metadata/metadata.c b/mono/metadata/metadata.c index 378ceb4dc139..55ac7fd86ba7 100644 --- a/mono/metadata/metadata.c +++ b/mono/metadata/metadata.c @@ -5080,6 +5080,44 @@ mono_metadata_generic_class_is_valuetype (MonoGenericClass *gclass) return gclass->container_class->valuetype; } +typedef struct +{ + GFunc func; + gpointer user_data; +} GenericClassForeachData; + + +static void +generic_class_foreach_callback(gpointer key, gpointer value, gpointer user_data) +{ + GenericClassForeachData* data = (GenericClassForeachData*)user_data; + data->func(key, data->user_data); +} + +void +mono_metadata_generic_class_foreach(GFunc func, gpointer user_data) +{ + GenericClassForeachData data; + guint i; + + data.func = func; + data.user_data = user_data; + + for(i = 0; i < HASH_TABLE_SIZE; ++i) + { + MonoImageSet* imageSet = img_set_cache[i]; + + if (imageSet == NULL || imageSet->gclass_cache == NULL) + continue; + + mono_image_set_lock(imageSet); + + mono_conc_hashtable_foreach(imageSet->gclass_cache, generic_class_foreach_callback, &data); + + mono_image_set_unlock(imageSet); + } +} + static gboolean _mono_metadata_generic_class_equal (const MonoGenericClass *g1, const MonoGenericClass *g2, gboolean signature_only) { diff --git a/mono/metadata/metadata.h b/mono/metadata/metadata.h index 874852c9b076..5891b411d5a2 100644 --- a/mono/metadata/metadata.h +++ b/mono/metadata/metadata.h @@ -10,6 +10,7 @@ #include #include #include +#include MONO_BEGIN_DECLS @@ -423,6 +424,8 @@ MONO_API int mono_type_stack_size (MonoType *type, MONO_API mono_bool mono_type_generic_inst_is_valuetype (MonoType *type); MONO_API mono_bool mono_metadata_generic_class_is_valuetype (MonoGenericClass *gclass); +MONO_API void mono_metadata_generic_class_foreach(GFunc func, gpointer user_data); + MONO_API unsigned int mono_metadata_type_hash (MonoType *t1); MONO_API mono_bool mono_metadata_type_equal (MonoType *t1, MonoType *t2); diff --git a/mono/metadata/unity-memory-info.c b/mono/metadata/unity-memory-info.c index 5b531ad41c61..74f8bb1c30c0 100644 --- a/mono/metadata/unity-memory-info.c +++ b/mono/metadata/unity-memory-info.c @@ -1,15 +1,456 @@ #include #include #include "unity-memory-info.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct CollectMetadataContext +{ + GHashTable *allTypes; + int currentIndex; + MonoMetadataSnapshot* metadata; +} CollectMetadataContext; + +static void ContextInsertClass(CollectMetadataContext* context, MonoClass* klass) +{ + if (klass->inited && g_hash_table_lookup(context->allTypes, klass) == NULL) + g_hash_table_insert(context->allTypes, klass, (gpointer)(context->currentIndex++)); +} + +static void CollectHashMapClass(gpointer key, gpointer value, gpointer user_data) +{ + CollectMetadataContext* context = (CollectMetadataContext*)user_data; + MonoClass* klass = (MonoClass*)value; + ContextInsertClass(context, klass); +} + +static void CollectHashMapListClasses(gpointer key, gpointer value, gpointer user_data) +{ + CollectMetadataContext* context = (CollectMetadataContext*)user_data; + GSList* list = (GSList*)value; + + while (list != NULL) + { + MonoClass* klass = (MonoClass*)list->data; + ContextInsertClass(context, klass); + + list = g_slist_next(list); + } +} + +static void CollectGenericClass(gpointer value, gpointer user_data) +{ + CollectMetadataContext* context = (CollectMetadataContext*)user_data; + MonoGenericClass* genericClass = (MonoGenericClass*)value; + + if (genericClass->cached_class != NULL) + ContextInsertClass(context, genericClass->cached_class); +} + +static void CollectAssemblyMetaData(MonoAssembly *assembly, void *user_data) +{ + int i; + CollectMetadataContext* context = (CollectMetadataContext*)user_data; + MonoImage* image = mono_assembly_get_image(assembly); + MonoTableInfo *tdef = &image->tables[MONO_TABLE_TYPEDEF]; + + for (i = 0; i < tdef->rows - 1; ++i) + { + MonoClass* klass = mono_class_get(image, (i + 2) | MONO_TOKEN_TYPE_DEF); + ContextInsertClass(context, klass); + } + + if (image->array_cache) + g_hash_table_foreach(image->array_cache, CollectHashMapListClasses, user_data); + + if (image->szarray_cache) + g_hash_table_foreach(image->szarray_cache, CollectHashMapClass, user_data); + + if (image->ptr_cache) + g_hash_table_foreach(image->ptr_cache, CollectHashMapClass, user_data); +} + +static int FindClassIndex(GHashTable* hashTable, MonoClass* klass) +{ + gpointer value = g_hash_table_lookup(hashTable, klass); + + if (!value) + return -1; + + return (int)value; +} + +static void AddMetadataType(gpointer key, gpointer value, gpointer user_data) +{ + MonoClass* klass = (MonoClass*)key; + int index = (int)value; + CollectMetadataContext* context = (CollectMetadataContext*)user_data; + MonoMetadataSnapshot* metadata = context->metadata; + MonoMetadataType* type = &metadata->types[index]; + + if (klass->rank > 0) + { + type->flags = (MonoMetadataTypeFlags)(kArray | (kArrayRankMask & (klass->rank << 16))); + type->baseOrElementTypeIndex = FindClassIndex(context->allTypes, mono_class_get_element_class(klass)); + } + else + { + gpointer iter = NULL; + int fieldCount = 0; + MonoClassField* field; + MonoClass* baseClass; + MonoVTable* vtable; + void* statics_data; + + type->flags = (klass->valuetype || klass->byval_arg.type == MONO_TYPE_PTR) ? kValueType : kNone; + type->fieldCount = 0; + + if (mono_class_num_fields(klass) > 0) + { + type->fields = g_new(MonoMetadataField, mono_class_num_fields(klass)); + + while ((field = mono_class_get_fields(klass, &iter))) + { + MonoMetadataField* metaField = &type->fields[type->fieldCount]; + metaField->typeIndex = FindClassIndex(context->allTypes, mono_class_from_mono_type(field->type)); + + // This will happen if fields type is not initialized + // It's OK to skip it, because it means the field is guaranteed to be null on any object + if (metaField->typeIndex == -1) + continue; + + // literals have no actual storage, and are not relevant in this context. + if ((field->type->attrs & FIELD_ATTRIBUTE_LITERAL) != 0) + continue; + + metaField->isStatic = (field->type->attrs & FIELD_ATTRIBUTE_STATIC) != 0; + metaField->offset = field->offset; + metaField->name = field->name; + type->fieldCount++; + } + } + + vtable = mono_class_try_get_vtable(mono_domain_get(), klass); + statics_data = vtable ? mono_vtable_get_static_field_data(vtable) : NULL; + + type->staticsSize = statics_data ? mono_class_data_size(klass) : 0; + type->statics = NULL; + + if (type->staticsSize > 0) + { + type->statics = g_new0(uint8_t, type->staticsSize); + memcpy(type->statics, statics_data, type->staticsSize); + } + + baseClass = mono_class_get_parent(klass); + type->baseOrElementTypeIndex = baseClass ? FindClassIndex(context->allTypes, baseClass) : -1; + } + + type->assemblyName = mono_class_get_image(klass)->assembly->aname.name; + type->name = mono_type_get_name_full(&klass->byval_arg, MONO_TYPE_NAME_FORMAT_IL); + type->typeInfoAddress = (uint64_t)klass; + type->size = (klass->valuetype) != 0 ? (mono_class_instance_size(klass) - sizeof(MonoObject)) : mono_class_instance_size(klass); +} + +static void CollectMetadata(MonoMetadataSnapshot* metadata) +{ + CollectMetadataContext context; + + context.allTypes = g_hash_table_new(NULL, NULL); + context.currentIndex = 0; + context.metadata = metadata; + + mono_assembly_foreach((GFunc)CollectAssemblyMetaData, &context); + + mono_metadata_generic_class_foreach(CollectGenericClass, &context); + + metadata->typeCount = g_hash_table_size(context.allTypes); + metadata->types = g_new0(MonoMetadataType, metadata->typeCount); + + g_hash_table_foreach(context.allTypes, AddMetadataType, &context); + + g_hash_table_destroy(context.allTypes); +} + +static void MonoMemPoolNumChunksCallback(void* start, void* end, void* user_data) +{ + int* count = (int*)user_data; + (*count)++; +} + +static int MonoMemPoolNumChunks(MonoMemPool* pool) +{ + int count = 0; + mono_mempool_foreach_block(pool, MonoMemPoolNumChunksCallback, &count); + return count; +} + +typedef struct SectionIterationContext +{ + MonoManagedMemorySection* currentSection; +} SectionIterationContext; + +static void AllocateMemoryForSection(void* context, void* sectionStart, void* sectionEnd) +{ + ptrdiff_t sectionSize; + + SectionIterationContext* ctx = (SectionIterationContext*)context; + MonoManagedMemorySection* section = ctx->currentSection; + + section->sectionStartAddress = (uint64_t)sectionStart; + sectionSize = (uint8_t*)(sectionEnd)-(uint8_t*)(sectionStart); + + section->sectionSize = (uint32_t)(sectionSize); + section->sectionBytes = g_new(uint8_t, section->sectionSize); + + ctx->currentSection++; +} + +static void AllocateMemoryForMemPoolChunk(void* chunkStart, void* chunkEnd, void* context) +{ + AllocateMemoryForSection(context, chunkStart, chunkEnd); +} + +static void CopyHeapSection(void* context, void* sectionStart, void* sectionEnd) +{ + SectionIterationContext* ctx = (SectionIterationContext*)(context); + MonoManagedMemorySection* section = ctx->currentSection; + + g_assert(section->sectionStartAddress == (uint64_t)(sectionStart)); + g_assert(section->sectionSize == (uint8_t*)(sectionEnd)-(uint8_t*)(sectionStart)); + memcpy(section->sectionBytes, sectionStart, section->sectionSize); + + ctx->currentSection++; +} + +static void CopyMemPoolChunk(void* chunkStart, void* chunkEnd, void* context) +{ + CopyHeapSection(context, chunkStart, chunkEnd); +} + +static void AddImageMemoryPoolChunkCount(MonoAssembly *assembly, MonoManagedHeap* heap) +{ + heap->sectionCount += MonoMemPoolNumChunks(assembly->image->mempool); +} + +static void IncrementCountForImageMemPoolNumChunks(MonoAssembly *assembly, void *user_data) +{ + int* count = (int*)user_data; + (*count) += MonoMemPoolNumChunks(assembly->image->mempool); +} + +static int MonoImagesMemPoolNumChunks() +{ + int count = 0; + mono_assembly_foreach((GFunc)IncrementCountForImageMemPoolNumChunks, &count); + return count; +} + +static void AllocateMemoryForImageMemPool(MonoAssembly *assembly, void *user_data) +{ + MonoImage* image = assembly->image; + + mono_image_lock(image); + mono_mempool_foreach_block(image->mempool, AllocateMemoryForMemPoolChunk, user_data); + mono_image_unlock(image); +} + +static void* CaptureHeapInfo(void* monoManagedHeap) +{ + MonoManagedHeap* heap = (MonoManagedHeap*)monoManagedHeap; + MonoDomain* domain = mono_domain_get(); + SectionIterationContext iterationContext; + + // Increment count for each heap section + heap->sectionCount = GC_get_heap_section_count(); + // Increment count for the domain mem pool chunk + heap->sectionCount += MonoMemPoolNumChunks(domain->mp); + // Increment count for each image mem pool chunk + heap->sectionCount += MonoImagesMemPoolNumChunks(); + + heap->sections = g_new0(MonoManagedMemorySection, heap->sectionCount); + + iterationContext.currentSection = heap->sections; + + // Allocate memory for each heap section + GC_foreach_heap_section(&iterationContext, AllocateMemoryForSection); + // Allocate memory for the domain mem pool chunk + mono_domain_lock(domain); + mono_mempool_foreach_block(domain->mp, AllocateMemoryForMemPoolChunk, &iterationContext); + mono_domain_unlock(domain); + // Allocate memory for each image mem pool chunk + mono_assembly_foreach((GFunc)AllocateMemoryForImageMemPool, &iterationContext); + + return NULL; +} + +static void FreeMonoManagedHeap(MonoManagedHeap* heap) +{ + uint32_t i; + + for (i = 0; i < heap->sectionCount; i++) + { + g_free(heap->sections[i].sectionBytes); + } + + g_free(heap->sections); +} + +typedef struct VerifyHeapSectionStillValidIterationContext +{ + MonoManagedMemorySection* currentSection; + gboolean wasValid; +} VerifyHeapSectionStillValidIterationContext; + +static void VerifyHeapSectionIsStillValid(void* context, void* sectionStart, void* sectionEnd) +{ + VerifyHeapSectionStillValidIterationContext* iterationContext = (VerifyHeapSectionStillValidIterationContext*)context; + if (iterationContext->currentSection->sectionSize != (uint8_t*)(sectionEnd)-(uint8_t*)(sectionStart)) + iterationContext->wasValid = FALSE; + else if (iterationContext->currentSection->sectionStartAddress != (uint64_t)(sectionStart)) + iterationContext->wasValid = FALSE; + + iterationContext->currentSection++; +} + +static gboolean MonoManagedHeapStillValid(MonoManagedHeap* heap) +{ + MonoDomain* domain = mono_domain_get(); + VerifyHeapSectionStillValidIterationContext iterationContext; + int currentSectionCount; + + currentSectionCount = GC_get_heap_section_count(); + currentSectionCount += MonoMemPoolNumChunks(domain->mp); + currentSectionCount += MonoImagesMemPoolNumChunks(); + + if (heap->sectionCount != currentSectionCount) + return FALSE; + + iterationContext.currentSection = heap->sections; + iterationContext.wasValid = TRUE; + + GC_foreach_heap_section(&iterationContext, VerifyHeapSectionIsStillValid); + + return iterationContext.wasValid; +} + +// The difficulty in capturing the managed snapshot is that we need to do quite some work with the world stopped, +// to make sure that our snapshot is "valid", and didn't change as we were copying it. However, stopping the world, +// makes it so you cannot take any lock or allocations. We deal with it like this: +// +// 1) We take note of the amount of heap sections and their sizes, and we allocate memory to copy them into. +// 2) We stop the world. +// 3) We check if the amount of heapsections and their sizes didn't change in the mean time. If they did, try again. +// 4) Now, with the world still stopped, we memcpy() the memory from the real heapsections, into the memory that we +// allocated for their copies. +// 5) Start the world again. + +static void CaptureManagedHeap(MonoManagedHeap* heap) +{ + MonoDomain* domain = mono_domain_get(); + SectionIterationContext iterationContext; + + while (TRUE) + { + GC_call_with_alloc_lock(CaptureHeapInfo, heap); + GC_stop_world_external(); + + if (MonoManagedHeapStillValid(heap)) + break; + + GC_start_world_external(); + + FreeMonoManagedHeap(heap); + } + + iterationContext.currentSection = heap->sections; + GC_foreach_heap_section(&iterationContext, CopyHeapSection); + + mono_mempool_foreach_block(domain->mp, CopyMemPoolChunk, &iterationContext); + + GC_start_world_external(); +} + +static void GCHandleIterationCallback(MonoObject* managedObject, GList** managedObjects) +{ + *managedObjects = g_list_append(*managedObjects, managedObject); +} + +static inline void CaptureGCHandleTargets(MonoGCHandles* gcHandles) +{ + uint32_t i; + GList* trackedObjects, *trackedObject; + + trackedObjects = NULL; + + mono_gc_strong_handle_foreach((GFunc)GCHandleIterationCallback, &trackedObjects); + + gcHandles->trackedObjectCount = (uint32_t)g_list_length(trackedObjects); + gcHandles->pointersToObjects = (uint64_t*)g_new0(uint64_t, gcHandles->trackedObjectCount); + + trackedObject = trackedObjects; + + for (i = 0; i < gcHandles->trackedObjectCount; i++) + { + gcHandles->pointersToObjects[i] = (uint64_t)trackedObject->data; + trackedObject = g_list_next(trackedObject); + } + + g_list_free(trackedObjects); +} + +static void FillRuntimeInformation(MonoRuntimeInformation* runtimeInfo) +{ + runtimeInfo->pointerSize = (uint32_t)(sizeof(void*)); + runtimeInfo->objectHeaderSize = (uint32_t)(sizeof(MonoObject)); + runtimeInfo->arrayHeaderSize = offsetof(MonoArray, vector); + runtimeInfo->arraySizeOffsetInHeader = offsetof(MonoArray, max_length); + runtimeInfo->arrayBoundsOffsetInHeader = offsetof(MonoArray, bounds); + runtimeInfo->allocationGranularity = (uint32_t)(2 * sizeof(void*)); +} MonoManagedMemorySnapshot* mono_unity_capture_memory_snapshot() { MonoManagedMemorySnapshot* snapshot; snapshot = g_new0(MonoManagedMemorySnapshot, 1); + + CollectMetadata(&snapshot->metadata); + CaptureManagedHeap(&snapshot->heap); + CaptureGCHandleTargets(&snapshot->gcHandles); + FillRuntimeInformation(&snapshot->runtimeInformation); + return snapshot; } void mono_unity_free_captured_memory_snapshot(MonoManagedMemorySnapshot* snapshot) { + uint32_t i; + MonoMetadataSnapshot* metadata = &snapshot->metadata; + + FreeMonoManagedHeap(&snapshot->heap); + + g_free(snapshot->gcHandles.pointersToObjects); + + for (i = 0; i < metadata->typeCount; i++) + { + if ((metadata->types[i].flags & kArray) == 0) + { + g_free(metadata->types[i].fields); + g_free(metadata->types[i].statics); + } + + g_free(metadata->types[i].name); + } + + g_free(metadata->types); g_free(snapshot); } \ No newline at end of file From 02e341b607552a87bce1e2b31ec03a0da25a34b0 Mon Sep 17 00:00:00 2001 From: Brian Raderman Date: Mon, 19 Mar 2018 11:27:47 -0400 Subject: [PATCH 176/582] unity_process_breakpoint_inner(), like its Mono counterpart, will process breakpoint, stepping, and method exit/entry events all at the same time when checking a sequence point. So, if there is is a breakpoint and a stepping event at the same time, the debugger agent will suspend the current thread twice, which means you have to click the step button in the debugger client twice on that line. The fix for this is to only consider one of these events at a time and ignore the others. --- mono/mini/debugger-agent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index e08e23f7b89e..ca10db1f6778 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -12277,9 +12277,9 @@ unity_process_breakpoint_inner(DebuggerTlsData *tls, gboolean from_signal, Il2Cp if (ss_reqs->len > 0) ss_events = create_event_list(EVENT_KIND_STEP, ss_reqs, sequencePoint, NULL, &suspend_policy); - if (bp_reqs->len > 0) + else if (bp_reqs->len > 0) bp_events = create_event_list(EVENT_KIND_BREAKPOINT, bp_reqs, sequencePoint, NULL, &suspend_policy); - if (kind != EVENT_KIND_BREAKPOINT) + else if (kind != EVENT_KIND_BREAKPOINT) enter_leave_events = create_event_list(kind, NULL, sequencePoint, NULL, &suspend_policy); mono_loader_unlock(); From 24a16c17987c5d008a86b58c8ba7fa749b27e50e Mon Sep 17 00:00:00 2001 From: Brian Raderman Date: Tue, 13 Mar 2018 10:28:19 -0400 Subject: [PATCH 177/582] If a bad header is received from the client or the connection is broken, send an internal VM_DISPOSE command to shut down the debugger thread properly. This prevents runtime hangs that occur during profile events after the debugger shuts down. --- mono/mini/debugger-agent.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index e08e23f7b89e..841d4e158f42 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -12015,17 +12015,21 @@ debugger_thread (void *arg) /* This will break if the socket is closed during shutdown too */ if (res != HEADER_LENGTH) { DEBUG_PRINTF (1, "[dbg] transport_recv () returned %d, expected %d.\n", res, HEADER_LENGTH); - break; - } - - p = header; - end = header + HEADER_LENGTH; + len = HEADER_LENGTH; + id = 0; + flags = 0; + command_set = CMD_SET_VM; + command = CMD_VM_DISPOSE; + } else { + p = header; + end = header + HEADER_LENGTH; - len = decode_int (p, &p, end); - id = decode_int (p, &p, end); - flags = decode_byte (p, &p, end); - command_set = (CommandSet)decode_byte (p, &p, end); - command = decode_byte (p, &p, end); + len = decode_int (p, &p, end); + id = decode_int (p, &p, end); + flags = decode_byte (p, &p, end); + command_set = (CommandSet)decode_byte (p, &p, end); + command = decode_byte (p, &p, end); + } g_assert (flags == 0); From 9304fdd2f8893a4e9494f9c8f8344d0233b887ea Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Mon, 19 Mar 2018 11:56:39 -0400 Subject: [PATCH 178/582] Remove IL2CPP copy scripts. This is in IL2CPP repo now. --- external/buildscripts/build.pl | 12 - external/buildscripts/copy_il2cpp_sources.pl | 64 --- external/buildscripts/sources.txt | 547 ------------------- 3 files changed, 623 deletions(-) delete mode 100644 external/buildscripts/copy_il2cpp_sources.pl delete mode 100644 external/buildscripts/sources.txt diff --git a/external/buildscripts/build.pl b/external/buildscripts/build.pl index f186145f0e90..7b05e3d2ecae 100644 --- a/external/buildscripts/build.pl +++ b/external/buildscripts/build.pl @@ -1669,18 +1669,6 @@ system("cp", "$monoprefix/bin/mono-2.0-sgen.pdb", "$embedDirArchDestination/mono-2.0-sgen.pdb") eq 0 or die ("failed copying mono-2.0-sgen.pdb\n"); } - # sources directory setup - print ">>> Copying mono sources needed for il2cpp\n"; - system("mkdir -p $sourcesroot") eq 0 or die "failed making directory $sourcesroot\n"; - - # need to build some arm headers to package up for android - chdir("$monoroot/mono/arch/arm") eq 1 or die ("failed to chdir to mono/arch/arm directory\n"); - system(@commandPrefix, ("make")) eq 0 or die ("failed to make arm headers\n"); - print(">>> Changing directory back to : $currentdir\n"); - chdir("$currentdir") eq 1 or die ("failed to chdir to $currentdir\n"); - - system("perl", "$buildscriptsdir/copy_il2cpp_sources.pl", "--monoroot=$monoroot", "--sourcesroot=$sourcesroot") eq 0 or die ('failed to copy the source files needed for il2cpp'); - # monodistribution directory setup print(">>> Creating monodistribution directory\n"); if ($android || $iphone || $iphoneCross || $iphoneSimulator || $tizen || $tizenEmulator) diff --git a/external/buildscripts/copy_il2cpp_sources.pl b/external/buildscripts/copy_il2cpp_sources.pl deleted file mode 100644 index 2f5b63364bb4..000000000000 --- a/external/buildscripts/copy_il2cpp_sources.pl +++ /dev/null @@ -1,64 +0,0 @@ -# -# Use this script to copy the Mono file used by IL2CPP. -# perl external\buildscripts\copy_il2cpp_sources.pl --monoroot= --sourcesroot=\External\MonoBleedingEdge\builds\source -# - -use File::Basename; -use File::Copy; -use File::Path; -use Getopt::Long; - -my $monoroot =""; -my $sourcesroot = ""; - -GetOptions( - 'monoroot=s'=>\$monoroot, - 'sourcesroot=s'=>\$sourcesroot, -) or die ("illegal cmdline options"); - -my $sourcesFile = "$monoroot/external/buildscripts/sources.txt"; -open(SOURCE_FILE, $sourcesFile) or die "failed opening $sourcesFile\n"; -my @listOfSourceFilesLines = ; -close(SOURCE_FILE); -chomp(@listOfSourceFilesLines); - -my $isPrivateFile = 0; -foreach my $sourcesLine(@listOfSourceFilesLines) -{ - if($sourcesLine =~ /#.*/) - { - next; - } - elsif($sourcesLine =~ /SOURCES:/ or $sourcesLine =~ /HEADERS:/ or $sourcesLine =~ /METADATA:/) - { - $isPrivateFile = 0; - next; - } - elsif($sourcesLine =~ /PRIVATE:/) - { - $isPrivateFile = 1; - next; - } - - $fileToCopy = "$monoroot/$sourcesLine"; - $destFile = "$sourcesroot/$sourcesLine"; - if($isPrivateFile) - { - $destFile =~ s/(.*)\/(.*\.c)/$1\/private\/$2/g; - } - - $destDir = dirname("$destFile"); - if (!-d $destDir) - { - mkpath($destDir) or die "failed making directory $destDir\n"; - } - - if (-e $fileToCopy) - { - copy($fileToCopy, $destFile) or die "failed to copy $fileToCopy to $destFile\n"; - } - else - { - die "Source file to copy does not exist: $fileToCopy\n"; - } -} diff --git a/external/buildscripts/sources.txt b/external/buildscripts/sources.txt deleted file mode 100644 index 884a7456ec75..000000000000 --- a/external/buildscripts/sources.txt +++ /dev/null @@ -1,547 +0,0 @@ -#################### -#mono eglib files -#################### -SOURCES: -mono/eglib/garray.c -mono/eglib/gbytearray.c -mono/eglib/gerror.c -mono/eglib/gfile.c -mono/eglib/ghashtable.c -mono/eglib/giconv.c -mono/eglib/glist.c -mono/eglib/gmarkup.c -mono/eglib/gmem.c -mono/eglib/goutput.c -mono/eglib/gpattern.c -mono/eglib/gptrarray.c -mono/eglib/gqsort.c -mono/eglib/gqueue.c -mono/eglib/gshell.c -mono/eglib/gslist.c -mono/eglib/gspawn.c -mono/eglib/gpath.c -mono/eglib/gstr.c -mono/eglib/gstring.c -mono/eglib/gunicode.c -mono/eglib/gutf8.c -mono/eglib/gmisc-unity.c -mono/eglib/gfile-unity.c -mono/eglib/gdate-unity.c -mono/eglib/gdir-unity.c -mono/eglib/gunicode-win32.c -HEADERS: -mono/eglib/glib.h -mono/eglib/gmodule.h -mono/eglib/sort.frag.h -mono/eglib/eglib-remap.h -mono/eglib/unicode-data.h -#################### -#mono utils files -#################### -SOURCES: -mono/utils/dlmalloc.c -mono/utils/hazard-pointer.c -mono/utils/json.c -mono/utils/lock-free-alloc.c -mono/utils/lock-free-array-queue.c -mono/utils/lock-free-queue.c -mono/utils/mach-support-amd64.c -mono/utils/mach-support-x86.c -mono/utils/mach-support.c -mono/utils/mono-codeman.c -mono/utils/mono-conc-hashtable.c -mono/utils/mono-context.c -mono/utils/mono-counters.c -mono/utils/mono-dl-unity.c -mono/utils/mono-dl-windows.c -mono/utils/mono-dl-darwin.c -mono/utils/mono-dl-posix.c -mono/utils/mono-dl.c -mono/utils/mono-error.c -mono/utils/mono-filemap.c -mono/utils/mono-internal-hash.c -mono/utils/mono-io-portability.c -mono/utils/mono-linked-list-set.c -mono/utils/mono-logger.c -mono/utils/mono-log-unity.c -mono/utils/mono-log-android.c -mono/utils/mono-log-windows.c -mono/utils/mono-log-darwin.c -mono/utils/mono-log-posix.c -mono/utils/mono-log-common.c -mono/utils/mono-math.c -mono/utils/mono-md5.c -mono/utils/mono-mmap.c -mono/utils/mono-mmap-windows.c -mono/utils/mono-os-mutex.c -mono/utils/mono-os-wait-win32.c -mono/utils/mono-os-wait-win32-uwp.c -mono/utils/mono-networkinterfaces.c -mono/utils/mono-threads-state-machine.c -mono/utils/networking.c -mono/utils/networking-posix.c -mono/utils/networking-missing.c -mono/utils/networking-windows.c -mono/utils/networking-unity.c -mono/utils/mono-path.c -mono/utils/mono-poll.c -mono/utils/mono-proclib.c -mono/utils/mono-proclib-windows.c -mono/utils/mono-property-hash.c -mono/utils/mono-publib.c -mono/utils/mono-sha1.c -mono/utils/mono-stdlib.c -mono/utils/mono-threads-android.c -mono/utils/mono-threads-mach.c -mono/utils/mono-threads-mach-helper.c -mono/utils/mono-threads-posix.c -mono/utils/mono-threads-posix-signals.c -mono/utils/mono-threads-windows.c -mono/utils/mono-threads.c -mono/utils/mono-threads-coop.c -mono/utils/mono-threads-unity.c -mono/utils/mono-tls.c -mono/utils/mono-uri.c -mono/utils/mono-value-hash.c -mono/utils/monobitset.c -mono/utils/strenc.c -mono/utils/atomic.c -mono/utils/mono-hwcap.c -mono/utils/mono-hwcap-arm.c -mono/utils/mono-hwcap-x86.c -mono/utils/bsearch.c -mono/utils/memfuncs.c -mono/utils/parse.c -mono/utils/os-event-unity.c -mono/utils/os-event-win32.c -mono/utils/os-event-unix.c -mono/utils/unity-rand.c -mono/utils/unity-time.c -mono/utils/win64.asm -HEADERS: -mono/utils/checked-build.h -mono/utils/dlmalloc.h -mono/utils/dtrace.h -mono/utils/freebsd-dwarf.h -mono/utils/freebsd-elf32.h -mono/utils/freebsd-elf64.h -mono/utils/freebsd-elf_common.h -mono/utils/gc_wrapper.h -mono/utils/hazard-pointer.h -mono/utils/json.h -mono/utils/linux_magic.h -mono/utils/lock-free-alloc.h -mono/utils/lock-free-array-queue.h -mono/utils/lock-free-queue.h -mono/utils/mach-support.h -mono/utils/memcheck.h -mono/utils/mono-codeman.h -mono/utils/mono-compiler.h -mono/utils/mono-complex.h -mono/utils/mono-conc-hashtable.h -mono/utils/mono-context.h -mono/utils/mono-coop-mutex.h -mono/utils/mono-coop-semaphore.h -mono/utils/mono-counters.h -mono/utils/mono-digest.h -mono/utils/mono-dl-fallback.h -mono/utils/mono-dl-windows-internals.h -mono/utils/mono-dl.h -mono/utils/mono-embed.h -mono/utils/mono-error-internals.h -mono/utils/mono-error.h -mono/utils/mono-internal-hash.h -mono/utils/mono-io-portability.h -mono/utils/mono-lazy-init.h -mono/utils/mono-linked-list-set.h -mono/utils/mono-logger-internals.h -mono/utils/mono-logger.h -mono/utils/mono-machine.h -mono/utils/mono-math.h -mono/utils/mono-membar.h -mono/utils/mono-memory-model.h -mono/utils/mono-mmap-internals.h -mono/utils/mono-mmap-windows-internals.h -mono/utils/mono-mmap.h -mono/utils/mono-networkinterfaces.h -mono/utils/mono-once.h -mono/utils/mono-os-mutex.h -mono/utils/mono-os-semaphore.h -mono/utils/mono-os-wait.h -mono/utils/mono-path.h -mono/utils/mono-poll.h -mono/utils/mono-proclib.h -mono/utils/mono-property-hash.h -mono/utils/mono-publib.h -mono/utils/mono-rand.h -mono/utils/mono-sigcontext.h -mono/utils/mono-signal-handler.h -mono/utils/mono-stack-unwinding.h -mono/utils/mono-stdlib.h -mono/utils/mono-string.h -mono/utils/mono-threads.h -mono/utils/mono-threads-api.h -mono/utils/mono-threads-coop.h -mono/utils/mono-threads-debug.h -mono/utils/mono-time.h -mono/utils/mono-tls.h -mono/utils/mono-uri.h -mono/utils/mono-value-hash.h -mono/utils/monobitset.h -mono/utils/networking.h -mono/utils/refcount.h -mono/utils/strenc.h -mono/utils/valgrind.h -mono/utils/atomic.h -mono/utils/mono-hwcap-vars.h -mono/utils/mono-hwcap.h -mono/utils/bsearch.h -mono/utils/memfuncs.h -mono/utils/parse.h -mono/utils/os-event.h -mono/utils/unlocked.h -mono/utils/w32api.h -mono/utils/ward.h -#################### -#mono runtime files -#################### -SOURCES: -mono/metadata/appdomain.c -mono/metadata/assembly.c -mono/metadata/attach.c -mono/metadata/boehm-gc.c -mono/metadata/class.c -mono/metadata/class-accessors.c -mono/metadata/cominterop.c -mono/metadata/console-unity.c -mono/metadata/console-unix.c -mono/metadata/console-win32.c -mono/metadata/coree.c -mono/metadata/custom-attrs.c -mono/metadata/debug-helpers.c -mono/metadata/debug-mono-ppdb.c -mono/metadata/debug-mono-symfile.c -mono/metadata/decimal-ms.c -mono/metadata/domain.c -mono/metadata/dynamic-image.c -mono/metadata/dynamic-stream.c -mono/metadata/environment.c -mono/metadata/exception.c -mono/metadata/fdhandle.c -mono/metadata/file-mmap-posix.c -mono/metadata/file-mmap-unity.c -mono/metadata/file-mmap-windows.c -mono/metadata/filewatcher.c -mono/metadata/gc-stats.c -mono/metadata/gc.c -mono/metadata/handle.c -mono/metadata/icall.c -mono/metadata/icall-windows.c -mono/metadata/image.c -mono/metadata/jit-info.c -mono/metadata/loader.c -mono/metadata/locales.c -mono/metadata/lock-tracer.c -mono/metadata/marshal.c -mono/metadata/marshal-windows.c -mono/metadata/mempool.c -mono/metadata/metadata-verify.c -mono/metadata/metadata.c -mono/metadata/metadata-cross-helpers.c -mono/metadata/method-builder.c -mono/metadata/monitor.c -mono/metadata/mono-basic-block.c -mono/metadata/mono-conc-hash.c -mono/metadata/mono-config.c -mono/metadata/mono-config-dirs.c -mono/metadata/mono-debug.c -mono/metadata/mono-endian.c -mono/metadata/mono-hash.c -mono/metadata/mono-mlist.c -mono/metadata/mono-perfcounters.c -mono/metadata/mono-route.c -mono/metadata/mono-security.c -mono/metadata/mono-security-windows.c -mono/metadata/null-gc.c -mono/metadata/null-gc-handles.h -mono/metadata/number-ms.c -mono/metadata/object.c -mono/metadata/opcodes.c -mono/metadata/profiler.c -mono/metadata/property-bag.c -mono/metadata/rand.c -mono/metadata/reflection.c -mono/metadata/remoting.c -mono/metadata/runtime.c -mono/metadata/security-core-clr.c -mono/metadata/security-manager.c -mono/metadata/seq-points-data.c -mono/metadata/sgen-mono.c -mono/metadata/sgen-bridge.c -mono/metadata/sgen-new-bridge.c -mono/metadata/sgen-old-bridge.c -mono/metadata/sgen-tarjan-bridge.c -mono/metadata/sgen-toggleref.c -mono/metadata/sgen-stw.c -mono/metadata/sre.c -mono/metadata/sre-encode.c -mono/metadata/sre-save.c -mono/metadata/string-icalls.c -mono/metadata/sysmath.c -mono/metadata/threads.c -mono/metadata/threadpool.c -mono/metadata/threadpool-io.c -mono/metadata/threadpool-worker-default.c -mono/metadata/verify.c -mono/metadata/unity-liveness.c -mono/metadata/unity-utils.c -mono/metadata/unity-icall.c -mono/metadata/w32error-unity.c -mono/metadata/w32error-win32.c -mono/metadata/w32error-unix.c -mono/metadata/w32event-unity.c -mono/metadata/w32event-unix.c -mono/metadata/w32event-win32.c -mono/metadata/w32file-unity.c -mono/metadata/w32file-unix.c -mono/metadata/w32file-win32.c -mono/metadata/w32file-unix-glob.c -mono/metadata/w32file.c -mono/metadata/w32handle-namespace.c -mono/metadata/w32handle.c -mono/metadata/w32mutex-unity.c -mono/metadata/w32mutex-unix.c -mono/metadata/w32mutex-win32.c -mono/metadata/w32process-unity.c -mono/metadata/w32process-unix-osx.c -mono/metadata/w32process-unix-default.c -mono/metadata/w32process-unix.c -mono/metadata/w32process-win32.c -mono/metadata/w32process.c -mono/metadata/w32semaphore-unity.c -mono/metadata/w32semaphore-unix.c -mono/metadata/w32semaphore-win32.c -mono/metadata/w32socket-unity.c -mono/metadata/w32socket-unix.c -mono/metadata/w32socket-win32.c -mono/metadata/w32socket.c -HEADERS: -mono/metadata/abi-details.h -mono/metadata/attrdefs.h -mono/metadata/appdomain.h -mono/metadata/appdomain-icalls.h -mono/metadata/assembly-internals.h -mono/metadata/assembly.h -mono/metadata/attach.h -mono/metadata/blob.h -mono/metadata/callspec.h -mono/metadata/cil-coff.h -mono/metadata/class-inlines.h -mono/metadata/class-internals.h -mono/metadata/class.h -mono/metadata/cominterop-win32-internals.h -mono/metadata/cominterop.h -mono/metadata/console-io.h -mono/metadata/coree-internals.h -mono/metadata/coree.h -mono/metadata/culture-info-tables.h -mono/metadata/culture-info.h -mono/metadata/custom-attrs-internals.h -mono/metadata/debug-helpers.h -mono/metadata/debug-internals.h -mono/metadata/debug-mono-ppdb.h -mono/metadata/debug-mono-symfile.h -mono/metadata/decimal-ms.h -mono/metadata/domain-internals.h -mono/metadata/dynamic-image-internals.h -mono/metadata/dynamic-stream-internals.h -mono/metadata/environment.h -mono/metadata/exception-internals.h -mono/metadata/exception.h -mono/metadata/fdhandle.h -mono/metadata/filewatcher.h -mono/metadata/file-mmap.h -mono/metadata/gc-internals.h -mono/metadata/handle.h -mono/metadata/number-ms.h -mono/metadata/remoting.h -mono/metadata/row-indexes.h -mono/metadata/seq-points-data.h -mono/metadata/sgen-bridge-internals.h -mono/metadata/sgen-client-mono.h -mono/metadata/sgen-dynarray.h -mono/sgen/gc-internal-agnostic.h -mono/metadata/icall-def.h -mono/metadata/icall-internals.h -mono/metadata/icall-windows-internals.h -mono/metadata/il2cpp-compat-metadata.h -mono/metadata/image-internals.h -mono/metadata/image.h -mono/metadata/loader.h -mono/metadata/locales.h -mono/metadata/lock-tracer.h -mono/metadata/marshal-internals.h -mono/metadata/marshal-windows-internals.h -mono/metadata/marshal.h -mono/metadata/mempool-internals.h -mono/metadata/mempool.h -mono/metadata/metadata-internals.h -mono/metadata/metadata.h -mono/metadata/method-builder.h -mono/metadata/monitor.h -mono/metadata/mono-basic-block.h -mono/metadata/mono-conc-hash.h -mono/metadata/mono-config.h -mono/metadata/mono-config-dirs.h -mono/metadata/mono-debug.h -mono/metadata/mono-endian.h -mono/metadata/mono-gc.h -mono/metadata/mono-hash.h -mono/metadata/mono-mlist.h -mono/metadata/mono-perfcounters-def.h -mono/metadata/mono-perfcounters.h -mono/metadata/mono-ptr-array.h -mono/metadata/mono-route.h -mono/metadata/mono-security-windows-internals.h -mono/metadata/normalization-tables.h -mono/metadata/number-formatter.h -mono/metadata/object-internals.h -mono/metadata/object-offsets.h -mono/metadata/object.h -mono/metadata/opcodes.h -mono/metadata/profiler-private.h -mono/metadata/profiler.h -mono/metadata/profiler-events.h -mono/metadata/property-bag.h -mono/metadata/rand.h -mono/metadata/reflection.h -mono/metadata/reflection-cache.h -mono/metadata/reflection-internals.h -mono/metadata/runtime.h -mono/metadata/security-core-clr.h -mono/metadata/security-manager.h -mono/metadata/security.h -mono/metadata/sgen-bridge.h -mono/metadata/sgen-toggleref.h -mono/metadata/sre-internals.h -mono/metadata/string-icalls.h -mono/metadata/sysmath.h -mono/metadata/tabledefs.h -mono/metadata/threadpool.h -mono/metadata/threadpool-io.h -mono/metadata/threadpool-worker.h -mono/metadata/threads.h -mono/metadata/threads-types.h -mono/metadata/tokentype.h -mono/metadata/verify-internals.h -mono/metadata/verify.h -mono/metadata/unity-utils.h -mono/metadata/wrapper-types.h -mono/metadata/w32error.h -mono/metadata/w32event.h -mono/metadata/w32file-internals.h -mono/metadata/w32file-win32-internals.h -mono/metadata/w32file-unix-glob.h -mono/metadata/w32file.h -mono/metadata/w32handle-namespace.h -mono/metadata/w32handle.h -mono/metadata/w32mutex.h -mono/metadata/w32process-internals.h -mono/metadata/w32process-unix-internals.h -mono/metadata/w32process-win32-internals.h -mono/metadata/w32process.h -mono/metadata/w32semaphore.h -mono/metadata/w32socket.h -mono/metadata/w32socket-internals.h -PRIVATE: -mono/metadata/threadpool-io-epoll.c -mono/metadata/threadpool-io-kqueue.c -mono/metadata/threadpool-io-poll.c -#################### -#mono sgen files -#################### -SOURCES: -mono/sgen/sgen-alloc.c -mono/sgen/sgen-array-list.c -mono/sgen/sgen-cardtable.c -mono/sgen/sgen-debug.c -mono/sgen/sgen-descriptor.c -mono/sgen/sgen-gc.c -mono/sgen/sgen-gchandles.c -mono/sgen/sgen-gray.c -mono/sgen/sgen-hash-table.c -mono/sgen/sgen-internal.c -mono/sgen/sgen-los.c -mono/sgen/sgen-marksweep.c -mono/sgen/sgen-memory-governor.c -mono/sgen/sgen-nursery-allocator.c -mono/sgen/sgen-pinning-stats.c -mono/sgen/sgen-pinning.c -mono/sgen/sgen-pointer-queue.c -mono/sgen/sgen-protocol.c -mono/sgen/sgen-qsort.c -mono/sgen/sgen-simple-nursery.c -mono/sgen/sgen-split-nursery.c -mono/sgen/sgen-thread-pool.c -mono/sgen/sgen-workers.c -mono/sgen/sgen-fin-weak-hash.c -mono/sgen/sgen-layout-stats.c -HEADERS: -mono/sgen/gc-internal-agnostic.h -mono/sgen/sgen-archdep.h -mono/sgen/sgen-array-list.h -mono/sgen/sgen-cardtable.h -mono/sgen/sgen-client.h -mono/sgen/sgen-conf.h -mono/sgen/sgen-copy-object.h -mono/sgen/sgen-descriptor.h -mono/sgen/sgen-gc.h -mono/sgen/sgen-gray.h -mono/sgen/sgen-hash-table.h -mono/sgen/sgen-layout-stats.h -mono/sgen/sgen-major-copy-object.h -mono/sgen/sgen-marksweep-drain-gray-stack.h -mono/sgen/sgen-memory-governor.h -mono/sgen/sgen-minor-copy-object.h -mono/sgen/sgen-minor-scan-object.h -mono/sgen/sgen-pinning.h -mono/sgen/sgen-pointer-queue.h -mono/sgen/sgen-protocol-def.h -mono/sgen/sgen-protocol.h -mono/sgen/sgen-qsort.h -mono/sgen/sgen-scan-object.h -mono/sgen/sgen-tagged-pointer.h -mono/sgen/sgen-thread-pool.h -mono/sgen/sgen-workers.h -#################### -#mono cil files -#################### -METADATA: -mono/cil/opcode.def -mono/cil/tables.def -#################### -#mono arch files -#################### -HEADERS: -mono/arch/amd64/amd64-codegen.h -mono/arch/x86/x86-codegen.h -mono/arch/arm/arm-codegen.h -mono/arch/arm/arm_dpimacros.h -mono/arch/arm/arm-vfp-codegen.h -mono/arch/arm/arm_vfpmacros.h -#################### -#mono complex files -#################### -SOURCES: -support/libm/complex.c -HEADERS: -support/libm/complex.h -support/libm/math_private.h -#################### -#mono mini files -#################### -mono/mini/debugger-agent.c -mono/mini/debugger-agent.h -mono/mini/il2cpp-c-types.h -mono/mini/il2cpp-compat.h -mono/mini/il2cpp-stubs.cpp From e73093fe0c298aafd14dd6b7899f729cea2774f2 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Wed, 21 Mar 2018 15:32:50 -0400 Subject: [PATCH 179/582] Sync with IL2CPP changes for memory mapped files --- mono/metadata/file-mmap-unity.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/mono/metadata/file-mmap-unity.c b/mono/metadata/file-mmap-unity.c index e1956e7cade7..cc338f107977 100644 --- a/mono/metadata/file-mmap-unity.c +++ b/mono/metadata/file-mmap-unity.c @@ -77,20 +77,15 @@ int mono_mmap_map (void *handle, gint64 offset, gint64 *size, int access, void * MmapInstance *h = g_malloc0 (sizeof (MmapInstance)); h->length = *size; - #ifdef HOST_WIN32 h->address = UnityPalMemoryMappedFileMapWithParams((UnityPalFileHandle*) handle, (size_t) *size, (size_t) offset); - #else - MmapHandle *fh = (MmapHandle *)handle; - h->address = UnityPalMemoryMappedFileMapWithFileDescriptor(fh->fd, (size_t) *size, (size_t) offset); - #endif - if (h->address) + if (h->address) { *mmap_handle = h; *base_address = (char*) h->address + offset; return 0; - } - else + } + else { g_free (h); return COULD_NOT_MAP_MEMORY; From 28a9910d578ec17d8f22bf73ea4735dd27647d94 Mon Sep 17 00:00:00 2001 From: brianradunity Date: Wed, 21 Mar 2018 16:01:13 -0400 Subject: [PATCH 180/582] This fixes an issue we are seeing with VSTU debgugging in Unity. (#7634) process_breakpoint() will process breakpoint, stepping, and method exit/entry events all at the same time when checking a sequence point. So, if there is is a breakpoint and a stepping event at the same time, the debugger agent will suspend the current thread twice, which means you have to click the step button in the debugger client twice on that line. Considering only one of these events at a time seems to fix the issue without breaking any current unit tests or showing any other noticeable issues in testing. --- mono/mini/debugger-agent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 9966d5d4b6e1..5212b713c247 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -5531,9 +5531,9 @@ process_breakpoint (DebuggerTlsData *tls, gboolean from_signal) if (ss_reqs->len > 0) ss_events = create_event_list (EVENT_KIND_STEP, ss_reqs, ji, NULL, &suspend_policy); - if (bp_reqs->len > 0) + else if (bp_reqs->len > 0) bp_events = create_event_list (EVENT_KIND_BREAKPOINT, bp_reqs, ji, NULL, &suspend_policy); - if (kind != EVENT_KIND_BREAKPOINT) + else if (kind != EVENT_KIND_BREAKPOINT) enter_leave_events = create_event_list (kind, NULL, ji, NULL, &suspend_policy); mono_loader_unlock (); From 18b5d6868c29f36e4c917bebc580334dc92ec2ae Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Wed, 21 Mar 2018 16:02:53 -0400 Subject: [PATCH 181/582] Add .NET FW to beginning of path rather than end --- external/buildscripts/build_unityscript_bareminimum_win.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/buildscripts/build_unityscript_bareminimum_win.pl b/external/buildscripts/build_unityscript_bareminimum_win.pl index 4d2d793a457c..753cf408dd62 100644 --- a/external/buildscripts/build_unityscript_bareminimum_win.pl +++ b/external/buildscripts/build_unityscript_bareminimum_win.pl @@ -37,7 +37,7 @@ () } print("Using .Net framework: $netFrameworkLocation"); - $ENV{PATH} = "$ENV{PATH};$netFrameworkLocation"; + $ENV{PATH} = "$netFrameworkLocation;$ENV{PATH}"; } AddDotNetFolderToPath(); From cfa536f0e932e9de2ae180d7f570a7bcaad86c6b Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 15 Aug 2017 13:10:29 -0400 Subject: [PATCH 182/582] Raise marshaling exception rather than aborting when marshaling invalid data type as array (case 935726) --- mono/metadata/marshal.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mono/metadata/marshal.c b/mono/metadata/marshal.c index d2859202fbe6..295ad7444b79 100644 --- a/mono/metadata/marshal.c +++ b/mono/metadata/marshal.c @@ -1616,9 +1616,11 @@ emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv mono_mb_emit_byte (mb, CEE_STIND_REF); break; } - case MONO_MARSHAL_CONV_ARRAY_LPARRAY: - g_error ("Structure field of type %s can't be marshalled as LPArray", mono_class_from_mono_type (type)->name); + case MONO_MARSHAL_CONV_ARRAY_LPARRAY: { + char *msg = g_strdup_printf ("Structure field of type %s can't be marshalled as LPArray", mono_class_from_mono_type (type)->name); + mono_mb_emit_exception_marshal_directive (mb, msg); break; + } #ifndef DISABLE_COM case MONO_MARSHAL_CONV_OBJECT_INTERFACE: From 929620b4152b3c4b9de58d51a5fa7f1148e1eb87 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 15 Aug 2017 09:54:18 -0400 Subject: [PATCH 183/582] Allow structure to pointer conversion for blittable multi-dimensional arrays (case 940012) --- mono/metadata/marshal.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mono/metadata/marshal.c b/mono/metadata/marshal.c index 295ad7444b79..f95f51cb79c8 100644 --- a/mono/metadata/marshal.c +++ b/mono/metadata/marshal.c @@ -1825,6 +1825,10 @@ emit_object_to_ptr_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv if (type->type == MONO_TYPE_SZARRAY) { eklass = type->data.klass; + } else if (type->type == MONO_TYPE_ARRAY) { + eklass = type->data.array->eklass; + if (!eklass->blittable) + g_assert_not_reached (); } else { g_assert_not_reached (); } From 01019fe446fe9170250e42513cea9d83a4c66e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Kliger=20=28=CE=BBgeek=29?= Date: Mon, 25 Dec 2017 04:45:52 -0500 Subject: [PATCH 184/582] [object] mono_string_new should not assert on UTF conversion failures (#6333) Revert the embedding API behavior change introduced by dcdfb3c5005297b375c985ec5f0a4af99f8ad7cf mono_string_new will: * return NULL if the given byte sequence is not a valid UTF-8 sequence * assert if there is not enough memory to allocate a new MonoString. This only changes the behavior of the API function. The runtime will continue to use mono_string_new_checked which sets MonoError* for both sorts of failures. --- mono/metadata/object.c | 10 +++++++++- mono/utils/mono-error-internals.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mono/metadata/object.c b/mono/metadata/object.c index 6cc790cb0817..b41747db57bb 100644 --- a/mono/metadata/object.c +++ b/mono/metadata/object.c @@ -6298,7 +6298,15 @@ mono_string_new (MonoDomain *domain, const char *text) MonoError error; MonoString *res = NULL; res = mono_string_new_checked (domain, text, &error); - mono_error_assert_ok (&error); + if (!is_ok (&error)) { + /* Mono API compatability: assert on Out of Memory errors, + * return NULL otherwise (most likely an invalid UTF-8 byte + * sequence). */ + if (mono_error_get_error_code (&error) == MONO_ERROR_OUT_OF_MEMORY) + mono_error_assert_ok (&error); + else + mono_error_cleanup (&error); + } return res; } diff --git a/mono/utils/mono-error-internals.h b/mono/utils/mono-error-internals.h index 045d85ec38ec..cbb452c4ca1c 100644 --- a/mono/utils/mono-error-internals.h +++ b/mono/utils/mono-error-internals.h @@ -63,7 +63,7 @@ struct _MonoErrorBoxed { void mono_error_assert_ok_pos (MonoError *error, const char* filename, int lineno) MONO_LLVM_INTERNAL; -#define mono_error_assert_ok(e) mono_error_assert_ok_pos (e, __FILE__, __LINE__); +#define mono_error_assert_ok(e) mono_error_assert_ok_pos (e, __FILE__, __LINE__) void mono_error_dup_strings (MonoError *error, gboolean dup_strings); From f650db8614596fdc81e55cdc546a803a9ee0416a Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 20 Mar 2018 13:26:58 -0400 Subject: [PATCH 185/582] Forward mono_string_new_wrapper to mono_string_new for error handling. In commit 8ba48b5a41ac48bf6fe9351406165d22c753722d mono_string_new was adjusted to only assert for out of memory rather than all errors to preserve previous behavior for invalid strings. This change preserves behavior for mono_string_new_wrapper. --- mono/metadata/object.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/mono/metadata/object.c b/mono/metadata/object.c index b41747db57bb..94a92c7517fa 100644 --- a/mono/metadata/object.c +++ b/mono/metadata/object.c @@ -6285,23 +6285,16 @@ mono_string_new_len_checked (MonoDomain *domain, const char *text, guint length, return o; } -/** - * mono_string_new: - * \param text a pointer to a UTF-8 string - * \deprecated Use \c mono_string_new_checked in new code. - * This function asserts if it cannot allocate a new string. - * \returns A newly created string object which contains \p text. - */ -MonoString* -mono_string_new (MonoDomain *domain, const char *text) +static MonoString* +mono_string_new_internal (MonoDomain *domain, const char *text) { MonoError error; MonoString *res = NULL; res = mono_string_new_checked (domain, text, &error); if (!is_ok (&error)) { /* Mono API compatability: assert on Out of Memory errors, - * return NULL otherwise (most likely an invalid UTF-8 byte - * sequence). */ + * return NULL otherwise (most likely an invalid UTF-8 byte + * sequence). */ if (mono_error_get_error_code (&error) == MONO_ERROR_OUT_OF_MEMORY) mono_error_assert_ok (&error); else @@ -6310,6 +6303,19 @@ mono_string_new (MonoDomain *domain, const char *text) return res; } +/** + * mono_string_new: + * \param text a pointer to a UTF-8 string + * \deprecated Use \c mono_string_new_checked in new code. + * This function asserts if it cannot allocate a new string. + * \returns A newly created string object which contains \p text. + */ +MonoString* +mono_string_new (MonoDomain *domain, const char *text) +{ + return mono_string_new_internal (domain, text); +} + /** * mono_string_new_checked: * \param text a pointer to an utf8 string @@ -6380,16 +6386,7 @@ mono_string_new_wrapper (const char *text) { MONO_REQ_GC_UNSAFE_MODE; - MonoDomain *domain = mono_domain_get (); - - if (text) { - MonoError error; - MonoString *result = mono_string_new_checked (domain, text, &error); - mono_error_assert_ok (&error); - return result; - } - - return NULL; + return mono_string_new_internal (mono_domain_get (), text); } /** From 0e083f5e68cb7901c7f7ec198aecb13150d0105e Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Wed, 21 Mar 2018 16:49:11 +0100 Subject: [PATCH 186/582] [arm] fix stack alignment for structs (#7691) fixes https://github.com/mono/mono/issues/7449 --- mono/mini/mini-arm.c | 7 +++---- mono/tests/libtest.c | 19 +++++++++++++++++ mono/tests/pinvoke11.cs | 45 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/mono/mini/mini-arm.c b/mono/mini/mini-arm.c index 75e4fd098a4e..b2601706af5d 100644 --- a/mono/mini/mini-arm.c +++ b/mono/mini/mini-arm.c @@ -1524,7 +1524,7 @@ get_call_info (MonoMemPool *mp, MonoMethodSignature *sig) ainfo->storage = RegTypeStructByVal; ainfo->struct_size = size; ainfo->align = align; - /* FIXME: align stack_size if needed */ + if (eabi_supported) { if (align >= 8 && (gr & 1)) gr ++; @@ -1542,9 +1542,8 @@ get_call_info (MonoMemPool *mp, MonoMethodSignature *sig) gr += n_in_regs; nwords -= n_in_regs; } - if (sig->call_convention == MONO_CALL_VARARG) - /* This matches the alignment in mono_ArgIterator_IntGetNextArg () */ - stack_size = ALIGN_TO (stack_size, align); + stack_size = ALIGN_TO (stack_size, align); + ainfo->offset = stack_size; /*g_print ("offset for arg %d at %d\n", n, stack_size);*/ stack_size += nwords * sizeof (gpointer); diff --git a/mono/tests/libtest.c b/mono/tests/libtest.c index 46f8cc5d3d52..338d8223555e 100644 --- a/mono/tests/libtest.c +++ b/mono/tests/libtest.c @@ -280,6 +280,25 @@ mono_return_nested_float (void) return f; } +struct Scalar4 { + double val[4]; +}; + +struct Rect { + int x; + int y; + int width; + int height; +}; + +LIBTEST_API char * STDCALL +mono_return_struct_4_double (void *ptr, struct Rect rect, struct Scalar4 sc4, int a, int b, int c) +{ + char *buffer = (char *) malloc (1024 * sizeof (char)); + sprintf (buffer, "sc4 = {%.1f, %.1f, %.1f, %.1f }, a=%x, b=%x, c=%x\n", (float) sc4.val [0], (float) sc4.val [1], (float) sc4.val [2], (float) sc4.val [3], a, b, c); + return buffer; +} + LIBTEST_API int STDCALL mono_test_many_int_arguments (int a, int b, int c, int d, int e, int f, int g, int h, int i, int j); diff --git a/mono/tests/pinvoke11.cs b/mono/tests/pinvoke11.cs index 252700fe3442..776dbc4035f2 100644 --- a/mono/tests/pinvoke11.cs +++ b/mono/tests/pinvoke11.cs @@ -60,6 +60,39 @@ public struct NestedFloat { public float f4; } +[Serializable] +[StructLayout(LayoutKind.Sequential)] +public struct Rectangle +{ + public int X; + public int Y; + public int Width; + public int Height; + + public Rectangle(int x, int y, int width, int height) + { + X = x; + Y = y; + Width = width; + Height = height; + } +} + +[Serializable] +public struct Scalar4 { + public double Val0; + public double Val1; + public double Val2; + public double Val3; + + public Scalar4 (double v0, double v1, double v2, double v3) { + Val0 = v0; + Val1 = v1; + Val2 = v2; + Val3 = v3; + } +} + public class Test { [DllImport ("libtest")] @@ -89,6 +122,10 @@ public class Test [DllImport ("libtest", EntryPoint="mono_return_nested_float")] public static extern NestedFloat mono_return_nested_float (); + [DllImport("libtest", EntryPoint="mono_return_struct_4_double")] + [return: MarshalAs(UnmanagedType.LPStr)] + public static extern string mono_return_struct_4_double (IntPtr ptr, Rectangle rect, Scalar4 sc4, int a, int b, int c); + static int Main() { if (mono_return_int (5) != 5) @@ -159,6 +196,14 @@ static int Main() if (f.fi.f1 != 1.0) return 12; + Rectangle rect = new Rectangle (10, 10, 100, 20); + Scalar4 sc4 = new Scalar4 (32, 64, 128, 256); + var sc4_ret = mono_return_struct_4_double (IntPtr.Zero, rect, sc4, 0x1337, 0x1234, 0x9876); + if (sc4_ret != "sc4 = {32.0, 64.0, 128.0, 256.0 }, a=1337, b=1234, c=9876\n") { + Console.WriteLine ("sc4_ret = " + sc4_ret); + return 13; + } + return 0; } } From 14b7ebe263f004bbbef130a1d6562e5ac528eb6f Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Fri, 23 Mar 2018 16:57:24 -0400 Subject: [PATCH 187/582] add boo to unityscript folder --- external/buildscripts/build_us_and_boo.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/external/buildscripts/build_us_and_boo.pl b/external/buildscripts/build_us_and_boo.pl index 8d406d26a876..ecbbd0da07e9 100644 --- a/external/buildscripts/build_us_and_boo.pl +++ b/external/buildscripts/build_us_and_boo.pl @@ -137,7 +137,8 @@ sub BuildUnityScriptFor45 print(">>> Copying $monoprefix45/us.exe to $usBuildDir\n"); copy("$monoprefix45/us.exe", "$usBuildDir/."); - + print(">>> Copying $monoprefix45/booc.exe to $usBuildDir\n"); + copy("$monoprefix45/booc.exe", "$usBuildDir/."); # put unityscript and boo into their own directories that we can reference for compilation only in Unity my $usLibDir = "$monoprefix/lib/mono/unityscript"; @@ -154,4 +155,4 @@ sub BuildUnityScriptFor45 print(">>> Copying $file to $usLibDir\n"); copy($file, "$usLibDir/."); } -} \ No newline at end of file +} From da417b7cb0c8bd71cb27730c4d80cdf83c6f868f Mon Sep 17 00:00:00 2001 From: Brian Raderman Date: Tue, 27 Mar 2018 14:35:01 -0400 Subject: [PATCH 188/582] Exposing MonoClass.has_cctor via a new unity-utils function. Need this to check if a class has a static constructor, so we can call it before a static method gets invoked. --- mono/metadata/unity-utils.c | 5 +++++ mono/metadata/unity-utils.h | 1 + 2 files changed, 6 insertions(+) diff --git a/mono/metadata/unity-utils.c b/mono/metadata/unity-utils.c index d1ddb0bc8a2a..3f936239f682 100644 --- a/mono/metadata/unity-utils.c +++ b/mono/metadata/unity-utils.c @@ -354,6 +354,11 @@ mono_class_is_blittable(MonoClass *klass) return klass->blittable; } +gboolean mono_unity_class_has_cctor(MonoClass *klass) +{ + return klass->has_cctor ? TRUE : FALSE; +} + //method MonoMethod* mono_unity_method_get_generic_definition(MonoMethod* method) diff --git a/mono/metadata/unity-utils.h b/mono/metadata/unity-utils.h index d4c19aa043b2..1bec5570544e 100644 --- a/mono/metadata/unity-utils.h +++ b/mono/metadata/unity-utils.h @@ -74,6 +74,7 @@ MonoBoolean mono_unity_class_is_class_type(MonoClass* klass); MONO_API gboolean mono_class_is_generic(MonoClass *klass); MONO_API gboolean mono_class_is_blittable(MonoClass *klass); MONO_API gboolean mono_class_is_inflated(MonoClass *klass); +gboolean mono_unity_class_has_cctor(MonoClass *klass); //method MonoMethod* mono_unity_method_get_generic_definition(MonoMethod* method); From d889370e7393cd6e01e5687d7da21495b1093590 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Wed, 28 Mar 2018 12:52:50 -0400 Subject: [PATCH 189/582] Revert "Remove mono specific reference assemblies" This reverts commit f517be783b39894282e786f6c40f5532b8c070e5. --- mcs/class/reference-assemblies/Makefile | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/mcs/class/reference-assemblies/Makefile b/mcs/class/reference-assemblies/Makefile index 798799a3d7d6..d8f99734d2f0 100644 --- a/mcs/class/reference-assemblies/Makefile +++ b/mcs/class/reference-assemblies/Makefile @@ -50,17 +50,16 @@ install-local: $(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.7/Facades/*.dll $(PROFILE_DIR)/4.7-api/Facades $(INSTALL_LIB) ../../../external/binary-reference-assemblies/v4.7.1/Facades/*.dll $(PROFILE_DIR)/4.7.1-api/Facades - # Unity: these are mono extensions to .NET we don't want to support going forward $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/2.0-api - #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.0-api - #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.5-api - #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.5.1-api - #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.5.2-api - #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.6-api - #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.6.1-api - #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.6.2-api - #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.7-api - #$(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.7.1-api + $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.0-api + $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.5-api + $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.5.1-api + $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.5.2-api + $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.6-api + $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.6.1-api + $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.6.2-api + $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.7-api + $(INSTALL_LIB) ../../../external/binary-reference-assemblies/mono/*.dll $(PROFILE_DIR)/4.7.1-api # Unfortunately, a few programs (most notably NUnit and FSharp) have hardcoded checks for /lib/mono/4.0/mscorlib.dll or Mono.Posix.dll, # so we need to place something there or those tools break. We decided to symlink to the reference assembly for now. From dab14a96b3a88149eba6463b35a592eefe89746f Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Thu, 29 Mar 2018 13:19:02 -0400 Subject: [PATCH 190/582] Use An AOT-friendly Linq implementation The corefx implementation of Linq is not AOT-friendly, and won't work with IL2CPP until IL2CPP gets full generic sharing support. So use the Linq implementation from reference source for the unityaot profile. This implementation is AOT-friendly. This change addresses case 1013854 in Unity. --- .../unityaot_System.Core.dll.exclude.sources | 1 + .../unityaot_System.Core.dll.sources | 2 + .../System.Core/System/Linq/Enumerable.cs | 49 +++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 mcs/class/System.Core/unityaot_System.Core.dll.exclude.sources diff --git a/mcs/class/System.Core/unityaot_System.Core.dll.exclude.sources b/mcs/class/System.Core/unityaot_System.Core.dll.exclude.sources new file mode 100644 index 000000000000..7953f1b8f0ef --- /dev/null +++ b/mcs/class/System.Core/unityaot_System.Core.dll.exclude.sources @@ -0,0 +1 @@ +../../../external/corefx/src/System.Linq/src/System/Linq/*.cs diff --git a/mcs/class/System.Core/unityaot_System.Core.dll.sources b/mcs/class/System.Core/unityaot_System.Core.dll.sources index fe9ad015d119..5ec6fe909185 100644 --- a/mcs/class/System.Core/unityaot_System.Core.dll.sources +++ b/mcs/class/System.Core/unityaot_System.Core.dll.sources @@ -1 +1,3 @@ #include winaot_System.Core.dll.sources +../referencesource/System.Core/System/Linq/Enumerable.cs +corefx/SR.cs diff --git a/mcs/class/referencesource/System.Core/System/Linq/Enumerable.cs b/mcs/class/referencesource/System.Core/System/Linq/Enumerable.cs index 84a043557188..91fdedb40f99 100644 --- a/mcs/class/referencesource/System.Core/System/Linq/Enumerable.cs +++ b/mcs/class/referencesource/System.Core/System/Linq/Enumerable.cs @@ -2776,7 +2776,11 @@ public string Empty { get { +#if UNITY_AOT + return SR.EmptyEnumerable; +#else return Strings.EmptyEnumerable; +#endif } } } @@ -2829,4 +2833,49 @@ public object[] Items [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] private int count; } + +#if UNITY_AOT + // + /// An iterator that can produce an array or through an optimized path. + /// + internal interface IIListProvider : IEnumerable + { + /// + /// Produce an array of the sequence through an optimized path. + /// + /// The array. + TElement[] ToArray(); + + /// + /// Produce a of the sequence through an optimized path. + /// + /// The . + List ToList(); + + /// + /// Returns the count of elements in the sequence. + /// + /// If true then the count should only be calculated if doing + /// so is quick (sure or likely to be constant time), otherwise -1 should be returned. + /// The number of elements. + int GetCount(bool onlyIfCheap); + } + + internal static partial class Error + { + internal static Exception ArgumentNull(string s) => new ArgumentNullException(s); + + internal static Exception ArgumentOutOfRange(string s) => new ArgumentOutOfRangeException(s); + + internal static Exception MoreThanOneElement() => new InvalidOperationException(SR.MoreThanOneElement); + + internal static Exception MoreThanOneMatch() => new InvalidOperationException(SR.MoreThanOneMatch); + + internal static Exception NoElements() => new InvalidOperationException(SR.NoElements); + + internal static Exception NoMatch() => new InvalidOperationException(SR.NoMatch); + + internal static Exception NotSupported() => new NotSupportedException(); + } +#endif } From e09ab04fc6617800ab46471c223adf90f40e405a Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Fri, 30 Mar 2018 14:18:43 -0400 Subject: [PATCH 191/582] Report the proper socket error When a connection fails, the socket error was being incorrectly reported as an address family not supported error, instead of connection refused. It looks like this happened between c4e698cece510bce0a05a741ba4b9274354110c0 (Unity 2018.1b5), where the proper error was reported, and ec98a4eeb5de45d7dfa30a79c1574bd95d5a4681 (Unity 2018.1b6), there the incorrect error is reported. Why did this happen? Between those two changesets (there are about 180 intervening changesets), the order of addresses returned from `Dns.GetHostAddresses` changed. The newer code returns the IPv6 address first, and the IPv4 address second. While `GetCheckedIPs` mentioned in a comment that it skips addresses that don't match the address family, it did not. The code using the addresses returned by `GetCheckedIPs` will use the first address in the array. If this address happens to match the address family of the socket, things will work "properly" (the correct socket error will occur). If, however the first entry has the wrong address family, then the socket error will be an address family not supported error, since the socket was created with different address family. This change modifies `GetCheckedIPs` to filter the addresses, removing those which do not match the address family. This corrects Unity case 1012875. --- mcs/class/System/System.Net.Sockets/Socket.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mcs/class/System/System.Net.Sockets/Socket.cs b/mcs/class/System/System.Net.Sockets/Socket.cs index ef43e8198eec..6b55a8655ee8 100644 --- a/mcs/class/System/System.Net.Sockets/Socket.cs +++ b/mcs/class/System/System.Net.Sockets/Socket.cs @@ -1160,7 +1160,19 @@ bool GetCheckedIPs (SocketAsyncEventArgs e, out IPAddress [] addresses) // while skipping entries that do not match the address family DnsEndPoint dep = e.RemoteEndPoint as DnsEndPoint; if (dep != null) { - addresses = Dns.GetHostAddresses (dep.Host); + var possibleAddresses = Dns.GetHostAddresses (dep.Host); + var numberOfAddresses = 0; + int[] addressIndices = new int[possibleAddresses.Length]; + for (var i = 0; i < possibleAddresses.Length; i++) { + if (possibleAddresses[i].AddressFamily == dep.AddressFamily) { + addressIndices[numberOfAddresses] = i; + numberOfAddresses++; + } + } + addresses = new IPAddress[numberOfAddresses]; + for (var i = 0; i < numberOfAddresses; i++) + addresses[i] = possibleAddresses[addressIndices[i]]; + return true; } else { e.ConnectByNameError = null; From 043dafa004b56111d4d5686fa0c975335ae39f9e Mon Sep 17 00:00:00 2001 From: Lukasz Paczkowski Date: Tue, 3 Apr 2018 16:08:52 +0200 Subject: [PATCH 192/582] Fix bug where image mem pool would not be copied. Copy image class cache hash table and root domain mem pool. Add code in debug builds to verify that all collected classes are in the collect memory sections. --- mono/metadata/metadata.c | 22 +++++ mono/metadata/metadata.h | 2 +- mono/metadata/unity-memory-info.c | 143 +++++++++++++++++++++++++++++- 3 files changed, 164 insertions(+), 3 deletions(-) diff --git a/mono/metadata/metadata.c b/mono/metadata/metadata.c index 55ac7fd86ba7..1d3a146ca83d 100644 --- a/mono/metadata/metadata.c +++ b/mono/metadata/metadata.c @@ -5118,6 +5118,28 @@ mono_metadata_generic_class_foreach(GFunc func, gpointer user_data) } } +void +mono_metadata_image_set_foreach(GFunc func, gpointer user_data) +{ + GenericClassForeachData data; + guint i; + + data.func = func; + data.user_data = user_data; + + for (i = 0; i < HASH_TABLE_SIZE; ++i) + { + MonoImageSet* imageSet = img_set_cache[i]; + + if (imageSet == NULL) + continue; + + mono_image_set_lock(imageSet); + func(imageSet, user_data); + mono_image_set_unlock(imageSet); + } +} + static gboolean _mono_metadata_generic_class_equal (const MonoGenericClass *g1, const MonoGenericClass *g2, gboolean signature_only) { diff --git a/mono/metadata/metadata.h b/mono/metadata/metadata.h index 5891b411d5a2..2888a9317584 100644 --- a/mono/metadata/metadata.h +++ b/mono/metadata/metadata.h @@ -424,9 +424,9 @@ MONO_API int mono_type_stack_size (MonoType *type, MONO_API mono_bool mono_type_generic_inst_is_valuetype (MonoType *type); MONO_API mono_bool mono_metadata_generic_class_is_valuetype (MonoGenericClass *gclass); +MONO_API void mono_metadata_image_set_foreach(GFunc func, gpointer user_data); MONO_API void mono_metadata_generic_class_foreach(GFunc func, gpointer user_data); - MONO_API unsigned int mono_metadata_type_hash (MonoType *t1); MONO_API mono_bool mono_metadata_type_equal (MonoType *t1, MonoType *t2); diff --git a/mono/metadata/unity-memory-info.c b/mono/metadata/unity-memory-info.c index 74f8bb1c30c0..39177fdef65d 100644 --- a/mono/metadata/unity-memory-info.c +++ b/mono/metadata/unity-memory-info.c @@ -255,27 +255,106 @@ static int MonoImagesMemPoolNumChunks() return count; } +static void AllocateMemoryForMemPool(MonoMemPool* pool, void *user_data) +{ + mono_mempool_foreach_block(pool, AllocateMemoryForMemPoolChunk, user_data); +} + static void AllocateMemoryForImageMemPool(MonoAssembly *assembly, void *user_data) { MonoImage* image = assembly->image; + mono_image_lock(image); + AllocateMemoryForMemPool(image->mempool, user_data); + mono_image_unlock(image); +} + +static void CopyMemPool(MonoMemPool *pool, SectionIterationContext *context) +{ + mono_mempool_foreach_block(pool, CopyMemPoolChunk, context); +} + +static void CopyImageMemPool(MonoAssembly *assembly, SectionIterationContext *context) +{ + MonoImage* image = assembly->image; + + mono_image_lock(image); + CopyMemPool(image->mempool, context); + mono_image_unlock(image); +} + +static void MonoImagesCountCallback(MonoAssembly *assembly, void *user_data) +{ + int* count = (int*)user_data; + (*count)++; +} + +static int MonoImagesCount() +{ + int count = 0; + mono_assembly_foreach((GFunc)MonoImagesCountCallback, &count); + return count; +} + +static void AllocateMemoryForImageClassCache(MonoAssembly *assembly, void *user_data) +{ + MonoImage* image = assembly->image; + mono_image_lock(image); + AllocateMemoryForSection(user_data, image->class_cache.table, ((uint8_t*)image->class_cache.table) + image->class_cache.size); + mono_image_unlock(image); +} + +static void CopyImageClassCache(MonoAssembly *assembly, SectionIterationContext *context) +{ + MonoImage* image = assembly->image; mono_image_lock(image); - mono_mempool_foreach_block(image->mempool, AllocateMemoryForMemPoolChunk, user_data); + + CopyHeapSection(context, image->class_cache.table, ((uint8_t*)image->class_cache.table) + image->class_cache.size); + mono_image_unlock(image); } +static void IncrementCountForImageSetMemPoolNumChunks(MonoImageSet *imageSet, void *user_data) +{ + int* count = (int*)user_data; + (*count) += MonoMemPoolNumChunks(imageSet->mempool); +} + +static int MonoImageSetsMemPoolNumChunks() +{ + int count = 0; + mono_metadata_image_set_foreach((GFunc)IncrementCountForImageSetMemPoolNumChunks, &count); + return count; +} + +static void AllocateMemoryForImageSetMemPool(MonoImageSet* imageSet, void *user_data) +{ + AllocateMemoryForMemPool(imageSet->mempool, user_data); +} + +static void CopyImageSetMemPool(MonoImageSet* imageSet, void *user_data) +{ + CopyMemPool(imageSet->mempool, user_data); +} + static void* CaptureHeapInfo(void* monoManagedHeap) { MonoManagedHeap* heap = (MonoManagedHeap*)monoManagedHeap; MonoDomain* domain = mono_domain_get(); + MonoDomain* rootDomain = mono_get_root_domain(); SectionIterationContext iterationContext; // Increment count for each heap section heap->sectionCount = GC_get_heap_section_count(); // Increment count for the domain mem pool chunk + heap->sectionCount += MonoMemPoolNumChunks(rootDomain->mp); heap->sectionCount += MonoMemPoolNumChunks(domain->mp); // Increment count for each image mem pool chunk heap->sectionCount += MonoImagesMemPoolNumChunks(); + // Increment count for each image->class_cache hash table. + heap->sectionCount += MonoImagesCount(); + // Increment count for each image set mem pool chunk + heap->sectionCount += MonoImageSetsMemPoolNumChunks(); heap->sections = g_new0(MonoManagedMemorySection, heap->sectionCount); @@ -284,11 +363,18 @@ static void* CaptureHeapInfo(void* monoManagedHeap) // Allocate memory for each heap section GC_foreach_heap_section(&iterationContext, AllocateMemoryForSection); // Allocate memory for the domain mem pool chunk + mono_domain_lock(rootDomain); + mono_mempool_foreach_block(rootDomain->mp, AllocateMemoryForMemPoolChunk, &iterationContext); + mono_domain_unlock(rootDomain); mono_domain_lock(domain); mono_mempool_foreach_block(domain->mp, AllocateMemoryForMemPoolChunk, &iterationContext); mono_domain_unlock(domain); // Allocate memory for each image mem pool chunk mono_assembly_foreach((GFunc)AllocateMemoryForImageMemPool, &iterationContext); + // Allocate memory for each image->class_cache hash table. + mono_assembly_foreach((GFunc)AllocateMemoryForImageClassCache, &iterationContext); + // Allocate memory for each image->class_cache hash table. + mono_metadata_image_set_foreach((GFunc)AllocateMemoryForImageSetMemPool, &iterationContext); return NULL; } @@ -324,13 +410,18 @@ static void VerifyHeapSectionIsStillValid(void* context, void* sectionStart, voi static gboolean MonoManagedHeapStillValid(MonoManagedHeap* heap) { + MonoDomain* rootDomain = mono_get_root_domain(); MonoDomain* domain = mono_domain_get(); + VerifyHeapSectionStillValidIterationContext iterationContext; int currentSectionCount; currentSectionCount = GC_get_heap_section_count(); + currentSectionCount += MonoMemPoolNumChunks(rootDomain->mp); currentSectionCount += MonoMemPoolNumChunks(domain->mp); currentSectionCount += MonoImagesMemPoolNumChunks(); + currentSectionCount += MonoImagesCount(); // image->class_cache hash table. + currentSectionCount += MonoImageSetsMemPoolNumChunks(); if (heap->sectionCount != currentSectionCount) return FALSE; @@ -356,6 +447,7 @@ static gboolean MonoManagedHeapStillValid(MonoManagedHeap* heap) static void CaptureManagedHeap(MonoManagedHeap* heap) { + MonoDomain* rootDomain = mono_get_root_domain(); MonoDomain* domain = mono_domain_get(); SectionIterationContext iterationContext; @@ -373,9 +465,13 @@ static void CaptureManagedHeap(MonoManagedHeap* heap) } iterationContext.currentSection = heap->sections; - GC_foreach_heap_section(&iterationContext, CopyHeapSection); + GC_foreach_heap_section(&iterationContext, CopyHeapSection); + mono_mempool_foreach_block(rootDomain->mp, CopyMemPoolChunk, &iterationContext); mono_mempool_foreach_block(domain->mp, CopyMemPoolChunk, &iterationContext); + mono_assembly_foreach((GFunc)CopyImageMemPool, &iterationContext); + mono_assembly_foreach((GFunc)CopyImageClassCache, &iterationContext); + mono_metadata_image_set_foreach((GFunc)CopyImageSetMemPool, &iterationContext); GC_start_world_external(); } @@ -418,6 +514,45 @@ static void FillRuntimeInformation(MonoRuntimeInformation* runtimeInfo) runtimeInfo->allocationGranularity = (uint32_t)(2 * sizeof(void*)); } +static gboolean ManagedHeapContainsAddress(MonoManagedHeap* heap, uint64_t address) +{ + uint32_t i; + + for (i = 0; i < heap->sectionCount; ++i) + { + MonoManagedMemorySection* section = &heap->sections[i]; + uint64_t sectionBegin = section->sectionStartAddress; + uint64_t sectionEnd = sectionBegin + section->sectionSize; + + if (address >= sectionBegin && address <= sectionEnd) + return TRUE; + } + + return FALSE; +} + +static void VerifySnapshot(MonoManagedMemorySnapshot* snapshot) +{ + uint32_t i; + FILE* file; + MonoMetadataSnapshot* meta = &snapshot->metadata; + + file = fopen("MonoMemorySnapshotLog.txt", "w"); + + /* Verify that we have collected memory sections for all types */ + for (i = 0; i < meta->typeCount; ++i) + { + MonoMetadataType* type = &meta->types[i]; + + if (!ManagedHeapContainsAddress(&snapshot->heap, type->typeInfoAddress)) + { + fprintf(file, "The memory for type '%s' @ 0x%016X is not the part the snapshot.\n", type->name, type->typeInfoAddress); + } + } + + fclose(file); +} + MonoManagedMemorySnapshot* mono_unity_capture_memory_snapshot() { MonoManagedMemorySnapshot* snapshot; @@ -428,6 +563,10 @@ MonoManagedMemorySnapshot* mono_unity_capture_memory_snapshot() CaptureGCHandleTargets(&snapshot->gcHandles); FillRuntimeInformation(&snapshot->runtimeInformation); +#if _DEBUG + VerifySnapshot(snapshot); +#endif + return snapshot; } From cf9637e1594797cf393a1858a654a84b442fafbc Mon Sep 17 00:00:00 2001 From: Tak Date: Fri, 23 Mar 2018 13:22:02 +0100 Subject: [PATCH 193/582] Fixup dllmap for MonoPosixHelper --- data/config.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/config.in b/data/config.in index 282bc114950a..d03bfe3e8b81 100644 --- a/data/config.in +++ b/data/config.in @@ -10,8 +10,8 @@ - - + + From aafa4acf63b316f49bd3cc092dfba82e3a206a5f Mon Sep 17 00:00:00 2001 From: David Rogers Date: Wed, 4 Apr 2018 10:32:46 -0500 Subject: [PATCH 194/582] File IO profile support --- mono/metadata/profiler-events.h | 1 + mono/metadata/profiler-private.h | 1 + mono/metadata/profiler.c | 30 ++++++++++++++- mono/metadata/profiler.h | 1 + mono/metadata/w32file-unix.c | 3 ++ mono/metadata/w32file-win32.c | 3 ++ mono/profiler/log-args.c | 1 + mono/profiler/log.c | 63 +++++++++++++++++++++++++++++++- mono/profiler/log.h | 4 +- 9 files changed, 104 insertions(+), 3 deletions(-) diff --git a/mono/metadata/profiler-events.h b/mono/metadata/profiler-events.h index 5e933d0c9fbf..c603ca224323 100644 --- a/mono/metadata/profiler-events.h +++ b/mono/metadata/profiler-events.h @@ -95,6 +95,7 @@ MONO_PROFILER_EVENT_1(gc_finalized_object, GCFinalizedObject, MonoObject *, obje MONO_PROFILER_EVENT_5(gc_root_register, RootRegister, const mono_byte *, start, uintptr_t, size, MonoGCRootSource, source, const void *, key, const char *, name) MONO_PROFILER_EVENT_1(gc_root_unregister, RootUnregister, const mono_byte *, start) MONO_PROFILER_EVENT_3(gc_roots, GCRoots, uint64_t, count, const mono_byte *const *, addresses, MonoObject *const *, objects) +MONO_PROFILER_EVENT_2(fileio, FileIO, uint64_t, kind, uint64_t, size) MONO_PROFILER_EVENT_1(monitor_contention, MonitorContention, MonoObject *, object) MONO_PROFILER_EVENT_1(monitor_failed, MonitorFailed, MonoObject *, object) diff --git a/mono/metadata/profiler-private.h b/mono/metadata/profiler-private.h index 3c0fe896c4ff..6b5b0be860e3 100644 --- a/mono/metadata/profiler-private.h +++ b/mono/metadata/profiler-private.h @@ -59,6 +59,7 @@ typedef struct { guint32 sample_freq; gboolean allocations; + gboolean fileio; gboolean call_contexts; void (*context_enable) (void); diff --git a/mono/metadata/profiler.c b/mono/metadata/profiler.c index 705fa0cccc80..a4c7a71c6e0b 100644 --- a/mono/metadata/profiler.c +++ b/mono/metadata/profiler.c @@ -567,6 +567,12 @@ mono_profiler_enable_allocations (void) return mono_profiler_state.allocations = TRUE; } +mono_bool +mono_profiler_enable_fileio (void) +{ + return mono_profiler_state.fileio = TRUE; +} + /** * mono_profiler_set_call_instrumentation_filter_callback: * @@ -952,6 +958,7 @@ typedef void (*MonoLegacyProfileAllocFunc) (MonoLegacyProfiler *prof, MonoObject typedef void (*MonoLegacyProfileMethodFunc) (MonoLegacyProfiler *prof, MonoMethod *method); typedef void (*MonoLegacyProfileExceptionFunc) (MonoLegacyProfiler *prof, MonoObject *object); typedef void (*MonoLegacyProfileExceptionClauseFunc) (MonoLegacyProfiler *prof, MonoMethod *method, int clause_type, int clause_num); +typedef void (*MonoLegacyProfileFileIOFunc) (MonoLegacyProfiler *prof, int kind, int size); struct _MonoProfiler { MonoProfilerHandle handle; @@ -962,6 +969,7 @@ struct _MonoProfiler { MonoLegacyProfileGCResizeFunc gc_heap_resize; MonoLegacyProfileJitResult jit_end2; MonoLegacyProfileAllocFunc allocation; + MonoLegacyProfileFileIOFunc fileio; MonoLegacyProfileMethodFunc enter; MonoLegacyProfileMethodFunc leave; MonoLegacyProfileExceptionFunc throw_callback; @@ -978,6 +986,7 @@ MONO_API void mono_profiler_install_jit_end (MonoLegacyProfileJitResult end); MONO_API void mono_profiler_set_events (int flags); MONO_API void mono_profiler_install_allocation (MonoLegacyProfileAllocFunc callback); MONO_API void mono_profiler_install_enter_leave (MonoLegacyProfileMethodFunc enter, MonoLegacyProfileMethodFunc fleave); +MONO_API void mono_profiler_install_fileio (MonoLegacyProfileFileIOFunc callback); MONO_API void mono_profiler_install_exception (MonoLegacyProfileExceptionFunc throw_callback, MonoLegacyProfileMethodFunc exc_method_leave, MonoLegacyProfileExceptionClauseFunc clause_callback); static void @@ -1096,7 +1105,8 @@ typedef enum MONO_PROFILE_ENTER_LEAVE = 1 << 12, MONO_PROFILE_COVERAGE = 1 << 13, MONO_PROFILE_INS_COVERAGE = 1 << 14, - MONO_PROFILE_STATISTICAL = 1 << 15 + MONO_PROFILE_STATISTICAL = 1 << 15, + MONO_PROFILE_FILEIO = 1 << 16 } LegacyMonoProfileFlags; void @@ -1110,6 +1120,9 @@ mono_profiler_set_events (int flags) if (flags & MONO_PROFILE_ALLOCATIONS) mono_profiler_enable_allocations (); + + if (flags & MONO_PROFILE_FILEIO) + mono_profiler_enable_fileio (); } static void @@ -1127,6 +1140,21 @@ mono_profiler_install_allocation (MonoLegacyProfileAllocFunc callback) mono_profiler_set_gc_allocation_callback (current->handle, allocation_cb); } +static void +fileio_cb (MonoProfiler *prof, uint64_t kind, uint64_t size) +{ + prof->fileio (prof->profiler, kind, size); +} + +void +mono_profiler_install_fileio (MonoLegacyProfileFileIOFunc callback) +{ + current->fileio = callback; + + if (callback) + mono_profiler_set_fileio_callback (current->handle, fileio_cb); +} + static void enter_cb (MonoProfiler *prof, MonoMethod *method, MonoProfilerCallContext *context) { diff --git a/mono/metadata/profiler.h b/mono/metadata/profiler.h index a2110902296e..f86021698410 100644 --- a/mono/metadata/profiler.h +++ b/mono/metadata/profiler.h @@ -70,6 +70,7 @@ MONO_API mono_bool mono_profiler_set_sample_mode (MonoProfilerHandle handle, Mon MONO_API mono_bool mono_profiler_get_sample_mode (MonoProfilerHandle handle, MonoProfilerSampleMode *mode, uint32_t *freq); MONO_API mono_bool mono_profiler_enable_allocations (void); +MONO_API mono_bool mono_profiler_enable_fileio (void); typedef struct _MonoProfilerCallContext MonoProfilerCallContext; diff --git a/mono/metadata/w32file-unix.c b/mono/metadata/w32file-unix.c index 94d9b547da3a..b170a3872afb 100644 --- a/mono/metadata/w32file-unix.c +++ b/mono/metadata/w32file-unix.c @@ -40,6 +40,7 @@ #include "w32file-unix-glob.h" #include "w32error.h" #include "fdhandle.h" +#include "mono/metadata/profiler-private.h" #include "utils/mono-io-portability.h" #include "utils/mono-logger-internals.h" #include "utils/mono-os-mutex.h" @@ -1037,6 +1038,7 @@ file_read(FileHandle *filehandle, gpointer buffer, guint32 numbytes, guint32 *by if (bytesread != NULL) { *bytesread = ret; + MONO_PROFILER_RAISE (fileio, (1, *bytesread)); } return(TRUE); @@ -1104,6 +1106,7 @@ file_write(FileHandle *filehandle, gconstpointer buffer, guint32 numbytes, guint } if (byteswritten != NULL) { *byteswritten = ret; + MONO_PROFILER_RAISE (fileio, (0, *byteswritten)); } return(TRUE); } diff --git a/mono/metadata/w32file-win32.c b/mono/metadata/w32file-win32.c index 7d08aefdeeb0..90fc55bfa08f 100644 --- a/mono/metadata/w32file-win32.c +++ b/mono/metadata/w32file-win32.c @@ -11,6 +11,7 @@ #include #include #include "mono/metadata/w32file-win32-internals.h" +#include "mono/metadata/profiler-private.h" void mono_w32file_init (void) @@ -87,6 +88,7 @@ mono_w32file_read(gpointer handle, gpointer buffer, guint32 numbytes, guint32 *b gboolean res; MONO_ENTER_GC_SAFE; res = ReadFile (handle, buffer, numbytes, bytesread, NULL); + MONO_PROFILER_RAISE (fileio, (1, *bytesread)); MONO_EXIT_GC_SAFE; return res; } @@ -97,6 +99,7 @@ mono_w32file_write (gpointer handle, gconstpointer buffer, guint32 numbytes, gui gboolean res; MONO_ENTER_GC_SAFE; res = WriteFile (handle, buffer, numbytes, byteswritten, NULL); + MONO_PROFILER_RAISE (fileio, (0, *byteswritten)); MONO_EXIT_GC_SAFE; return res; } diff --git a/mono/profiler/log-args.c b/mono/profiler/log-args.c index 0c8bd040a386..3c707283859d 100644 --- a/mono/profiler/log-args.c +++ b/mono/profiler/log-args.c @@ -27,6 +27,7 @@ static NameAndMask event_list[] = { { "counters", PROFLOG_COUNTER_EVENTS }, { "alloc", PROFLOG_ALLOC_ALIAS, PROFLOG_ALLOC_ALIAS | PROFLOG_GC_ROOT_EVENTS }, + { "fileio", PROFLOG_FILEIO_EVENTS }, { "legacy", PROFLOG_LEGACY_ALIAS }, }; diff --git a/mono/profiler/log.c b/mono/profiler/log.c index e0c19bed121e..c31f386edde0 100644 --- a/mono/profiler/log.c +++ b/mono/profiler/log.c @@ -112,7 +112,10 @@ static gint32 sync_points_ctr, coverage_methods_ctr, coverage_statements_ctr, coverage_classes_ctr, - coverage_assemblies_ctr; + coverage_assemblies_ctr, + fileio_reads_ctr, + fileio_writes_ctr; + // Pending data to be written to the log, for a single thread. // Threads periodically flush their own LogBuffers by calling safe_send @@ -1656,6 +1659,37 @@ finalize_object_end (MonoProfiler *prof, MonoObject *obj) EXIT_LOG; } +static void +fileio (MonoProfiler *prof, uint64_t kind, uint64_t size) +{ + if (kind == 0) + { + ENTER_LOG (&fileio_writes_ctr, buf, + EVENT_SIZE /* event */ + + LEB128_SIZE /* kind */ + + LEB128_SIZE /* size */ + ); + emit_event (buf, TYPE_FILEIO); + emit_value (buf, kind); + emit_value (buf, size); + + EXIT_LOG; + } + else + { + ENTER_LOG (&fileio_reads_ctr, buf, + EVENT_SIZE /* event */ + + LEB128_SIZE /* kind */ + + LEB128_SIZE /* size */ + ); + emit_event (buf, TYPE_FILEIO); + emit_value (buf, kind); + emit_value (buf, size); + + EXIT_LOG; + } +} + static char* push_nesting (char *p, MonoClass *klass) { @@ -4416,6 +4450,28 @@ proflog_icall_SetGCAllocationEvents (MonoBoolean value) mono_coop_mutex_unlock (&log_profiler.api_mutex); } +ICALL_EXPORT MonoBoolean +proflog_icall_GetFileIOEvents (void) +{ + return ENABLED (PROFLOG_FILEIO_EVENTS); +} + +ICALL_EXPORT void +proflog_icall_SetFileIOEvents (MonoBoolean value) +{ + mono_coop_mutex_lock (&log_profiler.api_mutex); + + if (value) { + ENABLE (PROFLOG_FILEIO_EVENTS); + mono_profiler_set_fileio_callback (log_profiler.handle, fileio); + } else { + DISABLE (PROFLOG_FILEIO_EVENTS); + mono_profiler_set_fileio_callback (log_profiler.handle, NULL); + } + + mono_coop_mutex_unlock (&log_profiler.api_mutex); +} + ICALL_EXPORT MonoBoolean proflog_icall_GetGCMoveEvents (void) { @@ -4604,6 +4660,8 @@ runtime_initialized (MonoProfiler *profiler) register_counter ("Event: Coverage statements", &coverage_statements_ctr); register_counter ("Event: Coverage classes", &coverage_classes_ctr); register_counter ("Event: Coverage assemblies", &coverage_assemblies_ctr); + register_counter ("Event: File IO reads", &fileio_reads_ctr); + register_counter ("Event: File IO writes", &fileio_writes_ctr); counters_init (); @@ -4848,6 +4906,9 @@ mono_profiler_init_log (const char *desc) mono_profiler_set_gc_finalizing_object_callback (handle, finalize_object_begin); } + if (ENABLED (PROFLOG_FILEIO_EVENTS)) + mono_profiler_set_fileio_callback (handle, fileio); + //On Demand heapshot uses the finalizer thread to force a collection and thus a heapshot mono_profiler_set_gc_finalized_callback (handle, finalize_end); diff --git a/mono/profiler/log.h b/mono/profiler/log.h index 8ea1991e36ec..7d306a764997 100644 --- a/mono/profiler/log.h +++ b/mono/profiler/log.h @@ -386,6 +386,7 @@ enum { TYPE_RUNTIME, TYPE_COVERAGE, TYPE_META, + TYPE_FILEIO, /* extended type for TYPE_HEAP */ TYPE_HEAP_START = 0 << 4, TYPE_HEAP_END = 1 << 4, @@ -491,10 +492,11 @@ typedef enum { #define PROFLOG_COUNTER_EVENTS (1 << 8) #define PROFLOG_SAMPLE_EVENTS (1 << 9) #define PROFLOG_JIT_EVENTS (1 << 10) +#define PROFLOG_FILEIO_EVENTS (1 << 11) #define PROFLOG_ALLOC_ALIAS (PROFLOG_GC_EVENTS | PROFLOG_GC_ALLOCATION_EVENTS | PROFLOG_GC_MOVE_EVENTS) #define PROFLOG_HEAPSHOT_ALIAS (PROFLOG_GC_EVENTS | PROFLOG_GC_ROOT_EVENTS) -#define PROFLOG_LEGACY_ALIAS (PROFLOG_EXCEPTION_EVENTS | PROFLOG_MONITOR_EVENTS | PROFLOG_GC_EVENTS | PROFLOG_GC_MOVE_EVENTS | PROFLOG_GC_ROOT_EVENTS | PROFLOG_GC_HANDLE_EVENTS | PROFLOG_GC_FINALIZATION_EVENTS | PROFLOG_COUNTER_EVENTS) +#define PROFLOG_LEGACY_ALIAS (PROFLOG_EXCEPTION_EVENTS | PROFLOG_MONITOR_EVENTS | PROFLOG_GC_EVENTS | PROFLOG_GC_MOVE_EVENTS | PROFLOG_GC_ROOT_EVENTS | PROFLOG_GC_HANDLE_EVENTS | PROFLOG_GC_FINALIZATION_EVENTS | PROFLOG_COUNTER_EVENTS | PROFLOG_FILEIO_EVENTS) typedef struct { //Events explicitly enabled From 554b601da1a028c6222ee77de94ea20e6815d9c3 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 9 Jan 2018 15:16:57 +0100 Subject: [PATCH 195/582] [w32process] Ensure process_handle is a legal value (#6449) * [w32process] Ensure process_handle is a legal value Fixes https://github.com/mono/mono/issues/6383 * [w32process] Remove dead code --- mcs/class/System/System.Diagnostics/Process.cs | 2 -- mono/metadata/w32process-unix.c | 8 +------- mono/metadata/w32process-win32.c | 4 ---- mono/metadata/w32process.h | 2 -- 4 files changed, 1 insertion(+), 15 deletions(-) diff --git a/mcs/class/System/System.Diagnostics/Process.cs b/mcs/class/System/System.Diagnostics/Process.cs index 35b7f3fac65f..6dfebd9a1978 100644 --- a/mcs/class/System/System.Diagnostics/Process.cs +++ b/mcs/class/System/System.Diagnostics/Process.cs @@ -60,9 +60,7 @@ private struct ProcInfo * the Start_internal icall in * mono/metadata/process.c */ - public IntPtr thread_handle; public int pid; // Contains -GetLastError () on failure. - public int tid; public string[] envVariables; public string UserName; public string Domain; diff --git a/mono/metadata/w32process-unix.c b/mono/metadata/w32process-unix.c index 2fb87faa4d44..e2100d266e80 100644 --- a/mono/metadata/w32process-unix.c +++ b/mono/metadata/w32process-unix.c @@ -2062,10 +2062,6 @@ process_create (const gunichar2 *appname, const gunichar2 *cmdline, if (process_info != NULL) { process_info->process_handle = handle; process_info->pid = pid; - - /* FIXME: we might need to handle the thread info some day */ - process_info->thread_handle = INVALID_HANDLE_VALUE; - process_info->tid = 0; } mono_w32handle_unref (handle_data); @@ -2218,20 +2214,18 @@ ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoW32ProcessStar } /* Shell exec should not return a process handle when it spawned a GUI thing, like a browser. */ mono_w32handle_close (process_info->process_handle); - process_info->process_handle = NULL; + process_info->process_handle = INVALID_HANDLE_VALUE; } done: if (ret == FALSE) { process_info->pid = -mono_w32error_get_last (); } else { - process_info->thread_handle = NULL; #if !defined(MONO_CROSS_COMPILE) process_info->pid = mono_w32process_get_pid (process_info->process_handle); #else process_info->pid = 0; #endif - process_info->tid = 0; } return ret; diff --git a/mono/metadata/w32process-win32.c b/mono/metadata/w32process-win32.c index 24fb97ce4d49..2b90f908f3be 100644 --- a/mono/metadata/w32process-win32.c +++ b/mono/metadata/w32process-win32.c @@ -111,13 +111,11 @@ ves_icall_System_Diagnostics_Process_ShellExecuteEx_internal (MonoW32ProcessStar process_info->pid = -GetLastError (); } else { process_info->process_handle = shellex.hProcess; - process_info->thread_handle = NULL; #if !defined(MONO_CROSS_COMPILE) process_info->pid = GetProcessId (shellex.hProcess); #else process_info->pid = 0; #endif - process_info->tid = 0; } return ret; @@ -335,11 +333,9 @@ ves_icall_System_Diagnostics_Process_CreateProcess_internal (MonoW32ProcessStart if (ret) { process_info->process_handle = procinfo.hProcess; /*process_info->thread_handle=procinfo.hThread;*/ - process_info->thread_handle = NULL; if (procinfo.hThread != NULL && procinfo.hThread != INVALID_HANDLE_VALUE) CloseHandle (procinfo.hThread); process_info->pid = procinfo.dwProcessId; - process_info->tid = procinfo.dwThreadId; } else { process_info->pid = -GetLastError (); } diff --git a/mono/metadata/w32process.h b/mono/metadata/w32process.h index 0565ac1eb684..41c3a3154d9f 100644 --- a/mono/metadata/w32process.h +++ b/mono/metadata/w32process.h @@ -34,9 +34,7 @@ typedef enum { typedef struct { gpointer process_handle; - gpointer thread_handle; guint32 pid; /* Contains mono_w32error_get_last () on failure */ - guint32 tid; MonoArray *env_variables; MonoString *username; MonoString *domain; From 149c289a03a0d8a4a7e033f740344591fafdb43d Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Wed, 17 Jan 2018 15:10:15 +0100 Subject: [PATCH 196/582] [exception] propagte stackoverflow exception to managed code (#6458) we return the address of the StackOverflowException object in `restore_soft_guard_pages`, so it ends up in the architecture specific result register (e.g. %rax) where the exception handler expects it. fixes https://bugzilla.xamarin.com/show_bug.cgi?id=60862 --- mono/mini/exceptions-amd64.c | 17 ++++++++++-- mono/mini/exceptions-x86.c | 20 ++++++++++--- mono/mini/mini-runtime.h | 1 + mono/tests/Makefile.am | 10 +++++++ mono/tests/bug-60862.cs | 54 ++++++++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 mono/tests/bug-60862.cs diff --git a/mono/mini/exceptions-amd64.c b/mono/mini/exceptions-amd64.c index 1773c784acec..a20f3ae335ec 100644 --- a/mono/mini/exceptions-amd64.c +++ b/mono/mini/exceptions-amd64.c @@ -813,12 +813,20 @@ mono_arch_ip_from_context (void *sigctx) #endif } -static void -restore_soft_guard_pages (void) +static MonoObject* +restore_soft_guard_pages () { MonoJitTlsData *jit_tls = (MonoJitTlsData *)mono_tls_get_jit_tls (); if (jit_tls->stack_ovf_guard_base) mono_mprotect (jit_tls->stack_ovf_guard_base, jit_tls->stack_ovf_guard_size, MONO_MMAP_NONE); + + if (jit_tls->stack_ovf_pending) { + MonoDomain *domain = mono_domain_get (); + jit_tls->stack_ovf_pending = 0; + return (MonoObject *) domain->stack_overflow_ex; + } + + return NULL; } /* @@ -851,8 +859,11 @@ altstack_handle_and_restore (MonoContext *ctx, MonoObject *obj, gboolean stack_o mctx = *ctx; mono_handle_exception (&mctx, obj); - if (stack_ovf) + if (stack_ovf) { + MonoJitTlsData *jit_tls = (MonoJitTlsData *) mono_tls_get_jit_tls (); + jit_tls->stack_ovf_pending = 1; prepare_for_guard_pages (&mctx); + } mono_restore_context (&mctx); } diff --git a/mono/mini/exceptions-x86.c b/mono/mini/exceptions-x86.c index b4df2f2c03b7..89ef7e57768e 100644 --- a/mono/mini/exceptions-x86.c +++ b/mono/mini/exceptions-x86.c @@ -1034,12 +1034,20 @@ mono_arch_handle_exception (void *sigctx, gpointer obj) #endif } -static void -restore_soft_guard_pages (void) +static MonoObject* +restore_soft_guard_pages () { MonoJitTlsData *jit_tls = mono_tls_get_jit_tls (); + if (jit_tls->stack_ovf_guard_base) mono_mprotect (jit_tls->stack_ovf_guard_base, jit_tls->stack_ovf_guard_size, MONO_MMAP_NONE); + + if (jit_tls->stack_ovf_pending) { + MonoDomain *domain = mono_domain_get (); + jit_tls->stack_ovf_pending = 0; + return (MonoObject *) domain->stack_overflow_ex; + } + return NULL; } /* @@ -1054,12 +1062,13 @@ prepare_for_guard_pages (MonoContext *mctx) gpointer *sp; sp = (gpointer)(mctx->esp); sp -= 1; - /* the resturn addr */ + /* the return addr */ sp [0] = (gpointer)(mctx->eip); mctx->eip = (unsigned long)restore_soft_guard_pages; mctx->esp = (unsigned long)sp; } + static void altstack_handle_and_restore (MonoContext *ctx, gpointer obj, gboolean stack_ovf) { @@ -1068,8 +1077,11 @@ altstack_handle_and_restore (MonoContext *ctx, gpointer obj, gboolean stack_ovf) mctx = *ctx; mono_handle_exception (&mctx, obj); - if (stack_ovf) + if (stack_ovf) { + MonoJitTlsData *jit_tls = (MonoJitTlsData *) mono_tls_get_jit_tls (); + jit_tls->stack_ovf_pending = 1; prepare_for_guard_pages (&mctx); + } mono_restore_context (&mctx); } diff --git a/mono/mini/mini-runtime.h b/mono/mini/mini-runtime.h index c4dcd503f6ab..d9475ab61a26 100644 --- a/mono/mini/mini-runtime.h +++ b/mono/mini/mini-runtime.h @@ -79,6 +79,7 @@ struct MonoJitTlsData { gpointer stack_ovf_guard_base; guint32 stack_ovf_guard_size; guint stack_ovf_valloced : 1; + guint stack_ovf_pending : 1; void (*abort_func) (MonoObject *object); /* Used to implement --debug=casts */ MonoClass *class_cast_from, *class_cast_to; diff --git a/mono/tests/Makefile.am b/mono/tests/Makefile.am index cff377fc0276..8464b3f5c22d 100755 --- a/mono/tests/Makefile.am +++ b/mono/tests/Makefile.am @@ -534,10 +534,18 @@ TESTS_CS_SRC= \ if AMD64 TESTS_CS_SRC += async-exc-compilation.cs finally_guard.cs finally_block_ending_in_dead_bb.cs +if !HOST_WIN32 +# requires working altstack +TESTS_CS_SRC += bug-60862.cs +endif endif if X86 TESTS_CS_SRC += async-exc-compilation.cs finally_guard.cs finally_block_ending_in_dead_bb.cs +if !HOST_WIN32 +# requires working altstack +TESTS_CS_SRC += bug-60862.cs +endif endif TESTS_IL_SRC= \ @@ -973,6 +981,7 @@ DISABLED_TESTS = \ # exit code 0, but doesn't actually execute the test. # block_guard_restore_aligment_on_exit.exe: flaky (10% of the time it hangs and thus times out) # weak-fields.exe: https://bugzilla.xamarin.com/show_bug.cgi?id=60973 +# bug-60862.exe: missing support to map IP->method; only works on platforms with altstack support. INTERP_DISABLED_TESTS = \ $(KNOWN_FAILING_TESTS) \ $(INTERP_PLATFORM_DISABLED_TESTS) \ @@ -993,6 +1002,7 @@ INTERP_DISABLED_TESTS = \ bug-58782-plain-throw.exe \ bug-81673.exe \ bug445361.exe \ + bug-60862.exe \ calliGenericTest.exe \ cominterop.exe \ context-static.exe \ diff --git a/mono/tests/bug-60862.cs b/mono/tests/bug-60862.cs new file mode 100644 index 000000000000..251838f584dd --- /dev/null +++ b/mono/tests/bug-60862.cs @@ -0,0 +1,54 @@ +/* https://bugzilla.xamarin.com/show_bug.cgi?id=60862 */ +using System; +using System.Threading; + +namespace StackOverflowTest +{ + class Program + { + static bool fault = false; + static Exception ex = null; + + public static int Main(string[] args) + { + Thread t = new Thread (Run); + t.Start (); + t.Join (); + if (fault) { + if (ex == null) { + Console.WriteLine ("fault occured, but no exception object available"); + return 1; + } else { + bool is_stackoverlfow = ex is StackOverflowException; + Console.WriteLine ("fault occured: ex = " + is_stackoverlfow); + return is_stackoverlfow ? 0 : 3; + } + } + Console.WriteLine("no fault"); + return 2; + } + + static void Run() + { + try { + Execute (); + } catch(Exception e) { + ex = e; + fault = true; + } + } + + static void Execute () + { + WaitOne (); + } + + static bool WaitOne (bool killProcessOnInterrupt = false, bool throwOnInterrupt = false) + { + try { + return WaitOne(); + } catch(ThreadInterruptedException e) { } + return false; + } + } +} From 2b4caf8bba4b4acf07290f4421ee2fac52853143 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 6 Apr 2018 15:47:01 -0400 Subject: [PATCH 197/582] Remove osx x86 builds. --- external/buildscripts/build.pl | 7 +- external/buildscripts/build_all_osx.pl | 89 -------------------------- 2 files changed, 3 insertions(+), 93 deletions(-) diff --git a/external/buildscripts/build.pl b/external/buildscripts/build.pl index 7b05e3d2ecae..c1163f0e19e9 100644 --- a/external/buildscripts/build.pl +++ b/external/buildscripts/build.pl @@ -1563,10 +1563,9 @@ } elsif($^O eq 'darwin') { - # Note these tmp directories will get merged into a single 'osx' directory later by a parent script - $embedDirArchDestination = "$embedDirRoot/osx-tmp-$monoHostArch"; - $distDirArchBin = "$distdir/bin-osx-tmp-$monoHostArch"; - $versionsOutputFile = $arch32 ? "$buildsroot/versions-osx32.txt" : "$buildsroot/versions-osx64.txt"; + $embedDirArchDestination = "$embedDirRoot/osx"; + $distDirArchBin = "$distdir/bin-osx"; + $versionsOutputFile = "$buildsroot/versions-osx.txt"; } else { diff --git a/external/buildscripts/build_all_osx.pl b/external/buildscripts/build_all_osx.pl index 0f0eb42d6aa3..af345d38a51f 100644 --- a/external/buildscripts/build_all_osx.pl +++ b/external/buildscripts/build_all_osx.pl @@ -51,11 +51,6 @@ 'buildusandboo=i'=>\$buildUsAndBoo, ); -my $monoArch32Target = "i386"; - -print(">>> Building $monoArch32Target\n"); -system("perl", "$buildscriptsdir/build.pl", "--arch32=1", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ("failing building $monoArch32Target"); - if ($artifactsCommon) { push @passAlongArgs, "--artifactscommon=1"; @@ -75,91 +70,7 @@ # Merge stuff in the embedruntimes directory my $embedDirRoot = "$buildsroot/embedruntimes"; my $embedDirDestination = "$embedDirRoot/osx"; - my $embedDirSource32 = "$embedDirRoot/osx-tmp-$monoArch32Target"; - my $embedDirSource64 = "$embedDirRoot/osx-tmp-x86_64"; - - system("mkdir -p $embedDirDestination"); - - if (!(-d $embedDirSource32)) - { - die("Expected source directory not found : $embedDirSource32\n"); - } - - if (!(-d $embedDirSource64)) - { - die("Expected source directory not found : $embedDirSource64\n"); - } - - # Create universal binaries - for my $file ('libmonobdwgc-2.0.dylib','libmonosgen-2.0.dylib','libMonoPosixHelper.dylib') - { - print(">>> lipo $embedDirSource32/$file $embedDirSource64/$file -create -output $embedDirDestination/$file\n\n"); - system ('lipo', "$embedDirSource32/$file", "$embedDirSource64/$file", '-create', '-output', "$embedDirDestination/$file"); - } - - if (not $buildMachine) - { - print(">>> Doing non-build machine stuff...\n"); - for my $file ('libmonobdwgc-2.0.dylib','libmonosgen-2.0.dylib','libMonoPosixHelper.dylib') - { - print(">>> Removing $embedDirDestination/$file.dSYM\n"); - rmtree ("$embedDirDestination/$file.dSYM"); - print(">>> 'dsymutil $embedDirDestination/$file\n"); - system ('dsymutil', "$embedDirDestination/$file") eq 0 or warn ("Failed creating $embedDirDestination/$file.dSYM"); - } - - print(">>> Done with non-build machine stuff\n"); - } - - # Merge stuff in the monodistribution directory - my $distDirRoot = "$buildsroot/monodistribution"; - my $distDirDestinationBin = "$buildsroot/monodistribution/bin"; - my $distDirDestinationLib = "$buildsroot/monodistribution/lib"; - my $distDirSourceBin32 = "$distDirRoot/bin-osx-tmp-$monoArch32Target"; - my $distDirSourceBin64 = "$distDirRoot/bin-osx-tmp-x86_64"; - # Should always exist because build_all would have put stuff in it, but in some situations - # depending on the options it may not. So create it if it does not exist - if (!(-d $distDirDestinationBin)) - { - system("mkdir -p $distDirDestinationBin"); - } - - if (!(-d $distDirDestinationLib)) - { - system("mkdir -p $distDirDestinationLib"); - } - if (!(-d $distDirSourceBin32)) - { - die("Expected source directory not found : $distDirSourceBin32\n"); - } - - if (!(-d $distDirSourceBin64)) - { - die("Expected source directory not found : $distDirSourceBin64\n"); - } - for my $file ('mono','pedump') - { - print(">>> lipo $distDirSourceBin32/$file $distDirSourceBin64/$file -create -output $distDirDestinationBin/$file\n\n"); - system ('lipo', "$distDirSourceBin32/$file", "$distDirSourceBin64/$file", '-create', '-output', "$distDirDestinationBin/$file"); - } - - #Create universal binaries for stuff is in the embed dir but will end up in the dist dir - for my $file ('libMonoPosixHelper.dylib') - { - print(">>> lipo $embedDirSource32/$file $embedDirSource64/$file -create -output $distDirDestinationLib/$file\n\n"); - system ('lipo', "$embedDirSource32/$file", "$embedDirSource64/$file", '-create', '-output', "$distDirDestinationLib/$file"); - } - - if ($buildMachine) - { - print(">>> Clean up temporary arch specific build directories\n"); - - rmtree("$distDirSourceBin32"); - rmtree("$distDirSourceBin64"); - rmtree("$embedDirSource32"); - rmtree("$embedDirSource64"); - } } From 3d05f2ff563576d774828d844a89ef6f8a3a0c54 Mon Sep 17 00:00:00 2001 From: Eneko Osia Date: Mon, 9 Apr 2018 14:21:14 +0200 Subject: [PATCH 198/582] [metadata] change return type in mono_type_get_attrs function --- mono/metadata/metadata.c | 2 +- mono/metadata/metadata.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mono/metadata/metadata.c b/mono/metadata/metadata.c index b18ba6cfa2f8..5b824f849548 100644 --- a/mono/metadata/metadata.c +++ b/mono/metadata/metadata.c @@ -6613,7 +6613,7 @@ mono_type_is_byref (MonoType *type) * * Returns: the param attributes. */ -uint16_t +uint32_t mono_type_get_attrs (MonoType *type) { return type->attrs; diff --git a/mono/metadata/metadata.h b/mono/metadata/metadata.h index 236028f4ba9a..ee07f991e9c9 100644 --- a/mono/metadata/metadata.h +++ b/mono/metadata/metadata.h @@ -335,7 +335,7 @@ typedef enum { MONO_API mono_bool mono_type_is_byref (MonoType *type); -MONO_API uint16_t +MONO_API uint32_t mono_type_get_attrs (MonoType *type); MONO_API int From c3026b779099d3a6ed12a6c1ff442444a9b0e6ab Mon Sep 17 00:00:00 2001 From: Michael Herring Date: Mon, 16 Apr 2018 12:12:09 +0900 Subject: [PATCH 199/582] Changes necessary for managed debugging on Switch --- mono/mini/debugger-agent.c | 3 +++ mono/mini/il2cpp-c-types.h | 2 -- mono/mini/il2cpp-stubs.cpp | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 5212b713c247..e0f4741411df 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -119,6 +119,9 @@ #include "debugger-agent.h" +Il2CppMonoDefaults il2cpp_mono_defaults; +Il2CppMonoDebugOptions il2cpp_mono_debug_options; + #ifdef RUNTIME_IL2CPP const Il2CppDebuggerMetadataRegistration *g_il2cpp_metadata; #endif diff --git a/mono/mini/il2cpp-c-types.h b/mono/mini/il2cpp-c-types.h index 627d0cc8366d..fc50bb51d7ab 100644 --- a/mono/mini/il2cpp-c-types.h +++ b/mono/mini/il2cpp-c-types.h @@ -93,8 +93,6 @@ struct _Il2CppEmptyStruct TYPED_HANDLE_DECL (MonoObject); TYPED_HANDLE_DECL (MonoReflectionAssembly); -Il2CppMonoDefaults il2cpp_mono_defaults; -Il2CppMonoDebugOptions il2cpp_mono_debug_options; typedef void (*Il2CppMonoProfileFunc) (MonoProfiler *prof); typedef void (*Il2CppMonoProfileAppDomainFunc) (MonoProfiler *prof, MonoDomain *domain); diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index 060d8b68b3e0..608fe8555815 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -42,6 +42,10 @@ extern "C" { #include #include #include "il2cpp-c-types.h" + +Il2CppMonoDefaults il2cpp_mono_defaults; +Il2CppMonoDebugOptions il2cpp_mono_debug_options; + #include static MonoGHashTable *method_signatures; From 1edb2d50305eaac8e7c2b704e9f7684f9a0afb1a Mon Sep 17 00:00:00 2001 From: Lukasz Paczkowski Date: Mon, 16 Apr 2018 17:00:26 +0200 Subject: [PATCH 200/582] Initial work on collecting classes from dynamic assemblies. --- mono/metadata/appdomain.h | 4 ++ mono/metadata/domain.c | 21 ++++++ mono/metadata/unity-memory-info.c | 108 +++++++++++++++++++++++++----- 3 files changed, 116 insertions(+), 17 deletions(-) diff --git a/mono/metadata/appdomain.h b/mono/metadata/appdomain.h index 9d42bdda4903..3f87fe08b2b9 100644 --- a/mono/metadata/appdomain.h +++ b/mono/metadata/appdomain.h @@ -26,6 +26,7 @@ typedef struct _MonoAppDomain MonoAppDomain; typedef struct _MonoJitInfo MonoJitInfo; typedef void (*MonoDomainFunc) (MonoDomain *domain, void* user_data); +typedef void(*MonoDomainAssemblyFunc) (MonoAssembly *assembly, void* user_data); MONO_API MonoDomain* mono_init (const char *filename); @@ -108,6 +109,9 @@ mono_domain_from_appdomain (MonoAppDomain *appdomain); MONO_API void mono_domain_foreach (MonoDomainFunc func, void* user_data); +MONO_API void +mono_domain_assembly_foreach (MonoDomain* domain, MonoDomainAssemblyFunc func, void* user_data); + MONO_API MonoAssembly * mono_domain_assembly_open (MonoDomain *domain, const char *name); diff --git a/mono/metadata/domain.c b/mono/metadata/domain.c index 2947589dbb76..6e029bf0a12a 100644 --- a/mono/metadata/domain.c +++ b/mono/metadata/domain.c @@ -982,6 +982,27 @@ mono_domain_foreach (MonoDomainFunc func, gpointer user_data) gc_free_fixed_non_heap_list (copy); } +MONO_API void +mono_domain_assembly_foreach (MonoDomain* domain, MonoDomainFunc func, void* user_data) +{ + MonoAssembly* assembly; + GSList *iter; + + /* Skipping internal assembly builders created by remoting, + as it is done in ves_icall_System_AppDomain_GetAssemblies + */ + mono_domain_assemblies_lock(domain); + for (iter = domain->domain_assemblies; iter; iter = iter->next) + { + assembly = (MonoAssembly *)iter->data; + if (assembly->corlib_internal) + continue; + + func(assembly, user_data); + } + mono_domain_assemblies_unlock(domain); +} + /* FIXME: maybe we should integrate this with mono_assembly_open? */ /** * mono_domain_assembly_open: diff --git a/mono/metadata/unity-memory-info.c b/mono/metadata/unity-memory-info.c index 39177fdef65d..3095530e065e 100644 --- a/mono/metadata/unity-memory-info.c +++ b/mono/metadata/unity-memory-info.c @@ -20,6 +20,32 @@ typedef struct CollectMetadataContext MonoMetadataSnapshot* metadata; } CollectMetadataContext; +typedef struct AllDomainAssembliesForeachData +{ + MonoDomainAssemblyFunc func; + void* user_data; + +} AllDomainAssembliesForeachData; + +static void AllDomainAssembliesForeachHelper(MonoDomain* domain, void* user_data) +{ + AllDomainAssembliesForeachData *data = (AllDomainAssembliesForeachData*)user_data; + + mono_domain_assembly_foreach(domain, data->func, data->user_data); +} + +static void AllDomainAssembliesForeach(MonoDomainAssemblyFunc func, void* user_data) +{ + AllDomainAssembliesForeachData data; + + data.func = func; + data.user_data = user_data; + + AllDomainAssembliesForeachHelper(mono_domain_get(), &data); + +// mono_domain_foreach(AllDomainAssembliesForeachHelper, &data); +} + static void ContextInsertClass(CollectMetadataContext* context, MonoClass* klass) { if (klass->inited && g_hash_table_lookup(context->allTypes, klass) == NULL) @@ -56,27 +82,74 @@ static void CollectGenericClass(gpointer value, gpointer user_data) ContextInsertClass(context, genericClass->cached_class); } -static void CollectAssemblyMetaData(MonoAssembly *assembly, void *user_data) +MonoClass* MonoLookupDynamiClass(MonoImage *image, guint32 token, MonoGenericContext *context, MonoError *error) +{ + MonoClass *handle_class; + error_init(error); + return (MonoClass*)mono_reflection_lookup_dynamic_token(image, token, FALSE, &handle_class, context, error); +} + +static void CollectImageMetaData(MonoImage* image, CollectMetadataContext* context) { int i; - CollectMetadataContext* context = (CollectMetadataContext*)user_data; - MonoImage* image = mono_assembly_get_image(assembly); MonoTableInfo *tdef = &image->tables[MONO_TABLE_TYPEDEF]; - for (i = 0; i < tdef->rows - 1; ++i) + if (image->module_count > 0) { - MonoClass* klass = mono_class_get(image, (i + 2) | MONO_TOKEN_TYPE_DEF); - ContextInsertClass(context, klass); + for (i = 0; i < image->module_count; ++i) + { + MonoImage* moduleImage = image->modules[i]; + + if(moduleImage) + CollectImageMetaData(moduleImage, context); + } + } + + if (image->dynamic) + { + MonoDynamicImage* dynamicImage = (MonoDynamicImage*)image; + GList* types = g_hash_table_get_keys(dynamicImage->typeref); + GList* type; + + for (type = types; type != NULL; type = type->next) + { + MonoType* monoType = (MonoType*)type->data; + MonoClass* klass = mono_type_get_class(monoType); + + if (klass) + ContextInsertClass(context, klass); + } + } + + for (i = 1; i < tdef->rows; ++i) + { + MonoClass *klass; + MonoError error; + + guint32 token = (i + 1) | MONO_TOKEN_TYPE_DEF; + + klass = mono_class_get_checked(image, token, &error); + + if (klass) + ContextInsertClass(context, klass); } if (image->array_cache) - g_hash_table_foreach(image->array_cache, CollectHashMapListClasses, user_data); + g_hash_table_foreach(image->array_cache, CollectHashMapListClasses, context); if (image->szarray_cache) - g_hash_table_foreach(image->szarray_cache, CollectHashMapClass, user_data); + g_hash_table_foreach(image->szarray_cache, CollectHashMapClass, context); if (image->ptr_cache) - g_hash_table_foreach(image->ptr_cache, CollectHashMapClass, user_data); + g_hash_table_foreach(image->ptr_cache, CollectHashMapClass, context); +} + +static void CollectAssemblyMetaData(MonoAssembly *assembly, void *user_data) +{ + MonoImage* image = mono_assembly_get_image(assembly); + CollectMetadataContext* context = (CollectMetadataContext*)user_data; + + CollectImageMetaData(image, context); } static int FindClassIndex(GHashTable* hashTable, MonoClass* klass) @@ -169,7 +242,7 @@ static void CollectMetadata(MonoMetadataSnapshot* metadata) context.currentIndex = 0; context.metadata = metadata; - mono_assembly_foreach((GFunc)CollectAssemblyMetaData, &context); + AllDomainAssembliesForeach(CollectAssemblyMetaData, &context); mono_metadata_generic_class_foreach(CollectGenericClass, &context); @@ -251,7 +324,8 @@ static void IncrementCountForImageMemPoolNumChunks(MonoAssembly *assembly, void static int MonoImagesMemPoolNumChunks() { int count = 0; - mono_assembly_foreach((GFunc)IncrementCountForImageMemPoolNumChunks, &count); + + AllDomainAssembliesForeach((GFunc)IncrementCountForImageMemPoolNumChunks, &count); return count; } @@ -291,7 +365,7 @@ static void MonoImagesCountCallback(MonoAssembly *assembly, void *user_data) static int MonoImagesCount() { int count = 0; - mono_assembly_foreach((GFunc)MonoImagesCountCallback, &count); + AllDomainAssembliesForeach((GFunc)MonoImagesCountCallback, &count); return count; } @@ -370,9 +444,9 @@ static void* CaptureHeapInfo(void* monoManagedHeap) mono_mempool_foreach_block(domain->mp, AllocateMemoryForMemPoolChunk, &iterationContext); mono_domain_unlock(domain); // Allocate memory for each image mem pool chunk - mono_assembly_foreach((GFunc)AllocateMemoryForImageMemPool, &iterationContext); + AllDomainAssembliesForeach((GFunc)AllocateMemoryForImageMemPool, &iterationContext); // Allocate memory for each image->class_cache hash table. - mono_assembly_foreach((GFunc)AllocateMemoryForImageClassCache, &iterationContext); + AllDomainAssembliesForeach((GFunc)AllocateMemoryForImageClassCache, &iterationContext); // Allocate memory for each image->class_cache hash table. mono_metadata_image_set_foreach((GFunc)AllocateMemoryForImageSetMemPool, &iterationContext); @@ -469,8 +543,8 @@ static void CaptureManagedHeap(MonoManagedHeap* heap) GC_foreach_heap_section(&iterationContext, CopyHeapSection); mono_mempool_foreach_block(rootDomain->mp, CopyMemPoolChunk, &iterationContext); mono_mempool_foreach_block(domain->mp, CopyMemPoolChunk, &iterationContext); - mono_assembly_foreach((GFunc)CopyImageMemPool, &iterationContext); - mono_assembly_foreach((GFunc)CopyImageClassCache, &iterationContext); + AllDomainAssembliesForeach((GFunc)CopyImageMemPool, &iterationContext); + AllDomainAssembliesForeach((GFunc)CopyImageClassCache, &iterationContext); mono_metadata_image_set_foreach((GFunc)CopyImageSetMemPool, &iterationContext); GC_start_world_external(); @@ -546,7 +620,7 @@ static void VerifySnapshot(MonoManagedMemorySnapshot* snapshot) if (!ManagedHeapContainsAddress(&snapshot->heap, type->typeInfoAddress)) { - fprintf(file, "The memory for type '%s' @ 0x%016X is not the part the snapshot.\n", type->name, type->typeInfoAddress); + fprintf(file, "The memory for type '%s' @ 0x%016llX is not the part the snapshot.\n", type->name, type->typeInfoAddress); } } From 43db84160cbaf95aa2b11ed93e7f4bc9b69a8e64 Mon Sep 17 00:00:00 2001 From: Michael Herring Date: Wed, 18 Apr 2018 14:19:33 +0900 Subject: [PATCH 201/582] Add extern to il2cpp_mono symbols in debugger-agent.c --- mono/mini/debugger-agent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index e0f4741411df..4da988d21ea9 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -119,8 +119,8 @@ #include "debugger-agent.h" -Il2CppMonoDefaults il2cpp_mono_defaults; -Il2CppMonoDebugOptions il2cpp_mono_debug_options; +extern Il2CppMonoDefaults il2cpp_mono_defaults; +extern Il2CppMonoDebugOptions il2cpp_mono_debug_options; #ifdef RUNTIME_IL2CPP const Il2CppDebuggerMetadataRegistration *g_il2cpp_metadata; From 945fb4885019dc000c643a322efd0e133b1d99a5 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 20 Apr 2018 12:21:31 -0400 Subject: [PATCH 202/582] Fix build --- mono/mini/debugger-agent.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 4da988d21ea9..79337e0e26fc 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -119,10 +119,9 @@ #include "debugger-agent.h" +#ifdef RUNTIME_IL2CPP extern Il2CppMonoDefaults il2cpp_mono_defaults; extern Il2CppMonoDebugOptions il2cpp_mono_debug_options; - -#ifdef RUNTIME_IL2CPP const Il2CppDebuggerMetadataRegistration *g_il2cpp_metadata; #endif From 442ea640f36a999e338f5ea452c74be82c30708e Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Fri, 20 Apr 2018 14:48:34 -0400 Subject: [PATCH 203/582] Expose two public types These types are public in the .NET 4.7.1 profile, so they should be public in Mono as well. --- .../CompositeControlDesigner.cs | 2 +- .../System.ServiceModel.Channels/TransactionMessageProperty.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mcs/class/System.Design/System.Web.UI.Design.WebControls/CompositeControlDesigner.cs b/mcs/class/System.Design/System.Web.UI.Design.WebControls/CompositeControlDesigner.cs index 17997212533c..8a13185c5ab1 100644 --- a/mcs/class/System.Design/System.Web.UI.Design.WebControls/CompositeControlDesigner.cs +++ b/mcs/class/System.Design/System.Web.UI.Design.WebControls/CompositeControlDesigner.cs @@ -35,7 +35,7 @@ namespace System.Web.UI.Design.WebControls { - class CompositeControlDesigner : ControlDesigner + public class CompositeControlDesigner : ControlDesigner { public CompositeControlDesigner () { throw new NotImplementedException (); diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransactionMessageProperty.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransactionMessageProperty.cs index 7fc83b92bae6..37d4688d6f83 100644 --- a/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransactionMessageProperty.cs +++ b/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TransactionMessageProperty.cs @@ -36,7 +36,7 @@ namespace System.ServiceModel.Channels { - internal class TransactionMessageProperty + public class TransactionMessageProperty { Transaction tx; Message msg; From c622195cdd0bda63029c4153ca0b1c886fc03503 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 20 Apr 2018 15:22:34 -0400 Subject: [PATCH 204/582] Remove android static libraries --- external/buildscripts/build.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/buildscripts/build.pl b/external/buildscripts/build.pl index c1163f0e19e9..3ee2bc709cdb 100644 --- a/external/buildscripts/build.pl +++ b/external/buildscripts/build.pl @@ -1609,7 +1609,7 @@ } elsif ($android) { - for my $file ('libmonosgen-2.0.so','libmonosgen-2.0.a','libmonobdwgc-2.0.so','libmonobdwgc-2.0.a') + for my $file ('libmonosgen-2.0.so','libmonobdwgc-2.0.so') { print ">>> Copying $file\n"; system("cp", "$monoroot/mono/mini/.libs/$file","$embedDirArchDestination/$file") eq 0 or die ("failed copying $file\n"); From 5c80d51ba85d5e1ab88e2e23524b19154169b7c4 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 20 Apr 2018 15:29:01 -0400 Subject: [PATCH 205/582] Remove Tizen support from build --- external/buildscripts/build_runtime_tizen.pl | 18 ------------------ external/buildscripts/build_runtime_tizen.sh | 10 ++++++++-- 2 files changed, 8 insertions(+), 20 deletions(-) delete mode 100644 external/buildscripts/build_runtime_tizen.pl diff --git a/external/buildscripts/build_runtime_tizen.pl b/external/buildscripts/build_runtime_tizen.pl deleted file mode 100644 index 039e26c8ef9f..000000000000 --- a/external/buildscripts/build_runtime_tizen.pl +++ /dev/null @@ -1,18 +0,0 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -my $clean = 1; - -GetOptions( - "clean=i"=>\$clean, -) or die ("illegal cmdline options"); - -system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--tizen=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for tizen\n"); -system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--tizen=1", "--tizenemulator=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for tizen emulator\n"); diff --git a/external/buildscripts/build_runtime_tizen.sh b/external/buildscripts/build_runtime_tizen.sh index b7a4b24bc699..f7bc324230ea 100644 --- a/external/buildscripts/build_runtime_tizen.sh +++ b/external/buildscripts/build_runtime_tizen.sh @@ -3,6 +3,12 @@ # The build configs are looking for this file rather than the perl script. # easier to add this -BASEDIR=$(dirname $0) +# Note : Tizen support is removed. Script is here to make the katana build pass so that the mono build artifact is created +if [ -d builds ]; then + echo "Skip making builds directory. Already exists" +else + mkdir builds +fi + +touch builds/dummy_tizen.txt -perl "$BASEDIR/build_runtime_tizen.pl" "$@" From 62189df9a66343b0ab383cf1f23b384552124be7 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 20 Apr 2018 17:00:32 -0400 Subject: [PATCH 206/582] Fix copying of mono executable and library after osx 32-bit removal --- external/buildscripts/build.pl | 2 +- external/buildscripts/build_all_osx.pl | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/external/buildscripts/build.pl b/external/buildscripts/build.pl index c1163f0e19e9..59187877a9f2 100644 --- a/external/buildscripts/build.pl +++ b/external/buildscripts/build.pl @@ -1564,7 +1564,7 @@ elsif($^O eq 'darwin') { $embedDirArchDestination = "$embedDirRoot/osx"; - $distDirArchBin = "$distdir/bin-osx"; + $distDirArchBin = "$distdir/bin"; $versionsOutputFile = "$buildsroot/versions-osx.txt"; } else diff --git a/external/buildscripts/build_all_osx.pl b/external/buildscripts/build_all_osx.pl index af345d38a51f..03fa7ecd3db0 100644 --- a/external/buildscripts/build_all_osx.pl +++ b/external/buildscripts/build_all_osx.pl @@ -66,11 +66,13 @@ if ($artifact) { - print(">>> Creating universal binaries\n"); - # Merge stuff in the embedruntimes directory - my $embedDirRoot = "$buildsroot/embedruntimes"; - my $embedDirDestination = "$embedDirRoot/osx"; - + print(">>> Copying libMonoPosixHelper.dylib to lib directory\n"); + my $libDir = "$buildsroot/monodistribution/lib"; + if (!(-d $libDir)) + { + system("mkdir -p $libDir"); + } + system("cp","$buildsroot/embedruntimes/osx/libMonoPosixHelper.dylib", "$libDir/") } From 1de54af56bf1a531267058f085144a963ff26e62 Mon Sep 17 00:00:00 2001 From: Lukasz Paczkowski Date: Mon, 23 Apr 2018 14:48:25 +0200 Subject: [PATCH 207/582] Refactor iteration over all MonoImage's by collecting them all in hash table and iterating over the hash table. --- mono/metadata/unity-memory-info.c | 189 ++++++++++++++---------------- 1 file changed, 85 insertions(+), 104 deletions(-) diff --git a/mono/metadata/unity-memory-info.c b/mono/metadata/unity-memory-info.c index 3095530e065e..3edf59d4bd63 100644 --- a/mono/metadata/unity-memory-info.c +++ b/mono/metadata/unity-memory-info.c @@ -20,32 +20,6 @@ typedef struct CollectMetadataContext MonoMetadataSnapshot* metadata; } CollectMetadataContext; -typedef struct AllDomainAssembliesForeachData -{ - MonoDomainAssemblyFunc func; - void* user_data; - -} AllDomainAssembliesForeachData; - -static void AllDomainAssembliesForeachHelper(MonoDomain* domain, void* user_data) -{ - AllDomainAssembliesForeachData *data = (AllDomainAssembliesForeachData*)user_data; - - mono_domain_assembly_foreach(domain, data->func, data->user_data); -} - -static void AllDomainAssembliesForeach(MonoDomainAssemblyFunc func, void* user_data) -{ - AllDomainAssembliesForeachData data; - - data.func = func; - data.user_data = user_data; - - AllDomainAssembliesForeachHelper(mono_domain_get(), &data); - -// mono_domain_foreach(AllDomainAssembliesForeachHelper, &data); -} - static void ContextInsertClass(CollectMetadataContext* context, MonoClass* klass) { if (klass->inited && g_hash_table_lookup(context->allTypes, klass) == NULL) @@ -82,29 +56,11 @@ static void CollectGenericClass(gpointer value, gpointer user_data) ContextInsertClass(context, genericClass->cached_class); } -MonoClass* MonoLookupDynamiClass(MonoImage *image, guint32 token, MonoGenericContext *context, MonoError *error) -{ - MonoClass *handle_class; - error_init(error); - return (MonoClass*)mono_reflection_lookup_dynamic_token(image, token, FALSE, &handle_class, context, error); -} - -static void CollectImageMetaData(MonoImage* image, CollectMetadataContext* context) +static void CollectImageMetaData(MonoImage* image, gpointer value, CollectMetadataContext* context) { int i; MonoTableInfo *tdef = &image->tables[MONO_TABLE_TYPEDEF]; - if (image->module_count > 0) - { - for (i = 0; i < image->module_count; ++i) - { - MonoImage* moduleImage = image->modules[i]; - - if(moduleImage) - CollectImageMetaData(moduleImage, context); - } - } - if (image->dynamic) { MonoDynamicImage* dynamicImage = (MonoDynamicImage*)image; @@ -144,14 +100,6 @@ static void CollectImageMetaData(MonoImage* image, CollectMetadataContext* conte g_hash_table_foreach(image->ptr_cache, CollectHashMapClass, context); } -static void CollectAssemblyMetaData(MonoAssembly *assembly, void *user_data) -{ - MonoImage* image = mono_assembly_get_image(assembly); - CollectMetadataContext* context = (CollectMetadataContext*)user_data; - - CollectImageMetaData(image, context); -} - static int FindClassIndex(GHashTable* hashTable, MonoClass* klass) { gpointer value = g_hash_table_lookup(hashTable, klass); @@ -234,7 +182,7 @@ static void AddMetadataType(gpointer key, gpointer value, gpointer user_data) type->size = (klass->valuetype) != 0 ? (mono_class_instance_size(klass) - sizeof(MonoObject)) : mono_class_instance_size(klass); } -static void CollectMetadata(MonoMetadataSnapshot* metadata) +static void CollectMetadata(MonoMetadataSnapshot* metadata, GHashTable* monoImages) { CollectMetadataContext context; @@ -242,7 +190,7 @@ static void CollectMetadata(MonoMetadataSnapshot* metadata) context.currentIndex = 0; context.metadata = metadata; - AllDomainAssembliesForeach(CollectAssemblyMetaData, &context); + g_hash_table_foreach(monoImages, (GHFunc)CollectImageMetaData, &context); mono_metadata_generic_class_foreach(CollectGenericClass, &context); @@ -310,22 +258,17 @@ static void CopyMemPoolChunk(void* chunkStart, void* chunkEnd, void* context) CopyHeapSection(context, chunkStart, chunkEnd); } -static void AddImageMemoryPoolChunkCount(MonoAssembly *assembly, MonoManagedHeap* heap) -{ - heap->sectionCount += MonoMemPoolNumChunks(assembly->image->mempool); -} - -static void IncrementCountForImageMemPoolNumChunks(MonoAssembly *assembly, void *user_data) +static void IncrementCountForImageMemPoolNumChunks(MonoImage *image, gpointer* value, void *user_data) { int* count = (int*)user_data; - (*count) += MonoMemPoolNumChunks(assembly->image->mempool); + (*count) += MonoMemPoolNumChunks(image->mempool); } -static int MonoImagesMemPoolNumChunks() +static int MonoImagesMemPoolNumChunks(GHashTable* monoImages) { int count = 0; - AllDomainAssembliesForeach((GFunc)IncrementCountForImageMemPoolNumChunks, &count); + g_hash_table_foreach(monoImages, (GHFunc)IncrementCountForImageMemPoolNumChunks, &count); return count; } @@ -334,9 +277,8 @@ static void AllocateMemoryForMemPool(MonoMemPool* pool, void *user_data) mono_mempool_foreach_block(pool, AllocateMemoryForMemPoolChunk, user_data); } -static void AllocateMemoryForImageMemPool(MonoAssembly *assembly, void *user_data) +static void AllocateMemoryForImageMemPool(MonoImage *image, gpointer value, void *user_data) { - MonoImage* image = assembly->image; mono_image_lock(image); AllocateMemoryForMemPool(image->mempool, user_data); mono_image_unlock(image); @@ -347,40 +289,23 @@ static void CopyMemPool(MonoMemPool *pool, SectionIterationContext *context) mono_mempool_foreach_block(pool, CopyMemPoolChunk, context); } -static void CopyImageMemPool(MonoAssembly *assembly, SectionIterationContext *context) +static void CopyImageMemPool(MonoImage *image, gpointer value, SectionIterationContext *context) { - MonoImage* image = assembly->image; - mono_image_lock(image); CopyMemPool(image->mempool, context); mono_image_unlock(image); } -static void MonoImagesCountCallback(MonoAssembly *assembly, void *user_data) -{ - int* count = (int*)user_data; - (*count)++; -} - -static int MonoImagesCount() +static void AllocateMemoryForImageClassCache(MonoImage *image, gpointer *value, void *user_data) { - int count = 0; - AllDomainAssembliesForeach((GFunc)MonoImagesCountCallback, &count); - return count; -} - -static void AllocateMemoryForImageClassCache(MonoAssembly *assembly, void *user_data) -{ - MonoImage* image = assembly->image; mono_image_lock(image); AllocateMemoryForSection(user_data, image->class_cache.table, ((uint8_t*)image->class_cache.table) + image->class_cache.size); mono_image_unlock(image); } -static void CopyImageClassCache(MonoAssembly *assembly, SectionIterationContext *context) +static void CopyImageClassCache(MonoImage *image, gpointer value, SectionIterationContext *context) { - MonoImage* image = assembly->image; mono_image_lock(image); CopyHeapSection(context, image->class_cache.table, ((uint8_t*)image->class_cache.table) + image->class_cache.size); @@ -411,9 +336,19 @@ static void CopyImageSetMemPool(MonoImageSet* imageSet, void *user_data) CopyMemPool(imageSet->mempool, user_data); } -static void* CaptureHeapInfo(void* monoManagedHeap) +typedef struct +{ + MonoManagedHeap* heap; + GHashTable* monoImages; + +} CaptureHeapInfoData; + +static void* CaptureHeapInfo(void* user) { - MonoManagedHeap* heap = (MonoManagedHeap*)monoManagedHeap; + CaptureHeapInfoData* data = (CaptureHeapInfoData*)user; + MonoManagedHeap* heap = data->heap; + GHashTable* monoImages = data->monoImages; + MonoDomain* domain = mono_domain_get(); MonoDomain* rootDomain = mono_get_root_domain(); SectionIterationContext iterationContext; @@ -424,9 +359,9 @@ static void* CaptureHeapInfo(void* monoManagedHeap) heap->sectionCount += MonoMemPoolNumChunks(rootDomain->mp); heap->sectionCount += MonoMemPoolNumChunks(domain->mp); // Increment count for each image mem pool chunk - heap->sectionCount += MonoImagesMemPoolNumChunks(); + heap->sectionCount += MonoImagesMemPoolNumChunks(monoImages); // Increment count for each image->class_cache hash table. - heap->sectionCount += MonoImagesCount(); + heap->sectionCount += g_hash_table_size(monoImages); // Increment count for each image set mem pool chunk heap->sectionCount += MonoImageSetsMemPoolNumChunks(); @@ -444,9 +379,9 @@ static void* CaptureHeapInfo(void* monoManagedHeap) mono_mempool_foreach_block(domain->mp, AllocateMemoryForMemPoolChunk, &iterationContext); mono_domain_unlock(domain); // Allocate memory for each image mem pool chunk - AllDomainAssembliesForeach((GFunc)AllocateMemoryForImageMemPool, &iterationContext); + g_hash_table_foreach(monoImages, (GHFunc)AllocateMemoryForImageMemPool, &iterationContext); // Allocate memory for each image->class_cache hash table. - AllDomainAssembliesForeach((GFunc)AllocateMemoryForImageClassCache, &iterationContext); + g_hash_table_foreach(monoImages, (GHFunc)AllocateMemoryForImageClassCache, &iterationContext); // Allocate memory for each image->class_cache hash table. mono_metadata_image_set_foreach((GFunc)AllocateMemoryForImageSetMemPool, &iterationContext); @@ -482,7 +417,7 @@ static void VerifyHeapSectionIsStillValid(void* context, void* sectionStart, voi iterationContext->currentSection++; } -static gboolean MonoManagedHeapStillValid(MonoManagedHeap* heap) +static gboolean MonoManagedHeapStillValid(MonoManagedHeap* heap, GHashTable* monoImages) { MonoDomain* rootDomain = mono_get_root_domain(); MonoDomain* domain = mono_domain_get(); @@ -493,8 +428,8 @@ static gboolean MonoManagedHeapStillValid(MonoManagedHeap* heap) currentSectionCount = GC_get_heap_section_count(); currentSectionCount += MonoMemPoolNumChunks(rootDomain->mp); currentSectionCount += MonoMemPoolNumChunks(domain->mp); - currentSectionCount += MonoImagesMemPoolNumChunks(); - currentSectionCount += MonoImagesCount(); // image->class_cache hash table. + currentSectionCount += MonoImagesMemPoolNumChunks(monoImages); + currentSectionCount += g_hash_table_size(monoImages); // image->class_cache hash table. currentSectionCount += MonoImageSetsMemPoolNumChunks(); if (heap->sectionCount != currentSectionCount) @@ -519,18 +454,23 @@ static gboolean MonoManagedHeapStillValid(MonoManagedHeap* heap) // allocated for their copies. // 5) Start the world again. -static void CaptureManagedHeap(MonoManagedHeap* heap) +static void CaptureManagedHeap(MonoManagedHeap* heap, GHashTable* monoImages) { MonoDomain* rootDomain = mono_get_root_domain(); MonoDomain* domain = mono_domain_get(); SectionIterationContext iterationContext; + CaptureHeapInfoData data; + + data.heap = heap; + data.monoImages = monoImages; + while (TRUE) { - GC_call_with_alloc_lock(CaptureHeapInfo, heap); + GC_call_with_alloc_lock(CaptureHeapInfo, &data); GC_stop_world_external(); - if (MonoManagedHeapStillValid(heap)) + if (MonoManagedHeapStillValid(heap, monoImages)) break; GC_start_world_external(); @@ -543,8 +483,8 @@ static void CaptureManagedHeap(MonoManagedHeap* heap) GC_foreach_heap_section(&iterationContext, CopyHeapSection); mono_mempool_foreach_block(rootDomain->mp, CopyMemPoolChunk, &iterationContext); mono_mempool_foreach_block(domain->mp, CopyMemPoolChunk, &iterationContext); - AllDomainAssembliesForeach((GFunc)CopyImageMemPool, &iterationContext); - AllDomainAssembliesForeach((GFunc)CopyImageClassCache, &iterationContext); + g_hash_table_foreach(monoImages, (GHFunc)CopyImageMemPool, &iterationContext); + g_hash_table_foreach(monoImages, (GHFunc)CopyImageClassCache, &iterationContext); mono_metadata_image_set_foreach((GFunc)CopyImageSetMemPool, &iterationContext); GC_start_world_external(); @@ -605,14 +545,24 @@ static gboolean ManagedHeapContainsAddress(MonoManagedHeap* heap, uint64_t addre return FALSE; } -static void VerifySnapshot(MonoManagedMemorySnapshot* snapshot) +static void VerifySnapshot(MonoManagedMemorySnapshot* snapshot, GHashTable* monoImages) { uint32_t i; FILE* file; + GHashTableIter iter; + gpointer key; MonoMetadataSnapshot* meta = &snapshot->metadata; file = fopen("MonoMemorySnapshotLog.txt", "w"); + g_hash_table_iter_init(&iter, monoImages); + + while (g_hash_table_iter_next(&iter, &key, NULL)) + { + MonoImage* image = (MonoImage*)key; + fprintf(file, "MonoImage [0x%016llX] dynamic: %i name: '%s'\n", (void*)image, image->dynamic, image->name); + } + /* Verify that we have collected memory sections for all types */ for (i = 0; i < meta->typeCount; ++i) { @@ -627,20 +577,51 @@ static void VerifySnapshot(MonoManagedMemorySnapshot* snapshot) fclose(file); } +static void CollectMonoImage(MonoImage* image, GHashTable* monoImages) +{ + if (g_hash_table_lookup(monoImages, image) == NULL) + g_hash_table_insert(monoImages, image, image); + + if (image->module_count > 0) + { + int i; + + for (i = 0; i < image->module_count; ++i) + { + MonoImage* moduleImage = image->modules[i]; + + if (moduleImage) + CollectMonoImage(moduleImage, monoImages); + } + } +} + +static void CollectMonoImageFromAssembly(MonoAssembly *assembly, void *user_data) +{ + GHashTable* monoImages = (GHashTable*)user_data; + CollectMonoImage(assembly->image, monoImages); +} + MonoManagedMemorySnapshot* mono_unity_capture_memory_snapshot() { MonoManagedMemorySnapshot* snapshot; snapshot = g_new0(MonoManagedMemorySnapshot, 1); - CollectMetadata(&snapshot->metadata); - CaptureManagedHeap(&snapshot->heap); + GHashTable* monoImages = g_hash_table_new(NULL, NULL); + + mono_domain_assembly_foreach(mono_domain_get(), CollectMonoImageFromAssembly, monoImages); + + CollectMetadata(&snapshot->metadata, monoImages); + CaptureManagedHeap(&snapshot->heap, monoImages); CaptureGCHandleTargets(&snapshot->gcHandles); FillRuntimeInformation(&snapshot->runtimeInformation); #if _DEBUG - VerifySnapshot(snapshot); + VerifySnapshot(snapshot, monoImages); #endif + g_hash_table_destroy(monoImages); + return snapshot; } From 9f3d05192bdf5976d236584950616dc45bf9cbfe Mon Sep 17 00:00:00 2001 From: Lukasz Paczkowski Date: Mon, 23 Apr 2018 16:17:21 +0200 Subject: [PATCH 208/582] Use iterator to get keys from hash table, does not allocate. --- mono/metadata/unity-memory-info.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mono/metadata/unity-memory-info.c b/mono/metadata/unity-memory-info.c index 3edf59d4bd63..b9650a69cf3a 100644 --- a/mono/metadata/unity-memory-info.c +++ b/mono/metadata/unity-memory-info.c @@ -63,13 +63,15 @@ static void CollectImageMetaData(MonoImage* image, gpointer value, CollectMetada if (image->dynamic) { + GHashTableIter iter; + gpointer key; MonoDynamicImage* dynamicImage = (MonoDynamicImage*)image; - GList* types = g_hash_table_get_keys(dynamicImage->typeref); - GList* type; - for (type = types; type != NULL; type = type->next) + g_hash_table_iter_init(&iter, dynamicImage->typeref); + + while (g_hash_table_iter_next(&iter, &key, NULL)) { - MonoType* monoType = (MonoType*)type->data; + MonoType* monoType = (MonoType*)key; MonoClass* klass = mono_type_get_class(monoType); if (klass) From 757b011c68268997f5f1108b0f09a86b904ddb01 Mon Sep 17 00:00:00 2001 From: andreasr Date: Tue, 24 Apr 2018 14:43:35 +0200 Subject: [PATCH 209/582] Fixed large buffers not being completely sent/received by SslStream/UnityTls We are expected to return wantMore==true not only when we're blocking but also when we read/write only part of the data. --- .../System/Mono.UnityTls/UnityTlsContext.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index f54c82cac81a..a9b21ce79b54 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -172,7 +172,7 @@ public override void Flush () public override (int ret, bool wantMore) Read (byte[] buffer, int offset, int count) { - bool wouldBlock = false; + bool wantMore = false; int numBytesRead = 0; lastException = null; @@ -183,19 +183,19 @@ public override (int ret, bool wantMore) Read (byte[] buffer, int offset, int co if (lastException != null) throw lastException; - if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) - wouldBlock = true; + if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK || numBytesRead < count) // In contrast to some other APIs (like Apple security) WOULD_BLOCK is not set if we did a partial read + wantMore = true; else if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_STREAM_CLOSED) return (0, false); // According to Apple and Btls implementation this is how we should handle gracefully closed connections. else Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to read data from TLS context"); - return (numBytesRead, wouldBlock); + return (numBytesRead, wantMore); } public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int count) { - bool wouldBlock = false; + bool wantMore = false; int numBytesWritten = 0; lastException = null; @@ -206,14 +206,14 @@ public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int c if (lastException != null) throw lastException; - if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK) - wouldBlock = true; + if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK || numBytesWritten < count) // In contrast to some other APIs (like Apple security) WOULD_BLOCK is not set if we did a partial write + wantMore = true; else if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_STREAM_CLOSED) return (0, false); // According to Apple and Btls implementation this is how we should handle gracefully closed connections. else Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to write data to TLS context"); - return (numBytesWritten, wouldBlock); + return (numBytesWritten, wantMore); } public override void Shutdown () From 134638a3edaaeaae576e60590c3739c1035830e5 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Mon, 30 Apr 2018 10:20:18 -0400 Subject: [PATCH 210/582] Revert "Fix copying of mono executable and library after osx 32-bit removal" This reverts commit 62189df9a66343b0ab383cf1f23b384552124be7. --- external/buildscripts/build.pl | 2 +- external/buildscripts/build_all_osx.pl | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/external/buildscripts/build.pl b/external/buildscripts/build.pl index 02aa34f4bc0b..3ee2bc709cdb 100644 --- a/external/buildscripts/build.pl +++ b/external/buildscripts/build.pl @@ -1564,7 +1564,7 @@ elsif($^O eq 'darwin') { $embedDirArchDestination = "$embedDirRoot/osx"; - $distDirArchBin = "$distdir/bin"; + $distDirArchBin = "$distdir/bin-osx"; $versionsOutputFile = "$buildsroot/versions-osx.txt"; } else diff --git a/external/buildscripts/build_all_osx.pl b/external/buildscripts/build_all_osx.pl index 03fa7ecd3db0..af345d38a51f 100644 --- a/external/buildscripts/build_all_osx.pl +++ b/external/buildscripts/build_all_osx.pl @@ -66,13 +66,11 @@ if ($artifact) { - print(">>> Copying libMonoPosixHelper.dylib to lib directory\n"); + print(">>> Creating universal binaries\n"); + # Merge stuff in the embedruntimes directory + my $embedDirRoot = "$buildsroot/embedruntimes"; + my $embedDirDestination = "$embedDirRoot/osx"; + - my $libDir = "$buildsroot/monodistribution/lib"; - if (!(-d $libDir)) - { - system("mkdir -p $libDir"); - } - system("cp","$buildsroot/embedruntimes/osx/libMonoPosixHelper.dylib", "$libDir/") } From ab25ce87e499aea60b5ffde3b2a78adda8a004db Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Mon, 30 Apr 2018 10:20:55 -0400 Subject: [PATCH 211/582] Revert "Remove osx x86 builds." This reverts commit 2b4caf8bba4b4acf07290f4421ee2fac52853143. --- external/buildscripts/build.pl | 7 +- external/buildscripts/build_all_osx.pl | 89 ++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 3 deletions(-) diff --git a/external/buildscripts/build.pl b/external/buildscripts/build.pl index 3ee2bc709cdb..504cf1cb79e7 100644 --- a/external/buildscripts/build.pl +++ b/external/buildscripts/build.pl @@ -1563,9 +1563,10 @@ } elsif($^O eq 'darwin') { - $embedDirArchDestination = "$embedDirRoot/osx"; - $distDirArchBin = "$distdir/bin-osx"; - $versionsOutputFile = "$buildsroot/versions-osx.txt"; + # Note these tmp directories will get merged into a single 'osx' directory later by a parent script + $embedDirArchDestination = "$embedDirRoot/osx-tmp-$monoHostArch"; + $distDirArchBin = "$distdir/bin-osx-tmp-$monoHostArch"; + $versionsOutputFile = $arch32 ? "$buildsroot/versions-osx32.txt" : "$buildsroot/versions-osx64.txt"; } else { diff --git a/external/buildscripts/build_all_osx.pl b/external/buildscripts/build_all_osx.pl index af345d38a51f..0f0eb42d6aa3 100644 --- a/external/buildscripts/build_all_osx.pl +++ b/external/buildscripts/build_all_osx.pl @@ -51,6 +51,11 @@ 'buildusandboo=i'=>\$buildUsAndBoo, ); +my $monoArch32Target = "i386"; + +print(">>> Building $monoArch32Target\n"); +system("perl", "$buildscriptsdir/build.pl", "--arch32=1", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ("failing building $monoArch32Target"); + if ($artifactsCommon) { push @passAlongArgs, "--artifactscommon=1"; @@ -70,7 +75,91 @@ # Merge stuff in the embedruntimes directory my $embedDirRoot = "$buildsroot/embedruntimes"; my $embedDirDestination = "$embedDirRoot/osx"; + my $embedDirSource32 = "$embedDirRoot/osx-tmp-$monoArch32Target"; + my $embedDirSource64 = "$embedDirRoot/osx-tmp-x86_64"; + + system("mkdir -p $embedDirDestination"); + + if (!(-d $embedDirSource32)) + { + die("Expected source directory not found : $embedDirSource32\n"); + } + + if (!(-d $embedDirSource64)) + { + die("Expected source directory not found : $embedDirSource64\n"); + } + + # Create universal binaries + for my $file ('libmonobdwgc-2.0.dylib','libmonosgen-2.0.dylib','libMonoPosixHelper.dylib') + { + print(">>> lipo $embedDirSource32/$file $embedDirSource64/$file -create -output $embedDirDestination/$file\n\n"); + system ('lipo', "$embedDirSource32/$file", "$embedDirSource64/$file", '-create', '-output', "$embedDirDestination/$file"); + } + + if (not $buildMachine) + { + print(">>> Doing non-build machine stuff...\n"); + for my $file ('libmonobdwgc-2.0.dylib','libmonosgen-2.0.dylib','libMonoPosixHelper.dylib') + { + print(">>> Removing $embedDirDestination/$file.dSYM\n"); + rmtree ("$embedDirDestination/$file.dSYM"); + print(">>> 'dsymutil $embedDirDestination/$file\n"); + system ('dsymutil', "$embedDirDestination/$file") eq 0 or warn ("Failed creating $embedDirDestination/$file.dSYM"); + } + + print(">>> Done with non-build machine stuff\n"); + } + + # Merge stuff in the monodistribution directory + my $distDirRoot = "$buildsroot/monodistribution"; + my $distDirDestinationBin = "$buildsroot/monodistribution/bin"; + my $distDirDestinationLib = "$buildsroot/monodistribution/lib"; + my $distDirSourceBin32 = "$distDirRoot/bin-osx-tmp-$monoArch32Target"; + my $distDirSourceBin64 = "$distDirRoot/bin-osx-tmp-x86_64"; + # Should always exist because build_all would have put stuff in it, but in some situations + # depending on the options it may not. So create it if it does not exist + if (!(-d $distDirDestinationBin)) + { + system("mkdir -p $distDirDestinationBin"); + } + + if (!(-d $distDirDestinationLib)) + { + system("mkdir -p $distDirDestinationLib"); + } + if (!(-d $distDirSourceBin32)) + { + die("Expected source directory not found : $distDirSourceBin32\n"); + } + + if (!(-d $distDirSourceBin64)) + { + die("Expected source directory not found : $distDirSourceBin64\n"); + } + for my $file ('mono','pedump') + { + print(">>> lipo $distDirSourceBin32/$file $distDirSourceBin64/$file -create -output $distDirDestinationBin/$file\n\n"); + system ('lipo', "$distDirSourceBin32/$file", "$distDirSourceBin64/$file", '-create', '-output', "$distDirDestinationBin/$file"); + } + + #Create universal binaries for stuff is in the embed dir but will end up in the dist dir + for my $file ('libMonoPosixHelper.dylib') + { + print(">>> lipo $embedDirSource32/$file $embedDirSource64/$file -create -output $distDirDestinationLib/$file\n\n"); + system ('lipo', "$embedDirSource32/$file", "$embedDirSource64/$file", '-create', '-output', "$distDirDestinationLib/$file"); + } + + if ($buildMachine) + { + print(">>> Clean up temporary arch specific build directories\n"); + + rmtree("$distDirSourceBin32"); + rmtree("$distDirSourceBin64"); + rmtree("$embedDirSource32"); + rmtree("$embedDirSource64"); + } } From 27083f964a7efe89debaf0a503226765aacc9c59 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 20 Apr 2018 17:28:53 -0400 Subject: [PATCH 212/582] Use 7z in addition to zip --- external/buildscripts/collect_allbuilds.pl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/external/buildscripts/collect_allbuilds.pl b/external/buildscripts/collect_allbuilds.pl index 71ba0b01e2de..d6316e937504 100644 --- a/external/buildscripts/collect_allbuilds.pl +++ b/external/buildscripts/collect_allbuilds.pl @@ -1,8 +1,14 @@ use lib ('external/buildscripts/perl_lib'); +use Cwd 'abs_path'; +use File::Basename; use File::Copy::Recursive qw(dircopy rmove); use File::Path; use Tools qw(InstallNameTool); + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); + my $path = "incomingbuilds/"; rmtree("collectedbuilds"); @@ -44,3 +50,17 @@ close(MYFILE); system("zip -r builds.zip *") eq 0 or die("failed zipping up builds"); + +if($^O eq "linux") +{ + system("$monoroot/../../mono-build-deps/build/7z/linux64/7za a builds.7z * -x!builds.zip") eq 0 or die("failed 7z up builds"); +} +elsif($^O eq 'darwin') +{ + system("$monoroot/../../mono-build-deps/build/7z/osx/7za a builds.7z * -x!builds.zip") eq 0 or die("failed 7z up builds"); +} +else +{ + die("Unsupported platform for build collection.") +} + From a49f45c96f2f31c00cfd4b9306978ede43a7ffe4 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 1 May 2018 12:46:06 -0400 Subject: [PATCH 213/582] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 917e18a22345..c4dcd664be53 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ Branches for released Unity versions are of the form unity-\\[-mbe\][- * [unity-trunk (PR to this branch for Mono)](https://github.com/Unity-Technologies/mono/tree/unity-trunk) * [unity-master (PR to this branch for MonoBleedingEdge)](https://github.com/Unity-Technologies/mono/tree/unity-master) +#### 2018.2 +* [unity-2018.2](https://github.com/Unity-Technologies/mono/tree/unity-2018.2) +* [unity-2018.2-mbe](https://github.com/Unity-Technologies/mono/tree/unity-2018.2-mbe) + #### 2018.1 * [unity-2018.1](https://github.com/Unity-Technologies/mono/tree/unity-2018.1) * [unity-2018.1-mbe](https://github.com/Unity-Technologies/mono/tree/unity-2018.1-mbe) From 90f73a5d4e67429db9d1140c98dbaf20eff11ea1 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Wed, 2 May 2018 23:36:39 +0200 Subject: [PATCH 214/582] [mcs] Mimic csc behaviour when attribute value is a typedef and add also assembly reference for it --- mcs/mcs/assembly.cs | 3 ++- mcs/mcs/attribute.cs | 36 ++++++++++++++++++++++++++++-------- mcs/mcs/class.cs | 3 ++- mcs/mcs/field.cs | 5 +++-- mcs/mcs/module.cs | 12 ++++++++++++ 5 files changed, 47 insertions(+), 12 deletions(-) diff --git a/mcs/mcs/assembly.cs b/mcs/mcs/assembly.cs index aa4c54317a23..96e43e70d999 100644 --- a/mcs/mcs/assembly.cs +++ b/mcs/mcs/assembly.cs @@ -554,7 +554,8 @@ public virtual void Emit () if (prop != null) { AttributeEncoder encoder = new AttributeEncoder (); encoder.EncodeNamedPropertyArgument (prop, new BoolLiteral (Compiler.BuiltinTypes, true, Location.Null)); - SetCustomAttribute (pa.Constructor, encoder.ToArray ()); + SetCustomAttribute (pa.Constructor, encoder.ToArray (out var references)); + module.AddAssemblyReferences (references); } } } diff --git a/mcs/mcs/attribute.cs b/mcs/mcs/attribute.cs index 4f520b7487e7..669a9927d0d5 100644 --- a/mcs/mcs/attribute.cs +++ b/mcs/mcs/attribute.cs @@ -1053,8 +1053,10 @@ public void Emit (Dictionary> allEmitted) } byte[] cdata; + List references; if (pos_args == null && named_values == null) { cdata = AttributeEncoder.Empty; + references = null; } else { AttributeEncoder encoder = new AttributeEncoder (); @@ -1127,7 +1129,7 @@ public void Emit (Dictionary> allEmitted) encoder.EncodeEmptyNamedArguments (); } - cdata = encoder.ToArray (); + cdata = encoder.ToArray (out references); } if (!IsConditionallyExcluded (ctor.DeclaringType)) { @@ -1146,6 +1148,8 @@ public void Emit (Dictionary> allEmitted) Error_AttributeEmitError (e.Message); return; } + + context.Module.AddAssemblyReferences (references); } if (!usage_attr.AllowMultiple && allEmitted != null) { @@ -1404,6 +1408,7 @@ public enum EncodedTypeProperties byte[] buffer; int pos; const ushort Version = 1; + List imports; static AttributeEncoder () { @@ -1583,7 +1588,15 @@ public EncodedTypeProperties Encode (TypeSpec type) public void EncodeTypeName (TypeSpec type) { var old_type = type.GetMetaInfo (); - Encode (type.MemberDefinition.IsImported ? old_type.AssemblyQualifiedName : old_type.FullName); + if (type.MemberDefinition.IsImported) { + if (imports == null) + imports = new List (); + + imports.Add (old_type.Assembly); + Encode (old_type.AssemblyQualifiedName); + } else { + Encode (old_type.FullName); + } } public void EncodeTypeName (TypeContainer type) @@ -1664,8 +1677,10 @@ void WriteCompressedValue (int value) Encode (value); } - public byte[] ToArray () + public byte[] ToArray (out List assemblyReferences) { + assemblyReferences = imports; + byte[] buf = new byte[pos]; Array.Copy (buffer, buf, pos); return buf; @@ -1977,7 +1992,8 @@ public void EmitAttribute (FieldBuilder builder, System.Diagnostics.DebuggerBrow encoder.Encode ((int) state); encoder.EncodeEmptyNamedArguments (); - builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ()); + builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray (out var references)); + module.AddAssemblyReferences (references); } } @@ -2011,7 +2027,8 @@ public void EmitAttribute (AssemblyBuilder builder, System.Diagnostics.Debuggabl encoder.Encode ((int) modes); encoder.EncodeEmptyNamedArguments (); - builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ()); + builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray (out var references)); + module.AddAssemblyReferences (references); } } @@ -2037,7 +2054,8 @@ public void EmitAttribute (ParameterBuilder builder, decimal value, Location loc encoder.Encode ((uint) bits[0]); encoder.EncodeEmptyNamedArguments (); - builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ()); + builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray (out var references)); + module.AddAssemblyReferences (references); } public void EmitAttribute (FieldBuilder builder, decimal value, Location loc) @@ -2055,7 +2073,8 @@ public void EmitAttribute (FieldBuilder builder, decimal value, Location loc) encoder.Encode ((uint) bits[0]); encoder.EncodeEmptyNamedArguments (); - builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ()); + builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray (out var references)); + module.AddAssemblyReferences (references); } } @@ -2079,7 +2098,8 @@ public void EmitAttribute (MethodBuilder builder, StateMachine type) encoder.EncodeTypeName (type); encoder.EncodeEmptyNamedArguments (); - builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ()); + builder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray (out var references)); + module.AddAssemblyReferences (references); } } diff --git a/mcs/mcs/class.cs b/mcs/mcs/class.cs index da3ec32d6fb0..a2ef29f206cc 100644 --- a/mcs/mcs/class.cs +++ b/mcs/mcs/class.cs @@ -2105,7 +2105,8 @@ void EmitIndexerName () encoder.Encode (GetAttributeDefaultMember ()); encoder.EncodeEmptyNamedArguments (); - TypeBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ()); + TypeBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray (out var references)); + Module.AddAssemblyReferences (references); } public override void VerifyMembers () diff --git a/mcs/mcs/field.cs b/mcs/mcs/field.cs index 86bb028defcb..8c6673281436 100644 --- a/mcs/mcs/field.cs +++ b/mcs/mcs/field.cs @@ -542,7 +542,7 @@ void EmitFieldSize (int buffer_size) } ); - fixed_buffer_type.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ()); + fixed_buffer_type.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray (out _)); #endif // // Don't emit FixedBufferAttribute attribute for private types @@ -559,7 +559,8 @@ void EmitFieldSize (int buffer_size) encoder.Encode (buffer_size); encoder.EncodeEmptyNamedArguments (); - FieldBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray ()); + FieldBuilder.SetCustomAttribute ((ConstructorInfo) ctor.GetMetaInfo (), encoder.ToArray (out var references)); + Module.AddAssemblyReferences (references); } } diff --git a/mcs/mcs/module.cs b/mcs/mcs/module.cs index 00afac6c6042..f990325e137f 100644 --- a/mcs/mcs/module.cs +++ b/mcs/mcs/module.cs @@ -472,6 +472,18 @@ public void AddAttribute (Attribute attr, IMemberContext context) attributes.AddAttribute (attr); } + public void AddAssemblyReferences (List names) + { + if (names == null) + return; + +#if STATIC + foreach (var name in names) { + Builder.__GetAssemblyToken (name); + } +#endif + } + public override void AddTypeContainer (TypeContainer tc) { AddTypeContainerMember (tc); From e76a72befb5d8f90fb24904f348658a0dd33d8de Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Tue, 8 May 2018 14:22:57 -0400 Subject: [PATCH 215/582] add MONO_API to fix frame lookup --- mono/metadata/oop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mono/metadata/oop.c b/mono/metadata/oop.c index 9d8251ed37ff..f58fa1389851 100644 --- a/mono/metadata/oop.c +++ b/mono/metadata/oop.c @@ -369,7 +369,7 @@ oop_jit_info_table_find( return NULL; } -int +MONO_API int mono_unity_oop_get_stack_frame_details( const MonoDomain* domain, const void* frameAddress, From 826a9286d146fd7588082abdc081e1b7f1598704 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Tue, 8 May 2018 15:40:22 -0400 Subject: [PATCH 216/582] Two types should be public to match .NET 4.7.1 This change allows the unityaot profile to match .NET 4.7.1 for these two types. --- .../System/net/System/Net/UnicodeDecodingConformance.cs | 2 +- .../System/net/System/Net/UnicodeEncodingConformance.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mcs/class/referencesource/System/net/System/Net/UnicodeDecodingConformance.cs b/mcs/class/referencesource/System/net/System/Net/UnicodeDecodingConformance.cs index 5b4ce4502114..2441d13b6650 100644 --- a/mcs/class/referencesource/System/net/System/Net/UnicodeDecodingConformance.cs +++ b/mcs/class/referencesource/System/net/System/Net/UnicodeDecodingConformance.cs @@ -16,7 +16,7 @@ namespace System.Net.Configuration /// See http://www.w3.org/International/questions/qa-escapes#bytheway for more information /// on how Unicode characters in the SMP are supposed to be encoded in HTML. /// -#if !MOBILE +#if !MOBILE || UNITY_AOT public #endif enum UnicodeDecodingConformance diff --git a/mcs/class/referencesource/System/net/System/Net/UnicodeEncodingConformance.cs b/mcs/class/referencesource/System/net/System/Net/UnicodeEncodingConformance.cs index 7ac444e1a162..670954cca7a6 100644 --- a/mcs/class/referencesource/System/net/System/Net/UnicodeEncodingConformance.cs +++ b/mcs/class/referencesource/System/net/System/Net/UnicodeEncodingConformance.cs @@ -16,7 +16,7 @@ namespace System.Net.Configuration /// See http://www.w3.org/International/questions/qa-escapes#bytheway for more information /// on how Unicode characters in the SMP are supposed to be encoded in HTML. /// -#if !MOBILE +#if !MOBILE || UNITY_AOT public #endif enum UnicodeEncodingConformance From 0854d9b0182595f22e944e21943ddecf4ad4823d Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Wed, 9 May 2018 11:46:07 -0400 Subject: [PATCH 217/582] Make ProperInfo.GetValue AOt-friendly On AOT platforms, the GetValue method won't work with the normal implementation. To make this work, fall back to the slower AOT-friendly implementation. Once we have AOT platforms using only the unityaot profile in Unity, we will make this change only for AOT platforms. For now though, let's fix it everywhere. These changes correct case 1030427 in Unity. --- mcs/class/corlib/System.Reflection/MonoProperty.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mcs/class/corlib/System.Reflection/MonoProperty.cs b/mcs/class/corlib/System.Reflection/MonoProperty.cs index 16f44ec583b4..e9553cfe0eb5 100644 --- a/mcs/class/corlib/System.Reflection/MonoProperty.cs +++ b/mcs/class/corlib/System.Reflection/MonoProperty.cs @@ -378,7 +378,9 @@ public override object GetValue (object obj, object[] index) { if (index == null || index.Length == 0) { /*FIXME we should check if the number of arguments matches the expected one, otherwise the error message will be pretty criptic.*/ -#if !FULL_AOT_RUNTIME +// Once we ship the changes to make il2cpp always use the unityaot profile, we should change +// this define to be UNITY_AOT. for now though, we'll take the AOT-friendly code path in all profiles. +#if !FULL_AOT_RUNTIME && !UNITY if (cached_getter == null) { MethodInfo method = GetGetMethod (true); if (!DeclaringType.IsValueType && !method.ContainsGenericParameters) { //FIXME find a way to build an invoke delegate for value types. From 9a853e998c04aa8a7aba797120fc47ba5a4a2dab Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Fri, 11 May 2018 09:53:29 -0400 Subject: [PATCH 218/582] Use CharUnicodeInfo from corert to fix webgl failure --- mcs/class/corlib/System/Debug.cs | 13 +++++++++++++ mcs/class/corlib/corlib.dll.sources | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 mcs/class/corlib/System/Debug.cs diff --git a/mcs/class/corlib/System/Debug.cs b/mcs/class/corlib/System/Debug.cs new file mode 100644 index 000000000000..aa111394c504 --- /dev/null +++ b/mcs/class/corlib/System/Debug.cs @@ -0,0 +1,13 @@ +//Stubs for Assert used by CharUnicodeInfo pulled in from corert +namespace System.Globalization +{ + public static partial class CharUnicodeInfo + { + internal static class Debug + { + internal static void Assert(bool condition, string message) + { + } + } + } +} diff --git a/mcs/class/corlib/corlib.dll.sources b/mcs/class/corlib/corlib.dll.sources index ec1c6983e422..0e0202aad781 100644 --- a/mcs/class/corlib/corlib.dll.sources +++ b/mcs/class/corlib/corlib.dll.sources @@ -1111,7 +1111,9 @@ ReferenceSources/AppContextDefaultValues.cs ../referencesource/mscorlib/system/globalization/CalendricalCalculationsHelper.cs ../referencesource/mscorlib/system/globalization/calendardata.cs ../referencesource/mscorlib/system/globalization/calendarweekrule.cs -../referencesource/mscorlib/system/globalization/charunicodeinfo.cs +System/Debug.cs +../../../external/corert/src/System.Private.CoreLib/src/System/Globalization/CharUnicodeInfo.cs +../../../external/corert/src/System.Private.CoreLib/src/System/Globalization/CharUnicodeInfoData.cs ../referencesource/mscorlib/system/globalization/chineselunisolarcalendar.cs ../referencesource/mscorlib/system/globalization/compareinfo.cs ../referencesource/mscorlib/system/globalization/culturenotfoundexception.cs From d3260de5ad5d20db25f75a04f02d1a0ff8b94b6e Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Wed, 16 May 2018 09:38:39 -0400 Subject: [PATCH 219/582] Avoid access to /dev/shm on OSX (case 1035654) --- external/buildscripts/build.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/external/buildscripts/build.pl b/external/buildscripts/build.pl index 504cf1cb79e7..4211a77b3069 100644 --- a/external/buildscripts/build.pl +++ b/external/buildscripts/build.pl @@ -1205,6 +1205,7 @@ # Need to define because Apple's SIP gets in the way of us telling mono where to find this push @configureparams, "--with-libgdiplus=$addtoresultsdistdir/lib/libgdiplus.dylib"; + push @configureparams, "--enable-minimal=shared_perfcounters"; print "\n"; print ">>> Setting environment:\n"; From 7208db8ee211a2f104cda31680af0d10662d1d46 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Wed, 16 May 2018 13:52:27 -0400 Subject: [PATCH 220/582] Correct the base types for a new enum types To match the .NET 4.7.1 profile, these enum types should have special base types. --- mcs/class/System.Xaml/System.Xaml.Schema/XamlCollectionKind.cs | 2 +- mcs/class/System.Xaml/System.Xaml/XamlNodeType.cs | 2 +- mcs/class/corlib/System.Runtime.InteropServices/LIBFLAGS.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mcs/class/System.Xaml/System.Xaml.Schema/XamlCollectionKind.cs b/mcs/class/System.Xaml/System.Xaml.Schema/XamlCollectionKind.cs index 3e3253936feb..27fd119253ec 100644 --- a/mcs/class/System.Xaml/System.Xaml.Schema/XamlCollectionKind.cs +++ b/mcs/class/System.Xaml/System.Xaml.Schema/XamlCollectionKind.cs @@ -25,7 +25,7 @@ namespace System.Xaml.Schema { - public enum XamlCollectionKind + public enum XamlCollectionKind : byte { None, Collection, diff --git a/mcs/class/System.Xaml/System.Xaml/XamlNodeType.cs b/mcs/class/System.Xaml/System.Xaml/XamlNodeType.cs index b71fcdd23bb9..eb3400f37005 100644 --- a/mcs/class/System.Xaml/System.Xaml/XamlNodeType.cs +++ b/mcs/class/System.Xaml/System.Xaml/XamlNodeType.cs @@ -28,7 +28,7 @@ namespace System.Xaml { - public enum XamlNodeType + public enum XamlNodeType : byte { None, StartObject, diff --git a/mcs/class/corlib/System.Runtime.InteropServices/LIBFLAGS.cs b/mcs/class/corlib/System.Runtime.InteropServices/LIBFLAGS.cs index f58f6a608dc8..9dccb0a55377 100644 --- a/mcs/class/corlib/System.Runtime.InteropServices/LIBFLAGS.cs +++ b/mcs/class/corlib/System.Runtime.InteropServices/LIBFLAGS.cs @@ -34,7 +34,7 @@ namespace System.Runtime.InteropServices { [Obsolete] [Flags, Serializable] - public enum LIBFLAGS + public enum LIBFLAGS : short { LIBFLAG_FRESTRICTED = 1, LIBFLAG_FCONTROL = 2, From b98c8f2867b141446589f5ce5c368b6cb6719a40 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Thu, 17 May 2018 15:02:45 -0400 Subject: [PATCH 221/582] Move implementations of some types out of facades These type implementations in facades are problematic, because they don't match the .NET 4.7.1 API, where these type implementations are not in facade assemblies. So move them to the assemblies where they should be to match the .NET 4.7.1 API. This change is part of the change from upstream Mono at: https://github.com/mono/mono/commit/6e246cf6134b7496d0d1ac0a36df485c7d8b2f77 That changeset has other change in it, including changes to submodules that we don't need now. So I've taken only the changes we need by hand here. --- .../System.Runtime.Serialization.Primitives.dll.sources | 2 -- .../System.Runtime.Serialization.Primitives/TypeForwarders.cs | 1 + .../System.Security.Cryptography.Algorithms.dll.sources | 1 - .../System.Security.Cryptography.Algorithms/TypeForwarders.cs | 1 + .../System.Security.SecureString.dll.sources | 1 - .../Facades/System.Security.SecureString/TypeForwarders.cs | 1 + mcs/class/System.Core/common_System.Core.dll.sources | 2 ++ .../System.Runtime.Serialization.dll.sources | 2 ++ mcs/class/System/common.sources | 2 ++ 9 files changed, 9 insertions(+), 4 deletions(-) diff --git a/mcs/class/Facades/System.Runtime.Serialization.Primitives/System.Runtime.Serialization.Primitives.dll.sources b/mcs/class/Facades/System.Runtime.Serialization.Primitives/System.Runtime.Serialization.Primitives.dll.sources index fd4c99b18ad3..719628dc7c61 100644 --- a/mcs/class/Facades/System.Runtime.Serialization.Primitives/System.Runtime.Serialization.Primitives.dll.sources +++ b/mcs/class/Facades/System.Runtime.Serialization.Primitives/System.Runtime.Serialization.Primitives.dll.sources @@ -1,4 +1,2 @@ TypeForwarders.cs AssemblyInfo.cs - -../../../../external/corefx/src/System.Runtime.Serialization.Primitives/src/System/Runtime/Serialization/ISerializationSurrogateProvider.cs diff --git a/mcs/class/Facades/System.Runtime.Serialization.Primitives/TypeForwarders.cs b/mcs/class/Facades/System.Runtime.Serialization.Primitives/TypeForwarders.cs index ea71c80449cb..8768234c08da 100644 --- a/mcs/class/Facades/System.Runtime.Serialization.Primitives/TypeForwarders.cs +++ b/mcs/class/Facades/System.Runtime.Serialization.Primitives/TypeForwarders.cs @@ -30,6 +30,7 @@ [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.IExtensibleDataObject))] [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.IgnoreDataMemberAttribute))] [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.InvalidDataContractException))] +[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.ISerializationSurrogateProvider))] [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.KnownTypeAttribute))] [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.OnDeserializedAttribute))] [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Runtime.Serialization.OnDeserializingAttribute))] diff --git a/mcs/class/Facades/System.Security.Cryptography.Algorithms/System.Security.Cryptography.Algorithms.dll.sources b/mcs/class/Facades/System.Security.Cryptography.Algorithms/System.Security.Cryptography.Algorithms.dll.sources index bc50224ae2c5..a2f4cd1a9d72 100644 --- a/mcs/class/Facades/System.Security.Cryptography.Algorithms/System.Security.Cryptography.Algorithms.dll.sources +++ b/mcs/class/Facades/System.Security.Cryptography.Algorithms/System.Security.Cryptography.Algorithms.dll.sources @@ -1,4 +1,3 @@ TypeForwarders.cs AssemblyInfo.cs SR.cs -../../../../external/corefx/src/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/IncrementalHash.net46.cs diff --git a/mcs/class/Facades/System.Security.Cryptography.Algorithms/TypeForwarders.cs b/mcs/class/Facades/System.Security.Cryptography.Algorithms/TypeForwarders.cs index 2a7c09f47141..10ded3bedd96 100644 --- a/mcs/class/Facades/System.Security.Cryptography.Algorithms/TypeForwarders.cs +++ b/mcs/class/Facades/System.Security.Cryptography.Algorithms/TypeForwarders.cs @@ -43,6 +43,7 @@ [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.HMACSHA256))] [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.HMACSHA384))] [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.HMACSHA512))] +[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.IncrementalHash))] [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.MaskGenerationMethod))] [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.MD5))] [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.Cryptography.PKCS1MaskGenerationMethod))] diff --git a/mcs/class/Facades/System.Security.SecureString/System.Security.SecureString.dll.sources b/mcs/class/Facades/System.Security.SecureString/System.Security.SecureString.dll.sources index d12a84b6abd2..719628dc7c61 100644 --- a/mcs/class/Facades/System.Security.SecureString/System.Security.SecureString.dll.sources +++ b/mcs/class/Facades/System.Security.SecureString/System.Security.SecureString.dll.sources @@ -1,3 +1,2 @@ TypeForwarders.cs AssemblyInfo.cs -../../../../external/corefx/src/System.Runtime.InteropServices/src/System/Security/SecureStringMarshal.cs diff --git a/mcs/class/Facades/System.Security.SecureString/TypeForwarders.cs b/mcs/class/Facades/System.Security.SecureString/TypeForwarders.cs index 4267f40e03b0..e34303ce1947 100644 --- a/mcs/class/Facades/System.Security.SecureString/TypeForwarders.cs +++ b/mcs/class/Facades/System.Security.SecureString/TypeForwarders.cs @@ -21,3 +21,4 @@ // [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.SecureString))] +[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Security.SecureStringMarshal))] diff --git a/mcs/class/System.Core/common_System.Core.dll.sources b/mcs/class/System.Core/common_System.Core.dll.sources index cfe271aeee0f..6d2f6aaf34ef 100644 --- a/mcs/class/System.Core/common_System.Core.dll.sources +++ b/mcs/class/System.Core/common_System.Core.dll.sources @@ -289,3 +289,5 @@ System.Security.Cryptography/SHA512CryptoServiceProvider.cs ../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/DelegateHelpers.cs ../../../external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/DelegateHelpers.Generated.cs + +../../../external/corefx/src/System.Security.Cryptography.Algorithms/src/System/Security/Cryptography/IncrementalHash.net46.cs diff --git a/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.dll.sources b/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.dll.sources index c1ebbd981530..bdc4b9adcc20 100644 --- a/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.dll.sources +++ b/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization.dll.sources @@ -16,3 +16,5 @@ ReferenceSources/XmlDataContract_static.cs ReferenceSources/XmlFormatReaderGenerator_static.cs ReferenceSources/XmlFormatWriterGenerator_static.cs + +../../../external/corefx/src/System.Runtime.Serialization.Primitives/src/System/Runtime/Serialization/ISerializationSurrogateProvider.cs diff --git a/mcs/class/System/common.sources b/mcs/class/System/common.sources index c3b0f8a1bf11..29ca5d4b9cfb 100644 --- a/mcs/class/System/common.sources +++ b/mcs/class/System/common.sources @@ -931,3 +931,5 @@ corefx/SR.cs ../../../external/corefx/src/System.Private.Uri/src/System/UriBuilder.cs ../../../external/corefx/src/System.Runtime.Extensions/src/System/CodeDom/Compiler/IndentedTextWriter.cs + +../../../external/corefx/src/System.Runtime.InteropServices/src/System/Security/SecureStringMarshal.cs From ebbf4c403cdd9064ccc98c1c96fc1d776e9a0476 Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Fri, 18 May 2018 13:08:06 +0200 Subject: [PATCH 222/582] Add write barriers for incremental boehm support --- mono/metadata/boehm-gc.c | 119 +++++++++++++++++++++++++++++++++++---- mono/metadata/object.c | 4 ++ mono/mini/method-to-ir.c | 5 ++ 3 files changed, 118 insertions(+), 10 deletions(-) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index 260a09842a69..f94618db527a 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -230,6 +230,13 @@ mono_gc_base_init (void) } else if (g_str_has_prefix (opt, "toggleref-test")) { register_test_toggleref_callback (); continue; + } else if (g_str_has_prefix (opt, "incremental")) { + GC_enable_incremental(); + #if HAVE_BDWGC_GC + // value is in milliseconds + GC_set_time_limit(3); + #endif + continue; } else { /* Could be a parameter for sgen */ /* @@ -250,11 +257,11 @@ mono_gc_base_init (void) mono_thread_info_attach (); -#ifdef HAVE_BDWGC_GC - GC_set_on_event (on_gc_notification); -#else +//#ifdef HAVE_BDWGC_GC + //GC_set_on_event (on_gc_notification); +//#else GC_set_on_collection_event (on_gc_notification); -#endif +//#endif GC_on_heap_resize = on_gc_heap_resize; gc_initialized = TRUE; @@ -634,6 +641,7 @@ mono_gc_weak_link_add (void **link_addr, MonoObject *obj, gboolean track) { /* libgc requires that we use HIDE_POINTER... */ *link_addr = (void*)HIDE_POINTER (obj); + GC_end_stubborn_change(link_addr); if (track) GC_REGISTER_LONG_LINK (link_addr, obj); else @@ -878,41 +886,48 @@ void mono_gc_wbarrier_set_field (MonoObject *obj, gpointer field_ptr, MonoObject* value) { *(void**)field_ptr = value; + GC_end_stubborn_change(field_ptr); } void mono_gc_wbarrier_set_arrayref (MonoArray *arr, gpointer slot_ptr, MonoObject* value) { *(void**)slot_ptr = value; + GC_end_stubborn_change(slot_ptr); } void mono_gc_wbarrier_arrayref_copy (gpointer dest_ptr, gpointer src_ptr, int count) { mono_gc_memmove_aligned (dest_ptr, src_ptr, count * sizeof (gpointer)); + GC_end_stubborn_change(dest_ptr); } void mono_gc_wbarrier_generic_store (gpointer ptr, MonoObject* value) { *(void**)ptr = value; + GC_end_stubborn_change(ptr); } void mono_gc_wbarrier_generic_store_atomic (gpointer ptr, MonoObject *value) { mono_atomic_store_ptr ((volatile gpointer *)ptr, value); + GC_end_stubborn_change(ptr); } void mono_gc_wbarrier_generic_nostore (gpointer ptr) { + GC_end_stubborn_change(ptr); } void mono_gc_wbarrier_value_copy (gpointer dest, gpointer src, int count, MonoClass *klass) { mono_gc_memmove_atomic (dest, src, count * mono_class_value_size (klass, NULL)); + GC_end_stubborn_change(dest); } void @@ -921,6 +936,7 @@ mono_gc_wbarrier_object_copy (MonoObject* obj, MonoObject *src) /* do not copy the sync state */ mono_gc_memmove_aligned ((char*)obj + sizeof (MonoObject), (char*)src + sizeof (MonoObject), mono_object_class (obj)->instance_size - sizeof (MonoObject)); + GC_end_stubborn_change(obj); } void @@ -1310,11 +1326,48 @@ mono_gc_get_managed_allocator_types (void) return 0; } +static MonoMethod *write_barrier_conc_method; MonoMethod* mono_gc_get_write_barrier (void) { - g_assert_not_reached (); - return NULL; + MonoMethod *res; + MonoMethodBuilder *mb; + MonoMethodSignature *sig; + MonoMethod **write_barrier_method_addr; + WrapperInfo *info; + + write_barrier_method_addr = &write_barrier_conc_method; + + if (*write_barrier_method_addr) + return *write_barrier_method_addr; + + /* Create the IL version of mono_gc_barrier_generic_store () */ + sig = mono_metadata_signature_alloc (mono_defaults.corlib, 1); + sig->ret = &mono_defaults.void_class->byval_arg; + sig->params [0] = &mono_defaults.int_class->byval_arg; + + mb = mono_mb_new (mono_defaults.object_class, "wbarrier_conc", MONO_WRAPPER_WRITE_BARRIER); + + mono_mb_emit_ldarg (mb, 0); + mono_mb_emit_icall (mb, mono_gc_wbarrier_generic_nostore); + mono_mb_emit_byte (mb, MONO_CEE_RET); + + res = mono_mb_create_method (mb, sig, 16); + info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NONE); + mono_marshal_set_wrapper_info (res, info); + mono_mb_free (mb); + + if (*write_barrier_method_addr) { + /* Already created */ + mono_free_method (res); + } else { + /* double-checked locking */ + mono_memory_barrier (); + *write_barrier_method_addr = res; + } + + return *write_barrier_method_addr; + } #else @@ -1349,11 +1402,48 @@ mono_gc_get_managed_allocator_types (void) return 0; } +static MonoMethod *write_barrier_conc_method; MonoMethod* mono_gc_get_write_barrier (void) { - g_assert_not_reached (); - return NULL; + MonoMethod *res; + MonoMethodBuilder *mb; + MonoMethodSignature *sig; + MonoMethod **write_barrier_method_addr; + WrapperInfo *info; + + write_barrier_method_addr = &write_barrier_conc_method; + + if (*write_barrier_method_addr) + return *write_barrier_method_addr; + + /* Create the IL version of mono_gc_barrier_generic_store () */ + sig = mono_metadata_signature_alloc (mono_defaults.corlib, 1); + sig->ret = &mono_defaults.void_class->byval_arg; + sig->params [0] = &mono_defaults.int_class->byval_arg; + + mb = mono_mb_new (mono_defaults.object_class, "wbarrier_conc", MONO_WRAPPER_WRITE_BARRIER); + + mono_mb_emit_ldarg (mb, 0); + mono_mb_emit_icall (mb, mono_gc_wbarrier_generic_nostore); + mono_mb_emit_byte (mb, MONO_CEE_RET); + + res = mono_mb_create_method (mb, sig, 16); + info = mono_wrapper_info_create (mb, WRAPPER_SUBTYPE_NONE); + mono_marshal_set_wrapper_info (res, info); + mono_mb_free (mb); + + if (*write_barrier_method_addr) { + /* Already created */ + mono_free_method (res); + } else { + /* double-checked locking */ + mono_memory_barrier (); + *write_barrier_method_addr = res; + } + + return *write_barrier_method_addr; + } #endif @@ -1398,7 +1488,11 @@ mono_gc_set_desktop_mode (void) gboolean mono_gc_is_moving (void) { +#if HAVE_BDWGC_GC + return GC_is_incremental_mode(); +#else return FALSE; +#endif } gboolean @@ -1413,7 +1507,8 @@ mono_gc_is_disabled (void) void mono_gc_wbarrier_range_copy (gpointer _dest, gpointer _src, int size) { - g_assert_not_reached (); + memcpy(_dest, _src, size); + GC_end_stubborn_change(_dest); } void* @@ -1425,7 +1520,6 @@ mono_gc_get_range_copy_func (void) guint8* mono_gc_get_card_table (int *shift_bits, gpointer *card_mask) { - g_assert_not_reached (); return NULL; } @@ -1775,6 +1869,7 @@ handle_data_grow (HandleData *handles, gboolean track) gpointer *entries; entries = (void **)mono_gc_alloc_fixed (sizeof (*handles->entries) * new_size, NULL, MONO_ROOT_SOURCE_GC_HANDLE, NULL, "GC Handle Table (Boehm)"); mono_gc_memmove_aligned (entries, handles->entries, sizeof (*handles->entries) * handles->size); + GC_end_stubborn_change(entries); mono_gc_free_fixed (handles->entries); handles->entries = entries; } @@ -1807,6 +1902,7 @@ alloc_handle (HandleData *handles, MonoObject *obj, gboolean track) mono_gc_weak_link_add (&(handles->entries [slot]), obj, track); } else { handles->entries [slot] = obj; + GC_end_stubborn_change(handles->entries + slot); } #ifndef DISABLE_PERFCOUNTERS @@ -1924,6 +2020,7 @@ mono_gchandle_set_target (guint32 gchandle, MonoObject *obj) handles->domain_ids [slot] = (obj ? mono_object_get_domain (obj) : mono_domain_get ())->domain_id; } else { handles->entries [slot] = obj; + GC_end_stubborn_change(handles->entries + slot); } } else { /* print a warning? */ @@ -2002,6 +2099,7 @@ mono_gchandle_free (guint32 gchandle) mono_gc_weak_link_remove (&handles->entries [slot], handles->type == HANDLE_WEAK_TRACK); } else { handles->entries [slot] = NULL; + GC_end_stubborn_change(handles->entries + slot); } vacate_slot (handles, slot); } else { @@ -2044,6 +2142,7 @@ mono_gchandle_free_domain (MonoDomain *domain) if (handles->entries [slot] && mono_object_domain (handles->entries [slot]) == domain) { vacate_slot (handles, slot); handles->entries [slot] = NULL; + GC_end_stubborn_change(handles->entries + slot); } } } diff --git a/mono/metadata/object.c b/mono/metadata/object.c index 94a92c7517fa..3fa8c85bd192 100644 --- a/mono/metadata/object.c +++ b/mono/metadata/object.c @@ -2085,6 +2085,8 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, MonoErro g_assert ((fklass->byval_arg.type == MONO_TYPE_PTR) || (fklass->byval_arg.type == MONO_TYPE_FNPTR)); *t = *(char *)data; } + // can probably be in else clause above: + mono_gc_wbarrier_generic_nostore(t); continue; } } @@ -3294,6 +3296,7 @@ mono_field_static_set_value (MonoVTable *vt, MonoClassField *field, void *value) dest = (char*)mono_vtable_get_static_field_data (vt) + field->offset; } mono_copy_value (field->type, dest, value, FALSE); + mono_gc_wbarrier_generic_nostore(dest); } /** @@ -3331,6 +3334,7 @@ mono_field_get_addr (MonoObject *obj, MonoVTable *vt, MonoClassField *field) src = (guint8 *)mono_get_special_static_data (GPOINTER_TO_UINT (addr)); } else { src = (guint8*)mono_vtable_get_static_field_data (vt) + field->offset; + mono_gc_wbarrier_generic_nostore(src); } } else { src = (guint8*)obj + field->offset; diff --git a/mono/mini/method-to-ir.c b/mono/mini/method-to-ir.c index ed9001779cf9..977262a0d42d 100644 --- a/mono/mini/method-to-ir.c +++ b/mono/mini/method-to-ir.c @@ -10740,6 +10740,11 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b EMIT_NEW_STORE_MEMBASE_TYPE (cfg, store, ftype, ins->dreg, 0, store_val->dreg); store->flags |= ins_flag; + if (cfg->gen_write_barriers && cfg->method->wrapper_type != MONO_WRAPPER_WRITE_BARRIER && + mini_type_is_reference (ftype)) { + /* insert call to write barrier */ + mini_emit_write_barrier (cfg, store, ins); + } } else { gboolean is_const = FALSE; MonoVTable *vtable = NULL; From e5769df74dd8340f9a36ac4156f72fc8a0d18606 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Mon, 21 May 2018 15:25:11 -0400 Subject: [PATCH 223/582] Interrupt syncronous file read/write IO on Win32 by registering interrupt callback. --- mono/metadata/w32file-win32.c | 46 ++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/mono/metadata/w32file-win32.c b/mono/metadata/w32file-win32.c index 90fc55bfa08f..333d1b2142a6 100644 --- a/mono/metadata/w32file-win32.c +++ b/mono/metadata/w32file-win32.c @@ -82,25 +82,49 @@ mono_w32file_delete (const gunichar2 *name) return res; } +static void +cancel_w32_io (HANDLE file_handle) +{ + CancelIoEx (file_handle, NULL); +} + gboolean -mono_w32file_read(gpointer handle, gpointer buffer, guint32 numbytes, guint32 *bytesread) +mono_w32file_read (gpointer handle, gpointer buffer, guint32 numbytes, guint32 *bytesread) { - gboolean res; - MONO_ENTER_GC_SAFE; - res = ReadFile (handle, buffer, numbytes, bytesread, NULL); - MONO_PROFILER_RAISE (fileio, (1, *bytesread)); - MONO_EXIT_GC_SAFE; + gboolean res = FALSE; + gboolean interrupted; + + mono_thread_info_install_interrupt (cancel_w32_io, handle, &interrupted); + if (!interrupted) + { + MONO_ENTER_GC_SAFE; + res = ReadFile (handle, buffer, numbytes, bytesread, NULL); + MONO_PROFILER_RAISE (fileio, (1, *bytesread)); + MONO_EXIT_GC_SAFE; + + mono_thread_info_uninstall_interrupt (&interrupted); + } + return res; } gboolean mono_w32file_write (gpointer handle, gconstpointer buffer, guint32 numbytes, guint32 *byteswritten) { - gboolean res; - MONO_ENTER_GC_SAFE; - res = WriteFile (handle, buffer, numbytes, byteswritten, NULL); - MONO_PROFILER_RAISE (fileio, (0, *byteswritten)); - MONO_EXIT_GC_SAFE; + gboolean res = FALSE; + gboolean interrupted; + + mono_thread_info_install_interrupt (cancel_w32_io, handle, &interrupted); + if (!interrupted) + { + MONO_ENTER_GC_SAFE; + res = WriteFile (handle, buffer, numbytes, byteswritten, NULL); + MONO_PROFILER_RAISE (fileio, (0, *byteswritten)); + MONO_EXIT_GC_SAFE; + + mono_thread_info_uninstall_interrupt (&interrupted); + } + return res; } From d1676803f4c3145683a612f423a16e6ad9797141 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Mon, 21 May 2018 12:35:04 -0400 Subject: [PATCH 224/582] Add missing sre features to the mscorlib link.xml To make sure that System.Reflection.Emit types in the class libraries are properly removed by the linker, mark them with the "sre" feature in the embedded linker descriptor file for mscorlib. --- .../corlib/LinkerDescriptor/mscorlib.xml | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/mcs/class/corlib/LinkerDescriptor/mscorlib.xml b/mcs/class/corlib/LinkerDescriptor/mscorlib.xml index 4d36758a43c9..1be0d4cef368 100644 --- a/mcs/class/corlib/LinkerDescriptor/mscorlib.xml +++ b/mcs/class/corlib/LinkerDescriptor/mscorlib.xml @@ -594,39 +594,39 @@ - - - - - + + + + + - + - - - - - + + + + + - + - - - + + + - + - + - - + + @@ -634,34 +634,34 @@ - + - + - - + + - + - + - + - + - + - + - + From dc98d954b4351e99562d29da47773a58aeadc43b Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 22 May 2018 10:14:41 -0400 Subject: [PATCH 225/582] Expose embedding APIs for querying generic instance arguments. --- mono/metadata/unity-utils.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/mono/metadata/unity-utils.c b/mono/metadata/unity-utils.c index 3f936239f682..3c684a4c2f7d 100644 --- a/mono/metadata/unity-utils.c +++ b/mono/metadata/unity-utils.c @@ -1129,6 +1129,31 @@ mono_unity_class_get_generic_parameter_count (MonoClass* klass) return generic_container->type_argc; } +MONO_API MonoClass* +mono_unity_class_get_generic_argument_at (MonoClass* klass, guint32 index) +{ + if (!mono_class_is_ginst (klass)) + return NULL; + + MonoGenericClass* generic_class = mono_class_get_generic_class (klass); + + if (index >= generic_class->context.class_inst->type_argc) + return NULL; + + return mono_class_from_mono_type (generic_class->context.class_inst->type_argv[index]); +} + +MONO_API guint32 +mono_unity_class_get_generic_argument_count (MonoClass* klass) +{ + if (!mono_class_is_ginst (klass)) + return NULL; + + MonoGenericClass* generic_class = mono_class_get_generic_class (klass); + + return generic_class->context.class_inst->type_argc; +} + MONO_API MonoClass* mono_unity_class_get(MonoImage* image, guint32 type_token) { From 3fb48d818d38ee030dd5dd2b593f5f17974fd84d Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Wed, 23 May 2018 15:46:33 +0200 Subject: [PATCH 226/582] Update Boehm to a version which supports MANUAL_VDB incremental mode --- external/bdwgc | 2 +- mono/mini/Makefile.am.in | 2 +- mono/utils/gc_wrapper.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/external/bdwgc b/external/bdwgc index 8440aa8cdffd..2ca67995b018 160000 --- a/external/bdwgc +++ b/external/bdwgc @@ -1 +1 @@ -Subproject commit 8440aa8cdffda0b9aa324a0e63f950f05551ab27 +Subproject commit 2ca67995b018495bfdede9f943239b8c703680bd diff --git a/mono/mini/Makefile.am.in b/mono/mini/Makefile.am.in index a2b7cbd30227..aa472da5d10d 100755 --- a/mono/mini/Makefile.am.in +++ b/mono/mini/Makefile.am.in @@ -19,7 +19,7 @@ libgc_static_libs=$(monodir)/libgc/libmonogc-static.la endif libbdwgc_libs=$(monodir)/external/bdwgc/libgc.la -libbdwgc_static_libs=$(monodir)/external/bdwgc/libgc-static.la +libbdwgc_static_libs=$(monodir)/external/bdwgc/libgc.la boehm_libs= \ $(monodir)/mono/metadata/libmonoruntime.la \ diff --git a/mono/utils/gc_wrapper.h b/mono/utils/gc_wrapper.h index 0e14fbf0a911..6133d90c131f 100644 --- a/mono/utils/gc_wrapper.h +++ b/mono/utils/gc_wrapper.h @@ -21,7 +21,7 @@ #define IGNORE_DYNAMIC_LOADING 1 #define GC_DONT_REGISTER_MAIN_STATIC_DATA 1 #define GC_VERSION_MAJOR 7 -#define GC_VERSION_MINOR 4 +#define GC_VERSION_MINOR 7 #define GC_VERSION_MICRO 0 #define GC_THREADS 1 #define USE_MMAP 1 From 178c05ebfeaf310925d4780d95e3222b6b735326 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Wed, 23 May 2018 09:52:25 -0400 Subject: [PATCH 227/582] Ignore assembly version when loading non-strong named reference assemblies (case 996473) Partial backfix of upstream PR https://github.com/mono/mono/pull/8821 --- mono/metadata/appdomain.c | 8 +++++- mono/metadata/assembly-internals.h | 18 ++++++++++++ mono/metadata/assembly.c | 45 +++++++++++++++--------------- 3 files changed, 48 insertions(+), 23 deletions(-) diff --git a/mono/metadata/appdomain.c b/mono/metadata/appdomain.c index 3234f6228ea9..0127ad6fd909 100644 --- a/mono/metadata/appdomain.c +++ b/mono/metadata/appdomain.c @@ -2072,12 +2072,18 @@ mono_domain_assembly_search (MonoAssemblyName *aname, GSList *tmp; MonoAssembly *ass; gboolean refonly = GPOINTER_TO_UINT (user_data); + const gboolean strong_name = aname->public_key_token[0] != 0; + /* If it's not a strong name, any version that has the right simple + * name is good enough to satisfy the request. .NET Framework also + * ignores case differences in this case. */ + const MonoAssemblyNameEqFlags eq_flags = strong_name ? MONO_ANAME_EQ_IGNORE_CASE : + (MONO_ANAME_EQ_IGNORE_PUBKEY | MONO_ANAME_EQ_IGNORE_VERSION | MONO_ANAME_EQ_IGNORE_CASE); mono_domain_assemblies_lock (domain); for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) { ass = (MonoAssembly *)tmp->data; /* Dynamic assemblies can't match here in MS.NET */ - if (assembly_is_dynamic (ass) || refonly != ass->ref_only || !mono_assembly_names_equal (aname, &ass->aname)) + if (assembly_is_dynamic (ass) || refonly != ass->ref_only || !mono_assembly_names_equal_flags (aname, &ass->aname, eq_flags)) continue; mono_domain_assemblies_unlock (domain); diff --git a/mono/metadata/assembly-internals.h b/mono/metadata/assembly-internals.h index 65dc09f8712b..3116ffae1229 100644 --- a/mono/metadata/assembly-internals.h +++ b/mono/metadata/assembly-internals.h @@ -9,6 +9,24 @@ #include #include +#include + +/* Flag bits for mono_assembly_names_equal_flags (). */ +typedef enum { + /* Default comparison: all fields must match */ + MONO_ANAME_EQ_NONE = 0x0, + /* Don't compare public key token */ + MONO_ANAME_EQ_IGNORE_PUBKEY = 0x1, + /* Don't compare the versions */ + MONO_ANAME_EQ_IGNORE_VERSION = 0x2, + /* When comparing simple names, ignore case differences */ + MONO_ANAME_EQ_IGNORE_CASE = 0x4, + + MONO_ANAME_EQ_MASK = 0x7 +} MonoAssemblyNameEqFlags; + +gboolean +mono_assembly_names_equal_flags (MonoAssemblyName *l, MonoAssemblyName *r, MonoAssemblyNameEqFlags flags); MONO_API MonoImage* mono_assembly_load_module_checked (MonoAssembly *assembly, uint32_t idx, MonoError *error); diff --git a/mono/metadata/assembly.c b/mono/metadata/assembly.c index b681385be67a..3b5c81d75df8 100644 --- a/mono/metadata/assembly.c +++ b/mono/metadata/assembly.c @@ -63,18 +63,6 @@ typedef struct { gboolean framework_facade_assembly; } AssemblyVersionMap; -/* Flag bits for assembly_names_equal_flags (). */ -typedef enum { - /* Default comparison: all fields must match */ - ANAME_EQ_NONE = 0x0, - /* Don't compare public key token */ - ANAME_EQ_IGNORE_PUBKEY = 0x1, - /* Don't compare the versions */ - ANAME_EQ_IGNORE_VERSION = 0x2, - - ANAME_EQ_MASK = 0x3 -} AssemblyNameEqFlags; - /* the default search path is empty, the first slot is replaced with the computed value */ static const char* default_path [] = { @@ -359,9 +347,6 @@ mono_assembly_is_in_gac (const gchar *filanem); static MonoAssembly* prevent_reference_assembly_from_running (MonoAssembly* candidate, gboolean refonly); -static gboolean -assembly_names_equal_flags (MonoAssemblyName *l, MonoAssemblyName *r, AssemblyNameEqFlags flags); - /* Assembly name matching */ static gboolean exact_sn_match (MonoAssemblyName *wanted_name, MonoAssemblyName *candidate_name); @@ -685,16 +670,32 @@ check_policy_versions (MonoAssemblyBindingInfo *info, MonoAssemblyName *name) gboolean mono_assembly_names_equal (MonoAssemblyName *l, MonoAssemblyName *r) { - return assembly_names_equal_flags (l, r, ANAME_EQ_NONE); + return mono_assembly_names_equal_flags (l, r, MONO_ANAME_EQ_NONE); } +/** + * mono_assembly_names_equal_flags: + * \param l first assembly name + * \param r second assembly name + * \param flags flags that affect what is compared. + * + * Compares two \c MonoAssemblyName instances and returns whether they are equal. + * + * This compares the simple names and cultures and optionally the versions and + * public key tokens, depending on the \c flags. + * + * \returns TRUE if both assembly names are equal. + */ gboolean -assembly_names_equal_flags (MonoAssemblyName *l, MonoAssemblyName *r, AssemblyNameEqFlags flags) +mono_assembly_names_equal_flags (MonoAssemblyName *l, MonoAssemblyName *r, MonoAssemblyNameEqFlags flags) { if (!l->name || !r->name) return FALSE; - if (strcmp (l->name, r->name)) + if ((flags & MONO_ANAME_EQ_IGNORE_CASE) != 0 && g_strcasecmp (l->name, r->name)) + return FALSE; + + if ((flags & MONO_ANAME_EQ_IGNORE_CASE) == 0 && strcmp (l->name, r->name)) return FALSE; if (l->culture && r->culture && strcmp (l->culture, r->culture)) @@ -702,11 +703,11 @@ assembly_names_equal_flags (MonoAssemblyName *l, MonoAssemblyName *r, AssemblyNa if ((l->major != r->major || l->minor != r->minor || l->build != r->build || l->revision != r->revision) && - (flags & ANAME_EQ_IGNORE_VERSION) == 0) + (flags & MONO_ANAME_EQ_IGNORE_VERSION) == 0) if (! ((l->major == 0 && l->minor == 0 && l->build == 0 && l->revision == 0) || (r->major == 0 && r->minor == 0 && r->build == 0 && r->revision == 0))) return FALSE; - if (!l->public_key_token [0] || !r->public_key_token [0] || (flags & ANAME_EQ_IGNORE_PUBKEY) != 0) + if (!l->public_key_token [0] || !r->public_key_token [0] || (flags & MONO_ANAME_EQ_IGNORE_PUBKEY) != 0) return TRUE; if (!mono_public_tokens_are_equal (l->public_key_token, r->public_key_token)) @@ -3626,13 +3627,13 @@ framework_assembly_sn_match (MonoAssemblyName *wanted_name, MonoAssemblyName *ca if (vmap) { if (!vmap->framework_facade_assembly) { /* If the wanted name is a framework assembly, it's enough for the name/version/culture to match. If the assembly was remapped, the public key token is likely unrelated. */ - gboolean result = assembly_names_equal_flags (wanted_name, candidate_name, ANAME_EQ_IGNORE_PUBKEY); + gboolean result = mono_assembly_names_equal_flags (wanted_name, candidate_name, MONO_ANAME_EQ_IGNORE_PUBKEY); mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Predicate: candidate and wanted names %s (ignoring the public key token)", result ? "match, returning TRUE" : "don't match, returning FALSE"); return result; } else { /* For facades, the name and public key token should * match, but the version doesn't matter. */ - gboolean result = assembly_names_equal_flags (wanted_name, candidate_name, ANAME_EQ_IGNORE_VERSION); + gboolean result = mono_assembly_names_equal_flags (wanted_name, candidate_name, MONO_ANAME_EQ_IGNORE_VERSION); mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Predicate: candidate and wanted names %s (ignoring version)", result ? "match, returning TRUE" : "don't match, returning FALSE"); return result; } From 2cecd8913a911ba3882c7dea2176106e8b3b4af3 Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Wed, 23 May 2018 16:05:41 +0200 Subject: [PATCH 228/582] Allow specifying time limit in environment variable --- mono/metadata/boehm-gc.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index f94618db527a..da2704fe9d55 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -230,12 +230,18 @@ mono_gc_base_init (void) } else if (g_str_has_prefix (opt, "toggleref-test")) { register_test_toggleref_callback (); continue; - } else if (g_str_has_prefix (opt, "incremental")) { - GC_enable_incremental(); - #if HAVE_BDWGC_GC - // value is in milliseconds - GC_set_time_limit(3); - #endif + } else if (g_str_has_prefix (opt, "incremental=")) { + size_t time_limit; + + opt = strchr (opt, '=') + 1; + if (*opt && mono_gc_parse_environment_string_extract_number (opt, &time_limit)) { + GC_enable_incremental(); + #if HAVE_BDWGC_GC + if (time_limit != 0) + // value is in milliseconds + GC_set_time_limit(time_limit); + #endif + } continue; } else { /* Could be a parameter for sgen */ @@ -257,11 +263,7 @@ mono_gc_base_init (void) mono_thread_info_attach (); -//#ifdef HAVE_BDWGC_GC - //GC_set_on_event (on_gc_notification); -//#else GC_set_on_collection_event (on_gc_notification); -//#endif GC_on_heap_resize = on_gc_heap_resize; gc_initialized = TRUE; From 2172e09334d9c4888fa2b99127e78253171e2d07 Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Wed, 23 May 2018 17:17:06 +0200 Subject: [PATCH 229/582] Fix crash --- mono/metadata/domain.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mono/metadata/domain.c b/mono/metadata/domain.c index 2947589dbb76..57f8d77a2808 100644 --- a/mono/metadata/domain.c +++ b/mono/metadata/domain.c @@ -1227,8 +1227,12 @@ mono_domain_free (MonoDomain *domain, gboolean force) domain->setup = NULL; +#if !HAVE_BDWGC_GC + // This crashes in bdwgc because we never register such a root. + // Not sure why/how it works in sgen, or if it is needed? if (mono_gc_is_moving ()) mono_gc_deregister_root ((char*)&(domain->MONO_DOMAIN_FIRST_GC_TRACKED)); +#endif mono_appdomains_lock (); appdomains_list [domain->domain_id] = NULL; From 1aa74b9bea05d8b021b05f0779209a472dabfb91 Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Wed, 23 May 2018 17:23:40 +0200 Subject: [PATCH 230/582] Add comment --- mono/mini/method-to-ir.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mono/mini/method-to-ir.c b/mono/mini/method-to-ir.c index 977262a0d42d..ea462a6a900a 100644 --- a/mono/mini/method-to-ir.c +++ b/mono/mini/method-to-ir.c @@ -10742,7 +10742,9 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b store->flags |= ins_flag; if (cfg->gen_write_barriers && cfg->method->wrapper_type != MONO_WRAPPER_WRITE_BARRIER && mini_type_is_reference (ftype)) { - /* insert call to write barrier */ + /* insert call to write barrier. This is not needed by sgen, as it does not seem + to need write barriers for uncollectable objects (like the vtables storing static + fields), but it is needed for incremental boehm. */ mini_emit_write_barrier (cfg, store, ins); } } else { From 688f5205906f63744942bdcacf0ac2f3be70fe51 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Wed, 23 May 2018 13:12:56 -0400 Subject: [PATCH 231/582] Remove two methods with incorrect arguments These two methods on `IPersonalizable` don't match the .NET 4.7.1 API. In both cases the methods should take one `PersonalizableDictionary` argument, but _that_ type does not exist. Since nothing in the current class library code is using these methods, just remove them. --- .../System.Web.UI.WebControls.WebParts/IPersonalizable.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/mcs/class/System.Web/System.Web.UI.WebControls.WebParts/IPersonalizable.cs b/mcs/class/System.Web/System.Web.UI.WebControls.WebParts/IPersonalizable.cs index 719371ad7be3..8ffea6886041 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls.WebParts/IPersonalizable.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls.WebParts/IPersonalizable.cs @@ -35,9 +35,6 @@ namespace System.Web.UI.WebControls.WebParts { public interface IPersonalizable { - void Load (IDictionary sharedState, IDictionary userState); - void Save (IDictionary state); - bool IsDirty { get; } } } From 467627fa5f0ea57002540b31b85c62bc21a8cfa7 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Thu, 24 May 2018 10:03:34 +0200 Subject: [PATCH 232/582] Add mono_unity_gc_enable and mono_unity_gc_disable --- mono/metadata/unity-utils.c | 23 +++++++++++++++++++++++ mono/metadata/unity-utils.h | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/mono/metadata/unity-utils.c b/mono/metadata/unity-utils.c index 3c684a4c2f7d..cd2839c421aa 100644 --- a/mono/metadata/unity-utils.c +++ b/mono/metadata/unity-utils.c @@ -30,6 +30,10 @@ #include #include +#if HAVE_BDWGC_GC +#include +#endif + #include #ifdef WIN32 @@ -900,6 +904,25 @@ mono_unity_get_unitytls_interface() return gUnitytlsInterface; } +// gc +MONO_API void mono_unity_gc_enable() +{ +#if HAVE_BDWGC_GC + GC_enable(); +#else + g_assert_not_reached (); +#endif +} + +MONO_API void mono_unity_gc_disable() +{ +#if HAVE_BDWGC_GC + GC_disable(); +#else + g_assert_not_reached (); +#endif +} + MONO_API void mono_unity_install_unitytls_interface(unitytls_interface_struct* callbacks) { diff --git a/mono/metadata/unity-utils.h b/mono/metadata/unity-utils.h index 1bec5570544e..f7114a80fb04 100644 --- a/mono/metadata/unity-utils.h +++ b/mono/metadata/unity-utils.h @@ -150,6 +150,10 @@ typedef struct unitytls_interface_struct unitytls_interface_struct; MONO_API unitytls_interface_struct* mono_unity_get_unitytls_interface(); MONO_API void mono_unity_install_unitytls_interface(unitytls_interface_struct* callbacks); +// gc +MONO_API void mono_unity_gc_enable(); +MONO_API void mono_unity_gc_disable(); + //misc MonoAssembly* mono_unity_assembly_get_mscorlib(); MonoImage* mono_unity_image_get_mscorlib(); From 7f5ddeaaf1b3db3c9d8dc171481dfc401485a750 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Fri, 25 May 2018 08:23:40 +0200 Subject: [PATCH 233/582] Add mono_unity_gc_is_disabled --- mono/metadata/unity-utils.c | 10 ++++++++++ mono/metadata/unity-utils.h | 1 + 2 files changed, 11 insertions(+) diff --git a/mono/metadata/unity-utils.c b/mono/metadata/unity-utils.c index cd2839c421aa..ef8a37777e5a 100644 --- a/mono/metadata/unity-utils.c +++ b/mono/metadata/unity-utils.c @@ -923,6 +923,16 @@ MONO_API void mono_unity_gc_disable() #endif } +MONO_API int mono_unity_gc_is_disabled() +{ +#if HAVE_BDWGC_GC + return GC_is_disabled (); +#else + g_assert_not_reached (); + return 0; +#endif +} + MONO_API void mono_unity_install_unitytls_interface(unitytls_interface_struct* callbacks) { diff --git a/mono/metadata/unity-utils.h b/mono/metadata/unity-utils.h index f7114a80fb04..c476a5ef92d4 100644 --- a/mono/metadata/unity-utils.h +++ b/mono/metadata/unity-utils.h @@ -153,6 +153,7 @@ MONO_API void mono_unity_install_unitytls_interface(unitytls_interface_struct* c // gc MONO_API void mono_unity_gc_enable(); MONO_API void mono_unity_gc_disable(); +MONO_API int mono_unity_gc_is_disabled(); //misc MonoAssembly* mono_unity_assembly_get_mscorlib(); From 0ef3ae3404e841b92eac5e50e71c3fd9520b94f6 Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Fri, 25 May 2018 09:13:00 +0200 Subject: [PATCH 234/582] Update bdwgc to unity-master branch --- external/bdwgc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/bdwgc b/external/bdwgc index 2ca67995b018..cee60fa2817b 160000 --- a/external/bdwgc +++ b/external/bdwgc @@ -1 +1 @@ -Subproject commit 2ca67995b018495bfdede9f943239b8c703680bd +Subproject commit cee60fa2817b4b68cb7f864938c815ee24f11805 From defc6bc205ee4f2eea0a9ac91f99b267dcf0d15e Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Fri, 25 May 2018 10:50:30 +0200 Subject: [PATCH 235/582] Cleanup write barriers for static fields --- mono/metadata/object.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mono/metadata/object.c b/mono/metadata/object.c index 3fa8c85bd192..ea4a399c9c57 100644 --- a/mono/metadata/object.c +++ b/mono/metadata/object.c @@ -2084,9 +2084,11 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, MonoErro /* it's a pointer type: add check */ g_assert ((fklass->byval_arg.type == MONO_TYPE_PTR) || (fklass->byval_arg.type == MONO_TYPE_FNPTR)); *t = *(char *)data; + /* This is not needed by sgen, as it does not seem ++ to need write barriers for uncollectable objects (like the vtables storing static ++ fields), but it is needed for incremental boehm. */ + mono_gc_wbarrier_generic_nostore(t); } - // can probably be in else clause above: - mono_gc_wbarrier_generic_nostore(t); continue; } } @@ -3296,7 +3298,11 @@ mono_field_static_set_value (MonoVTable *vt, MonoClassField *field, void *value) dest = (char*)mono_vtable_get_static_field_data (vt) + field->offset; } mono_copy_value (field->type, dest, value, FALSE); - mono_gc_wbarrier_generic_nostore(dest); + /* This is not needed by sgen, as it does not seem + to need write barriers for uncollectable objects (like the vtables storing static ++ fields), but it is needed for incremental boehm. */ + if (field->offset == -1) + mono_gc_wbarrier_generic_nostore(dest); } /** @@ -3334,7 +3340,6 @@ mono_field_get_addr (MonoObject *obj, MonoVTable *vt, MonoClassField *field) src = (guint8 *)mono_get_special_static_data (GPOINTER_TO_UINT (addr)); } else { src = (guint8*)mono_vtable_get_static_field_data (vt) + field->offset; - mono_gc_wbarrier_generic_nostore(src); } } else { src = (guint8*)obj + field->offset; From e5f26c5056e29f206b1b55557a45319531177689 Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Fri, 25 May 2018 11:24:32 +0200 Subject: [PATCH 236/582] Directly call GC_dirty instead of GC_end_stubborn_change --- mono/metadata/boehm-gc.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index da2704fe9d55..cf8f5ade5c26 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -40,6 +40,10 @@ #if HAVE_BOEHM_GC +#if !HAVE_BDWGC_GC +#define GC_dirty(x) +#endif + #undef TRUE #undef FALSE #define THREAD_LOCAL_ALLOC 1 @@ -643,7 +647,7 @@ mono_gc_weak_link_add (void **link_addr, MonoObject *obj, gboolean track) { /* libgc requires that we use HIDE_POINTER... */ *link_addr = (void*)HIDE_POINTER (obj); - GC_end_stubborn_change(link_addr); + GC_dirty(link_addr); if (track) GC_REGISTER_LONG_LINK (link_addr, obj); else @@ -888,48 +892,48 @@ void mono_gc_wbarrier_set_field (MonoObject *obj, gpointer field_ptr, MonoObject* value) { *(void**)field_ptr = value; - GC_end_stubborn_change(field_ptr); + GC_dirty(field_ptr); } void mono_gc_wbarrier_set_arrayref (MonoArray *arr, gpointer slot_ptr, MonoObject* value) { *(void**)slot_ptr = value; - GC_end_stubborn_change(slot_ptr); + GC_dirty(slot_ptr); } void mono_gc_wbarrier_arrayref_copy (gpointer dest_ptr, gpointer src_ptr, int count) { mono_gc_memmove_aligned (dest_ptr, src_ptr, count * sizeof (gpointer)); - GC_end_stubborn_change(dest_ptr); + GC_dirty(dest_ptr); } void mono_gc_wbarrier_generic_store (gpointer ptr, MonoObject* value) { *(void**)ptr = value; - GC_end_stubborn_change(ptr); + GC_dirty(ptr); } void mono_gc_wbarrier_generic_store_atomic (gpointer ptr, MonoObject *value) { mono_atomic_store_ptr ((volatile gpointer *)ptr, value); - GC_end_stubborn_change(ptr); + GC_dirty(ptr); } void mono_gc_wbarrier_generic_nostore (gpointer ptr) { - GC_end_stubborn_change(ptr); + GC_dirty(ptr); } void mono_gc_wbarrier_value_copy (gpointer dest, gpointer src, int count, MonoClass *klass) { mono_gc_memmove_atomic (dest, src, count * mono_class_value_size (klass, NULL)); - GC_end_stubborn_change(dest); + GC_dirty(dest); } void @@ -938,7 +942,7 @@ mono_gc_wbarrier_object_copy (MonoObject* obj, MonoObject *src) /* do not copy the sync state */ mono_gc_memmove_aligned ((char*)obj + sizeof (MonoObject), (char*)src + sizeof (MonoObject), mono_object_class (obj)->instance_size - sizeof (MonoObject)); - GC_end_stubborn_change(obj); + GC_dirty(obj); } void @@ -1510,7 +1514,7 @@ void mono_gc_wbarrier_range_copy (gpointer _dest, gpointer _src, int size) { memcpy(_dest, _src, size); - GC_end_stubborn_change(_dest); + GC_dirty(_dest); } void* @@ -1871,7 +1875,7 @@ handle_data_grow (HandleData *handles, gboolean track) gpointer *entries; entries = (void **)mono_gc_alloc_fixed (sizeof (*handles->entries) * new_size, NULL, MONO_ROOT_SOURCE_GC_HANDLE, NULL, "GC Handle Table (Boehm)"); mono_gc_memmove_aligned (entries, handles->entries, sizeof (*handles->entries) * handles->size); - GC_end_stubborn_change(entries); + GC_dirty(entries); mono_gc_free_fixed (handles->entries); handles->entries = entries; } @@ -1904,7 +1908,7 @@ alloc_handle (HandleData *handles, MonoObject *obj, gboolean track) mono_gc_weak_link_add (&(handles->entries [slot]), obj, track); } else { handles->entries [slot] = obj; - GC_end_stubborn_change(handles->entries + slot); + GC_dirty(handles->entries + slot); } #ifndef DISABLE_PERFCOUNTERS @@ -2022,7 +2026,7 @@ mono_gchandle_set_target (guint32 gchandle, MonoObject *obj) handles->domain_ids [slot] = (obj ? mono_object_get_domain (obj) : mono_domain_get ())->domain_id; } else { handles->entries [slot] = obj; - GC_end_stubborn_change(handles->entries + slot); + GC_dirty(handles->entries + slot); } } else { /* print a warning? */ @@ -2101,7 +2105,7 @@ mono_gchandle_free (guint32 gchandle) mono_gc_weak_link_remove (&handles->entries [slot], handles->type == HANDLE_WEAK_TRACK); } else { handles->entries [slot] = NULL; - GC_end_stubborn_change(handles->entries + slot); + GC_dirty(handles->entries + slot); } vacate_slot (handles, slot); } else { @@ -2144,7 +2148,7 @@ mono_gchandle_free_domain (MonoDomain *domain) if (handles->entries [slot] && mono_object_domain (handles->entries [slot]) == domain) { vacate_slot (handles, slot); handles->entries [slot] = NULL; - GC_end_stubborn_change(handles->entries + slot); + GC_dirty(handles->entries + slot); } } } From e743ead0761c6ee87f098ce8fb6048dd9dcc89f3 Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Fri, 25 May 2018 14:24:06 +0200 Subject: [PATCH 237/582] Try to fix katana build --- external/bdwgc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/bdwgc b/external/bdwgc index cee60fa2817b..6f932c1b9af6 160000 --- a/external/bdwgc +++ b/external/bdwgc @@ -1 +1 @@ -Subproject commit cee60fa2817b4b68cb7f864938c815ee24f11805 +Subproject commit 6f932c1b9af6d6ab9203131a4a14a961def5ee68 From 64b20acdb91f1820915813922e9a260482bae561 Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Mon, 28 May 2018 09:17:35 +0200 Subject: [PATCH 238/582] Update bdwgc with libatomic_ops submodule --- external/bdwgc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/bdwgc b/external/bdwgc index 6f932c1b9af6..a8ddb045cfe2 160000 --- a/external/bdwgc +++ b/external/bdwgc @@ -1 +1 @@ -Subproject commit 6f932c1b9af6d6ab9203131a4a14a961def5ee68 +Subproject commit a8ddb045cfe203516362319715f333f97ede470d From a48baf5ed81200bac72969608598dfe74dcba4d4 Mon Sep 17 00:00:00 2001 From: Lukasz Paczkowski Date: Mon, 28 May 2018 10:07:09 +0200 Subject: [PATCH 239/582] Use extended hash table lookup to properly check for key when value is 0 Fixed in .NET 3.5 memory profiler here: https://github.com/Unity-Technologies/mono/pull/893 https://github.com/Unity-Technologies/mono/pull/918 --- mono/metadata/unity-memory-info.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/mono/metadata/unity-memory-info.c b/mono/metadata/unity-memory-info.c index b9650a69cf3a..0239e976a509 100644 --- a/mono/metadata/unity-memory-info.c +++ b/mono/metadata/unity-memory-info.c @@ -22,8 +22,13 @@ typedef struct CollectMetadataContext static void ContextInsertClass(CollectMetadataContext* context, MonoClass* klass) { - if (klass->inited && g_hash_table_lookup(context->allTypes, klass) == NULL) - g_hash_table_insert(context->allTypes, klass, (gpointer)(context->currentIndex++)); + gpointer orig_key, value; + /* use g_hash_table_lookup_extended as it returns boolean to indicate if value was found. + * If we use g_hash_table_lookup it returns the value which we were comparing to NULL. The problem is + * that 0 is a valid class index and was confusing our logic. + */ + if (klass->inited && !g_hash_table_lookup_extended(context->allTypes, klass, &orig_key, &value)) + g_hash_table_insert(context->allTypes, klass, GINT_TO_POINTER(context->currentIndex++)); } static void CollectHashMapClass(gpointer key, gpointer value, gpointer user_data) @@ -104,18 +109,18 @@ static void CollectImageMetaData(MonoImage* image, gpointer value, CollectMetada static int FindClassIndex(GHashTable* hashTable, MonoClass* klass) { - gpointer value = g_hash_table_lookup(hashTable, klass); + gpointer orig_key, value; - if (!value) + if (!g_hash_table_lookup_extended(hashTable, klass, &orig_key, &value)) return -1; - return (int)value; + return GPOINTER_TO_INT(value); } static void AddMetadataType(gpointer key, gpointer value, gpointer user_data) { MonoClass* klass = (MonoClass*)key; - int index = (int)value; + int index = GPOINTER_TO_INT(value); CollectMetadataContext* context = (CollectMetadataContext*)user_data; MonoMetadataSnapshot* metadata = context->metadata; MonoMetadataType* type = &metadata->types[index]; @@ -562,7 +567,7 @@ static void VerifySnapshot(MonoManagedMemorySnapshot* snapshot, GHashTable* mono while (g_hash_table_iter_next(&iter, &key, NULL)) { MonoImage* image = (MonoImage*)key; - fprintf(file, "MonoImage [0x%016llX] dynamic: %i name: '%s'\n", (void*)image, image->dynamic, image->name); + fprintf(file, "MonoImage [0x%016llX] dynamic: %i name: '%s'\n", (uint64_t)image, image->dynamic, image->name); } /* Verify that we have collected memory sections for all types */ From e5ff80696e3d1edcb27e88c0e1dccaeb671ca33a Mon Sep 17 00:00:00 2001 From: Lukasz Paczkowski Date: Mon, 28 May 2018 12:39:01 +0200 Subject: [PATCH 240/582] Collect additional images and collect missing dynamic classes from MonoImage->reflection_info_unregister_classes --- mono/metadata/unity-memory-info.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/mono/metadata/unity-memory-info.c b/mono/metadata/unity-memory-info.c index 0239e976a509..69ab8cda12f8 100644 --- a/mono/metadata/unity-memory-info.c +++ b/mono/metadata/unity-memory-info.c @@ -65,6 +65,7 @@ static void CollectImageMetaData(MonoImage* image, gpointer value, CollectMetada { int i; MonoTableInfo *tdef = &image->tables[MONO_TABLE_TYPEDEF]; + GSList *list; if (image->dynamic) { @@ -84,6 +85,21 @@ static void CollectImageMetaData(MonoImage* image, gpointer value, CollectMetada } } + /* Some classes are only in this list. + They are added in reflection_setup_internal_class_internal. + */ + list = image->reflection_info_unregister_classes; + + while (list) + { + MonoClass *klass = (MonoClass *)list->data; + + if (klass) + ContextInsertClass(context, klass); + + list = list->next; + } + for (i = 1; i < tdef->rows; ++i) { MonoClass *klass; @@ -586,8 +602,16 @@ static void VerifySnapshot(MonoManagedMemorySnapshot* snapshot, GHashTable* mono static void CollectMonoImage(MonoImage* image, GHashTable* monoImages) { - if (g_hash_table_lookup(monoImages, image) == NULL) - g_hash_table_insert(monoImages, image, image); + if (g_hash_table_lookup(monoImages, image) != NULL) + return; + + g_hash_table_insert(monoImages, image, image); + + if (image->assembly->image != NULL && + image != image->assembly->image) + { + CollectMonoImage(image->assembly->image, monoImages); + } if (image->module_count > 0) { From 295ffc64f51d2d036e27bf2b9635d3363a573b53 Mon Sep 17 00:00:00 2001 From: Lukasz Paczkowski Date: Mon, 28 May 2018 12:55:30 +0200 Subject: [PATCH 241/582] Clear all GC handle types in domain. Same fix as was fixed in .NET 3.5 Mono here: https://github.com/Unity-Technologies/mono/pull/843 --- mono/metadata/boehm-gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index 0a428ce00233..43189f1b973a 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -2027,7 +2027,7 @@ mono_gchandle_free_domain (MonoDomain *domain) { guint type; - for (type = HANDLE_TYPE_MIN; type < HANDLE_PINNED; ++type) { + for (type = HANDLE_TYPE_MIN; type <= HANDLE_PINNED; ++type) { guint slot; HandleData *handles = &gc_handles [type]; lock_handles (handles); From a02c8fdd42620698e9b78acfbb1543a94f68604d Mon Sep 17 00:00:00 2001 From: Lukasz Paczkowski Date: Mon, 28 May 2018 13:33:03 +0200 Subject: [PATCH 242/582] Adding missing bdwgc header include. Protected code with #if HAVE_BDWGC_GC Comment debug code. --- mono/metadata/unity-memory-info.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/mono/metadata/unity-memory-info.c b/mono/metadata/unity-memory-info.c index 69ab8cda12f8..198e919f182d 100644 --- a/mono/metadata/unity-memory-info.c +++ b/mono/metadata/unity-memory-info.c @@ -13,6 +13,10 @@ #include #include +#if HAVE_BDWGC_GC + +#include "external/bdwgc/include/gc.h" + typedef struct CollectMetadataContext { GHashTable *allTypes; @@ -648,7 +652,7 @@ MonoManagedMemorySnapshot* mono_unity_capture_memory_snapshot() FillRuntimeInformation(&snapshot->runtimeInformation); #if _DEBUG - VerifySnapshot(snapshot, monoImages); +// VerifySnapshot(snapshot, monoImages); #endif g_hash_table_destroy(monoImages); @@ -678,4 +682,21 @@ void mono_unity_free_captured_memory_snapshot(MonoManagedMemorySnapshot* snapsho g_free(metadata->types); g_free(snapshot); -} \ No newline at end of file +} + +#else + +MonoManagedMemorySnapshot* mono_unity_capture_memory_snapshot() +{ + MonoManagedMemorySnapshot* snapshot; + snapshot = g_new0(MonoManagedMemorySnapshot, 1); + + return snapshot; +} + +void mono_unity_free_captured_memory_snapshot(MonoManagedMemorySnapshot* snapshot) +{ + g_free(snapshot); +} + +#endif \ No newline at end of file From a485275257a02db9e7b373631aa1b09b77c7accb Mon Sep 17 00:00:00 2001 From: Lukasz Paczkowski Date: Mon, 28 May 2018 13:50:58 +0200 Subject: [PATCH 243/582] Fix conflicting types for 'mono_domain_assembly_foreach' compile error. --- mono/metadata/appdomain.h | 2 +- mono/metadata/domain.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mono/metadata/appdomain.h b/mono/metadata/appdomain.h index 3f87fe08b2b9..6885044693a2 100644 --- a/mono/metadata/appdomain.h +++ b/mono/metadata/appdomain.h @@ -26,7 +26,7 @@ typedef struct _MonoAppDomain MonoAppDomain; typedef struct _MonoJitInfo MonoJitInfo; typedef void (*MonoDomainFunc) (MonoDomain *domain, void* user_data); -typedef void(*MonoDomainAssemblyFunc) (MonoAssembly *assembly, void* user_data); +typedef void (*MonoDomainAssemblyFunc) (MonoAssembly *assembly, void* user_data); MONO_API MonoDomain* mono_init (const char *filename); diff --git a/mono/metadata/domain.c b/mono/metadata/domain.c index 6e029bf0a12a..db707b1aaefa 100644 --- a/mono/metadata/domain.c +++ b/mono/metadata/domain.c @@ -983,7 +983,7 @@ mono_domain_foreach (MonoDomainFunc func, gpointer user_data) } MONO_API void -mono_domain_assembly_foreach (MonoDomain* domain, MonoDomainFunc func, void* user_data) +mono_domain_assembly_foreach (MonoDomain* domain, MonoDomainAssemblyFunc func, void* user_data) { MonoAssembly* assembly; GSList *iter; From d7d2ee3ccfb1e0712a108ad95cc8121989fa309a Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Mon, 28 May 2018 13:56:57 +0200 Subject: [PATCH 244/582] Fix windows --- msvc/libgcbdwgc.vcxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msvc/libgcbdwgc.vcxproj b/msvc/libgcbdwgc.vcxproj index 3adf562efea5..feaf74d78a27 100644 --- a/msvc/libgcbdwgc.vcxproj +++ b/msvc/libgcbdwgc.vcxproj @@ -125,7 +125,7 @@ Disabled $(MONO_LIBBDWGC_INCLUDE_DIR);$(MONO_LIBATOMICS_INCLUDE_DIR);%(AdditionalIncludeDirectories) - WIN32_THREADS;ALL_INTERIOR_POINTERS=1;GC_GCJ_SUPPORT=1;JAVA_FINALIZATION=1;NO_EXECUTE_PERMISSION=1;GC_NO_THREADS_DISCOVERY=1;IGNORE_DYNAMIC_LOADING=1;GC_DONT_REGISTER_MAIN_STATIC_DATA=1;GC_VERSION_MAJOR=7;GC_VERSION_MINOR=4;GC_VERSION_MICRO=0;GC_THREADS=1;USE_MMAP=1;USE_MUNMAP=1; + WIN32_THREADS;ALL_INTERIOR_POINTERS=1;GC_GCJ_SUPPORT=1;JAVA_FINALIZATION=1;NO_EXECUTE_PERMISSION=1;GC_NO_THREADS_DISCOVERY=1;IGNORE_DYNAMIC_LOADING=1;GC_DONT_REGISTER_MAIN_STATIC_DATA=1;GC_VERSION_MAJOR=7;GC_VERSION_MINOR=7;GC_VERSION_MICRO=0;GC_THREADS=1;USE_MMAP=1;USE_MUNMAP=1; true EnableFastChecks From 10bc6d8ee5cbf449c6b1090771fba0e189a8ae0b Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Mon, 28 May 2018 14:12:44 +0200 Subject: [PATCH 245/582] Update Boehm --- external/bdwgc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/bdwgc b/external/bdwgc index a8ddb045cfe2..1d1432724b81 160000 --- a/external/bdwgc +++ b/external/bdwgc @@ -1 +1 @@ -Subproject commit a8ddb045cfe203516362319715f333f97ede470d +Subproject commit 1d1432724b818f4f27247f11d8a031127b67a648 From 9cb20823a206c8b386fc226d3a08331bc03a414e Mon Sep 17 00:00:00 2001 From: Lukasz Paczkowski Date: Mon, 28 May 2018 14:45:03 +0200 Subject: [PATCH 246/582] Remove glib.h dependency from metadata.h. Move mono_metadata_image_set_foreach to metadata-internals.h. --- mono/metadata/metadata-internals.h | 4 ++++ mono/metadata/metadata.c | 6 +++--- mono/metadata/metadata.h | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mono/metadata/metadata-internals.h b/mono/metadata/metadata-internals.h index 1ad92b319a65..dd10e13c65c6 100644 --- a/mono/metadata/metadata-internals.h +++ b/mono/metadata/metadata-internals.h @@ -621,6 +621,8 @@ typedef struct { char *aot_options; } MonoAotCacheConfig; +typedef void(*MonoImageSetFunc) (MonoImageSet *imageSet, void* user_data); + #define MONO_SIZEOF_METHOD_SIGNATURE (sizeof (struct _MonoMethodSignature) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P) static inline gboolean @@ -722,6 +724,8 @@ mono_image_set_unlock (MonoImageSet *set); char* mono_image_set_strdup (MonoImageSet *set, const char *s); +void mono_metadata_image_set_foreach(MonoImageSetFunc func, gpointer user_data); + #define mono_image_set_new0(image,type,size) ((type *) mono_image_set_alloc0 (image, sizeof (type)* (size))) gboolean diff --git a/mono/metadata/metadata.c b/mono/metadata/metadata.c index 1d3a146ca83d..75acfa4d9880 100644 --- a/mono/metadata/metadata.c +++ b/mono/metadata/metadata.c @@ -5082,7 +5082,7 @@ mono_metadata_generic_class_is_valuetype (MonoGenericClass *gclass) typedef struct { - GFunc func; + MonoGenericClassFunc func; gpointer user_data; } GenericClassForeachData; @@ -5095,7 +5095,7 @@ generic_class_foreach_callback(gpointer key, gpointer value, gpointer user_data) } void -mono_metadata_generic_class_foreach(GFunc func, gpointer user_data) +mono_metadata_generic_class_foreach(MonoGenericClassFunc func, void* user_data) { GenericClassForeachData data; guint i; @@ -5119,7 +5119,7 @@ mono_metadata_generic_class_foreach(GFunc func, gpointer user_data) } void -mono_metadata_image_set_foreach(GFunc func, gpointer user_data) +mono_metadata_image_set_foreach(MonoImageSetFunc func, gpointer user_data) { GenericClassForeachData data; guint i; diff --git a/mono/metadata/metadata.h b/mono/metadata/metadata.h index 2888a9317584..a85dc2735ba6 100644 --- a/mono/metadata/metadata.h +++ b/mono/metadata/metadata.h @@ -10,7 +10,6 @@ #include #include #include -#include MONO_BEGIN_DECLS @@ -333,6 +332,8 @@ typedef enum { MONO_PARSE_FIELD } MonoParseTypeMode; +typedef void(*MonoGenericClassFunc) (MonoGenericClass *genericClass, void* user_data); + MONO_API mono_bool mono_type_is_byref (MonoType *type); @@ -424,8 +425,7 @@ MONO_API int mono_type_stack_size (MonoType *type, MONO_API mono_bool mono_type_generic_inst_is_valuetype (MonoType *type); MONO_API mono_bool mono_metadata_generic_class_is_valuetype (MonoGenericClass *gclass); -MONO_API void mono_metadata_image_set_foreach(GFunc func, gpointer user_data); -MONO_API void mono_metadata_generic_class_foreach(GFunc func, gpointer user_data); +MONO_API void mono_metadata_generic_class_foreach(MonoGenericClassFunc func, void* user_data); MONO_API unsigned int mono_metadata_type_hash (MonoType *t1); MONO_API mono_bool mono_metadata_type_equal (MonoType *t1, MonoType *t2); From b7c8a546010264e02d85667a48cb94af73feeff4 Mon Sep 17 00:00:00 2001 From: Lukasz Paczkowski Date: Mon, 28 May 2018 14:46:08 +0200 Subject: [PATCH 247/582] Remove GFunc callback casting. --- mono/metadata/unity-memory-info.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mono/metadata/unity-memory-info.c b/mono/metadata/unity-memory-info.c index 198e919f182d..a81b0a28711f 100644 --- a/mono/metadata/unity-memory-info.c +++ b/mono/metadata/unity-memory-info.c @@ -56,10 +56,9 @@ static void CollectHashMapListClasses(gpointer key, gpointer value, gpointer use } } -static void CollectGenericClass(gpointer value, gpointer user_data) +static void CollectGenericClass(MonoGenericClass* genericClass, gpointer user_data) { CollectMetadataContext* context = (CollectMetadataContext*)user_data; - MonoGenericClass* genericClass = (MonoGenericClass*)value; if (genericClass->cached_class != NULL) ContextInsertClass(context, genericClass->cached_class); @@ -349,7 +348,7 @@ static void IncrementCountForImageSetMemPoolNumChunks(MonoImageSet *imageSet, vo static int MonoImageSetsMemPoolNumChunks() { int count = 0; - mono_metadata_image_set_foreach((GFunc)IncrementCountForImageSetMemPoolNumChunks, &count); + mono_metadata_image_set_foreach(IncrementCountForImageSetMemPoolNumChunks, &count); return count; } @@ -410,7 +409,7 @@ static void* CaptureHeapInfo(void* user) // Allocate memory for each image->class_cache hash table. g_hash_table_foreach(monoImages, (GHFunc)AllocateMemoryForImageClassCache, &iterationContext); // Allocate memory for each image->class_cache hash table. - mono_metadata_image_set_foreach((GFunc)AllocateMemoryForImageSetMemPool, &iterationContext); + mono_metadata_image_set_foreach(AllocateMemoryForImageSetMemPool, &iterationContext); return NULL; } @@ -512,7 +511,7 @@ static void CaptureManagedHeap(MonoManagedHeap* heap, GHashTable* monoImages) mono_mempool_foreach_block(domain->mp, CopyMemPoolChunk, &iterationContext); g_hash_table_foreach(monoImages, (GHFunc)CopyImageMemPool, &iterationContext); g_hash_table_foreach(monoImages, (GHFunc)CopyImageClassCache, &iterationContext); - mono_metadata_image_set_foreach((GFunc)CopyImageSetMemPool, &iterationContext); + mono_metadata_image_set_foreach(CopyImageSetMemPool, &iterationContext); GC_start_world_external(); } From 75c629425ebdae047ef7c69b121cae08b966195a Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Mon, 28 May 2018 15:26:50 +0200 Subject: [PATCH 248/582] Fix windows --- msvc/libgcbdwgc.vcxproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/msvc/libgcbdwgc.vcxproj b/msvc/libgcbdwgc.vcxproj index feaf74d78a27..8a288646dc80 100644 --- a/msvc/libgcbdwgc.vcxproj +++ b/msvc/libgcbdwgc.vcxproj @@ -84,7 +84,7 @@ Disabled $(MONO_LIBBDWGC_INCLUDE_DIR);$(MONO_LIBATOMICS_INCLUDE_DIR);%(AdditionalIncludeDirectories) - WIN32_THREADS;ALL_INTERIOR_POINTERS=1;GC_GCJ_SUPPORT=1;JAVA_FINALIZATION=1;NO_EXECUTE_PERMISSION=1;GC_NO_THREADS_DISCOVERY=1;IGNORE_DYNAMIC_LOADING=1;GC_DONT_REGISTER_MAIN_STATIC_DATA=1;GC_VERSION_MAJOR=7;GC_VERSION_MINOR=4;GC_VERSION_MICRO=0;GC_THREADS=1;USE_MMAP=1;USE_MUNMAP=1;GC_INSIDE_DLL=1 + WIN32_THREADS;ALL_INTERIOR_POINTERS=1;GC_GCJ_SUPPORT=1;JAVA_FINALIZATION=1;NO_EXECUTE_PERMISSION=1;GC_NO_THREADS_DISCOVERY=1;IGNORE_DYNAMIC_LOADING=1;GC_DONT_REGISTER_MAIN_STATIC_DATA=1;GC_VERSION_MAJOR=7;GC_VERSION_MINOR=7;GC_VERSION_MICRO=0;GC_THREADS=1;USE_MMAP=1;USE_MUNMAP=1;GC_INSIDE_DLL=1 true EnableFastChecks @@ -105,7 +105,7 @@ MinSpace $(MONO_LIBBDWGC_INCLUDE_DIR);$(MONO_LIBATOMICS_INCLUDE_DIR);%(AdditionalIncludeDirectories) - WIN32_THREADS;ALL_INTERIOR_POINTERS=1;GC_GCJ_SUPPORT=1;JAVA_FINALIZATION=1;NO_EXECUTE_PERMISSION=1;GC_NO_THREADS_DISCOVERY=1;IGNORE_DYNAMIC_LOADING=1;GC_DONT_REGISTER_MAIN_STATIC_DATA=1;GC_VERSION_MAJOR=7;GC_VERSION_MINOR=4;GC_VERSION_MICRO=0;GC_THREADS=1;USE_MMAP=1;USE_MUNMAP=1; + WIN32_THREADS;ALL_INTERIOR_POINTERS=1;GC_GCJ_SUPPORT=1;JAVA_FINALIZATION=1;NO_EXECUTE_PERMISSION=1;GC_NO_THREADS_DISCOVERY=1;IGNORE_DYNAMIC_LOADING=1;GC_DONT_REGISTER_MAIN_STATIC_DATA=1;GC_VERSION_MAJOR=7;GC_VERSION_MINOR=7;GC_VERSION_MICRO=0;GC_THREADS=1;USE_MMAP=1;USE_MUNMAP=1; ProgramDatabase @@ -148,7 +148,7 @@ MinSpace $(MONO_LIBBDWGC_INCLUDE_DIR);$(MONO_LIBATOMICS_INCLUDE_DIR);%(AdditionalIncludeDirectories) - WIN32_THREADS;ALL_INTERIOR_POINTERS=1;GC_GCJ_SUPPORT=1;JAVA_FINALIZATION=1;NO_EXECUTE_PERMISSION=1;GC_NO_THREADS_DISCOVERY=1;IGNORE_DYNAMIC_LOADING=1;GC_DONT_REGISTER_MAIN_STATIC_DATA=1;GC_VERSION_MAJOR=7;GC_VERSION_MINOR=4;GC_VERSION_MICRO=0;GC_THREADS=1;USE_MMAP=1;USE_MUNMAP=1; + WIN32_THREADS;ALL_INTERIOR_POINTERS=1;GC_GCJ_SUPPORT=1;JAVA_FINALIZATION=1;NO_EXECUTE_PERMISSION=1;GC_NO_THREADS_DISCOVERY=1;IGNORE_DYNAMIC_LOADING=1;GC_DONT_REGISTER_MAIN_STATIC_DATA=1;GC_VERSION_MAJOR=7;GC_VERSION_MINOR=7;GC_VERSION_MICRO=0;GC_THREADS=1;USE_MMAP=1;USE_MUNMAP=1; ProgramDatabase From 5fbf2c40e4480c53225fcf6dffa953d028f7c885 Mon Sep 17 00:00:00 2001 From: Lukasz Date: Wed, 30 May 2018 09:04:27 +0200 Subject: [PATCH 249/582] Update bdwgc to latest unity-release-7_4 revision --- external/bdwgc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/bdwgc b/external/bdwgc index 8440aa8cdffd..b46167f4118a 160000 --- a/external/bdwgc +++ b/external/bdwgc @@ -1 +1 @@ -Subproject commit 8440aa8cdffda0b9aa324a0e63f950f05551ab27 +Subproject commit b46167f4118a03a96bb8055639e64a9e4e73cab5 From fb01bbabb70b40063f5ab6fa1565fd4efaf488de Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Wed, 30 May 2018 16:13:14 +0200 Subject: [PATCH 250/582] Use separately built libgc-static to make sure we actually statically link bdwgc --- external/bdwgc | 2 +- mono/mini/Makefile.am.in | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/external/bdwgc b/external/bdwgc index 1d1432724b81..8499689b228e 160000 --- a/external/bdwgc +++ b/external/bdwgc @@ -1 +1 @@ -Subproject commit 1d1432724b818f4f27247f11d8a031127b67a648 +Subproject commit 8499689b228e94eea44aecd5722578449e0e0b48 diff --git a/mono/mini/Makefile.am.in b/mono/mini/Makefile.am.in index aa472da5d10d..535e2069daeb 100755 --- a/mono/mini/Makefile.am.in +++ b/mono/mini/Makefile.am.in @@ -18,8 +18,7 @@ libgc_libs=$(monodir)/libgc/libmonogc.la libgc_static_libs=$(monodir)/libgc/libmonogc-static.la endif -libbdwgc_libs=$(monodir)/external/bdwgc/libgc.la -libbdwgc_static_libs=$(monodir)/external/bdwgc/libgc.la +libbdwgc_libs=$(monodir)/external/bdwgc/libgc-static.la boehm_libs= \ $(monodir)/mono/metadata/libmonoruntime.la \ @@ -49,7 +48,7 @@ bdwgc_static_libs= \ $(monodir)/mono/metadata/libmonoruntimebdwgc-static.la \ $(monodir)/mono/utils/libmonoutils.la \ $(GLIB_LIBS) $(LIBICONV) \ - $(libbdwgc_static_libs) + $(libbdwgc_libs) sgen_static_libs = \ $(monodir)/mono/metadata/libmonoruntimesgen-static.la \ From 8e0947992e6aab128bc50312754d7538c305f2ec Mon Sep 17 00:00:00 2001 From: Michael Voorhees Date: Thu, 5 Apr 2018 16:05:59 -0400 Subject: [PATCH 251/582] Clean up mscorlib link xml Removes some duplication of preservations Consolidations some preservations under a single element --- .../corlib/LinkerDescriptor/mscorlib.xml | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/mcs/class/corlib/LinkerDescriptor/mscorlib.xml b/mcs/class/corlib/LinkerDescriptor/mscorlib.xml index 1be0d4cef368..dd498a1a6fe3 100644 --- a/mcs/class/corlib/LinkerDescriptor/mscorlib.xml +++ b/mcs/class/corlib/LinkerDescriptor/mscorlib.xml @@ -4,7 +4,6 @@ - @@ -498,13 +497,6 @@ note: there's no fields (static type) but that will mark the type itself --> - - - - - - - @@ -546,8 +538,12 @@ - - + + + + + + @@ -718,13 +714,18 @@ + + + + + @@ -735,18 +736,6 @@ - - - - - - - - - - - - From 066398c0690f56419a2d4d10e388bc27d5782934 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Tue, 29 May 2018 15:15:39 -0400 Subject: [PATCH 252/582] Use the ProfileStubber utility This change ensures that the unityjit and unityaot profiles match the .NET 4.7.1 API by using the profile stubber to modify the IL code in the class library assemblies. --- external/buildscripts/build.pl | 26 +++++++++++++ external/buildscripts/stub_classlibs.pl | 52 +++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 external/buildscripts/stub_classlibs.pl diff --git a/external/buildscripts/build.pl b/external/buildscripts/build.pl index 4211a77b3069..1622b44ddd3f 100644 --- a/external/buildscripts/build.pl +++ b/external/buildscripts/build.pl @@ -180,6 +180,8 @@ # abs_path ends up returning an empty string $externalBuildDeps = abs_path($externalBuildDeps) if (-d $externalBuildDeps); +my $extraBuildTools = "$monoroot/../../mono-build-tools-extra/build"; + my $existingExternalMonoRoot = "$externalBuildDeps/MonoBleedingEdge"; my $existingExternalMono = ""; my $existingExternalMonoBinDir = ""; @@ -269,6 +271,23 @@ push @configureparams, "--with-monotouch=no"; } + if (!(-d "$extraBuildTools")) + { + # Check out on the fly + print(">>> Checking out mono build tools extra to : $extraBuildTools\n"); + my $repo = 'git@gitlab.internal.unity3d.com:vm/mono-build-tools-extra.git'; + print(">>> Cloning $repo at $extraBuildTools\n"); + my $checkoutResult = system("git", "clone", "--recurse-submodules", $repo, "$extraBuildTools"); + + if ($checkoutResult ne 0) + { + die("Failed to checkout mono build tools extra\n"); + } + + # Only clean up if the dir exists. Otherwise abs_path will return empty string + $extraBuildTools = abs_path($extraBuildTools) if (-d $extraBuildTools); + } + if ($existingMonoRootPath eq "") { print(">>> No existing mono supplied. Checking for external...\n"); @@ -1415,6 +1434,13 @@ } chdir("$monoroot"); + + my $stubResult = system("perl", "$buildscriptsdir/stub_classlibs.pl"); + + if ($stubResult ne 0) + { + die("Failed to run the profile stubber\n"); + } } } else diff --git a/external/buildscripts/stub_classlibs.pl b/external/buildscripts/stub_classlibs.pl new file mode 100644 index 000000000000..83192f3cb1f9 --- /dev/null +++ b/external/buildscripts/stub_classlibs.pl @@ -0,0 +1,52 @@ +use Cwd; +use Cwd 'abs_path'; +use File::Basename; +use File::Path; + +if($^O ne "darwin") +{ + print ">>> The ProfileStubber is only built and run in the class library build on macOS\n"; + exit +} + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $extraBuildTools = "$monoroot/../../mono-build-tools-extra/build"; + +print ">>> Building the ProfileStubber utility\n"; + +my $result = system("xbuild", + "$extraBuildTools/mono-build-tools-extra.sln", + "/p:Configuration=Release"); + +if ($result ne 0) +{ + die("Failed to build ProfileStubber utility\n"); +} + +my $profileRoot = "tmp/lib/mono"; +my $referenceProfile = "$profileRoot/4.7.1-api"; + +print ">>> Modifying the unityjit profile to match the .NET 4.7.1 API\n"; + +$result = system("mono", + "$extraBuildTools/build/ProfileStubber.exe", + "--reference-profile=$referenceProfile", + "--stub-profile=$profileRoot/unityjit"); + +if ($result ne 0) +{ + die("Failed to stub the unityjit profile\n"); +} + +print ">>> Modifying the unityaot profile to match the .NET 4.7.1 API\n"; + +$result = system("mono", + "$extraBuildTools/build/ProfileStubber.exe", + "--reference-profile=$referenceProfile", + "--stub-profile=$profileRoot/unityaot"); + +if ($result ne 0) +{ + die("Failed to stub the unityaot profile\n"); +} From d90469b9abc8713a5d9f0998dbc3725e117756c7 Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Fri, 1 Jun 2018 09:53:57 +0200 Subject: [PATCH 253/582] Update bdwgc --- external/bdwgc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/bdwgc b/external/bdwgc index 8499689b228e..b6af81bd96fd 160000 --- a/external/bdwgc +++ b/external/bdwgc @@ -1 +1 @@ -Subproject commit 8499689b228e94eea44aecd5722578449e0e0b48 +Subproject commit b6af81bd96fd1ef8a29f9efec3ca39a03d37db91 From 64c364ee9e2d91306d1133e0977b73e00d1e3a54 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 1 Jun 2018 15:26:45 -0400 Subject: [PATCH 254/582] Avoid temporary allocation in List.AddRange (case 1041305) --- .../mscorlib/system/collections/generic/list.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mcs/class/referencesource/mscorlib/system/collections/generic/list.cs b/mcs/class/referencesource/mscorlib/system/collections/generic/list.cs index 44210ced5e3f..2c68adc18381 100644 --- a/mcs/class/referencesource/mscorlib/system/collections/generic/list.cs +++ b/mcs/class/referencesource/mscorlib/system/collections/generic/list.cs @@ -732,9 +732,13 @@ public void InsertRange(int index, IEnumerable collection) { Array.Copy(_items, index+count, _items, index*2, _size-index); } else { +#if MONO + c.CopyTo(_items, index); +#else T[] itemsToInsert = new T[count]; c.CopyTo(itemsToInsert, 0); itemsToInsert.CopyTo(_items, index); +#endif } _size += count; } From 1b70466acdccba21d0e3dff26381cb474a68b80f Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Mon, 4 Jun 2018 21:36:23 +0200 Subject: [PATCH 255/582] Update bdwgc (Fix Android) --- external/bdwgc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/bdwgc b/external/bdwgc index b6af81bd96fd..5d8db990f8b3 160000 --- a/external/bdwgc +++ b/external/bdwgc @@ -1 +1 @@ -Subproject commit b6af81bd96fd1ef8a29f9efec3ca39a03d37db91 +Subproject commit 5d8db990f8b307f0f5f6a0f1939a52ba72190e14 From 9f67753dd17bb82c7d1d0be8064688d63e7dbda5 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 5 Jun 2018 15:14:39 -0400 Subject: [PATCH 256/582] Remove resources/charinfo.nlp from mscrolib since we are using CoreRT implementation of CharUnicodeInfo with managed data --- mcs/class/corlib/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/mcs/class/corlib/Makefile b/mcs/class/corlib/Makefile index 910f7b672f4c..a5cfd954198a 100644 --- a/mcs/class/corlib/Makefile +++ b/mcs/class/corlib/Makefile @@ -42,7 +42,6 @@ MODULE_DEPS = $(IL_REPLACE) endif RESOURCE_FILES = \ - resources/charinfo.nlp \ resources/collation.core.bin \ resources/collation.tailoring.bin \ resources/collation.cjkCHS.bin \ From def426460713d558d11c98cf6e0469d322d1f83f Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Wed, 6 Jun 2018 01:30:18 +1000 Subject: [PATCH 257/582] initial test checkin Additional Test Basic Tests Pass add time conversion tests all test pass cleanup change from int* to MonoBoolean* Match mono code conventions cleanup classlib changes Use mono format for tests add test for singapore, as this is a timezone that tripped us up in the past --- mcs/class/corlib/System/TimeZone.cs | 2 +- mcs/class/corlib/System/TimeZoneInfo.Unity.cs | 131 ++++-- .../corlib/Test/System/TimeZoneInfoTest.cs | 377 +++++++++++++++++- mono/metadata/icall-internals.h | 2 +- mono/metadata/unity-icall.c | 96 ++--- 5 files changed, 497 insertions(+), 111 deletions(-) diff --git a/mcs/class/corlib/System/TimeZone.cs b/mcs/class/corlib/System/TimeZone.cs index ba24b44788fa..b32195359662 100644 --- a/mcs/class/corlib/System/TimeZone.cs +++ b/mcs/class/corlib/System/TimeZone.cs @@ -221,7 +221,7 @@ public override bool IsDaylightSavingTime (DateTime dateTime) // name[1]: name of this timezone when daylight saving. #if UNITY [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern bool GetTimeZoneData (int year, out Int64[] data, out string[] names); + public static extern bool GetTimeZoneData (int year, out Int64[] data, out string[] names, out bool daylight_inverted); #endif } } diff --git a/mcs/class/corlib/System/TimeZoneInfo.Unity.cs b/mcs/class/corlib/System/TimeZoneInfo.Unity.cs index 9100a328670d..bc79e4139930 100644 --- a/mcs/class/corlib/System/TimeZoneInfo.Unity.cs +++ b/mcs/class/corlib/System/TimeZoneInfo.Unity.cs @@ -22,8 +22,8 @@ namespace System { public partial class TimeZoneInfo { enum TimeZoneData { - DaylightSavingStartIdx, - DaylightSavingEndIdx, + DaylightSavingFirstTransitionIdx, + DaylightSavingSecondTransitionIdx, UtcOffsetIdx, AdditionalDaylightOffsetIdx }; @@ -34,12 +34,14 @@ enum TimeZoneNames DaylightNameIdx }; - static AdjustmentRule CreateAdjustmentRule(int year, out Int64[] data, out string[] names, string standardNameCurrentYear, string daylightNameCurrentYear) + static List CreateAdjustmentRule (int year, out Int64[] data, out string[] names, string standardNameCurrentYear, string daylightNameCurrentYear) { - if(!System.CurrentSystemTimeZone.GetTimeZoneData(year, out data, out names)) - return null; - var startTime = new DateTime (data[(int)TimeZoneData.DaylightSavingStartIdx]); - var endTime = new DateTime (data[(int)TimeZoneData.DaylightSavingEndIdx]); + List rulesForYear = new List (); + bool dst_inverted; + if (!System.CurrentSystemTimeZone.GetTimeZoneData(year, out data, out names, out dst_inverted)) + return rulesForYear; + var firstTransition = new DateTime (data[(int)TimeZoneData.DaylightSavingFirstTransitionIdx]); + var secondTransition = new DateTime (data[(int)TimeZoneData.DaylightSavingSecondTransitionIdx]); var daylightOffset = new TimeSpan (data[(int)TimeZoneData.AdditionalDaylightOffsetIdx]); /* C# TimeZoneInfo does not support timezones the same way as unix. In unix, timezone files are specified by region such as @@ -48,73 +50,116 @@ static AdjustmentRule CreateAdjustmentRule(int year, out Int64[] data, out strin * savings time. As such we'll only generate timezone rules for a region at the times associated with the timezone of the current year. */ if(standardNameCurrentYear != names[(int)TimeZoneNames.StandardNameIdx]) - return null; + return rulesForYear; if(daylightNameCurrentYear != names[(int)TimeZoneNames.DaylightNameIdx]) - return null; - - var dlsTransitionStart = TransitionTime.CreateFixedDateRule(new DateTime(1,1,1).Add(startTime.TimeOfDay), - startTime.Month, startTime.Day); - var dlsTransitionEnd = TransitionTime.CreateFixedDateRule(new DateTime(1,1,1).Add(endTime.TimeOfDay), - endTime.Month, endTime.Day); - - var rule = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(new DateTime(year, 1, 1), - new DateTime(year, 12, DateTime.DaysInMonth(year, 12)), - daylightOffset, - dlsTransitionStart, - dlsTransitionEnd); - return rule; + return rulesForYear; + + var beginningOfYear = new DateTime (year, 1, 1, 0, 0, 0, 0); + var endOfYearDay = new DateTime (year, 12, DateTime.DaysInMonth (year, 12)); + var endOfYearMaxTimeout = new DateTime (year, 12, DateTime.DaysInMonth(year, 12), 23, 59, 59, 999); + + if (!dst_inverted) { + // For daylight savings time that happens between jan and dec, create a rule from jan 1 to dec 31 (the entire year) + + // This rule (for the whole year) specifies the starting and ending months of daylight savings time. + var startOfDaylightSavingsTime = TransitionTime.CreateFixedDateRule (new DateTime (1,1,1).Add (firstTransition.TimeOfDay), + firstTransition.Month, firstTransition.Day); + var endOfDaylightSavingsTime = TransitionTime.CreateFixedDateRule (new DateTime (1,1,1).Add (secondTransition.TimeOfDay), + secondTransition.Month, secondTransition.Day); + + var fullYearRule = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule (beginningOfYear, + endOfYearDay, + daylightOffset, + startOfDaylightSavingsTime, + endOfDaylightSavingsTime); + rulesForYear.Add (fullYearRule); + } else { + // Some timezones (Australia/Sydney) have daylight savings over the new year. + // Our icall returns the transitions for the current year, so we need two adjustment rules each year for this case + + // The first rule specifies daylight savings starting at jan 1 and ending at the first transition. + var startOfFirstDaylightSavingsTime = TransitionTime.CreateFixedDateRule (new DateTime (1,1,1), 1, 1); + var endOfFirstDaylightSavingsTime = TransitionTime.CreateFixedDateRule (new DateTime (1,1,1).Add (firstTransition.TimeOfDay), + firstTransition.Month, firstTransition.Day); + + var transitionOutOfDaylightSavingsRule = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule ( + new DateTime (year, 1, 1), + new DateTime (firstTransition.Year, firstTransition.Month, firstTransition.Day), + daylightOffset, + startOfFirstDaylightSavingsTime, + endOfFirstDaylightSavingsTime); + rulesForYear.Add (transitionOutOfDaylightSavingsRule); + + // The second rule specifies daylight savings time starting the day after we transition out of daylight savings + // and ending at the end of the year, with daylight savings starting near the end and ending on the last day of the year + var startOfSecondDaylightSavingsTime = TransitionTime.CreateFixedDateRule (new DateTime (1,1,1).Add (secondTransition.TimeOfDay), + secondTransition.Month, secondTransition.Day); + var endOfSecondDaylightSavingsTime = TransitionTime.CreateFixedDateRule (new DateTime (1,1,1).Add (endOfYearMaxTimeout.TimeOfDay), + endOfYearMaxTimeout.Month, endOfYearMaxTimeout.Day); + + var transitionIntoDaylightSavingsRule = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule ( + new DateTime (firstTransition.Year, firstTransition.Month, firstTransition.Day).AddDays (1), + endOfYearDay, + daylightOffset, + startOfSecondDaylightSavingsTime, + endOfSecondDaylightSavingsTime); + rulesForYear.Add (transitionIntoDaylightSavingsRule); + } + return rulesForYear; } static TimeZoneInfo CreateLocalUnity () { Int64[] data; string[] names; + //Some timezones start in DST on january first and disable it during the summer + bool dst_inverted; int currentYear = DateTime.UtcNow.Year; - if (!System.CurrentSystemTimeZone.GetTimeZoneData (currentYear, out data, out names)) + if (!System.CurrentSystemTimeZone.GetTimeZoneData (currentYear, out data, out names, out dst_inverted)) throw new NotSupportedException ("Can't get timezone name."); - var utcOffsetTS = TimeSpan.FromTicks(data[(int)TimeZoneData.UtcOffsetIdx]); + var utcOffsetTS = TimeSpan.FromTicks (data[(int)TimeZoneData.UtcOffsetIdx]); char utcOffsetSign = (utcOffsetTS >= TimeSpan.Zero) ? '+' : '-'; - string displayName = "(GMT" + utcOffsetSign + utcOffsetTS.ToString(@"hh\:mm") + ") Local Time"; + string displayName = "(GMT" + utcOffsetSign + utcOffsetTS.ToString (@"hh\:mm") + ") Local Time"; string standardDisplayName = names[(int)TimeZoneNames.StandardNameIdx]; string daylightDisplayName = names[(int)TimeZoneNames.DaylightNameIdx]; - var adjustmentList = new List(); - bool disableDaylightSavings = data[(int)TimeZoneData.AdditionalDaylightOffsetIdx] <= 0; + var adjustmentRulesList = new List (); + bool disableDaylightSavings = data[(int)TimeZoneData.AdditionalDaylightOffsetIdx] == 0; //If the timezone supports daylight savings time, generate adjustment rules for the timezone - if(!disableDaylightSavings) - { + if (!disableDaylightSavings) { //the icall only supports years from 1970 through 2037. int firstSupportedDate = 1971; int lastSupportedDate = 2037; //first, generate rules from the current year until the last year mktime is guaranteed to supports - for(int year = currentYear; year <= lastSupportedDate; year++) - { - var rule = CreateAdjustmentRule(year, out data, out names, standardDisplayName, daylightDisplayName); - //breakout if timezone changes, or fails - if(rule == null) + for (int year = currentYear; year <= lastSupportedDate; year++) { + var rulesForCurrentYear = CreateAdjustmentRule (year, out data, out names, standardDisplayName, daylightDisplayName); + //breakout if no more rules + if (rulesForCurrentYear.Count > 0) + adjustmentRulesList.AddRange (rulesForCurrentYear); + else break; - adjustmentList.Add(rule); + } - for(int year = currentYear - 1; year >= firstSupportedDate; year--) - { - var rule = CreateAdjustmentRule(year, out data, out names, standardDisplayName, daylightDisplayName); - //breakout if timezone changes, or fails - if(rule == null) + for (int year = currentYear - 1; year >= firstSupportedDate; year--) { + var rulesForCurrentYear = CreateAdjustmentRule (year, out data, out names, standardDisplayName, daylightDisplayName); + //breakout if no more rules + if (rulesForCurrentYear.Count > 0) + adjustmentRulesList.AddRange (rulesForCurrentYear); + else break; - adjustmentList.Add(rule); } - adjustmentList.Sort( (rule1, rule2) => rule1.DateStart.CompareTo(rule2.DateStart) ); + adjustmentRulesList.Sort ( (rule1, rule2) => rule1.DateStart.CompareTo (rule2.DateStart) ); } - return TimeZoneInfo.CreateCustomTimeZone("Local", + return TimeZoneInfo.CreateCustomTimeZone ("Local", utcOffsetTS, displayName, standardDisplayName, daylightDisplayName, - adjustmentList.ToArray(), + adjustmentRulesList.ToArray (), disableDaylightSavings); } } diff --git a/mcs/class/corlib/Test/System/TimeZoneInfoTest.cs b/mcs/class/corlib/Test/System/TimeZoneInfoTest.cs index b6384d11162e..25adc0c7d0a8 100644 --- a/mcs/class/corlib/Test/System/TimeZoneInfoTest.cs +++ b/mcs/class/corlib/Test/System/TimeZoneInfoTest.cs @@ -124,13 +124,388 @@ public void LocalId () } catch (DllNotFoundException e) { return; } -#if !MONOTOUCH && !XAMMAC +#if !MONOTOUCH && !XAMMAC && !UNITY // this assumption is incorrect for iOS, tvO, watchOS and OSX Assert.IsTrue (TimeZoneInfo.Local.Id != "Local", "Local timezone id should not be \"Local\""); #endif } } +#if UNITY + [TestFixture] + public class UnityTests + { + public TimeZoneInfo GetLocalUnity () + { + return (TimeZoneInfo)typeof (TimeZoneInfo).GetMethod ("CreateLocalUnity", BindingFlags.NonPublic | BindingFlags.Static).Invoke (null, null); + } + + public void AssertNoDLS (TimeZoneInfo local, DateTime beforeDLSStart, DateTime afterDLSStart, DateTime beforeDLSEnd, DateTime afterDLSEnd) + { + Assert.IsFalse (local.IsDaylightSavingTime(beforeDLSStart), "Expected Not Daylight Savings " + beforeDLSStart.ToString ()); + Assert.IsFalse (local.IsDaylightSavingTime(afterDLSStart), "Expected Not Daylight Savings " + afterDLSStart.ToString ()); + Assert.IsFalse (local.IsDaylightSavingTime(beforeDLSEnd), "Expected Not Daylight Savings " + beforeDLSEnd.ToString ()); + Assert.IsFalse (local.IsDaylightSavingTime(afterDLSEnd), "Expected Not Daylight Savings " + afterDLSEnd.ToString ()); + } + + public void AssertDLS (TimeZoneInfo local, DateTime beforeDLSStart, DateTime afterDLSStart, DateTime beforeDLSEnd, DateTime afterDLSEnd) + { + Assert.IsFalse (local.IsDaylightSavingTime (beforeDLSStart), "Expected Not Daylight Savings " + beforeDLSStart.ToString ()); + Assert.IsTrue (local.IsDaylightSavingTime (afterDLSStart), "Expected Daylight Savings " + afterDLSStart.ToString ()); + Assert.IsTrue (local.IsDaylightSavingTime (beforeDLSEnd), "Expected Daylight Savings " + beforeDLSEnd.ToString ()); + Assert.IsFalse (local.IsDaylightSavingTime (afterDLSEnd), "Expected Not Daylight Savings " + afterDLSEnd.ToString ()); + } + + //Similar to Above but for Timezones that begin in daylight savings time jan 1 + public void AssertDLSInverse (TimeZoneInfo local, DateTime beforeDLSEnd, DateTime afterDLSEnd, DateTime beforeDLSStart, DateTime afterDLSStart) + { + Assert.IsTrue (local.IsDaylightSavingTime (beforeDLSEnd), "Expected Daylight Savings " + beforeDLSEnd.ToString ()); + Assert.IsFalse (local.IsDaylightSavingTime (afterDLSEnd), "Expected Not Daylight Savings " + afterDLSEnd.ToString ()); + Assert.IsFalse (local.IsDaylightSavingTime (beforeDLSStart), "Expected Not Daylight Savings " + beforeDLSStart.ToString ()); + Assert.IsTrue (local.IsDaylightSavingTime (afterDLSStart), "Expected Daylight Savings " + afterDLSStart.ToString ()); + } + + [Test] + public void CanGetLocalUnity () + { + TimeZoneInfo local = GetLocalUnity (); + Assert.IsNotNull (local); + Assert.IsTrue (local.Id == "Local"); + } + + [Test] + public void LocalIsNotLocalUnityOnDesktop () + { + TimeZoneInfo local = GetLocalUnity (); + Assert.IsNotNull (local); + Assert.AreNotEqual (local, TimeZoneInfo.Local); + } + + [Test] + public void EST () + { + Environment.SetEnvironmentVariable ("TZ", "America/New_York"); + TimeZoneInfo local = GetLocalUnity (); + + Assert.IsNotNull (local); + Assert.AreEqual ("-05:00:00", local.BaseUtcOffset.ToString ()); + Assert.AreEqual ("Local", local.Id); + Assert.AreEqual ("EST", local.StandardName); + Assert.AreEqual ("EDT", local.DaylightName); + Assert.IsTrue (local.SupportsDaylightSavingTime); + Assert.AreEqual ("(GMT-05:00) Local Time", local.DisplayName); + + var UTCInStandardMonth = new DateTime (2018,2,5,11,22,56); + var StandardTimeConverted = TimeZoneInfo.ConvertTimeFromUtc (UTCInStandardMonth, local); + Assert.AreEqual(6, StandardTimeConverted.Hour); + + var UTCInDaylightMonth = new DateTime (2018,7,5,11,22,56); + var DaylightTimeConverted = TimeZoneInfo.ConvertTimeFromUtc (UTCInDaylightMonth, local); + Assert.AreEqual (7, DaylightTimeConverted.Hour); + + //Before DLS Supported Year + AssertNoDLS (local, + new DateTime (1970,4,25), + new DateTime (1970,4,27), + new DateTime (1970,10,24), + new DateTime (1970,10,26) + ); + + //First DLS Supported Year + AssertDLS (local, + new DateTime (1971,4,24), + new DateTime (1971,4,26), + new DateTime (1971,10,30), + new DateTime (1971,11,1) + ); + + //Near current year + AssertDLS (local, + new DateTime (2018,3,10), + new DateTime (2018,3,12), + new DateTime (2018,11,3), + new DateTime (2018,11,5) + ); + + //Last DLS Supported Year + AssertDLS (local, + new DateTime (2037,3,7), + new DateTime (2037,3,9), + new DateTime (2037,10,30), + new DateTime (2037,11,2) + ); + + //After Last DLS Supported Year + AssertNoDLS (local, + new DateTime (2038,2,1), + new DateTime (2038,5,1), + new DateTime (2038,6,1), + new DateTime (2038,12,1) + ); + } + + [Test] + public void PST () + { + Environment.SetEnvironmentVariable ("TZ", "America/Los_Angeles"); + TimeZoneInfo local = GetLocalUnity (); + + Assert.IsNotNull (local); + Assert.AreEqual ("-08:00:00", local.BaseUtcOffset.ToString ()); + Assert.AreEqual ("Local", local.Id); + Assert.AreEqual ("PST", local.StandardName); + Assert.AreEqual ("PDT", local.DaylightName); + Assert.IsTrue (local.SupportsDaylightSavingTime); + Assert.AreEqual ("(GMT-08:00) Local Time", local.DisplayName); + + var UTCInStandardMonth = new DateTime (2018,2,5,11,22,56); + var StandardTimeConverted = TimeZoneInfo.ConvertTimeFromUtc (UTCInStandardMonth, local); + Assert.AreEqual (3, StandardTimeConverted.Hour); + + var UTCInDaylightMonth = new DateTime (2018,7,5,11,22,56); + var DaylightTimeConverted = TimeZoneInfo.ConvertTimeFromUtc (UTCInDaylightMonth, local); + Assert.AreEqual (4, DaylightTimeConverted.Hour); + + //Before DLS Supported Year + AssertNoDLS (local, + new DateTime (1970,4,25), + new DateTime (1970,4,27), + new DateTime (1970,10,24), + new DateTime (1970,10,26) + ); + + //First DLS Supported Year + AssertDLS (local, + new DateTime (1971,4,24), + new DateTime (1971,4,26), + new DateTime (1971,10,30), + new DateTime (1971,11,1) + ); + + //Near current year + AssertDLS (local, + new DateTime (2018,3,10), + new DateTime (2018,3,12), + new DateTime (2018,11,3), + new DateTime (2018,11,5) + ); + + //Last DLS Supported Year + AssertDLS (local, + new DateTime (2037,3,7), + new DateTime (2037,3,9), + new DateTime (2037,10,30), + new DateTime (2037,11,2) + ); + + //After Last DLS Supported Year + AssertNoDLS (local, + new DateTime (2038,2,1), + new DateTime (2038,5,1), + new DateTime (2038,6,1), + new DateTime (2038,12,1) + ); + } + + [Test] + public void MST_Arizona () + { + //Arizona is special in that there hasn't been daylight savings since 1967 (before our first supported year) + Environment.SetEnvironmentVariable ("TZ", "America/Phoenix"); + TimeZoneInfo local = GetLocalUnity (); + Assert.IsNotNull (local); + Assert.AreEqual ("-07:00:00", local.BaseUtcOffset.ToString ()); + Assert.AreEqual ("Local", local.Id); + Assert.AreEqual ("MST", local.StandardName); + Assert.AreEqual ("", local.DaylightName); + Assert.IsFalse (local.SupportsDaylightSavingTime); + Assert.AreEqual ("(GMT-07:00) Local Time", local.DisplayName); + + var UTCInStandardMonth = new DateTime (2018,2,5,11,22,56); + var StandardTimeConverted = TimeZoneInfo.ConvertTimeFromUtc (UTCInStandardMonth, local); + Assert.AreEqual (4, StandardTimeConverted.Hour); + } + + [Test] + public void EET_Egypt () + { + //Egypt is special in that it stopped doing daylight savings in 2014 (after our first supported year) + Environment.SetEnvironmentVariable ("TZ", "Egypt"); + TimeZoneInfo local = GetLocalUnity (); + Assert.IsNotNull (local); + Assert.AreEqual ("02:00:00", local.BaseUtcOffset.ToString ()); + Assert.AreEqual ("Local", local.Id); + Assert.AreEqual ("EET", local.StandardName); + Assert.AreEqual ("", local.DaylightName); + Assert.IsFalse (local.SupportsDaylightSavingTime); + Assert.AreEqual ("(GMT+02:00) Local Time", local.DisplayName); + + var UTCInStandardMonth = new DateTime (2018,2,5,11,22,56); + var StandardTimeConverted = TimeZoneInfo.ConvertTimeFromUtc (UTCInStandardMonth, local); + Assert.AreEqual (13, StandardTimeConverted.Hour); + } + + [Test] + public void MSK_Crimea () + { + //Crimea is special, because they switched form EET(with dls) to MSK (without dls) due to world conflicts in 2014 + //C# timezoneinfo class only supports a single utc offset and transition times only account for daylight savings changes. + //In this case, it will display MSK with no support for daylight savings + Environment.SetEnvironmentVariable ("TZ", "Europe/Simferopol"); + TimeZoneInfo local = GetLocalUnity (); + Assert.IsNotNull (local); + Assert.AreEqual ("03:00:00", local.BaseUtcOffset.ToString ()); + Assert.AreEqual ("Local", local.Id); + Assert.AreEqual ("MSK", local.StandardName); + Assert.AreEqual ("", local.DaylightName); + Assert.IsFalse (local.SupportsDaylightSavingTime); + Assert.AreEqual ("(GMT+03:00) Local Time", local.DisplayName); + + var UTCInStandardMonth = new DateTime (2018,2,5,11,22,56); + var StandardTimeConverted = TimeZoneInfo.ConvertTimeFromUtc (UTCInStandardMonth, local); + Assert.AreEqual (14, StandardTimeConverted.Hour); + } + + [Test] + public void SA_Samoa () + { + //Samoa is special, switched form -10/-11 to +13/+14 in 2011...The Timezoneinfo class only supports a single base utcoffset so + //years before 2011 will not have daylight savings information + Environment.SetEnvironmentVariable ("TZ", "Pacific/Apia"); + TimeZoneInfo local = GetLocalUnity (); + Assert.IsNotNull (local); + Assert.AreEqual ("13:00:00", local.BaseUtcOffset.ToString ()); + Assert.AreEqual ("Local", local.Id); + Assert.AreEqual ("+13", local.StandardName); + Assert.AreEqual ("+14", local.DaylightName); + Assert.IsTrue (local.SupportsDaylightSavingTime); + Assert.AreEqual ("(GMT+13:00) Local Time", local.DisplayName); + + var UTCInStandardMonth = new DateTime (2018,4,5,1,22,56); + var StandardTimeConverted = TimeZoneInfo.ConvertTimeFromUtc (UTCInStandardMonth, local); + Assert.AreEqual (14, StandardTimeConverted.Hour); + + var UTCInDaylightMonth = new DateTime (2018,11,5,1,22,56); + var DaylightTimeConverted = TimeZoneInfo.ConvertTimeFromUtc (UTCInDaylightMonth, local); + Assert.AreEqual (15, DaylightTimeConverted.Hour); + + //2011 transitioned from utc -10 to utc +14...since we switched timezones in this year, we shouldn't have any DLS info for this year and prior + AssertNoDLS (local, + new DateTime (2011,4,1), + new DateTime (2011,4,3), + new DateTime (2011,12,28), + new DateTime (2011,12,31) + ); + AssertNoDLS (local, + new DateTime (2010,9,24), + new DateTime (2010,9,26), + new DateTime (2010,12,28), + new DateTime (2010,12,31) + ); + + //Near current year + AssertDLSInverse (local, + new DateTime (2018,3,31), + new DateTime (2018,4,2), + new DateTime (2018,9,29), + new DateTime (2018,10,1) + ); + } + + [Test] + public void AEST () + { + //Timezone that begins Jan 1 in DLS time + Environment.SetEnvironmentVariable ("TZ", "Australia/Sydney"); + TimeZoneInfo local = GetLocalUnity (); + Assert.IsNotNull (local); + Assert.AreEqual ("10:00:00", local.BaseUtcOffset.ToString ()); + Assert.AreEqual ("Local", local.Id); + Assert.AreEqual ("AEST", local.StandardName); + Assert.AreEqual ("AEDT", local.DaylightName); + Assert.IsTrue (local.SupportsDaylightSavingTime); + Assert.AreEqual ("(GMT+10:00) Local Time", local.DisplayName); + Assert.IsTrue (local.GetAdjustmentRules ().Length > 0); + + var UTCInStandardMonth = new DateTime (2018,5,5,11,22,56); + var StandardTimeConverted = TimeZoneInfo.ConvertTimeFromUtc (UTCInStandardMonth, local); + Assert.AreEqual (21, StandardTimeConverted.Hour); + + var UTCInDaylightMonth = new DateTime (2018,1,5,11,22,56); + var DaylightTimeConverted = TimeZoneInfo.ConvertTimeFromUtc (UTCInDaylightMonth, local); + Assert.AreEqual (22, DaylightTimeConverted.Hour); + + //Before DLS Supported Year + AssertNoDLS (local, + new DateTime (1970,4,25), + new DateTime (1970,4,27), + new DateTime (1970,10,24), + new DateTime (1970,10,26) + ); + + //First DLS Supported Year...Austrialia did not start DLS until oct of 71 + AssertNoDLS (local, + new DateTime (1971,10,30), + new DateTime (1971,11,1), + new DateTime (1971,2,26), + new DateTime (1971,2,28) + ); + + AssertDLSInverse (local, + new DateTime (1972,2,26), + new DateTime (1972,2,28), + new DateTime (1972,10,28), + new DateTime (1972,10,30) + ); + + //Near current year + AssertDLSInverse (local, + new DateTime (2018,3,31), + new DateTime (2018,4,2), + new DateTime (2018,10,6), + new DateTime (2018,10,8) + ); + + //Last DLS Supported Year + AssertDLSInverse (local, + new DateTime (2037,4,4), + new DateTime (2037,4,6), + new DateTime (2037,10,3), + new DateTime (2037,10,5) + ); + + //After Last DLS Supported Year + AssertNoDLS (local, + new DateTime (2038,2,1), + new DateTime (2038,5,1), + new DateTime (2038,6,1), + new DateTime (2038,12,1) + ); + } + + [Test] + public void Singapore () + { + //Singapore changes it's timezone from +0730 to +08...use the latest offsets + Environment.SetEnvironmentVariable ("TZ", "Asia/Singapore"); + TimeZoneInfo local = GetLocalUnity (); + Assert.IsNotNull (local); + + Assert.AreEqual ("08:00:00", local.BaseUtcOffset.ToString ()); + Assert.AreEqual ("Local", local.Id); + Assert.AreEqual ("+08", local.StandardName); + Assert.AreEqual ("", local.DaylightName); + Assert.IsFalse (local.SupportsDaylightSavingTime); + Assert.AreEqual ("(GMT+08:00) Local Time", local.DisplayName); + + var UTCInStandardMonth = new DateTime (2018,5,5,11,22,56); + var StandardTimeConverted = TimeZoneInfo.ConvertTimeFromUtc (UTCInStandardMonth, local); + Assert.AreEqual (19, StandardTimeConverted.Hour); + } + + } +#endif + [TestFixture] public class CreateCustomTimezoneTests { diff --git a/mono/metadata/icall-internals.h b/mono/metadata/icall-internals.h index c3ee79d03999..64b733980538 100644 --- a/mono/metadata/icall-internals.h +++ b/mono/metadata/icall-internals.h @@ -12,7 +12,7 @@ // UNITY guint32 -ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData (guint32 year, MonoArray **data, MonoArray **names); +ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData (guint32 year, MonoArray **data, MonoArray **names, MonoBoolean *daylight_inverted); // On Windows platform implementation of bellow methods are hosted in separate source file // icall-windows.c or icall-windows-*.c. On other platforms the implementation is still keept diff --git a/mono/metadata/unity-icall.c b/mono/metadata/unity-icall.c index 1de9b6be406d..03ec5b6dc3aa 100644 --- a/mono/metadata/unity-icall.c +++ b/mono/metadata/unity-icall.c @@ -98,7 +98,7 @@ gmt_offset(struct tm *tm, time_t t) * Returns true on success and zero on failure. */ guint32 -ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData (guint32 year, MonoArray **data, MonoArray **names) +ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData (guint32 year, MonoArray **data, MonoArray **names, MonoBoolean *daylight_inverted) { MonoError error; #ifndef PLATFORM_WIN32 @@ -106,8 +106,9 @@ ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData (guint32 year, MonoArray struct tm start, tt; time_t t; + long int gmtoff_start; long int gmtoff; - int is_daylight = 0, day; + int is_transitioned = 0, day; char tzone [64]; MONO_CHECK_ARG_NULL (data, FALSE); @@ -137,10 +138,14 @@ ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData (guint32 year, MonoArray strftime (tzone, sizeof (tzone), "%Z", &tt); mono_array_setref ((*names), 0, mono_string_new_checked (domain, tzone, &error)); mono_array_setref ((*names), 1, mono_string_new_checked (domain, tzone, &error)); + *daylight_inverted = 0; return 1; } + *daylight_inverted = start.tm_isdst; + gmtoff = gmt_offset (&start, t); + gmtoff_start = gmtoff; /* For each day of the year, calculate the tm_gmtoff. */ for (day = 0; day < 365; day++) { @@ -169,25 +174,39 @@ ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData (guint32 year, MonoArray strftime (tzone, sizeof (tzone), "%Z", &tt); /* Write data, if we're already in daylight saving, we're done. */ - if (is_daylight) { - mono_array_setref ((*names), 0, mono_string_new_checked (domain, tzone, &error)); + if (is_transitioned) { + if (!start.tm_isdst) + mono_array_setref ((*names), 0, mono_string_new_checked (domain, tzone, &error)); + else + mono_array_setref ((*names), 1, mono_string_new_checked (domain, tzone, &error)); + mono_array_set ((*data), gint64, 1, ((gint64)t1 + EPOCH_ADJUST) * 10000000L); return 1; } else { - mono_array_setref ((*names), 1, mono_string_new_checked (domain, tzone, &error)); + if (!start.tm_isdst) + mono_array_setref ((*names), 1, mono_string_new_checked (domain, tzone, &error)); + else + mono_array_setref ((*names), 0, mono_string_new_checked (domain, tzone, &error)); + mono_array_set ((*data), gint64, 0, ((gint64)t1 + EPOCH_ADJUST) * 10000000L); - is_daylight = 1; + is_transitioned = 1; } /* This is only set once when we enter daylight saving. */ - mono_array_set ((*data), gint64, 2, (gint64)gmtoff * 10000000L); - mono_array_set ((*data), gint64, 3, (gint64)(gmt_offset (&tt, t) - gmtoff) * 10000000L); + if (*daylight_inverted == 0) { + mono_array_set ((*data), gint64, 2, (gint64)gmtoff * 10000000L); + mono_array_set ((*data), gint64, 3, (gint64)(gmt_offset (&tt, t) - gmtoff) * 10000000L); + } else { + mono_array_set ((*data), gint64, 2, (gint64)(gmtoff_start + (gmt_offset (&tt, t) - gmtoff)) * 10000000L); + mono_array_set ((*data), gint64, 3, (gint64)(gmtoff - gmt_offset (&tt, t)) * 10000000L); + } + gmtoff = gmt_offset (&tt, t); } } - if (!is_daylight) { + if (!is_transitioned) { strftime (tzone, sizeof (tzone), "%Z", &tt); mono_array_setref ((*names), 0, mono_string_new_checked (domain, tzone, &error)); mono_array_setref ((*names), 1, mono_string_new_checked (domain, tzone, &error)); @@ -195,65 +214,12 @@ ves_icall_System_CurrentSystemTimeZone_GetTimeZoneData (guint32 year, MonoArray mono_array_set ((*data), gint64, 1, 0); mono_array_set ((*data), gint64, 2, (gint64) gmtoff * 10000000L); mono_array_set ((*data), gint64, 3, 0); + *daylight_inverted = 0; } return 1; #else - MonoDomain *domain = mono_domain_get (); - TIME_ZONE_INFORMATION tz_info; - FILETIME ft; - int i; - int err, tz_id; - - tz_id = GetTimeZoneInformation (&tz_info); - if (tz_id == TIME_ZONE_ID_INVALID) - return 0; - - MONO_CHECK_ARG_NULL (data); - MONO_CHECK_ARG_NULL (names); - - mono_gc_wbarrier_generic_store (data, mono_array_new (domain, mono_defaults.int64_class, 4)); - mono_gc_wbarrier_generic_store (names, mono_array_new (domain, mono_defaults.string_class, 2)); - - for (i = 0; i < 32; ++i) - if (!tz_info.DaylightName [i]) - break; - mono_array_setref ((*names), 1, mono_string_new_utf16 (domain, tz_info.DaylightName, i)); - for (i = 0; i < 32; ++i) - if (!tz_info.StandardName [i]) - break; - mono_array_setref ((*names), 0, mono_string_new_utf16 (domain, tz_info.StandardName, i)); - - if ((year <= 1601) || (year > 30827)) { - /* - * According to MSDN, the MS time functions can't handle dates outside - * this interval. - */ - return 1; - } - - /* even if the timezone has no daylight savings it may have Bias (e.g. GMT+13 it seems) */ - if (tz_id != TIME_ZONE_ID_UNKNOWN) { - tz_info.StandardDate.wYear = year; - convert_to_absolute_date(&tz_info.StandardDate); - err = SystemTimeToFileTime (&tz_info.StandardDate, &ft); - //g_assert(err); - if (err == 0) - return 0; - - mono_array_set ((*data), gint64, 1, FILETIME_ADJUST + (((guint64)ft.dwHighDateTime<<32) | ft.dwLowDateTime)); - tz_info.DaylightDate.wYear = year; - convert_to_absolute_date(&tz_info.DaylightDate); - err = SystemTimeToFileTime (&tz_info.DaylightDate, &ft); - //g_assert(err); - if (err == 0) - return 0; - - mono_array_set ((*data), gint64, 0, FILETIME_ADJUST + (((guint64)ft.dwHighDateTime<<32) | ft.dwLowDateTime)); - } - mono_array_set ((*data), gint64, 2, (tz_info.Bias + tz_info.StandardBias) * -600000000LL); - mono_array_set ((*data), gint64, 3, (tz_info.DaylightBias - tz_info.StandardBias) * -600000000LL); - - return 1; + //On Windows, we should always load timezones in managed + return 0; #endif } From 633d4e73954ab97ba1695484c1b9b19868fd1d0b Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Fri, 8 Jun 2018 08:41:41 +0200 Subject: [PATCH 258/582] Switch bdwgc repo back to unity-master branch now that all needed changes are in there --- external/bdwgc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/bdwgc b/external/bdwgc index 5d8db990f8b3..4d98daa2153d 160000 --- a/external/bdwgc +++ b/external/bdwgc @@ -1 +1 @@ -Subproject commit 5d8db990f8b307f0f5f6a0f1939a52ba72190e14 +Subproject commit 4d98daa2153d41f75339918422d9d59eb54bb86b From b6f1ba89f7ab285a0990e696e78798f7cf18dafb Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 8 Jun 2018 13:19:02 -0400 Subject: [PATCH 259/582] Ensure last Win32 error is preserved for IO operations (case 1047186) --- mono/metadata/w32file-win32.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mono/metadata/w32file-win32.c b/mono/metadata/w32file-win32.c index 333d1b2142a6..f428031a7a37 100644 --- a/mono/metadata/w32file-win32.c +++ b/mono/metadata/w32file-win32.c @@ -12,6 +12,7 @@ #include #include "mono/metadata/w32file-win32-internals.h" #include "mono/metadata/profiler-private.h" +#include "mono/metadata/w32error.h" void mono_w32file_init (void) @@ -97,12 +98,17 @@ mono_w32file_read (gpointer handle, gpointer buffer, guint32 numbytes, guint32 * mono_thread_info_install_interrupt (cancel_w32_io, handle, &interrupted); if (!interrupted) { + guint32 last_error; MONO_ENTER_GC_SAFE; res = ReadFile (handle, buffer, numbytes, bytesread, NULL); MONO_PROFILER_RAISE (fileio, (1, *bytesread)); MONO_EXIT_GC_SAFE; + /* need to save and restore since clients expect error code set for + * failed IO calls and mono_thread_info_uninstall_interrupt overwrites value */ + last_error = mono_w32error_get_last (); mono_thread_info_uninstall_interrupt (&interrupted); + mono_w32error_set_last (last_error); } return res; @@ -117,12 +123,17 @@ mono_w32file_write (gpointer handle, gconstpointer buffer, guint32 numbytes, gui mono_thread_info_install_interrupt (cancel_w32_io, handle, &interrupted); if (!interrupted) { + guint32 last_error; MONO_ENTER_GC_SAFE; res = WriteFile (handle, buffer, numbytes, byteswritten, NULL); MONO_PROFILER_RAISE (fileio, (0, *byteswritten)); MONO_EXIT_GC_SAFE; + /* need to save and restore since clients expect error code set for + * failed IO calls and mono_thread_info_uninstall_interrupt overwrites value */ + last_error = mono_w32error_get_last (); mono_thread_info_uninstall_interrupt (&interrupted); + mono_w32error_set_last (last_error); } return res; From 4cf267bac0e837acbd19e74d7ea04ad0a1bbd655 Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Thu, 14 Jun 2018 09:45:55 +0200 Subject: [PATCH 260/582] Match mono code conventions --- mono/metadata/boehm-gc.c | 38 +++++++++++++++++++------------------- mono/metadata/object.c | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index cf8f5ade5c26..5891ca2f1492 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -239,11 +239,11 @@ mono_gc_base_init (void) opt = strchr (opt, '=') + 1; if (*opt && mono_gc_parse_environment_string_extract_number (opt, &time_limit)) { - GC_enable_incremental(); + GC_enable_incremental (); #if HAVE_BDWGC_GC if (time_limit != 0) // value is in milliseconds - GC_set_time_limit(time_limit); + GC_set_time_limit (time_limit); #endif } continue; @@ -647,7 +647,7 @@ mono_gc_weak_link_add (void **link_addr, MonoObject *obj, gboolean track) { /* libgc requires that we use HIDE_POINTER... */ *link_addr = (void*)HIDE_POINTER (obj); - GC_dirty(link_addr); + GC_dirty (link_addr); if (track) GC_REGISTER_LONG_LINK (link_addr, obj); else @@ -892,48 +892,48 @@ void mono_gc_wbarrier_set_field (MonoObject *obj, gpointer field_ptr, MonoObject* value) { *(void**)field_ptr = value; - GC_dirty(field_ptr); + GC_dirty (field_ptr); } void mono_gc_wbarrier_set_arrayref (MonoArray *arr, gpointer slot_ptr, MonoObject* value) { *(void**)slot_ptr = value; - GC_dirty(slot_ptr); + GC_dirty (slot_ptr); } void mono_gc_wbarrier_arrayref_copy (gpointer dest_ptr, gpointer src_ptr, int count) { mono_gc_memmove_aligned (dest_ptr, src_ptr, count * sizeof (gpointer)); - GC_dirty(dest_ptr); + GC_dirty (dest_ptr); } void mono_gc_wbarrier_generic_store (gpointer ptr, MonoObject* value) { *(void**)ptr = value; - GC_dirty(ptr); + GC_dirty (ptr); } void mono_gc_wbarrier_generic_store_atomic (gpointer ptr, MonoObject *value) { mono_atomic_store_ptr ((volatile gpointer *)ptr, value); - GC_dirty(ptr); + GC_dirty (ptr); } void mono_gc_wbarrier_generic_nostore (gpointer ptr) { - GC_dirty(ptr); + GC_dirty (ptr); } void mono_gc_wbarrier_value_copy (gpointer dest, gpointer src, int count, MonoClass *klass) { mono_gc_memmove_atomic (dest, src, count * mono_class_value_size (klass, NULL)); - GC_dirty(dest); + GC_dirty (dest); } void @@ -942,7 +942,7 @@ mono_gc_wbarrier_object_copy (MonoObject* obj, MonoObject *src) /* do not copy the sync state */ mono_gc_memmove_aligned ((char*)obj + sizeof (MonoObject), (char*)src + sizeof (MonoObject), mono_object_class (obj)->instance_size - sizeof (MonoObject)); - GC_dirty(obj); + GC_dirty (obj); } void @@ -1495,7 +1495,7 @@ gboolean mono_gc_is_moving (void) { #if HAVE_BDWGC_GC - return GC_is_incremental_mode(); + return GC_is_incremental_mode (); #else return FALSE; #endif @@ -1513,8 +1513,8 @@ mono_gc_is_disabled (void) void mono_gc_wbarrier_range_copy (gpointer _dest, gpointer _src, int size) { - memcpy(_dest, _src, size); - GC_dirty(_dest); + memcpy (_dest, _src, size); + GC_dirty (_dest); } void* @@ -1875,7 +1875,7 @@ handle_data_grow (HandleData *handles, gboolean track) gpointer *entries; entries = (void **)mono_gc_alloc_fixed (sizeof (*handles->entries) * new_size, NULL, MONO_ROOT_SOURCE_GC_HANDLE, NULL, "GC Handle Table (Boehm)"); mono_gc_memmove_aligned (entries, handles->entries, sizeof (*handles->entries) * handles->size); - GC_dirty(entries); + GC_dirty (entries); mono_gc_free_fixed (handles->entries); handles->entries = entries; } @@ -1908,7 +1908,7 @@ alloc_handle (HandleData *handles, MonoObject *obj, gboolean track) mono_gc_weak_link_add (&(handles->entries [slot]), obj, track); } else { handles->entries [slot] = obj; - GC_dirty(handles->entries + slot); + GC_dirty (handles->entries + slot); } #ifndef DISABLE_PERFCOUNTERS @@ -2026,7 +2026,7 @@ mono_gchandle_set_target (guint32 gchandle, MonoObject *obj) handles->domain_ids [slot] = (obj ? mono_object_get_domain (obj) : mono_domain_get ())->domain_id; } else { handles->entries [slot] = obj; - GC_dirty(handles->entries + slot); + GC_dirty (handles->entries + slot); } } else { /* print a warning? */ @@ -2105,7 +2105,7 @@ mono_gchandle_free (guint32 gchandle) mono_gc_weak_link_remove (&handles->entries [slot], handles->type == HANDLE_WEAK_TRACK); } else { handles->entries [slot] = NULL; - GC_dirty(handles->entries + slot); + GC_dirty (handles->entries + slot); } vacate_slot (handles, slot); } else { @@ -2148,7 +2148,7 @@ mono_gchandle_free_domain (MonoDomain *domain) if (handles->entries [slot] && mono_object_domain (handles->entries [slot]) == domain) { vacate_slot (handles, slot); handles->entries [slot] = NULL; - GC_dirty(handles->entries + slot); + GC_dirty (handles->entries + slot); } } } diff --git a/mono/metadata/object.c b/mono/metadata/object.c index ea4a399c9c57..054ce9634385 100644 --- a/mono/metadata/object.c +++ b/mono/metadata/object.c @@ -2087,7 +2087,7 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, MonoErro /* This is not needed by sgen, as it does not seem + to need write barriers for uncollectable objects (like the vtables storing static + fields), but it is needed for incremental boehm. */ - mono_gc_wbarrier_generic_nostore(t); + mono_gc_wbarrier_generic_nostore (t); } continue; } @@ -3302,7 +3302,7 @@ mono_field_static_set_value (MonoVTable *vt, MonoClassField *field, void *value) to need write barriers for uncollectable objects (like the vtables storing static + fields), but it is needed for incremental boehm. */ if (field->offset == -1) - mono_gc_wbarrier_generic_nostore(dest); + mono_gc_wbarrier_generic_nostore (dest); } /** From 17d88a2493c3172eb7a6914e9a68744cb1629989 Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Wed, 20 Jun 2018 14:30:55 -0400 Subject: [PATCH 261/582] fix issue where pal was not returning the right data --- mono/utils/unity-time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mono/utils/unity-time.c b/mono/utils/unity-time.c index 0d0b1b4b0d2e..045d7e807673 100644 --- a/mono/utils/unity-time.c +++ b/mono/utils/unity-time.c @@ -26,7 +26,7 @@ mono_100ns_ticks (void) gint64 mono_100ns_datetime (void) { - return (gint64) UnityPalGetTicks100NanosecondsDateTime(); + return (gint64) UnityPalGetSystemTimeAsFileTime(); } gint64 From 4bd6b755f2f97deac9bed71cc24f6b42e748f12f Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Thu, 21 Jun 2018 09:04:27 -0400 Subject: [PATCH 262/582] Assume not having libc means this is not macOS We know that libc will always be present on macOS, so if it is not there, we can assume this is not macOS. More generally, use a try/finally to avoid leaking the allocated buffer when libc is not found and set `checkOS` properly so we don't try to check again. This corrects Unity case 1038918, and in general helps our platform story int he class libraries a little bit, until we get better platform detection support at runtime. --- mcs/class/System/System/Platform.cs | 36 ++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/mcs/class/System/System/Platform.cs b/mcs/class/System/System/Platform.cs index f4214393fc32..46395ff291a6 100644 --- a/mcs/class/System/System/Platform.cs +++ b/mcs/class/System/System/Platform.cs @@ -59,26 +59,40 @@ private static void CheckOS() { } IntPtr buf = Marshal.AllocHGlobal (8192); - if (uname (buf) == 0) { - string os = Marshal.PtrToStringAnsi (buf); - switch (os) { - case "Darwin": - isMacOS = true; - break; - case "FreeBSD": - isFreeBSD = true; - break; + try { + if (uname (buf) == 0) { + string os = Marshal.PtrToStringAnsi (buf); + switch (os) { + case "Darwin": + isMacOS = true; + break; + case "FreeBSD": + isFreeBSD = true; + break; + } } } - Marshal.FreeHGlobal (buf); - checkedOS = true; + finally { + Marshal.FreeHGlobal (buf); + checkedOS = true; + } } #endif public static bool IsMacOS { get { if (!checkedOS) +#if UNITY + try { + CheckOS(); + } + catch (DllNotFoundException e) { + // libc does not exist, so this is not MacOS + isMacOS = false; + } +#else CheckOS(); +#endif return isMacOS; } } From 138586007dd0ea42227644ad381ebb51bed024b3 Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Mon, 9 Jul 2018 14:41:56 -0400 Subject: [PATCH 263/582] Fix issue where no addresses will be returned for an address family of unspecified FB1045497 --- mcs/class/System/System.Net.Sockets/Socket.cs | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/mcs/class/System/System.Net.Sockets/Socket.cs b/mcs/class/System/System.Net.Sockets/Socket.cs index 6b55a8655ee8..8de0daf46ca1 100644 --- a/mcs/class/System/System.Net.Sockets/Socket.cs +++ b/mcs/class/System/System.Net.Sockets/Socket.cs @@ -1160,19 +1160,24 @@ bool GetCheckedIPs (SocketAsyncEventArgs e, out IPAddress [] addresses) // while skipping entries that do not match the address family DnsEndPoint dep = e.RemoteEndPoint as DnsEndPoint; if (dep != null) { - var possibleAddresses = Dns.GetHostAddresses (dep.Host); - var numberOfAddresses = 0; - int[] addressIndices = new int[possibleAddresses.Length]; - for (var i = 0; i < possibleAddresses.Length; i++) { - if (possibleAddresses[i].AddressFamily == dep.AddressFamily) { - addressIndices[numberOfAddresses] = i; - numberOfAddresses++; + if (dep.AddressFamily == AddressFamily.Unspecified) + { + addresses = Dns.GetHostAddresses(dep.Host); + } else { + var possibleAddresses = Dns.GetHostAddresses (dep.Host); + var numberOfAddresses = 0; + int[] addressIndices = new int[possibleAddresses.Length]; + for (var i = 0; i < possibleAddresses.Length; i++) { + if (possibleAddresses[i].AddressFamily == dep.AddressFamily) { + addressIndices[numberOfAddresses] = i; + numberOfAddresses++; + } } - } - addresses = new IPAddress[numberOfAddresses]; - for (var i = 0; i < numberOfAddresses; i++) - addresses[i] = possibleAddresses[addressIndices[i]]; + addresses = new IPAddress[numberOfAddresses]; + for (var i = 0; i < numberOfAddresses; i++) + addresses[i] = possibleAddresses[addressIndices[i]]; + } return true; } else { e.ConnectByNameError = null; From 3767f744a86317b2b230f977732a0e0b34f697c0 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Tue, 10 Jul 2018 11:06:03 -0400 Subject: [PATCH 264/582] Remove the 32-bit slice from the Mono runtime Apple is not allowing Mac App Store submissions with 32-bit slices in universal binaries any longer. We don't use the 32-bit slice in Mono, so remove it. --- external/buildscripts/build_all_osx.pl | 328 ++++++++++++------------- 1 file changed, 163 insertions(+), 165 deletions(-) diff --git a/external/buildscripts/build_all_osx.pl b/external/buildscripts/build_all_osx.pl index 0f0eb42d6aa3..130a5592eb74 100644 --- a/external/buildscripts/build_all_osx.pl +++ b/external/buildscripts/build_all_osx.pl @@ -1,165 +1,163 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $currentdir = getcwd(); - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildscriptsdir = "$monoroot/external/buildscripts"; -my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; -my $buildsroot = "$monoroot/builds"; - -my $artifact=0; -my $artifactsCommon=0; -my $buildUsAndBoo=0; - -my @thisScriptArgs = (); -my @passAlongArgs = (); -foreach my $arg (@ARGV) -{ - # Filter out --clean if someone uses it. We have to clean since we are doing two builds - if (not $arg =~ /^--clean=/) - { - # We don't need common artifacts, us, and boo, from both, so filter out temporarily and we'll - # only pass it to the second build - if ($arg =~ /^--artifactscommon=/ || $arg =~ /^--buildusandboo=/) - { - push @thisScriptArgs, $arg; - } - else - { - push @passAlongArgs, $arg; - } - } - - if ($arg =~ /^--artifact=/) - { - push @thisScriptArgs, $arg; - } -} - -print(">>> This Script Args = @thisScriptArgs\n"); -print(">>> Pass Along Args = @passAlongArgs\n"); - -@ARGV = @thisScriptArgs; -GetOptions( - 'artifact=i'=>\$artifact, - 'artifactscommon=i'=>\$artifactsCommon, - 'buildusandboo=i'=>\$buildUsAndBoo, -); - -my $monoArch32Target = "i386"; - -print(">>> Building $monoArch32Target\n"); -system("perl", "$buildscriptsdir/build.pl", "--arch32=1", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ("failing building $monoArch32Target"); - -if ($artifactsCommon) -{ - push @passAlongArgs, "--artifactscommon=1"; -} - -if ($buildUsAndBoo) -{ - push @passAlongArgs, "--buildusandboo=1"; -} - -print(">>> Building x86_64\n"); -system("perl", "$buildscriptsdir/build.pl", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building x86_64'); - -if ($artifact) -{ - print(">>> Creating universal binaries\n"); - # Merge stuff in the embedruntimes directory - my $embedDirRoot = "$buildsroot/embedruntimes"; - my $embedDirDestination = "$embedDirRoot/osx"; - my $embedDirSource32 = "$embedDirRoot/osx-tmp-$monoArch32Target"; - my $embedDirSource64 = "$embedDirRoot/osx-tmp-x86_64"; - - system("mkdir -p $embedDirDestination"); - - if (!(-d $embedDirSource32)) - { - die("Expected source directory not found : $embedDirSource32\n"); - } - - if (!(-d $embedDirSource64)) - { - die("Expected source directory not found : $embedDirSource64\n"); - } - - # Create universal binaries - for my $file ('libmonobdwgc-2.0.dylib','libmonosgen-2.0.dylib','libMonoPosixHelper.dylib') - { - print(">>> lipo $embedDirSource32/$file $embedDirSource64/$file -create -output $embedDirDestination/$file\n\n"); - system ('lipo', "$embedDirSource32/$file", "$embedDirSource64/$file", '-create', '-output', "$embedDirDestination/$file"); - } - - if (not $buildMachine) - { - print(">>> Doing non-build machine stuff...\n"); - for my $file ('libmonobdwgc-2.0.dylib','libmonosgen-2.0.dylib','libMonoPosixHelper.dylib') - { - print(">>> Removing $embedDirDestination/$file.dSYM\n"); - rmtree ("$embedDirDestination/$file.dSYM"); - print(">>> 'dsymutil $embedDirDestination/$file\n"); - system ('dsymutil', "$embedDirDestination/$file") eq 0 or warn ("Failed creating $embedDirDestination/$file.dSYM"); - } - - print(">>> Done with non-build machine stuff\n"); - } - - # Merge stuff in the monodistribution directory - my $distDirRoot = "$buildsroot/monodistribution"; - my $distDirDestinationBin = "$buildsroot/monodistribution/bin"; - my $distDirDestinationLib = "$buildsroot/monodistribution/lib"; - my $distDirSourceBin32 = "$distDirRoot/bin-osx-tmp-$monoArch32Target"; - my $distDirSourceBin64 = "$distDirRoot/bin-osx-tmp-x86_64"; - - # Should always exist because build_all would have put stuff in it, but in some situations - # depending on the options it may not. So create it if it does not exist - if (!(-d $distDirDestinationBin)) - { - system("mkdir -p $distDirDestinationBin"); - } - - if (!(-d $distDirDestinationLib)) - { - system("mkdir -p $distDirDestinationLib"); - } - - if (!(-d $distDirSourceBin32)) - { - die("Expected source directory not found : $distDirSourceBin32\n"); - } - - if (!(-d $distDirSourceBin64)) - { - die("Expected source directory not found : $distDirSourceBin64\n"); - } - - for my $file ('mono','pedump') - { - print(">>> lipo $distDirSourceBin32/$file $distDirSourceBin64/$file -create -output $distDirDestinationBin/$file\n\n"); - system ('lipo', "$distDirSourceBin32/$file", "$distDirSourceBin64/$file", '-create', '-output', "$distDirDestinationBin/$file"); - } - - #Create universal binaries for stuff is in the embed dir but will end up in the dist dir - for my $file ('libMonoPosixHelper.dylib') - { - print(">>> lipo $embedDirSource32/$file $embedDirSource64/$file -create -output $distDirDestinationLib/$file\n\n"); - system ('lipo', "$embedDirSource32/$file", "$embedDirSource64/$file", '-create', '-output', "$distDirDestinationLib/$file"); - } - - if ($buildMachine) - { - print(">>> Clean up temporary arch specific build directories\n"); - - rmtree("$distDirSourceBin32"); - rmtree("$distDirSourceBin64"); - rmtree("$embedDirSource32"); - rmtree("$embedDirSource64"); - } -} +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $currentdir = getcwd(); + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildscriptsdir = "$monoroot/external/buildscripts"; +my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; +my $buildsroot = "$monoroot/builds"; + +my $artifact=0; +my $artifactsCommon=0; +my $buildUsAndBoo=0; + +my @thisScriptArgs = (); +my @passAlongArgs = (); +foreach my $arg (@ARGV) +{ + # Filter out --clean if someone uses it. We have to clean since we are doing two builds + if (not $arg =~ /^--clean=/) + { + # We don't need common artifacts, us, and boo, from both, so filter out temporarily and we'll + # only pass it to the second build + if ($arg =~ /^--artifactscommon=/ || $arg =~ /^--buildusandboo=/) + { + push @thisScriptArgs, $arg; + } + else + { + push @passAlongArgs, $arg; + } + } + + if ($arg =~ /^--artifact=/) + { + push @thisScriptArgs, $arg; + } +} + +print(">>> This Script Args = @thisScriptArgs\n"); +print(">>> Pass Along Args = @passAlongArgs\n"); + +@ARGV = @thisScriptArgs; +GetOptions( + 'artifact=i'=>\$artifact, + 'artifactscommon=i'=>\$artifactsCommon, + 'buildusandboo=i'=>\$buildUsAndBoo, +); + +my $monoArch32Target = "i386"; + +print(">>> Building $monoArch32Target\n"); +system("perl", "$buildscriptsdir/build.pl", "--arch32=1", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ("failing building $monoArch32Target"); + +if ($artifactsCommon) +{ + push @passAlongArgs, "--artifactscommon=1"; +} + +if ($buildUsAndBoo) +{ + push @passAlongArgs, "--buildusandboo=1"; +} + +print(">>> Building x86_64\n"); +system("perl", "$buildscriptsdir/build.pl", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building x86_64'); + +if ($artifact) +{ + print(">>> Creating universal binaries\n"); + # Merge stuff in the embedruntimes directory + my $embedDirRoot = "$buildsroot/embedruntimes"; + my $embedDirDestination = "$embedDirRoot/osx"; + my $embedDirSource32 = "$embedDirRoot/osx-tmp-$monoArch32Target"; + my $embedDirSource64 = "$embedDirRoot/osx-tmp-x86_64"; + + system("mkdir -p $embedDirDestination"); + + if (!(-d $embedDirSource32)) + { + die("Expected source directory not found : $embedDirSource32\n"); + } + + if (!(-d $embedDirSource64)) + { + die("Expected source directory not found : $embedDirSource64\n"); + } + + for my $file ('libmonobdwgc-2.0.dylib','libmonosgen-2.0.dylib','libMonoPosixHelper.dylib') + { + print(">>> cp $embedDirSource64/$file $embedDirDestination/$file\n\n"); + system ('cp', "$embedDirSource64/$file", "$embedDirDestination/$file"); + } + + if (not $buildMachine) + { + print(">>> Doing non-build machine stuff...\n"); + for my $file ('libmonobdwgc-2.0.dylib','libmonosgen-2.0.dylib','libMonoPosixHelper.dylib') + { + print(">>> Removing $embedDirDestination/$file.dSYM\n"); + rmtree ("$embedDirDestination/$file.dSYM"); + print(">>> 'dsymutil $embedDirDestination/$file\n"); + system ('dsymutil', "$embedDirDestination/$file") eq 0 or warn ("Failed creating $embedDirDestination/$file.dSYM"); + } + + print(">>> Done with non-build machine stuff\n"); + } + + # Merge stuff in the monodistribution directory + my $distDirRoot = "$buildsroot/monodistribution"; + my $distDirDestinationBin = "$buildsroot/monodistribution/bin"; + my $distDirDestinationLib = "$buildsroot/monodistribution/lib"; + my $distDirSourceBin32 = "$distDirRoot/bin-osx-tmp-$monoArch32Target"; + my $distDirSourceBin64 = "$distDirRoot/bin-osx-tmp-x86_64"; + + # Should always exist because build_all would have put stuff in it, but in some situations + # depending on the options it may not. So create it if it does not exist + if (!(-d $distDirDestinationBin)) + { + system("mkdir -p $distDirDestinationBin"); + } + + if (!(-d $distDirDestinationLib)) + { + system("mkdir -p $distDirDestinationLib"); + } + + if (!(-d $distDirSourceBin32)) + { + die("Expected source directory not found : $distDirSourceBin32\n"); + } + + if (!(-d $distDirSourceBin64)) + { + die("Expected source directory not found : $distDirSourceBin64\n"); + } + + for my $file ('mono','pedump') + { + print(">>> lipo $distDirSourceBin32/$file $distDirSourceBin64/$file -create -output $distDirDestinationBin/$file\n\n"); + system ('lipo', "$distDirSourceBin32/$file", "$distDirSourceBin64/$file", '-create', '-output', "$distDirDestinationBin/$file"); + } + + for my $file ('libMonoPosixHelper.dylib') + { + print(">>> cp $embedDirSource64/$file $distDirDestinationLib/$file\n\n"); + system ('cp', "$embedDirSource64/$file", "$distDirDestinationLib/$file"); + } + + if ($buildMachine) + { + print(">>> Clean up temporary arch specific build directories\n"); + + rmtree("$distDirSourceBin32"); + rmtree("$distDirSourceBin64"); + rmtree("$embedDirSource32"); + rmtree("$embedDirSource64"); + } +} From 98dc7dbbdecb1585190616ca915a2db3cd1ae5a0 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 10 Jul 2018 13:47:33 -0400 Subject: [PATCH 265/582] Add shared enum types for value type sharing in IL2CPP. --- mcs/class/corlib/LinkerDescriptor/mscorlib.xml | 11 +++++++++++ mcs/class/corlib/System/EnumSharing.cs | 18 ++++++++++++++++++ mcs/class/corlib/corlib.dll.sources | 1 + 3 files changed, 30 insertions(+) create mode 100644 mcs/class/corlib/System/EnumSharing.cs diff --git a/mcs/class/corlib/LinkerDescriptor/mscorlib.xml b/mcs/class/corlib/LinkerDescriptor/mscorlib.xml index dd498a1a6fe3..3cb8488c7bef 100644 --- a/mcs/class/corlib/LinkerDescriptor/mscorlib.xml +++ b/mcs/class/corlib/LinkerDescriptor/mscorlib.xml @@ -842,5 +842,16 @@ + + + + + + + + + + + diff --git a/mcs/class/corlib/System/EnumSharing.cs b/mcs/class/corlib/System/EnumSharing.cs new file mode 100644 index 000000000000..aa1def337693 --- /dev/null +++ b/mcs/class/corlib/System/EnumSharing.cs @@ -0,0 +1,18 @@ +using System; + +#if UNITY_AOT + +namespace System +{ + enum SByteEnum : sbyte {} + enum Int16Enum : short {} + enum Int32Enum : int {} + enum Int64Enum : long {} + + enum ByteEnum : byte {} + enum UInt16Enum : ushort {} + enum UInt32Enum : uint {} + enum UInt64Enum : ulong {} +} + +#endif diff --git a/mcs/class/corlib/corlib.dll.sources b/mcs/class/corlib/corlib.dll.sources index 0e0202aad781..bd2fd295fdc5 100644 --- a/mcs/class/corlib/corlib.dll.sources +++ b/mcs/class/corlib/corlib.dll.sources @@ -104,6 +104,7 @@ System/Delegate.cs System/DelegateSerializationHolder.cs System/DomainManagerInitializationFlags.cs System/EmptyArray.cs +System/EnumSharing.cs System/Environment.cs System/EnvironmentVariableTarget.cs System/Guid.cs From 8aacdab902df404b28f908fc2251eec237bbb72f Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Thu, 12 Jul 2018 13:22:57 -0400 Subject: [PATCH 266/582] Fix monoTODO where driveinfo.IsReady is unimplemented --- mcs/class/corlib/System.IO/DriveInfo.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mcs/class/corlib/System.IO/DriveInfo.cs b/mcs/class/corlib/System.IO/DriveInfo.cs index 6c4c7eee87ce..b71e5d003895 100644 --- a/mcs/class/corlib/System.IO/DriveInfo.cs +++ b/mcs/class/corlib/System.IO/DriveInfo.cs @@ -140,10 +140,9 @@ public DirectoryInfo RootDirectory { } } - [MonoTODO("It always returns true")] public bool IsReady { get { - return true; + return Directory.Exists (Name); } } From 5311365c3a7f6946888310bb87c4221b27d0d8a4 Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Tue, 12 Jun 2018 10:54:29 -0400 Subject: [PATCH 267/582] Fix issue where getting network information from loopback causes IndexOutOfRangeException: No adapter found for index --- .../IPAddressCollection.cs | 19 +++++++ .../IPInterfaceProperties.cs | 31 +++--------- .../IPv4InterfaceProperties.cs | 10 ++-- .../NetworkInterface.cs | 16 +++--- .../Win32NetworkInterfaceMarshal.cs | 50 +++++++++++++++++-- 5 files changed, 83 insertions(+), 43 deletions(-) diff --git a/mcs/class/System/System.Net.NetworkInformation/IPAddressCollection.cs b/mcs/class/System/System.Net.NetworkInformation/IPAddressCollection.cs index 54b831f6a439..b8c824c415bc 100644 --- a/mcs/class/System/System.Net.NetworkInformation/IPAddressCollection.cs +++ b/mcs/class/System/System.Net.NetworkInformation/IPAddressCollection.cs @@ -84,6 +84,25 @@ public static Win32IPAddressCollection FromDnsServer (IntPtr ptr) return c; } + public static Win32IPAddressCollection FromSocketAddress (Win32_SOCKET_ADDRESS addr) + { + Win32IPAddressCollection c = new Win32IPAddressCollection (); + if (addr.Sockaddr != IntPtr.Zero) + c.InternalAdd (addr.GetIPAddress ()); + return c; + } + + public static Win32IPAddressCollection FromWinsServer (IntPtr ptr) + { + Win32IPAddressCollection c = new Win32IPAddressCollection (); + Win32_IP_ADAPTER_WINS_SERVER_ADDRESS a; + for (IntPtr p = ptr; p != IntPtr.Zero; p = a.Next) { + a = (Win32_IP_ADAPTER_WINS_SERVER_ADDRESS) Marshal.PtrToStructure (p, typeof (Win32_IP_ADAPTER_WINS_SERVER_ADDRESS)); + c.InternalAdd (a.Address.GetIPAddress ()); + } + return c; + } + void AddSubsequentlyString (IntPtr head) { Win32_IP_ADDR_STRING a; diff --git a/mcs/class/System/System.Net.NetworkInformation/IPInterfaceProperties.cs b/mcs/class/System/System.Net.NetworkInformation/IPInterfaceProperties.cs index bcae621e00d7..aa5bffa8307f 100644 --- a/mcs/class/System/System.Net.NetworkInformation/IPInterfaceProperties.cs +++ b/mcs/class/System/System.Net.NetworkInformation/IPInterfaceProperties.cs @@ -341,13 +341,11 @@ public Win32IPInterfaceProperties2 (Win32_IP_ADAPTER_ADDRESSES addr, Win32_MIB_I public override IPv4InterfaceProperties GetIPv4Properties () { - Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index); - return new Win32IPv4InterfaceProperties (v4info, mib4); + return new Win32IPv4InterfaceProperties (addr, mib4); } public override IPv6InterfaceProperties GetIPv6Properties () { - Win32_IP_ADAPTER_INFO v6info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib6.Index); return new Win32IPv6InterfaceProperties (mib6); } @@ -371,10 +369,9 @@ static IPAddressInformationCollection Win32FromAnycast (IntPtr ptr) public override IPAddressCollection DhcpServerAddresses { get { - Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index); // FIXME: should ipv6 DhcpServer be considered? try { - return new Win32IPAddressCollection (v4info.DhcpServer); + return Win32IPAddressCollection.FromSocketAddress (addr.Dhcpv4Server); } catch (IndexOutOfRangeException) { return Win32IPAddressCollection.Empty; } @@ -393,28 +390,17 @@ public override GatewayIPAddressInformationCollection GatewayAddresses { get { var col = new GatewayIPAddressInformationCollection (); try { - Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index); // FIXME: should ipv6 DhcpServer be considered? - - var a = v4info.GatewayList; - if (!String.IsNullOrEmpty (a.IpAddress)) { - col.InternalAdd(new SystemGatewayIPAddressInformation(IPAddress.Parse (a.IpAddress))); - AddSubsequently (a.Next, col); + Win32_IP_ADAPTER_GATEWAY_ADDRESS a; + for (IntPtr p = addr.FirstGatewayAddress; p != IntPtr.Zero; p = a.Next) { + a = (Win32_IP_ADAPTER_GATEWAY_ADDRESS) Marshal.PtrToStructure (p, typeof (Win32_IP_ADAPTER_GATEWAY_ADDRESS)); + col.InternalAdd (new SystemGatewayIPAddressInformation (a.Address.GetIPAddress ())); } } catch (IndexOutOfRangeException) {} return col; } } - static void AddSubsequently (IntPtr head, GatewayIPAddressInformationCollection col) - { - Win32_IP_ADDR_STRING a; - for (IntPtr p = head; p != IntPtr.Zero; p = a.Next) { - a = (Win32_IP_ADDR_STRING) Marshal.PtrToStructure (p, typeof (Win32_IP_ADDR_STRING)); - col.InternalAdd (new SystemGatewayIPAddressInformation (IPAddress.Parse (a.IpAddress))); - } - } - public override bool IsDnsEnabled { get { return Win32NetworkInterface.FixedInfo.EnableDns != 0; } } @@ -444,7 +430,6 @@ static MulticastIPAddressInformationCollection Win32FromMulticast (IntPtr ptr) public override UnicastIPAddressInformationCollection UnicastAddresses { get { try { - Win32_IP_ADAPTER_INFO ai = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index); // FIXME: should ipv6 DhcpServer be considered? return Win32FromUnicast (addr.FirstUnicastAddress); } catch (IndexOutOfRangeException) { @@ -467,9 +452,7 @@ static UnicastIPAddressInformationCollection Win32FromUnicast (IntPtr ptr) public override IPAddressCollection WinsServersAddresses { get { try { - Win32_IP_ADAPTER_INFO v4info = Win32NetworkInterface2.GetAdapterInfoByIndex (mib4.Index); - // FIXME: should ipv6 DhcpServer be considered? - return new Win32IPAddressCollection (v4info.PrimaryWinsServer, v4info.SecondaryWinsServer); + return Win32IPAddressCollection.FromWinsServer (addr.FirstWinsServerAddress); } catch (IndexOutOfRangeException) { return Win32IPAddressCollection.Empty; } diff --git a/mcs/class/System/System.Net.NetworkInformation/IPv4InterfaceProperties.cs b/mcs/class/System/System.Net.NetworkInformation/IPv4InterfaceProperties.cs index 86fba917ab90..ab92dd05f908 100644 --- a/mcs/class/System/System.Net.NetworkInformation/IPv4InterfaceProperties.cs +++ b/mcs/class/System/System.Net.NetworkInformation/IPv4InterfaceProperties.cs @@ -129,13 +129,13 @@ sealed class Win32IPv4InterfaceProperties : IPv4InterfaceProperties [DllImport ("iphlpapi.dll")] static extern int GetPerAdapterInfo (int IfIndex, Win32_IP_PER_ADAPTER_INFO pPerAdapterInfo, ref int pOutBufLen); - Win32_IP_ADAPTER_INFO ainfo; + Win32_IP_ADAPTER_ADDRESSES addr; Win32_IP_PER_ADAPTER_INFO painfo; Win32_MIB_IFROW mib; - public Win32IPv4InterfaceProperties (Win32_IP_ADAPTER_INFO ainfo, Win32_MIB_IFROW mib) + public Win32IPv4InterfaceProperties (Win32_IP_ADAPTER_ADDRESSES addr, Win32_MIB_IFROW mib) { - this.ainfo = ainfo; + this.addr = addr; this.mib = mib; // get per-adapter info. @@ -160,7 +160,7 @@ public override bool IsAutomaticPrivateAddressingEnabled { } public override bool IsDhcpEnabled { - get { return ainfo.DhcpEnabled != 0; } + get { return addr.DhcpEnabled; } } public override bool IsForwardingEnabled { @@ -173,7 +173,7 @@ public override int Mtu { } public override bool UsesWins { - get { return ainfo.HaveWins; } + get { return addr.FirstWinsServerAddress != IntPtr.Zero; } } } diff --git a/mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs b/mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs index fedf95dbb4d3..9743e0c58dcf 100644 --- a/mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs +++ b/mcs/class/System/System.Net.NetworkInformation/NetworkInterface.cs @@ -465,9 +465,13 @@ static Win32_IP_ADAPTER_ADDRESSES [] GetAdaptersAddresses () { IntPtr ptr = IntPtr.Zero; int len = 0; - GetAdaptersAddresses (0, 0, IntPtr.Zero, ptr, ref len); + uint flags = Win32_IP_ADAPTER_ADDRESSES.GAA_FLAG_INCLUDE_WINS_INFO | Win32_IP_ADAPTER_ADDRESSES.GAA_FLAG_INCLUDE_GATEWAYS; + GetAdaptersAddresses (0, flags, IntPtr.Zero, ptr, ref len); + if (Marshal.SizeOf (typeof (Win32_IP_ADAPTER_ADDRESSES)) > len) + throw new NetworkInformationException (); + ptr = Marshal.AllocHGlobal(len); - int ret = GetAdaptersAddresses (0, 0, IntPtr.Zero, ptr, ref len); + int ret = GetAdaptersAddresses (0, flags, IntPtr.Zero, ptr, ref len); if (ret != 0) throw new NetworkInformationException (ret); @@ -829,14 +833,6 @@ class Win32NetworkInterface2 : NetworkInterface [DllImport ("iphlpapi.dll", SetLastError = true)] static extern int GetIfEntry (ref Win32_MIB_IFROW row); - public static Win32_IP_ADAPTER_INFO GetAdapterInfoByIndex (int index) - { - foreach (Win32_IP_ADAPTER_INFO info in GetAdaptersInfo ()) - if (info.Index == index) - return info; - throw new IndexOutOfRangeException ("No adapter found for index " + index); - } - static Win32_IP_ADAPTER_INFO [] GetAdaptersInfo () { int len = 0; diff --git a/mcs/class/System/System.Net.NetworkInformation/Win32NetworkInterfaceMarshal.cs b/mcs/class/System/System.Net.NetworkInformation/Win32NetworkInterfaceMarshal.cs index 88ae0b8e3589..667428713214 100644 --- a/mcs/class/System/System.Net.NetworkInformation/Win32NetworkInterfaceMarshal.cs +++ b/mcs/class/System/System.Net.NetworkInformation/Win32NetworkInterfaceMarshal.cs @@ -121,15 +121,37 @@ struct Win32_IP_ADAPTER_ADDRESSES { public NetworkInterfaceType IfType; public OperationalStatus OperStatus; public int Ipv6IfIndex; - [MarshalAs (UnmanagedType.ByValArray, SizeConst = 16 * 4)] + [MarshalAs (UnmanagedType.ByValArray, SizeConst = 16)] public uint [] ZoneIndices; - - // Note that Vista-only members and XP-SP1-only member are - // omitted. + public IntPtr FirstPrefix; // to PIP_ADAPTER_PREFIX + public UInt64 TransmitLinkSpeed; + public UInt64 ReceiveLinkSpeed; + public IntPtr FirstWinsServerAddress; // to PIP_ADAPTER_WINS_SERVER_ADDRESS_LH + public IntPtr FirstGatewayAddress; // to PIP_ADAPTER_GATEWAY_ADDRESS_LH + public uint Ipv4Metric; + public uint Ipv6Metric; + public UInt64 Luid; + public Win32_SOCKET_ADDRESS Dhcpv4Server; + public uint CompartmentId; + public UInt64 NetworkGuid; + public int ConnectionType; + public int TunnelType; + public Win32_SOCKET_ADDRESS Dhcpv6Server; + [MarshalAs (UnmanagedType.ByValArray, SizeConst = MAX_DHCPV6_DUID_LENGTH)] + public byte [] Dhcpv6ClientDuid; + public ulong Dhcpv6ClientDuidLength; + public ulong Dhcpv6Iaid; + public IntPtr FirstDnsSuffix; // to PIP_ADAPTER_DNS_SUFFIX + + //Flags For GetAdapterAddresses + public const int GAA_FLAG_INCLUDE_WINS_INFO = 0x0040; + public const int GAA_FLAG_INCLUDE_GATEWAYS = 0x0080; const int MAX_ADAPTER_ADDRESS_LENGTH = 8; + const int MAX_DHCPV6_DUID_LENGTH = 130; const int IP_ADAPTER_DDNS_ENABLED = 1; + const int IP_ADAPTER_DHCP_ENABLED = 4; const int IP_ADAPTER_RECEIVE_ONLY = 8; const int IP_ADAPTER_NO_MULTICAST = 0x10; @@ -137,6 +159,10 @@ public bool DdnsEnabled { get { return (Flags & IP_ADAPTER_DDNS_ENABLED) != 0; } } + public bool DhcpEnabled { + get { return (Flags & IP_ADAPTER_DHCP_ENABLED) != 0; } + } + public bool IsReceiveOnly { get { return (Flags & IP_ADAPTER_RECEIVE_ONLY) != 0; } } @@ -267,6 +293,22 @@ struct Win32_IP_ADAPTER_MULTICAST_ADDRESS public Win32_SOCKET_ADDRESS Address; } + [StructLayout (LayoutKind.Sequential)] + struct Win32_IP_ADAPTER_GATEWAY_ADDRESS + { + public Win32LengthFlagsUnion LengthFlags; + public IntPtr Next; // to Win32_IP_ADAPTER_GATEWAY_ADDRESS + public Win32_SOCKET_ADDRESS Address; + } + + [StructLayout (LayoutKind.Sequential)] + struct Win32_IP_ADAPTER_WINS_SERVER_ADDRESS + { + public Win32LengthFlagsUnion LengthFlags; + public IntPtr Next; // to Win32_IP_ADAPTER_WINS_SERVER_ADDRESS + public Win32_SOCKET_ADDRESS Address; + } + [StructLayout (LayoutKind.Sequential)] struct Win32_IP_ADAPTER_UNICAST_ADDRESS { From f3b4079995b88fe98261fb28eb58e39acd9dfd47 Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Wed, 18 Jul 2018 13:24:49 -0400 Subject: [PATCH 268/582] Fix SetAttribute not respecting file mappings FB1061522 --- mono/metadata/w32file.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mono/metadata/w32file.c b/mono/metadata/w32file.c index 78569331c169..88f9664bb2f9 100644 --- a/mono/metadata/w32file.c +++ b/mono/metadata/w32file.c @@ -481,6 +481,11 @@ ves_icall_System_IO_MonoIO_SetFileAttributes (const gunichar2 *path, gint32 attr gint32 *error) { gboolean ret; + const gunichar2 *path_remapped; + + if (path_remapped = mono_unity_remap_path_utf16 (path)) + path = path_remapped; + *error=ERROR_SUCCESS; ret=mono_w32file_set_attributes (path, @@ -488,6 +493,9 @@ ves_icall_System_IO_MonoIO_SetFileAttributes (const gunichar2 *path, gint32 attr if(ret==FALSE) { *error=mono_w32error_get_last (); } + + g_free (path_remapped); + return(ret); } From 2d443fe1a2645d45e7b52ad040cd8634d334224f Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Thu, 19 Jul 2018 11:17:38 -0400 Subject: [PATCH 269/582] Copy the libMonoPosixHelper libraries to the android abi folders --- external/buildscripts/build.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/external/buildscripts/build.pl b/external/buildscripts/build.pl index 1622b44ddd3f..eee3432411fa 100644 --- a/external/buildscripts/build.pl +++ b/external/buildscripts/build.pl @@ -1642,6 +1642,8 @@ print ">>> Copying $file\n"; system("cp", "$monoroot/mono/mini/.libs/$file","$embedDirArchDestination/$file") eq 0 or die ("failed copying $file\n"); } + print ">>> Copying libMonoPosixHelper.so\n"; + system("cp", "$monoroot/support/.libs/libMonoPosixHelper.so","$embedDirArchDestination/libMonoPosixHelper.so") eq 0 or die ("failed copying libMonoPosixHelper.so\n"); } elsif ($tizen || $tizenEmulator) { From 573175c6e9b94b264303d7f173f1430f7a2db756 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 24 Jul 2018 11:47:39 -0400 Subject: [PATCH 270/582] Fix copy/paste error. Use size parameter for non-moving GC allocation. Remove return statements from void function to silence warnings. --- mono/metadata/domain.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mono/metadata/domain.c b/mono/metadata/domain.c index 4a7af0faabd2..2c680e952341 100644 --- a/mono/metadata/domain.c +++ b/mono/metadata/domain.c @@ -299,16 +299,16 @@ gc_alloc_fixed_non_heap_list (size_t size) if (mono_gc_is_moving ()) return g_malloc0 (size); else - return mono_gc_alloc_fixed (appdomain_list_size * sizeof (void*), MONO_GC_DESCRIPTOR_NULL, MONO_ROOT_SOURCE_DOMAIN, NULL, "Domain List"); + return mono_gc_alloc_fixed (size, MONO_GC_DESCRIPTOR_NULL, MONO_ROOT_SOURCE_DOMAIN, NULL, "Domain List"); } static void gc_free_fixed_non_heap_list (void *ptr) { if (mono_gc_is_moving ()) - return g_free (ptr); + g_free (ptr); else - return mono_gc_free_fixed (ptr); + mono_gc_free_fixed (ptr); } /* * Allocate an id for domain and set domain->domain_id. From 81253f6c0b3acc671c2f0eab9c067e71799171d6 Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Tue, 24 Jul 2018 13:26:52 -0400 Subject: [PATCH 271/582] Fix issue where get offset could return 0 when the type is uninited --- mono/metadata/class.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mono/metadata/class.c b/mono/metadata/class.c index ccdae030ef9b..b19c0e04b16f 100644 --- a/mono/metadata/class.c +++ b/mono/metadata/class.c @@ -9685,6 +9685,7 @@ mono_field_get_flags (MonoClassField *field) guint32 mono_field_get_offset (MonoClassField *field) { + mono_class_setup_fields(field->parent); return field->offset; } From 6307b9b088a3af6dd07cbe3629066c819fd8ba6d Mon Sep 17 00:00:00 2001 From: Brian Raderman Date: Tue, 24 Jul 2018 16:33:22 -0400 Subject: [PATCH 272/582] Remove assert when retrieving value of string with invalid chars Fix for Unity case 1052246. Debugger was asserting when trying to retrieve the value of a string that has invalid characters. The assert will crash the Unity player/editor. Changing to detect error, free the string if necessary, and return an error code to the client. --- mono/mini/debugger-agent.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 79337e0e26fc..d98327226909 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -11456,7 +11456,13 @@ string_commands (int command, guint8 *p, guint8 *end, Buffer *buf) } else { MonoError error; s = mono_string_to_utf8_checked (str, &error); - mono_error_assert_ok (&error); + if (!mono_error_ok (&error)) { + if (s) + g_free (s); + + return ERR_INVALID_ARGUMENT; + } + buffer_add_string (buf, s); g_free (s); } From 9386854fa54736eab4dddb12556a904bdb3c435f Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Wed, 25 Jul 2018 15:48:31 -0400 Subject: [PATCH 273/582] Update bdwgc submodule to unity-master https://github.com/Unity-Technologies/bdwgc/commit/f40bf2ab729fa043a20e400839aae1ffce03e2ca --- external/bdwgc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/bdwgc b/external/bdwgc index 4d98daa2153d..f40bf2ab729f 160000 --- a/external/bdwgc +++ b/external/bdwgc @@ -1 +1 @@ -Subproject commit 4d98daa2153d41f75339918422d9d59eb54bb86b +Subproject commit f40bf2ab729fa043a20e400839aae1ffce03e2ca From eb5815c3a5ced978696eda16cf87df66797d73fe Mon Sep 17 00:00:00 2001 From: Brian Raderman Date: Thu, 26 Jul 2018 16:00:29 -0400 Subject: [PATCH 274/582] Add check for a generic method when invoking in debugger Fix for Unity case 1049288. VSTU will try to invoke a generic (uninflated) method in certain situations, which was causing the Mono debugger to assert and crash Unity. Added a check for this situation before the invoke and returning an error to the client. Previously, this case wasn't caught until the method was in JIT compilation, which will assert. --- mcs/class/Mono.Debugger.Soft/Test/dtest.cs | 12 ++++++++++++ mono/mini/debugger-agent.c | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs index 7d5c0fdbe660..3d0c5e3d43f7 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs @@ -4396,5 +4396,17 @@ public void Pointer_GetValue () { AssertValue (3.0, f); } + + [Test] + public void InvokeGenericMethod () { + Event e = run_until ("bp1"); + StackFrame frame = e.Thread.GetFrames()[0]; + TypeMirror t = frame.Method.DeclaringType; + MethodMirror m; + m = t.GetMethod ("generic_method"); + AssertThrows (delegate { + t.InvokeMethod (e.Thread, m, null); + }); + } } // class DebuggerTests } // namespace diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index d98327226909..cba5b98e1d7e 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -8181,7 +8181,11 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 this_buf = (guint8 *)g_alloca (mono_class_instance_size (m->klass)); else this_buf = (guint8 *)g_alloca (sizeof (MonoObject*)); - if (m->klass->valuetype && (m->flags & METHOD_ATTRIBUTE_STATIC)) { + + if (m->is_generic) { + DEBUG_PRINTF (1, "[%p] Error: Attemtping to invoke uninflated generic method %s.\n", (gpointer)(gsize)mono_native_thread_id_get (), mono_method_full_name (m, TRUE)); + return ERR_INVALID_ARGUMENT; + } else if (m->klass->valuetype && (m->flags & METHOD_ATTRIBUTE_STATIC)) { /* Should be null */ int type = decode_byte (p, &p, end); if (type != VALUE_TYPE_ID_NULL) { From c839e04ee49c5daa212f7d39d7be09b79cb0fabe Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Fri, 27 Jul 2018 10:54:15 -0400 Subject: [PATCH 275/582] Only use the AOT code path for the AOT profile In the Unity repo we now use only the AOT profile for IL2CPP, so there is no need to take this AOT-friendly code path in the non_AOT profile. --- mcs/class/corlib/System.Reflection/MonoProperty.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mcs/class/corlib/System.Reflection/MonoProperty.cs b/mcs/class/corlib/System.Reflection/MonoProperty.cs index e9553cfe0eb5..a4c807d3de67 100644 --- a/mcs/class/corlib/System.Reflection/MonoProperty.cs +++ b/mcs/class/corlib/System.Reflection/MonoProperty.cs @@ -378,9 +378,7 @@ public override object GetValue (object obj, object[] index) { if (index == null || index.Length == 0) { /*FIXME we should check if the number of arguments matches the expected one, otherwise the error message will be pretty criptic.*/ -// Once we ship the changes to make il2cpp always use the unityaot profile, we should change -// this define to be UNITY_AOT. for now though, we'll take the AOT-friendly code path in all profiles. -#if !FULL_AOT_RUNTIME && !UNITY +#if !FULL_AOT_RUNTIME && !UNITY_AOT if (cached_getter == null) { MethodInfo method = GetGetMethod (true); if (!DeclaringType.IsValueType && !method.ContainsGenericParameters) { //FIXME find a way to build an invoke delegate for value types. From 8f2f3b1267a568e2cc639ea4a7b85caaabb89c0d Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 27 Jul 2018 10:59:41 -0400 Subject: [PATCH 276/582] Include gc_wrapper.h rather than gc.h directly. --- mono/metadata/unity-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mono/metadata/unity-utils.c b/mono/metadata/unity-utils.c index ef8a37777e5a..63d078e9ffc7 100644 --- a/mono/metadata/unity-utils.c +++ b/mono/metadata/unity-utils.c @@ -31,7 +31,7 @@ #include #if HAVE_BDWGC_GC -#include +#include #endif #include From 448f290ef403d49a4c75c44c513d07f15d949dab Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 31 Jul 2018 17:36:39 -0400 Subject: [PATCH 277/582] Sync IL2CPP change from 4607d96d9f45cf7cb296f2673f249778e71dd65f Get locals for a method with no locals --- mono/mini/debugger-agent.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index cba5b98e1d7e..23417ad48fd8 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -10262,8 +10262,16 @@ static void GetExecutionContextAndHeaderInfo(MonoMethod* method, uint32_t* execu if (il2cpp_mono_methods_match(il2cpp_get_seq_point_method(seqPoint), method)) { Il2CppMethodExecutionContextInfoIndex *index = &g_il2cpp_metadata->methodExecutionContextInfoIndexes[seqPoint->methodIndex]; - *executionContextInfoCount = index->count; - *executionContextInfo = &g_il2cpp_metadata->methodExecutionContextInfos[index->tableIndex][index->startIndex]; + if (index->count != -1) + { + *executionContextInfoCount = index->count; + *executionContextInfo = &g_il2cpp_metadata->methodExecutionContextInfos[index->tableIndex][index->startIndex]; + } + else + { + *executionContextInfoCount = 0; + *executionContextInfo = NULL; + } *headerInfo = &g_il2cpp_metadata->methodHeaderInfos[seqPoint->methodIndex]; *scopes = &g_il2cpp_metadata->methodScopes[(*headerInfo)->startScope]; return; @@ -10528,7 +10536,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g g_free (locals_map); #else uint32_t executionInfoCount, localVariableCount = 0, i; - const Il2CppMethodExecutionContextInfo* executionContextInfo; + const Il2CppMethodExecutionContextInfo* executionContextInfo = NULL; const Il2CppMethodHeaderInfo* headerInfo; const Il2CppMethodScope* scopes; From 4ca3689f3fde56dd8b77b2172c6cbae578fd016e Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Mon, 6 Aug 2018 09:20:10 -0400 Subject: [PATCH 278/582] Fix double gchandle free in thread detach logic --- mono/metadata/threads.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index 367fb67fc560..594e15f72f0a 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -3054,8 +3054,6 @@ thread_detach (MonoThreadInfo *info) internal = (MonoInternalThread*) mono_gchandle_get_target (gchandle); g_assert (internal); - mono_gchandle_free (gchandle); - mono_thread_detach_internal (internal); } From e65f2b08c9506d51237d5f62c80f8f70cbeecd6e Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Wed, 8 Aug 2018 14:07:15 +0200 Subject: [PATCH 279/582] Add option for strict write barriers --- mono/metadata/boehm-gc.c | 63 ++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index 51d213d572d6..9c867c4100c7 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -59,6 +59,7 @@ void *pthread_get_stackaddr_np(pthread_t); #define MIN_BOEHM_MAX_HEAP_SIZE (MIN_BOEHM_MAX_HEAP_SIZE_IN_MB << 20) static gboolean gc_initialized = FALSE; +static gboolean gc_strict_wbarriers = FALSE; static mono_mutex_t mono_gc_lock; typedef void (*GC_push_other_roots_proc)(void); @@ -247,7 +248,10 @@ mono_gc_base_init (void) #endif } continue; - } else { + } else if (g_str_has_prefix (opt, "strict-wbarriers")) { + gc_strict_wbarriers = TRUE; + continue; + }else { /* Could be a parameter for sgen */ /* fprintf (stderr, "MONO_GC_PARAMS must be a comma-delimited list of one or more of the following:\n"); @@ -273,6 +277,24 @@ mono_gc_base_init (void) gc_initialized = TRUE; } +void +mono_gc_dirty(void **ptr) +{ + GC_dirty (ptr); +} + +void +mono_gc_dirty_range(void **ptr, size_t size) +{ + if (G_UNLIKELY(gc_strict_wbarriers)) + { + for (int i = 0; i < size/sizeof(void*); i++) + GC_dirty(ptr + i); + } + else + GC_dirty (ptr); +} + void mono_gc_base_cleanup (void) { @@ -647,7 +669,7 @@ mono_gc_weak_link_add (void **link_addr, MonoObject *obj, gboolean track) { /* libgc requires that we use HIDE_POINTER... */ *link_addr = (void*)HIDE_POINTER (obj); - GC_dirty (link_addr); + mono_gc_dirty (link_addr); if (track) GC_REGISTER_LONG_LINK (link_addr, obj); else @@ -892,57 +914,60 @@ void mono_gc_wbarrier_set_field (MonoObject *obj, gpointer field_ptr, MonoObject* value) { *(void**)field_ptr = value; - GC_dirty (field_ptr); + mono_gc_dirty (field_ptr); } void mono_gc_wbarrier_set_arrayref (MonoArray *arr, gpointer slot_ptr, MonoObject* value) { *(void**)slot_ptr = value; - GC_dirty (slot_ptr); + mono_gc_dirty (slot_ptr); } void mono_gc_wbarrier_arrayref_copy (gpointer dest_ptr, gpointer src_ptr, int count) { mono_gc_memmove_aligned (dest_ptr, src_ptr, count * sizeof (gpointer)); - GC_dirty (dest_ptr); + mono_gc_dirty_range (dest_ptr, count * sizeof(gpointer)); } void mono_gc_wbarrier_generic_store (gpointer ptr, MonoObject* value) { *(void**)ptr = value; - GC_dirty (ptr); + mono_gc_dirty (ptr); } void mono_gc_wbarrier_generic_store_atomic (gpointer ptr, MonoObject *value) { mono_atomic_store_ptr ((volatile gpointer *)ptr, value); - GC_dirty (ptr); + mono_gc_dirty (ptr); } void mono_gc_wbarrier_generic_nostore (gpointer ptr) { - GC_dirty (ptr); + mono_gc_dirty (ptr); } void mono_gc_wbarrier_value_copy (gpointer dest, gpointer src, int count, MonoClass *klass) { - mono_gc_memmove_atomic (dest, src, count * mono_class_value_size (klass, NULL)); - GC_dirty (dest); + size_t size = count * mono_class_value_size (klass, NULL); + mono_gc_memmove_atomic (dest, src, size); + mono_gc_dirty_range (dest, size); } void mono_gc_wbarrier_object_copy (MonoObject* obj, MonoObject *src) { /* do not copy the sync state */ - mono_gc_memmove_aligned ((char*)obj + sizeof (MonoObject), (char*)src + sizeof (MonoObject), - mono_object_class (obj)->instance_size - sizeof (MonoObject)); - GC_dirty (obj); + size_t size = mono_object_class (obj)->instance_size - sizeof (MonoObject); + char * dstPtr = (char*)obj + sizeof (MonoObject); + mono_gc_memmove_aligned (dstPtr, (char*)src + sizeof (MonoObject), + size); + mono_gc_dirty_range ((void**)dstPtr, size); } void @@ -1514,7 +1539,7 @@ void mono_gc_wbarrier_range_copy (gpointer _dest, gpointer _src, int size) { memcpy (_dest, _src, size); - GC_dirty (_dest); + mono_gc_dirty_range (_dest, size); } void* @@ -1875,7 +1900,7 @@ handle_data_grow (HandleData *handles, gboolean track) gpointer *entries; entries = (void **)mono_gc_alloc_fixed (sizeof (*handles->entries) * new_size, NULL, MONO_ROOT_SOURCE_GC_HANDLE, NULL, "GC Handle Table (Boehm)"); mono_gc_memmove_aligned (entries, handles->entries, sizeof (*handles->entries) * handles->size); - GC_dirty (entries); + mono_gc_dirty_range (entries, new_size * sizeof (*handles->entries)); mono_gc_free_fixed (handles->entries); handles->entries = entries; } @@ -1908,7 +1933,7 @@ alloc_handle (HandleData *handles, MonoObject *obj, gboolean track) mono_gc_weak_link_add (&(handles->entries [slot]), obj, track); } else { handles->entries [slot] = obj; - GC_dirty (handles->entries + slot); + mono_gc_dirty (handles->entries + slot); } #ifndef DISABLE_PERFCOUNTERS @@ -2026,7 +2051,7 @@ mono_gchandle_set_target (guint32 gchandle, MonoObject *obj) handles->domain_ids [slot] = (obj ? mono_object_get_domain (obj) : mono_domain_get ())->domain_id; } else { handles->entries [slot] = obj; - GC_dirty (handles->entries + slot); + mono_gc_dirty (handles->entries + slot); } } else { /* print a warning? */ @@ -2105,7 +2130,7 @@ mono_gchandle_free (guint32 gchandle) mono_gc_weak_link_remove (&handles->entries [slot], handles->type == HANDLE_WEAK_TRACK); } else { handles->entries [slot] = NULL; - GC_dirty (handles->entries + slot); + mono_gc_dirty (handles->entries + slot); } vacate_slot (handles, slot); } else { @@ -2148,7 +2173,7 @@ mono_gchandle_free_domain (MonoDomain *domain) if (handles->entries [slot] && mono_object_domain (handles->entries [slot]) == domain) { vacate_slot (handles, slot); handles->entries [slot] = NULL; - GC_dirty (handles->entries + slot); + mono_gc_dirty (handles->entries + slot); } } } From a4994b54a3b9de779bb0be5e778614dfd0411bf6 Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Wed, 8 Aug 2018 15:10:48 +0200 Subject: [PATCH 280/582] Add several write barriers needed to comply with strict wbarrier mode --- mono/metadata/appdomain.c | 7 +++++++ mono/metadata/domain.c | 1 + mono/metadata/icall.c | 1 + mono/metadata/reflection.c | 3 +++ mono/metadata/threads.c | 8 ++++++++ 5 files changed, 20 insertions(+) diff --git a/mono/metadata/appdomain.c b/mono/metadata/appdomain.c index 0127ad6fd909..db8304213e60 100644 --- a/mono/metadata/appdomain.c +++ b/mono/metadata/appdomain.c @@ -198,6 +198,7 @@ create_domain_objects (MonoDomain *domain) mono_error_assert_ok (&error); mono_field_static_set_value (string_vt, string_empty_fld, empty_str); domain->empty_string = empty_str; + mono_gc_wbarrier_generic_nostore (&domain->empty_string); /* * Create an instance early since we can't do it when there is no memory. @@ -205,6 +206,7 @@ create_domain_objects (MonoDomain *domain) arg = mono_string_new_checked (domain, "Out of memory", &error); mono_error_assert_ok (&error); domain->out_of_memory_ex = mono_exception_from_name_two_strings_checked (mono_defaults.corlib, "System", "OutOfMemoryException", arg, NULL, &error); + mono_gc_wbarrier_generic_nostore (&domain->out_of_memory_ex); mono_error_assert_ok (&error); /* @@ -214,14 +216,17 @@ create_domain_objects (MonoDomain *domain) arg = mono_string_new_checked (domain, "A null value was found where an object instance was required", &error); mono_error_assert_ok (&error); domain->null_reference_ex = mono_exception_from_name_two_strings_checked (mono_defaults.corlib, "System", "NullReferenceException", arg, NULL, &error); + mono_gc_wbarrier_generic_nostore (&domain->null_reference_ex); mono_error_assert_ok (&error); arg = mono_string_new_checked (domain, "The requested operation caused a stack overflow.", &error); mono_error_assert_ok (&error); domain->stack_overflow_ex = mono_exception_from_name_two_strings_checked (mono_defaults.corlib, "System", "StackOverflowException", arg, NULL, &error); + mono_gc_wbarrier_generic_nostore (&domain->stack_overflow_ex); mono_error_assert_ok (&error); /*The ephemeron tombstone i*/ domain->ephemeron_tombstone = mono_object_new_checked (domain, mono_defaults.object_class, &error); + mono_gc_wbarrier_generic_nostore (&domain->ephemeron_tombstone); mono_error_assert_ok (&error); if (domain != old_domain) { @@ -292,7 +297,9 @@ mono_runtime_init_checked (MonoDomain *domain, MonoThreadStartCB start_cb, MonoT ad->data = domain; domain->domain = ad; + mono_gc_wbarrier_generic_nostore (&domain->domain); domain->setup = setup; + mono_gc_wbarrier_generic_nostore (&domain->setup); mono_thread_attach (domain); diff --git a/mono/metadata/domain.c b/mono/metadata/domain.c index 2c680e952341..71425639babf 100644 --- a/mono/metadata/domain.c +++ b/mono/metadata/domain.c @@ -923,6 +923,7 @@ mono_domain_set_internal_with_options (MonoDomain *domain, gboolean migrate_exce SET_APPDOMAIN (domain); SET_APPCONTEXT (domain->default_context); + mono_gc_wbarrier_generic_nostore (&domain->default_context); if (migrate_exception) { thread = mono_thread_internal_current (); diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c index 3537675aabcf..baf16bd07fbf 100644 --- a/mono/metadata/icall.c +++ b/mono/metadata/icall.c @@ -2479,6 +2479,7 @@ ves_icall_RuntimeType_GetInterfaces (MonoReflectionTypeHandle ref_type, MonoErro g_hash_table_destroy (iface_hash); if (!domain->empty_types) { domain->empty_types = mono_array_new_cached (domain, mono_defaults.runtimetype_class, 0, error); + mono_gc_wbarrier_generic_nostore (&domain->empty_types); goto_if_nok (error, fail); } return MONO_HANDLE_NEW (MonoArray, domain->empty_types); diff --git a/mono/metadata/reflection.c b/mono/metadata/reflection.c index 6ee435419744..e6e369e3af73 100644 --- a/mono/metadata/reflection.c +++ b/mono/metadata/reflection.c @@ -534,7 +534,10 @@ mono_type_get_object_checked (MonoDomain *domain, MonoType *type, MonoError *err mono_g_hash_table_insert (domain->type_hash, type, res); if (type->type == MONO_TYPE_VOID) + { domain->typeof_void = (MonoObject*)res; + mono_gc_wbarrier_generic_nostore (&domain->typeof_void); + } mono_domain_unlock (domain); mono_loader_unlock (); diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index 594e15f72f0a..c0a6367008ae 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -523,6 +523,7 @@ set_current_thread_for_domain (MonoDomain *domain, MonoInternalThread *thread, M g_assert (!*current_thread_ptr); *current_thread_ptr = current; + mono_gc_wbarrier_generic_nostore (current_thread_ptr); } static MonoThread* @@ -1781,6 +1782,7 @@ mono_thread_current (void) if (!*current_thread_ptr) { g_assert (domain != mono_get_root_domain ()); *current_thread_ptr = create_thread_object (domain, internal); + mono_gc_wbarrier_generic_nostore (current_thread_ptr); } return *current_thread_ptr; } @@ -1798,6 +1800,7 @@ mono_thread_current_for_thread (MonoInternalThread *internal) if (!*current_thread_ptr) { g_assert (domain != mono_get_root_domain ()); *current_thread_ptr = create_thread_object (domain, internal); + mono_gc_wbarrier_generic_nostore (current_thread_ptr); } return *current_thread_ptr; } @@ -4139,10 +4142,13 @@ mono_alloc_static_data (gpointer **static_data_ptr, guint32 offset, void *alloc_ if (mono_gc_user_markers_supported ()) static_data [i] = g_malloc0 (static_data_size [i]); else + { static_data [i] = mono_gc_alloc_fixed (static_data_size [i], MONO_GC_DESCRIPTOR_NULL, threadlocal ? MONO_ROOT_SOURCE_THREAD_STATIC : MONO_ROOT_SOURCE_CONTEXT_STATIC, alloc_key, threadlocal ? "ThreadStatic Fields" : "ContextStatic Fields"); + mono_gc_wbarrier_generic_nostore (static_data + i); + } } } @@ -4221,6 +4227,7 @@ context_adjust_static_data (MonoAppContext *ctx) if (context_static_info.offset || context_static_info.idx > 0) { guint32 offset = MAKE_SPECIAL_STATIC_OFFSET (context_static_info.idx, context_static_info.offset, 0); mono_alloc_static_data (&ctx->static_data, offset, ctx, FALSE); + mono_gc_wbarrier_generic_nostore (&ctx->static_data); ctx->data->static_data = ctx->static_data; } } @@ -4250,6 +4257,7 @@ alloc_context_static_data_helper (gpointer key, gpointer value, gpointer user) guint32 offset = GPOINTER_TO_UINT (user); mono_alloc_static_data (&ctx->static_data, offset, ctx, FALSE); + mono_gc_wbarrier_generic_nostore (&ctx->static_data); ctx->data->static_data = ctx->static_data; } From b6076e2fcb4fbe4ddadee9d6f4d8ec2f84899dae Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Thu, 9 Aug 2018 16:23:00 -0400 Subject: [PATCH 281/582] Apply debugger changes from il2cpp 0c52b0b5b2babc2cbec886b8ef8015f68249026e --- mono/mini/debugger-agent.c | 135 +++++++++++-------------------------- mono/mini/il2cpp-compat.h | 3 + mono/mini/il2cpp-stubs.cpp | 31 ++++----- 3 files changed, 55 insertions(+), 114 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 23417ad48fd8..3a8b7271a9d4 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -163,6 +163,8 @@ typedef struct MonoContext ctx; #ifndef RUNTIME_IL2CPP MonoDebugMethodJitInfo *jit; +#else + Il2CppSequencePointExecutionContext* frame_context; #endif MonoJitInfo *ji; MonoInterpFrameHandle interp_frame; @@ -3431,7 +3433,8 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) StackFrame* frame = g_new0(StackFrame, 1); MonoMethod *sp_method = il2cpp_get_seq_point_method(seq_point); frame->method = sp_method; - frame->actual_method = sp_method; + frame->actual_method = tls->il2cpp_context.executionContexts[frame_index]->method; + frame->frame_context = tls->il2cpp_context.executionContexts[frame_index]; frame->api_method = sp_method; frame->il_offset = seq_point->ilOffset; frame->native_offset = 0; @@ -4802,7 +4805,7 @@ set_breakpoint (MonoMethod *method, long il_offset, EventRequest *req, MonoError Il2CppSequencePoint *seqPoint; while(seqPoint = il2cpp_get_method_sequence_points(method, &seqPointIter)) { - if (bp_matches_method(bp, il2cpp_get_seq_point_method(seqPoint)) && seqPoint->ilOffset == bp->il_offset) + if (seqPoint->ilOffset == bp->il_offset) { if (req->event_kind == EVENT_KIND_BREAKPOINT && seqPoint->kind == kSequencePointKind_StepOut) continue; @@ -10253,34 +10256,6 @@ static void GetSequencePointsAndSourceFilesUniqueSequencePoints(MonoMethod* meth } } -static void GetExecutionContextAndHeaderInfo(MonoMethod* method, uint32_t* executionContextInfoCount, const Il2CppMethodExecutionContextInfo **executionContextInfo, const Il2CppMethodHeaderInfo **headerInfo, const Il2CppMethodScope **scopes) -{ - void *seqPointIter = NULL; - Il2CppSequencePoint *seqPoint; - while (seqPoint = il2cpp_get_method_sequence_points(method, &seqPointIter)) - { - if (il2cpp_mono_methods_match(il2cpp_get_seq_point_method(seqPoint), method)) - { - Il2CppMethodExecutionContextInfoIndex *index = &g_il2cpp_metadata->methodExecutionContextInfoIndexes[seqPoint->methodIndex]; - if (index->count != -1) - { - *executionContextInfoCount = index->count; - *executionContextInfo = &g_il2cpp_metadata->methodExecutionContextInfos[index->tableIndex][index->startIndex]; - } - else - { - *executionContextInfoCount = 0; - *executionContextInfo = NULL; - } - *headerInfo = &g_il2cpp_metadata->methodHeaderInfos[seqPoint->methodIndex]; - *scopes = &g_il2cpp_metadata->methodScopes[(*headerInfo)->startScope]; - return; - } - } - - g_assert(FALSE); // shouldn't be ever reached -} - #endif // RUNTIME_IL2CPP static ErrorCode @@ -10535,12 +10510,12 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g mono_debug_free_locals (locals); g_free (locals_map); #else - uint32_t executionInfoCount, localVariableCount = 0, i; + uint32_t executionInfoCount, i; const Il2CppMethodExecutionContextInfo* executionContextInfo = NULL; const Il2CppMethodHeaderInfo* headerInfo; - const Il2CppMethodScope* scopes; + const Il2CppMethodScope* scopes; - GetExecutionContextAndHeaderInfo(method, &executionInfoCount, &executionContextInfo, &headerInfo, &scopes); + il2cpp_debugger_get_method_execution_context_and_header_Info (method, &executionInfoCount, &executionContextInfo, &headerInfo, &scopes); if (CHECK_PROTOCOL_VERSION(2, 43)) { if (headerInfo) @@ -10558,32 +10533,18 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g } } - for (i = 0; i < executionInfoCount; i++) - { - if (executionContextInfo[i].variableKind == kMethodVariableKind_LocalVariable) - localVariableCount++; - } - - buffer_add_int(buf, localVariableCount); + buffer_add_int(buf, executionInfoCount); for (i = 0; i < executionInfoCount; i++) - { - if (executionContextInfo[i].variableKind == kMethodVariableKind_LocalVariable) - buffer_add_typeid(buf, domain, mono_class_from_mono_type(il2cpp_get_type_from_index(executionContextInfo[i].typeIndex))); - } + buffer_add_typeid(buf, domain, mono_class_from_mono_type(il2cpp_type_inflate (il2cpp_get_type_from_index(executionContextInfo[i].typeIndex), il2cpp_mono_method_get_context(method)))); for (i = 0; i < executionInfoCount; i++) - { - if (executionContextInfo[i].variableKind == kMethodVariableKind_LocalVariable) - buffer_add_string(buf, g_il2cpp_metadata->methodExecutionContextInfoStrings[executionContextInfo[i].nameIndex]); - } + buffer_add_string(buf, g_il2cpp_metadata->methodExecutionContextInfoStrings[executionContextInfo[i].nameIndex]); for (i = 0; i < executionInfoCount; i++) { - if (executionContextInfo[i].variableKind == kMethodVariableKind_LocalVariable) { - buffer_add_int(buf, executionContextInfo[i].startOffset); - buffer_add_int(buf, executionContextInfo[i].endOffset); - } + buffer_add_int(buf, g_il2cpp_metadata->methodScopes[executionContextInfo[i].scopeIndex].startOffset); + buffer_add_int(buf, g_il2cpp_metadata->methodScopes[executionContextInfo[i].scopeIndex].endOffset); } #endif // !RUNTIME_IL2CPP break; @@ -11016,42 +10977,31 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf) #ifdef RUNTIME_IL2CPP -static uint32_t GetExecutionContextIndexAndType(const Il2CppSequencePoint* sequencePoint, MethodVariableKind variableKind, uint32_t variablePosition, MonoType **type) +static void GetVariable(DebuggerTlsData* tls, StackFrame* frame, MethodVariableKind variableKind, uint32_t variablePosition, MonoType** type, void** var) { - uint32_t executionContextPosition, variablesIterated = 0; - - Il2CppMethodExecutionContextInfoIndex *index = &g_il2cpp_metadata->methodExecutionContextInfoIndexes[sequencePoint->methodIndex]; - Il2CppMethodExecutionContextInfo *executionContextInfos = &g_il2cpp_metadata->methodExecutionContextInfos[index->tableIndex][index->startIndex]; - - for (executionContextPosition = 0;; executionContextPosition++) - { - g_assert(executionContextPosition < index->count); - - if (executionContextInfos[executionContextPosition].variableKind == variableKind) - { - if (variablesIterated == variablePosition) - { - *type = il2cpp_get_type_from_index(executionContextInfos[executionContextPosition].typeIndex); - return executionContextPosition; - } + switch (variableKind) + { + case kMethodVariableKind_Parameter: { + *var = frame->frame_context->params[variablePosition]; + *type = il2cpp_method_get_param (frame->actual_method, variablePosition); + } + break; + case kMethodVariableKind_LocalVariable: { + uint32_t executionInfoCount, localVariableCount = 0, i; + const Il2CppMethodExecutionContextInfo* executionContextInfo = NULL; + const Il2CppMethodHeaderInfo* headerInfo; + const Il2CppMethodScope* scopes; - variablesIterated++; - } - } -} + il2cpp_debugger_get_method_execution_context_and_header_Info (frame->actual_method, &executionInfoCount, &executionContextInfo, &headerInfo, &scopes); -static void GetVariable(DebuggerTlsData* tls, StackFrame* frame, MethodVariableKind variableKind, uint32_t variablePosition, MonoType** type, void** var) -{ - for (int frame_index = 0; frame_index < tls->il2cpp_context.frameCount; ++frame_index) - { - if (il2cpp_get_seq_point_method(tls->il2cpp_context.sequencePoints[frame_index]) == frame->actual_method) - { - Il2CppSequencePoint* sequencePoint = tls->il2cpp_context.sequencePoints[frame_index]; - Il2CppSequencePointExecutionContext* executionContext = tls->il2cpp_context.executionContexts[frame_index]; - uint32_t executionContextPosition = GetExecutionContextIndexAndType(sequencePoint, variableKind, variablePosition, type); - *var = executionContext->values[executionContextPosition]; - } - } + *var = frame->frame_context->locals[variablePosition]; + *type = il2cpp_type_inflate ( il2cpp_get_type_from_index (executionContextInfo[variablePosition].typeIndex), il2cpp_mono_method_get_context (frame->actual_method)); + } + break; + case kMethodVariableKind_This: + default: + g_assert_not_reached (); + } } static void SendVariableData(DebuggerTlsData* tls, StackFrame* frame, Buffer* buf, MethodVariableKind variableKind, uint32_t variablePosition) @@ -11217,14 +11167,8 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) add_var (buf, jit, &frame->actual_method->klass->this_arg, jit->this_var, &frame->ctx, frame->domain, TRUE); } #else - for (int frame_index = 0; frame_index < tls->il2cpp_context.frameCount; ++frame_index) - { - if (il2cpp_get_seq_point_method(tls->il2cpp_context.sequencePoints[frame_index]) == frame->actual_method) - { - buffer_add_value_full (buf, &frame->actual_method->klass->this_arg, tls->il2cpp_context.executionContexts[frame_index]->values[0], frame->domain, TRUE, NULL); - break; - } - } + buffer_add_value_full (buf, &frame->actual_method->klass->this_arg, *frame->frame_context->thisArg, frame->domain, FALSE, NULL); + break; #endif } } else { @@ -11243,7 +11187,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) add_var (buf, jit, &frame->api_method->klass->byval_arg, jit->this_var, &frame->ctx, frame->domain, TRUE); } #else - SendVariableData (tls, frame, buf, kMethodVariableKind_This, 0); + buffer_add_value_full (buf, &frame->actual_method->klass->byval_arg, *frame->frame_context->thisArg, frame->domain, FALSE, NULL); #endif } } @@ -11365,8 +11309,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) set_var (&frame->actual_method->klass->this_arg, var, &frame->ctx, frame->domain, val_buf, frame->reg_locations, &tls->restore_state.ctx); } #else - GetVariable (tls, frame, kMethodVariableKind_This, 0, &t, &var); - il2cpp_set_var(val_buf, var, &frame->actual_method->klass->this_arg); + il2cpp_set_var(val_buf, *frame->frame_context->thisArg, &frame->actual_method->klass->this_arg); #endif break; } diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index 1258544f6dba..5cd1dc0a2d20 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -459,5 +459,8 @@ char* il2cpp_assembly_get_full_name(MonoAssembly *assembly); const MonoMethod* il2cpp_get_seq_point_method(Il2CppSequencePoint *seqPoint); const MonoClass* il2cpp_get_class_from_index(int index); const MonoType* il2cpp_get_type_from_index(int index); +const MonoType* il2cpp_get_type_from_method_context(MonoType* type, const MonoMethod* method); +const MonoType* il2cpp_type_inflate(MonoType* type, const MonoGenericContext* context); +void il2cpp_debugger_get_method_execution_context_and_header_Info(const MonoMethod* method, uint32_t* executionContextInfoCount, const Il2CppMethodExecutionContextInfo **executionContextInfo, const Il2CppMethodHeaderInfo **headerInfo, const Il2CppMethodScope **scopes); #endif // RUNTIME_IL2CPP diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index 608fe8555815..271bafdabdca 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -1300,25 +1300,8 @@ gboolean il2cpp_mono_methods_match(MonoMethod* left, MonoMethod* right) return TRUE; if (rightMethod == NULL || leftMethod == NULL) return FALSE; - if (rightMethod->is_inflated && !rightMethod->is_generic && rightMethod->genericMethod->methodDefinition == leftMethod) + if (leftMethod->methodDefinition == rightMethod->methodDefinition) return TRUE; - if (leftMethod->is_inflated && !leftMethod->is_generic && leftMethod->genericMethod->methodDefinition == rightMethod) - return TRUE; - if (leftMethod->is_generic && rightMethod->is_inflated && rightMethod->methodPointer && - leftMethod->klass == rightMethod->klass && - strcmp(leftMethod->name, rightMethod->name) == 0) - { - if (leftMethod->parameters_count != rightMethod->parameters_count) - return FALSE; - - for(int i = 0;i < leftMethod->parameters_count;++i) - { - if ((leftMethod->parameters[i].parameter_type->type != IL2CPP_TYPE_MVAR) && (leftMethod->parameters[i].parameter_type->type != IL2CPP_TYPE_VAR) && (leftMethod->parameters[i].parameter_type != rightMethod->parameters[i].parameter_type)) - return FALSE; - } - - return TRUE; - } return FALSE; } @@ -1529,5 +1512,17 @@ const MonoType* il2cpp_get_type_from_index(int index) return il2cpp::vm::MetadataCache::GetIl2CppTypeFromIndex(index); } +const MonoType* il2cpp_type_inflate(MonoType* type, const MonoGenericContext* context) +{ + return il2cpp::metadata::GenericMetadata::InflateIfNeeded(type, context, true); +} + +void il2cpp_debugger_get_method_execution_context_and_header_Info(const MonoMethod* method, uint32_t* executionContextInfoCount, const Il2CppMethodExecutionContextInfo **executionContextInfo, const Il2CppMethodHeaderInfo **headerInfo, const Il2CppMethodScope **scopes) +{ +#if IL2CPP_MONO_DEBUGGER + il2cpp::utils::Debugger::GetMethodExecutionContextInfo(method, executionContextInfoCount, executionContextInfo, headerInfo, scopes); +#endif +} + } #endif // RUNTIME_IL2CPP From 2bcb3820eec90b3d6ba053911ab438f2a4070e72 Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Tue, 14 Aug 2018 16:14:09 +0200 Subject: [PATCH 282/582] Add another write barriers needed to comply with strict wbarrier mode --- mono/metadata/threads.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index c0a6367008ae..60611ff36187 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -1402,6 +1402,7 @@ ves_icall_System_Threading_Thread_ConstructInternalThread (MonoThread *this_obj) internal->state = ThreadState_Unstarted; mono_atomic_cas_ptr ((volatile gpointer *)&this_obj->internal_thread, internal, NULL); + mono_gc_wbarrier_generic_nostore (&this_obj->internal_thread); } MonoThread * From 248f7c2412b4fcc72337eab4436def79cd7eec3d Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Tue, 14 Aug 2018 16:14:31 +0200 Subject: [PATCH 283/582] Fix crash when gc is disabled --- mono/metadata/gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mono/metadata/gc.c b/mono/metadata/gc.c index 11d20fe6a9a7..b7a9901fe231 100644 --- a/mono/metadata/gc.c +++ b/mono/metadata/gc.c @@ -712,7 +712,7 @@ mono_gc_finalize_notify (void) g_message ( "%s: prodding finalizer", __func__); #endif - if (mono_gc_is_null ()) + if (mono_gc_is_null () || mono_gc_is_disabled()) return; #ifdef HOST_WASM From 7194a04443bd9ecad350922103fe0977f89afc8c Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Wed, 15 Aug 2018 11:08:12 +0200 Subject: [PATCH 284/582] Make gc params work for Boehm --- mono/metadata/boehm-gc.c | 46 +++++++++++++++--------------- mono/metadata/gc.c | 48 ++++++++++++++++++++++++++++++++ mono/metadata/null-gc.c | 10 ------- mono/sgen/gc-internal-agnostic.h | 2 ++ mono/sgen/sgen-gc.c | 32 ++------------------- 5 files changed, 75 insertions(+), 63 deletions(-) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index 9c867c4100c7..4f875a22961e 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -117,6 +117,8 @@ void mono_gc_base_init (void) { char *env; + char *params_opts = NULL; + char *debug_opts = NULL; if (gc_initialized) return; @@ -189,19 +191,21 @@ mono_gc_base_init (void) /* If GC_no_dls is set to true, GC_find_limit is not called. This causes a seg fault on Android With Mono's Older Boehm. */ GC_no_dls = TRUE; #endif + + debug_opts = mono_gc_debug_get(); + if (debug_opts) { - if ((env = g_getenv ("MONO_GC_DEBUG"))) { - char **opts = g_strsplit (env, ",", -1); - for (char **ptr = opts; ptr && *ptr; ptr ++) { - char *opt = *ptr; - if (!strcmp (opt, "do-not-finalize")) { - mono_do_not_finalize = 1; - } else if (!strcmp (opt, "log-finalizers")) { - log_finalizers = 1; - } + char **opts = g_strsplit (debug_opts, ",", -1); + for (char **ptr = opts; ptr && *ptr; ptr ++) { + char *opt = *ptr; + if (!strcmp (opt, "do-not-finalize")) { + mono_do_not_finalize = 1; + } else if (!strcmp (opt, "log-finalizers")) { + log_finalizers = 1; } - g_free (env); } + g_strfreev (opts); + g_free (debug_opts); } GC_init (); @@ -213,10 +217,12 @@ mono_gc_base_init (void) GC_init_gcj_malloc (5, NULL); GC_allow_register_threads (); - if ((env = g_getenv ("MONO_GC_PARAMS"))) { - char **ptr, **opts = g_strsplit (env, ",", -1); + params_opts = mono_gc_params_get(); + if (params_opts) { + char **ptr, **opts = g_strsplit (params_opts, ",", -1); for (ptr = opts; *ptr; ++ptr) { char *opt = *ptr; + if (g_str_has_prefix (opt, "max-heap-size=")) { size_t max_heap; @@ -260,8 +266,8 @@ mono_gc_base_init (void) */ } } - g_free (env); g_strfreev (opts); + g_free (params_opts); } mono_thread_callbacks_init (); @@ -763,6 +769,10 @@ mono_gc_alloc_obj (MonoVTable *vtable, size_t size) { MonoObject *obj; + if (strcmp(vtable->klass->name, "RuntimeTestInfo") == 0) + { + printf("hello"); + } if (!vtable->klass->has_references) { obj = (MonoObject *)GC_MALLOC_ATOMIC (size); if (G_UNLIKELY (!obj)) @@ -1579,16 +1589,6 @@ mono_gc_get_logfile (void) return NULL; } -void -mono_gc_params_set (const char* options) -{ -} - -void -mono_gc_debug_set (const char* options) -{ -} - void mono_gc_conservatively_scan_area (void *start, void *end) { diff --git a/mono/metadata/gc.c b/mono/metadata/gc.c index b7a9901fe231..956938f8cb45 100644 --- a/mono/metadata/gc.c +++ b/mono/metadata/gc.c @@ -87,6 +87,12 @@ static MonoCoopCond pending_done_cond; static MonoCoopMutex pending_done_mutex; #endif +static char* gc_params_options; +static char* gc_debug_options; + +#define MONO_GC_PARAMS_NAME "MONO_GC_PARAMS" +#define MONO_GC_DEBUG_NAME "MONO_GC_DEBUG" + static void object_register_finalizer (MonoObject *obj, void (*callback)(void *, void*)); static void reference_queue_proccess_all (void); @@ -161,6 +167,48 @@ coop_cond_timedwait_alertable (MonoCoopCond *cond, MonoCoopMutex *mutex, guint32 return res; } +void +mono_gc_params_set (const char* options) +{ + if (gc_params_options) + g_free (gc_params_options); + + gc_params_options = g_strdup (options); +} + +char * +mono_gc_params_get () +{ + char *env; + if ((env = g_getenv (MONO_GC_PARAMS_NAME)) || gc_params_options) { + char *params_opts = g_strdup_printf ("%s,%s", gc_params_options ? gc_params_options : "", env ? env : ""); + g_free (env); + return params_opts; + } + return NULL; +} + +void +mono_gc_debug_set (const char* options) +{ + if (gc_debug_options) + g_free (gc_debug_options); + + gc_debug_options = g_strdup (options); +} + +char * +mono_gc_debug_get () +{ + char *env; + if ((env = g_getenv (MONO_GC_DEBUG_NAME)) || gc_debug_options) { + char *debug_opts = g_strdup_printf ("%s,%s", gc_debug_options ? gc_debug_options : "", env ? env : ""); + g_free (env); + return debug_opts; + } + return NULL; +} + /* * actually, we might want to queue the finalize requests in a separate thread, * but we need to be careful about the execution domain of the thread... diff --git a/mono/metadata/null-gc.c b/mono/metadata/null-gc.c index 88ab715cf5ec..4304f039904d 100644 --- a/mono/metadata/null-gc.c +++ b/mono/metadata/null-gc.c @@ -458,16 +458,6 @@ mono_gc_get_logfile (void) return NULL; } -void -mono_gc_params_set (const char* options) -{ -} - -void -mono_gc_debug_set (const char* options) -{ -} - void mono_gc_conservatively_scan_area (void *start, void *end) { diff --git a/mono/sgen/gc-internal-agnostic.h b/mono/sgen/gc-internal-agnostic.h index 1bc27c711c6a..ad9ddb589487 100644 --- a/mono/sgen/gc-internal-agnostic.h +++ b/mono/sgen/gc-internal-agnostic.h @@ -117,7 +117,9 @@ FILE *mono_gc_get_logfile (void); /* equivalent to options set via MONO_GC_PARAMS */ void mono_gc_params_set (const char* options); +char* mono_gc_params_get(); /* equivalent to options set via MONO_GC_DEBUG */ void mono_gc_debug_set (const char* options); +char *mono_gc_debug_get(); #endif diff --git a/mono/sgen/sgen-gc.c b/mono/sgen/sgen-gc.c index 8e597946baa8..1a823a12e5b9 100644 --- a/mono/sgen/sgen-gc.c +++ b/mono/sgen/sgen-gc.c @@ -302,8 +302,6 @@ static SGEN_TV_DECLARE (time_major_conc_collection_end); int gc_debug_level = 0; FILE* gc_debug_file; -static char* gc_params_options; -static char* gc_debug_options; /* void @@ -1022,24 +1020,6 @@ mono_gc_get_logfile (void) return gc_debug_file; } -void -mono_gc_params_set (const char* options) -{ - if (gc_params_options) - g_free (gc_params_options); - - gc_params_options = g_strdup (options); -} - -void -mono_gc_debug_set (const char* options) -{ - if (gc_debug_options) - g_free (gc_debug_options); - - gc_debug_options = g_strdup (options); -} - static void scan_finalizer_entries (SgenPointerQueue *fin_queue, ScanCopyContext ctx) { @@ -3326,11 +3306,7 @@ sgen_gc_init (void) mono_coop_mutex_init (&sgen_interruption_mutex); - if ((env = g_getenv (MONO_GC_PARAMS_NAME)) || gc_params_options) { - params_opts = g_strdup_printf ("%s,%s", gc_params_options ? gc_params_options : "", env ? env : ""); - g_free (env); - } - + params_opts = mono_gc_params_get(); if (params_opts) { opts = g_strsplit (params_opts, ",", -1); for (ptr = opts; *ptr; ++ptr) { @@ -3541,11 +3517,7 @@ sgen_gc_init (void) sgen_pinning_init (); sgen_cement_init (cement_enabled); - if ((env = g_getenv (MONO_GC_DEBUG_NAME)) || gc_debug_options) { - debug_opts = g_strdup_printf ("%s,%s", gc_debug_options ? gc_debug_options : "", env ? env : ""); - g_free (env); - } - + debug_opts = mono_gc_debug_get(); if (debug_opts) { gboolean usage_printed = FALSE; From 0c17414e25bd72654a6797ff554f862cf9b441f5 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Mon, 20 Aug 2018 14:57:28 -0400 Subject: [PATCH 285/582] Use LF line endings on all perl build scripts --- external/buildscripts/build.pl | 3620 ++++++++--------- external/buildscripts/build_all_linux.pl | 52 +- external/buildscripts/build_all_win.pl | 52 +- external/buildscripts/build_classlibs_osx.pl | 80 +- external/buildscripts/build_classlibs_wsl.pl | 106 +- external/buildscripts/build_ios_xwin.pl | 36 +- .../buildscripts/build_runtime_android.pl | 64 +- external/buildscripts/build_runtime_iphone.pl | 134 +- external/buildscripts/build_runtime_linux.pl | 46 +- external/buildscripts/build_runtime_osx.pl | 22 +- external/buildscripts/build_runtime_vs.pl | 104 +- external/buildscripts/build_runtime_win.pl | 28 +- external/buildscripts/build_runtime_win64.pl | 28 +- external/buildscripts/build_runtime_wsl.pl | 26 +- .../build_unityscript_bareminimum_win.pl | 318 +- external/buildscripts/build_us_and_boo.pl | 316 +- external/buildscripts/build_win_no_cygwin.pl | 562 +-- external/buildscripts/build_win_wrapper.pl | 436 +- external/buildscripts/collect_allbuilds.pl | 132 +- 19 files changed, 3081 insertions(+), 3081 deletions(-) diff --git a/external/buildscripts/build.pl b/external/buildscripts/build.pl index eee3432411fa..3578d474d357 100644 --- a/external/buildscripts/build.pl +++ b/external/buildscripts/build.pl @@ -1,1810 +1,1810 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; -use lib ('external/buildscripts', "../../Tools/perl_lib","perl_lib", 'external/buildscripts/perl_lib'); -use Tools qw(InstallNameTool); - -print ">>> PATH in Build All = $ENV{PATH}\n\n"; - -my $currentdir = getcwd(); - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); - -my $buildscriptsdir = "$monoroot/external/buildscripts"; -my $addtoresultsdistdir = "$buildscriptsdir/add_to_build_results/monodistribution"; -my $buildsroot = "$monoroot/builds"; -my $includesroot = "$buildsroot/include"; -my $sourcesroot = "$buildsroot/source"; -my $distdir = "$buildsroot/monodistribution"; -my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; - -# This script should not be ran on windows, if it is, kindly call the wrapper -# to switch over to cygwin -if ($^O eq "MSWin32") -{ - print(">>> build.pl called from Windows. Switching over to cygwin\n"); - system("perl", "$buildscriptsdir/build_win_wrapper.pl", @ARGV) eq 0 or die("\n"); - exit 0; -} - -system("source","~/.profile"); - -my $build=0; -my $clean=0; -my $jobs=8; -my $test=0; -my $artifact=0; -my $debug=0; -my $disableMcs=0; -my $mcsOnly=0; -my $buildUsAndBoo=0; -my $artifactsCommon=0; -my $artifactsRuntime=1; -my $runRuntimeTests=1; -my $runClasslibTests=1; -my $checkoutOnTheFly=0; -my $forceDefaultBuildDeps=0; -my $existingMonoRootPath = ''; -my $sdk = ''; -my $arch32 = 0; -my $winPerl = ""; -my $winMonoRoot = ""; -my $msBuildVersion = "14.0"; -my $buildDeps = ""; -my $android=0; -my $androidArch = ""; -my $iphone=0; -my $iphoneArch = ""; -my $iphoneCross=0; -my $iphoneSimulator=0; -my $iphoneSimulatorArch=""; -my $tizen=0; -my $tizenEmulator=0; -my $windowsSubsystemForLinux=0; - -# Handy troubleshooting/niche options -my $skipMonoMake=0; - -# The prefix hack probably isn't needed anymore. Let's disable it by default and see how things go -my $shortPrefix=1; - -# Disabled by default for now. causes more problems than it's worth when actively making changes to the build scripts. -# Would be okay to turn on once the build scripts stabilize and you just want to rebuild code changes -my $enableCacheFile=0; - -# Linux toolchain setup needs this -my @commandPrefix = (); - -print(">>> Build All Args = @ARGV\n"); - -GetOptions( - 'build=i'=>\$build, - 'clean=i'=>\$clean, - 'test=i'=>\$test, - 'artifact=i'=>\$artifact, - 'artifactscommon=i'=>\$artifactsCommon, - 'artifactsruntime=i'=>\$artifactsRuntime, - 'debug=i'=>\$debug, - 'disablemcs=i'=>\$disableMcs, - 'mcsonly=i'=>\$mcsOnly, - 'buildusandboo=i'=>\$buildUsAndBoo, - 'runtimetests=i'=>\$runRuntimeTests, - 'classlibtests=i'=>\$runClasslibTests, - 'arch32=i'=>\$arch32, - 'jobs=i'=>\$jobs, - 'sdk=s'=>\$sdk, - 'existingmono=s'=>\$existingMonoRootPath, - 'skipmonomake=i'=>\$skipMonoMake, - 'shortprefix=i'=>\$shortPrefix, - 'winperl=s'=>\$winPerl, - 'winmonoroot=s'=>\$winMonoRoot, - 'msbuildversion=s'=>\$msBuildVersion, - 'checkoutonthefly=i'=>\$checkoutOnTheFly, - 'builddeps=s'=>\$buildDeps, - 'forcedefaultbuilddeps=i'=>\$forceDefaultBuildDeps, - 'android=i'=>\$android, - 'androidarch=s'=>\$androidArch, - 'iphone=i'=>\$iphone, - 'iphonearch=s'=>\$iphoneArch, - 'iphonecross=i'=>\$iphoneCross, - 'iphonesimulator=i'=>\$iphoneSimulator, - 'tizen=i'=>\$tizen, - 'tizenemulator=i'=>\$tizenEmulator, - 'windowssubsystemforlinux=i'=>\$windowsSubsystemForLinux, - 'enablecachefile=i'=>\$enableCacheFile, -) or die ("illegal cmdline options"); - -print ">>> Mono checkout = $monoroot\n"; - -print(">> System Info : \n"); -system("uname", "-a"); - -my $monoRevision = `git rev-parse HEAD`; -chdir("$buildscriptsdir") eq 1 or die ("failed to chdir : $buildscriptsdir\n"); -my $buildScriptsRevision = `git rev-parse HEAD`; -chdir("$monoroot") eq 1 or die ("failed to chdir : $monoroot\n"); - -print(">>> Mono Revision = $monoRevision\n"); -print(">>> Build Scripts Revision = $buildScriptsRevision\n"); - -if ($androidArch ne "") -{ - $android = 1; -} - -if ($iphoneArch ne "") -{ - $iphone = 1; -} - -if($iphoneSimulator) -{ - if ($arch32) - { - $iphoneSimulatorArch = "i386"; - } - else - { - $iphoneSimulatorArch = "x86_64"; - } -} - -my $isDesktopBuild = 1; -if ($android || $iphone || $iphoneCross || $iphoneSimulator || $tizen || $tizenEmulator) -{ - $isDesktopBuild = 0; - - # Disable building of the class libraries by default when building the android runtime - # since we don't care about a class library build in this situation (as of writing this at least) - # but only if the test flag is not set. If the test flag was set, we'd need to build the classlibs - # in order to run the tests - $disableMcs = 1 if(!($test)); -} - -# Do any settings agnostic per-platform stuff -my $externalBuildDeps = ""; - -if ($buildDeps ne "" && not $forceDefaultBuildDeps) -{ - $externalBuildDeps = $buildDeps; -} -else -{ - $externalBuildDeps = "$monoroot/../../mono-build-deps/build"; -} - -# Only clean up the path if the directory exists, if it doesn't exist, -# abs_path ends up returning an empty string -$externalBuildDeps = abs_path($externalBuildDeps) if (-d $externalBuildDeps); - -my $extraBuildTools = "$monoroot/../../mono-build-tools-extra/build"; - -my $existingExternalMonoRoot = "$externalBuildDeps/MonoBleedingEdge"; -my $existingExternalMono = ""; -my $existingExternalMonoBinDir = ""; -my $monoHostArch = ""; -my $monoprefix = "$monoroot/tmp"; -my $runningOnWindows=0; -if($^O eq "linux") -{ - $monoHostArch = $arch32 ? "i686" : "x86_64"; - $existingExternalMono = "$existingExternalMonoRoot"; - $existingExternalMonoBinDir = "bin-linux64"; -} -elsif($^O eq 'darwin') -{ - $monoHostArch = $arch32 ? "i386" : "x86_64"; - $existingExternalMono = "$existingExternalMonoRoot"; - $existingExternalMonoBinDir = "bin"; - - # From Massi: I was getting failures in install_name_tool about space - # for the commands being too small, and adding here things like - # $ENV{LDFLAGS} = '-headerpad_max_install_names' and - # $ENV{LDFLAGS} = '-headerpad=0x40000' did not help at all (and also - # adding them to our final gcc invocation to make the bundle). - # Lucas noticed that I was lacking a Mono prefix, and having a long - # one would give us space, so here is this silly looong prefix. - if (not $shortPrefix) - { - $monoprefix = "$monoroot/tmp/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting"; - } -} -else -{ - $monoHostArch = "i686"; - $existingExternalMono = "$existingExternalMonoRoot"; - $existingExternalMonoBinDir = "bin-x64"; - $runningOnWindows = 1; - - # We only care about an existing mono if we need to build. - # So only do this path clean up if we are building. - if ($build) - { - if ($existingMonoRootPath ne "" && not $existingMonoRootPath =~ /^\/cygdrive/) - { - $existingMonoRootPath = `cygpath -u $existingMonoRootPath`; - chomp($existingMonoRootPath); - } - - $existingMonoRootPath =~ tr/\\//d; - } -} - -if ($runningOnWindows) -{ - # Fixes a line ending issue that happens on windows when we try to run autogen.sh - $ENV{'SHELLOPTS'} = "igncr"; -} - -print(">>> Existing Mono = $existingMonoRootPath\n"); -print(">>> Mono Arch = $monoHostArch\n"); - -if ($build) -{ - my $platformflags = ''; - my $host = ''; - my $mcs = ''; - - my $iphoneCrossAbi = "arm-apple-darwin10"; - my $iphoneCrossMonoBinToUse = "$monoroot/builds/monodistribution/bin"; - - my @configureparams = (); - - push @configureparams, "--disable-mcs-build" if($disableMcs); - push @configureparams, "--with-glib=embedded"; - push @configureparams, "--disable-nls"; #this removes the dependency on gettext package - push @configureparams, "--disable-btls"; #this removes the dependency on cmake to build btls for now - push @configureparams, "--with-mcs-docs=no"; - push @configureparams, "--prefix=$monoprefix"; - - if(!($disableMcs)) - { - push @configureparams, "--with-unityjit=yes"; - push @configureparams, "--with-unityaot=yes"; - } - - if ($isDesktopBuild) - { - push @configureparams, "--with-monotouch=no"; - } - - if (!(-d "$extraBuildTools")) - { - # Check out on the fly - print(">>> Checking out mono build tools extra to : $extraBuildTools\n"); - my $repo = 'git@gitlab.internal.unity3d.com:vm/mono-build-tools-extra.git'; - print(">>> Cloning $repo at $extraBuildTools\n"); - my $checkoutResult = system("git", "clone", "--recurse-submodules", $repo, "$extraBuildTools"); - - if ($checkoutResult ne 0) - { - die("Failed to checkout mono build tools extra\n"); - } - - # Only clean up if the dir exists. Otherwise abs_path will return empty string - $extraBuildTools = abs_path($extraBuildTools) if (-d $extraBuildTools); - } - - if ($existingMonoRootPath eq "") - { - print(">>> No existing mono supplied. Checking for external...\n"); - - if (!(-d "$externalBuildDeps")) - { - if (not $checkoutonthefly) - { - print(">>> No external build deps found. Might as well try to check them out. If it fails, we'll continue and trust mono is in your PATH\n"); - } - - # Check out on the fly - print(">>> Checking out mono build dependencies to : $externalBuildDeps\n"); - my $repo = "https://ono.unity3d.com/unity-extra/mono-build-deps"; - print(">>> Cloning $repo at $externalBuildDeps\n"); - my $checkoutResult = system("hg", "clone", $repo, "$externalBuildDeps"); - - if ($checkoutOnTheFly && $checkoutResult ne 0) - { - die("failed to checkout mono build dependencies\n"); - } - - # Only clean up if the dir exists. Otherwise abs_path will return empty string - $externalBuildDeps = abs_path($externalBuildDeps) if (-d $externalBuildDeps); - } - - if (-d "$existingExternalMono") - { - print(">>> External mono found at : $existingExternalMono\n"); - - if (-d "$existingExternalMono/builds") - { - print(">>> Mono already extracted at : $existingExternalMono/builds\n"); - } - - if (!(-d "$existingExternalMono/builds")) - { - # We need to extract builds.zip - print(">>> Extracting mono builds.zip...\n"); - system("unzip", "$existingExternalMono/builds.zip", "-d", "$existingExternalMono/builds") eq 0 or die("failed to extract mono builds.zip\n"); - } - - $existingMonoRootPath = "$existingExternalMono/builds/monodistribution"; - } - else - { - print(">>> No external mono found. Trusting a new enough mono is in your PATH.\n"); - } - } - - if ($existingMonoRootPath ne "" && !(-d $existingMonoRootPath)) - { - die("Existing mono not found at : $existingMonoRootPath\n"); - } - - if ($externalBuildDeps ne "") - { - print "\n"; - print ">>> Building autoconf, texinfo, automake, and libtool if needed...\n"; - my $autoconfVersion = "2.69"; - my $texinfoVersion = "4.8"; - my $automakeVersion = "1.15"; - my $libtoolVersion = "2.4.6"; - my $autoconfDir = "$externalBuildDeps/autoconf-$autoconfVersion"; - my $texinfoDir = "$externalBuildDeps/texinfo-$texinfoVersion"; - my $automakeDir = "$externalBuildDeps/automake-$automakeVersion"; - my $libtoolDir = "$externalBuildDeps/libtool-$libtoolVersion"; - my $builtToolsDir = "$externalBuildDeps/built-tools"; - - $ENV{PATH} = "$builtToolsDir/bin:$ENV{PATH}"; - - if (!(-d "$autoconfDir")) - { - chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); - system("tar xzf autoconf-$autoconfVersion.tar.gz") eq 0 or die ("failed to extract autoconf\n"); - - chdir("$autoconfDir") eq 1 or die ("failed to chdir to autoconf directory\n"); - system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure autoconf\n"); - system("make") eq 0 or die ("failed to make autoconf\n"); - system("make install") eq 0 or die ("failed to make install autoconf\n"); - - chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); - } - - if (!(-d "$texinfoDir") and $windowsSubsystemForLinux) - { - chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); - system("tar xzf texinfo-$texinfoVersion.tar.gz") eq 0 or die ("failed to extract texinfo\n"); - - chdir($texinfoDir) eq 1 or die ("failed to chdir to texinfo directory\n"); - system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure texinfo\n"); - system("make") eq 0 or die ("failed to make texinfo\n"); - system("make install") eq 0 or die ("failed to make install texinfo\n"); - - chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); - } - - if (!(-d "$automakeDir")) - { - my $automakeMakeFlags = ""; - chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); - system("tar xzf automake-$automakeVersion.tar.gz") eq 0 or die ("failed to extract automake\n"); - - chdir("$automakeDir") eq 1 or die ("failed to chdir to automake directory\n"); - if($windowsSubsystemForLinux) - { - #Windows subsystem needs to run bootstrap, and make needs to be run with -i due to one doc failing to build - system("./bootstrap.sh") eq 0 or die ("failed to bootstrap automake\n"); - $automakeMakeFlags = "-i"; - } - system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure automake\n"); - system("make $automakeMakeFlags") eq 0 or die ("failed to make automake\n"); - system("make install"); - chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); - } - - if (!(-d "$libtoolDir")) - { - chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); - system("tar xzf libtool-$libtoolVersion.tar.gz") eq 0 or die ("failed to extract libtool\n"); - - chdir("$libtoolDir") eq 1 or die ("failed to chdir to libtool directory\n"); - system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure libtool\n"); - system("make") eq 0 or die ("failed to make libtool\n"); - system("make install") eq 0 or die ("failed to make install libtool\n"); - - chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); - } - - $ENV{'LIBTOOLIZE'} = "$builtToolsDir/bin/libtoolize"; - $ENV{'LIBTOOL'} = "$builtToolsDir/bin/libtool"; - } - - my $macSdkPath = ""; - my $macversion = '10.8'; - my $darwinVersion = "10"; - if ($^O eq 'darwin') - { - if ($sdk eq '') - { - $sdk='10.11'; - } - - my $macBuildEnvDir = "$externalBuildDeps/MacBuildEnvironment"; - $macSdkPath = "$macBuildEnvDir/builds/MacOSX$sdk.sdk"; - if (! -d $macSdkPath) - { - print(">>> Unzipping mac build toolchain\n"); - system("$externalBuildDeps/unzip", '-qd', "$macBuildEnvDir", "$macBuildEnvDir/builds.zip") eq 0 or die ("failed unzipping mac build toolchain\n"); - } - } - - if ($iphone || $iphoneSimulator) - { - if ($runningOnWindows) - { - die("This build is not supported on Windows\n"); - } - - my $iosBuildEnvDir = "$externalBuildDeps/iOSBuildEnvironment"; - my $iosXcodeDefaultToolchainRoot = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain"; - - if (! -d "$iosBuildEnvDir/builds") - { - print(">>> Unzipping ios build toolchain\n"); - system("$externalBuildDeps/unzip", '-qd', "$iosBuildEnvDir/builds", "$iosBuildEnvDir/builds.zip") eq 0 or die ("failed unzipping ios build toolchain\n"); - } - - $ENV{PATH} = "$iosXcodeDefaultToolchainRoot/usr/bin:$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/usr/bin:$ENV{PATH}"; - # Need to keep our libtool in front - $ENV{PATH} = "$externalBuildDeps/built-tools/bin:$ENV{PATH}"; - - push @configureparams, "--cache-file=iphone-$iphoneArch.cache" if ($enableCacheFile); - - my $iosMinimalCommon = "com,remoting,shared_perfcounters,appdomains"; - my $iosCFlagsCommon = "-DMONOTOUCH -DHOST_IOS -DDISABLE_POLICY_EVIDENCE=1 -DDISABLE_PROCESS_HANDLING=1"; - - push @configureparams, "--with-tls=pthread"; - push @configureparams, "--without-ikvm-native"; - push @configureparams, "--disable-executables"; - push @configureparams, "--disable-visibility-hidden"; - - if ($iphone) - { - my $iosSdkVersion = "9.3"; - my $iphoneOsMinVersion = "3.0"; - my $iosSdkRoot = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$iosSdkVersion.sdk"; - - print(">>> iOS Build Environment = $iosBuildEnvDir\n"); - print(">>> iOS SDK Version = $iosSdkVersion\n"); - print(">>> iOS SDK Root = $iosSdkRoot\n"); - print(">>> iPhone Arch = $iphoneArch\n"); - - $ENV{PATH} = "$iosSdkRoot/usr/bin:$ENV{PATH}"; - - $ENV{C_INCLUDE_PATH} = "$iosSdkRoot/usr/include"; - $ENV{CPLUS_INCLUDE_PATH} = "$iosSdkRoot/usr/include"; - - $ENV{CC} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch $iphoneArch"; - $ENV{CXX} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch $iphoneArch"; - $ENV{LD} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"; - - $ENV{CFLAGS} = "$iosCFlagsCommon -gdwarf-2 -DSMALL_CONFIG -DHAVE_LARGE_FILE_SUPPORT=1 -DHAVE_ARMV6=1 -DARM_FPU_VFP=1 -Wl,-application_extension -miphoneos-version-min=$iphoneOsMinVersion -mno-thumb -Os -isysroot $iosSdkRoot"; - - # Unity defines - $ENV{CFLAGS} = "-DPLATFORM_IPHONE $ENV{CFLAGS}"; - - $ENV{CXXFLAGS} = "$ENV{CFLAGS} -U__powerpc__ -U__i386__ -D__arm__"; - $ENV{CPPFLAGS} = $ENV{CXXFLAGS}; - - $ENV{LDFLAGS} = "-arch $iphoneArch -liconv -lobjc -lc++ -Wl,-syslibroot,$iosSdkRoot"; - - print "\n"; - print ">>> Environment:\n"; - print ">>> \tCC = $ENV{CC}\n"; - print ">>> \tCXX = $ENV{CXX}\n"; - print ">>> \tLD = $ENV{LD}\n"; - print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; - print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; - print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; - print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; - print ">>> \tCPLUS_INCLUDE_PATH = $ENV{CPLUS_INCLUDE_PATH}\n"; - print ">>> \tC_INCLUDE_PATH = $ENV{C_INCLUDE_PATH}\n"; - - push @configureparams, "--host=arm-apple-darwin$darwinVersion"; - - push @configureparams, "--with-sigaltstack=no"; - push @configureparams, "--disable-shared-handles"; - push @configureparams, "--with-monotouch"; - - push @configureparams, "--enable-llvm-runtime"; - push @configureparams, "--with-bitcode=yes"; - - push @configureparams, "--with-lazy-gc-thread-creation=yes"; - push @configureparams, "--enable-icall-export"; - push @configureparams, "--enable-dtrace=no"; - - push @configureparams, "--enable-minimal=$iosMinimalCommon,ssa,jit,reflection_emit_save,reflection_emit,portability,assembly_remapping,attach,verifier,full_messages,security,sgen_remset,sgen_marksweep_par,sgen_marksweep_fixed,sgen_marksweep_fixed_par,sgen_copying,logging"; - - push @configureparams, "mono_cv_uscore=yes"; - push @configureparams, "cv_mono_sizeof_sunpath=104"; - push @configureparams, "ac_cv_func_posix_getpwuid_r=yes"; - push @configureparams, "ac_cv_func_backtrace_symbols=no"; - push @configureparams, "ac_cv_func_finite=no"; - push @configureparams, "ac_cv_header_curses_h=no"; - } - elsif ($iphoneSimulator) - { - my $iosSdkVersion = "9.3"; - my $iosSimMinVersion = "4.3"; - my $iosSdkRoot = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$iosSdkVersion.sdk"; - - print(">>> iOS Sim Build Environment = $iosBuildEnvDir\n"); - print(">>> iOS Sim SDK Version = $iosSdkVersion\n"); - print(">>> iOS Sim SDK Root = $iosSdkRoot\n"); - print(">>> iOS Sim Arch = $iphoneSimulatorArch\n"); - - $ENV{PATH} = "$iosSdkRoot/usr/bin:$ENV{PATH}"; - - $ENV{MACSDKOPTIONS} = "$iosCFlagsCommon -D_XOPEN_SOURCE=1 -g -O0 -DTARGET_IPHONE_SIMULATOR -mios-simulator-version-min=$iosSimMinVersion -isysroot $iosSdkRoot"; - $ENV{CFLAGS} = "-arch $iphoneSimulatorArch $ENV{MACSDKOPTIONS}"; - $ENV{CXXFLAGS} = "$ENV{CFLAGS}"; - $ENV{CPPFLAGS} = "$ENV{CFLAGS}"; - $ENV{CC} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/usr/bin/gcc"; - $ENV{CXX} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/usr/bin/g++"; - - print "\n"; - print ">>> Environment:\n"; - print ">>> \tCC = $ENV{CC}\n"; - print ">>> \tCXX = $ENV{CXX}\n"; - print ">>> \tLD = $ENV{LD}\n"; - print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; - print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; - print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; - print ">>> \tMACSDKOPTIONS = $ENV{MACSDKOPTIONS}\n"; - - push @configureparams, "--host=$iphoneSimulatorArch-apple-darwin$darwinVersion"; - push @configureparams, "--enable-minimal=$iosMinimalCommon"; - - push @configureparams, "mono_cv_uscore=yes"; - push @configureparams, "ac_cv_func_clock_nanosleep=no"; - } - else - { - die("This should not be hit\n"); - } - } - elsif ($iphoneCross) - { - if ($runningOnWindows) - { - die("Not implemented\n"); - } - else - { - $ENV{CFLAGS} = "-DMONOTOUCH -DARM_FPU_VFP=1 -DUSE_MUNMAP -DPLATFORM_IPHONE_XCOMP -mmacosx-version-min=$macversion"; - $ENV{CXXFLAGS} = "-mmacosx-version-min=$macversion -stdlib=libc++"; - $ENV{CPPFLAGS} = "$ENV{CFLAGS} -mmacosx-version-min=$macversion"; - - $ENV{CC} = "$macSdkPath/../usr/bin/clang -arch i386"; - $ENV{CXX} = "$macSdkPath/../usr/bin/clang++ -arch i386"; - $ENV{CPP} = "$ENV{CC} -E"; - $ENV{LD} = $ENV{CC}; - $ENV{LDFLAGS} = "-stdlib=libc++"; - $ENV{MACSDKOPTIONS} = "-mmacosx-version-min=$macversion -isysroot $macSdkPath"; - - print "\n"; - print ">>> Environment:\n"; - print ">>> \tCC = $ENV{CC}\n"; - print ">>> \tCXX = $ENV{CXX}\n"; - print ">>> \tLD = $ENV{LD}\n"; - print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; - print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; - print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; - print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; - print ">>> \tMACSDKOPTIONS = $ENV{MACSDKOPTIONS}\n"; - - push @configureparams, "--cache-file=iphone-cross.cache" if ($enableCacheFile); - - push @configureparams, "--with-sigaltstack=no"; - push @configureparams, "--disable-shared-handles"; - push @configureparams, "--with-tls=pthread"; - - push @configureparams, "--target=arm-darwin"; - push @configureparams, "--with-macversion=$macversion"; - push @configureparams, "--with-cross-offsets=$iphoneCrossAbi.h"; - - push @configureparams, "--build=i386-apple-darwin10"; - push @configureparams, "--disable-libraries"; - push @configureparams, "--enable-icall-symbol-map"; - push @configureparams, "--enable-minimal=com,remoting"; - - #push @configureparams, "--enable-llvm"; - #push @configureparams, "--with-llvm=llvm/usr"; - - my @mcsArgs = (); - push @mcsArgs, "$monoroot/tools/offsets-tool/MonoAotOffsetsDumper.cs"; - push @mcsArgs, "$monoroot/mcs/class/Mono.Options/Mono.Options/Options.cs"; - push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.AST.dll"; - push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.Generator.dll"; - push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.Parser.CSharp.dll"; - push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.Parser.dll"; - push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.dll"; - push @mcsArgs, "/debug"; - push @mcsArgs, "/nowarn:0436"; - push @mcsArgs, "/out:$monoroot/tools/offsets-tool/MonoAotOffsetsDumper.exe"; - - print ">>> Compiling MonoAotOffsetDumper : $iphoneCrossMonoBinToUse/mcs @mcsArgs\n"; - system("$iphoneCrossMonoBinToUse/mcs", @mcsArgs) eq 0 or die("failed to compile MonoAotOffsetsDumper\n"); - - # clean up any pre-existing offset header just in case - if (-f "$monoroot/$iphoneCrossAbi.h") - { - system("rm", "-rf", "$iphoneCrossAbi.h"); - } - } - } - elsif ($android) - { - if (!(-d $externalBuildDeps)) - { - die("mono build deps are required and the directory was not found : $externalBuildDeps\n"); - } - - my $ndkVersion = "r13b"; - my $isArmArch = 1; - my $toolchainName = ""; - my $platformRootPostfix = ""; - my $useKraitPatch = 1; - my $kraitPatchPath = "$monoroot/../../android_krait_signal_handler/build"; - my $toolChainExtension = ""; - - $isArmArch = 0 if ($androidArch eq "x86"); - - $ENV{ANDROID_PLATFORM} = "android-9"; - $ENV{GCC_VERSION} = "4.9"; - - if ($isArmArch) - { - $ENV{GCC_PREFIX} = "arm-linux-androideabi-"; - $toolchainName = "$ENV{GCC_PREFIX}$ENV{GCC_VERSION}"; - $platformRootPostfix = "arm"; - } - else - { - $ENV{GCC_PREFIX} = "i686-linux-android-"; - $toolchainName = "x86-$ENV{GCC_VERSION}"; - $platformRootPostfix = "x86"; - $useKraitPatch = 0; - } - - if ($^O eq "linux") - { - $ENV{HOST_ENV} = "linux"; - } - elsif ($^O eq 'darwin') - { - $ENV{HOST_ENV} = "darwin"; - } - else - { - $ENV{HOST_ENV} = "windows"; - } - - print "\n"; - print(">>> Android Platform = $ENV{ANDROID_PLATFORM}\n"); - print(">>> Android NDK Version = $ndkVersion\n"); - print(">>> Android GCC Prefix = $ENV{GCC_PREFIX}\n"); - print(">>> Android GCC Version = $ENV{GCC_VERSION}\n"); - - my $ndkName = ""; - if($^O eq "linux") - { - $ndkName = "android-ndk-$ndkVersion-linux-x86_64.zip"; - } - elsif($^O eq "darwin") - { - $ndkName = "android-ndk-$ndkVersion-darwin-x86_64.zip"; - } - else - { - $ndkName = "android-ndk-$ndkVersion-windows-x86.zip"; - } - - my $depsNdkArchive = "$externalBuildDeps/$ndkName"; - my $depsNdkFinal = "$externalBuildDeps/android-ndk-$ndkVersion"; - - print(">>> Android NDK Archive = $depsNdkArchive\n"); - print(">>> Android NDK Extraction Destination = $depsNdkFinal\n"); - print("\n"); - - $ENV{ANDROID_NDK_ROOT} = "$depsNdkFinal"; - - if (-d $depsNdkFinal) - { - print(">>> Android NDK already extracted\n"); - } - else - { - print(">>> Android NDK needs to be extracted\n"); - - if ($runningOnWindows) - { - my $sevenZip = "$externalBuildDeps/7z/win64/7za.exe"; - my $winDepsNdkArchive = `cygpath -w $depsNdkArchive`; - my $winDepsNdkExtract = `cygpath -w $externalBuildDeps`; - - # clean up trailing new lines that end up in the output from cygpath. If left, they cause problems down the line - # for 7zip - $winDepsNdkArchive =~ s/\n+$//; - $winDepsNdkExtract =~ s/\n+$//; - - system($sevenZip, "x", "$winDepsNdkArchive", "-o$winDepsNdkExtract"); - } - else - { - my ($name,$path,$suffix) = fileparse($depsNdkArchive, qr/\.[^.]*/); - - print(">>> Android NDK Extension = $suffix\n"); - - # Versions after r11 use .zip extension. Currently we use r10e, but let's support the .zip extension in case - # we upgrade down the road - if (lc $suffix eq '.zip') - { - system("unzip", "-q", $depsNdkArchive, "-d", $externalBuildDeps); - } - elsif (lc $suffix eq '.bin') - { chmod(0755, $depsNdkArchive); - system($depsNdkArchive, "-o$externalBuildDeps"); - } - else - { - die "Unknown file extension '" . $suffix . "'\n"; - } - } - } - - if (!(-f "$ENV{ANDROID_NDK_ROOT}/ndk-build")) - { - die("Something went wrong with the NDK extraction\n"); - } - - my $androidNdkRoot = $ENV{ANDROID_NDK_ROOT}; - my $androidPlatformRoot = "$androidNdkRoot/platforms/$ENV{ANDROID_PLATFORM}/arch-$platformRootPostfix"; - my $androidToolchain = "$androidNdkRoot/toolchains/$toolchainName/prebuilt/$ENV{HOST_ENV}"; - - if (!(-d "$androidToolchain")) - { - if (-d "$androidToolchain-x86") - { - $androidToolchain = "$androidToolchain-x86"; - } - else - { - $androidToolchain = "$androidToolchain-x86_64"; - } - } - - if ($runningOnWindows) - { - $toolChainExtension = ".exe"; - - $androidPlatformRoot = `cygpath -w $androidPlatformRoot`; - # clean up trailing new lines that end up in the output from cygpath. - $androidPlatformRoot =~ s/\n+$//; - # Switch over to forward slashes. They propagate down the toolchain correctly - $androidPlatformRoot =~ s/\\/\//g; - - # this will get passed as a path to the linker, so we need to windows-ify the path - $kraitPatchPath = `cygpath -w $kraitPatchPath`; - $kraitPatchPath =~ s/\n+$//; - $kraitPatchPath =~ s/\\/\//g; - } - - print(">>> Android Arch = $androidArch\n"); - print(">>> Android NDK Root = $androidNdkRoot\n"); - print(">>> Android Platform Root = $androidPlatformRoot\n"); - print(">>> Android Toolchain = $androidToolchain\n"); - - if (!(-d "$androidToolchain")) - { - die("Failed to locate android toolchain\n"); - } - - if (!(-d "$androidPlatformRoot")) - { - die("Failed to locate android platform root\n"); - } - - if ("$androidArch" eq 'armv5') - { - $ENV{CFLAGS} = "-DARM_FPU_NONE=1 -march=armv5te -mtune=xscale -msoft-float"; - } - elsif ("$androidArch" eq 'armv6_vfp') - { - $ENV{CFLAGS} = "-DARM_FPU_VFP=1 -march=armv6 -mtune=xscale -msoft-float -mfloat-abi=softfp -mfpu=vfp -DHAVE_ARMV6=1"; - } - elsif ("$androidArch" eq 'armv7a') - { - $ENV{CFLAGS} = "-DARM_FPU_VFP=1 -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -DHAVE_ARMV6=1"; - $ENV{LDFLAGS} = "-Wl,--fix-cortex-a8"; - } - elsif ("$androidArch" eq 'x86') - { - $ENV{LDFLAGS} = "-lgcc" - } - else - { - die("Unsupported android arch : $androidArch\n"); - } - - if ($isArmArch) - { - $ENV{CFLAGS} = "-funwind-tables $ENV{CFLAGS}"; - $ENV{LDFLAGS} = "-Wl,-rpath-link=$androidPlatformRoot/usr/lib $ENV{LDFLAGS}"; - } - - $ENV{PATH} = "$androidToolchain/bin:$ENV{PATH}"; - $ENV{CC} = "$androidToolchain/bin/$ENV{GCC_PREFIX}gcc$toolChainExtension --sysroot=$androidPlatformRoot"; - $ENV{CXX} = "$androidToolchain/bin/$ENV{GCC_PREFIX}g++$toolChainExtension --sysroot=$androidPlatformRoot"; - $ENV{CPP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}cpp$toolChainExtension"; - $ENV{CXXCPP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}cpp$toolChainExtension"; - $ENV{CPATH} = "$androidPlatformRoot/usr/include"; - $ENV{LD} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ld$toolChainExtension"; - $ENV{AS} = "$androidToolchain/bin/$ENV{GCC_PREFIX}as$toolChainExtension"; - $ENV{AR} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ar$toolChainExtension"; - $ENV{RANLIB} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ranlib$toolChainExtension"; - $ENV{STRIP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}strip$toolChainExtension"; - - $ENV{CFLAGS} = "-DANDROID -DPLATFORM_ANDROID -DLINUX -D__linux__ -DHAVE_USR_INCLUDE_MALLOC_H -DPAGE_SIZE=0x1000 -D_POSIX_PATH_MAX=256 -DS_IWRITE=S_IWUSR -DHAVE_PTHREAD_MUTEX_TIMEDLOCK -fpic -g -ffunction-sections -fdata-sections $ENV{CFLAGS}"; - $ENV{CXXFLAGS} = $ENV{CFLAGS}; - $ENV{CPPFLAGS} = $ENV{CFLAGS}; - - if ($useKraitPatch) - { - $ENV{LDFLAGS} = "-Wl,--wrap,sigaction -L$kraitPatchPath/obj/local/armeabi -lkrait-signal-handler $ENV{LDFLAGS}"; - } - - $ENV{LDFLAGS} = "-Wl,--no-undefined -Wl,--gc-sections -ldl -lm -llog -lc $ENV{LDFLAGS}"; - - print "\n"; - print ">>> Environment:\n"; - print ">>> \tCC = $ENV{CC}\n"; - print ">>> \tCXX = $ENV{CXX}\n"; - print ">>> \tCPP = $ENV{CPP}\n"; - print ">>> \tCXXCPP = $ENV{CXXCPP}\n"; - print ">>> \tCPATH = $ENV{CPATH}\n"; - print ">>> \tLD = $ENV{LD}\n"; - print ">>> \tAS = $ENV{AS}\n"; - print ">>> \tAR = $ENV{AR}\n"; - print ">>> \tRANLIB = $ENV{RANLIB}\n"; - print ">>> \tSTRIP = $ENV{STRIP}\n"; - print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; - print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; - print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; - print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; - - if ($useKraitPatch) - { - my $kraitPatchRepo = "git://github.com/Unity-Technologies/krait-signal-handler.git"; - if (-d "$kraitPatchPath") - { - print ">>> Krait patch repository already cloned\n"; - } - else - { - system("git", "clone", "--branch", "master", "$kraitPatchRepo", "$kraitPatchPath") eq 0 or die ('failing cloning Krait patch'); - } - - chdir("$kraitPatchPath") eq 1 or die ("failed to chdir to krait patch directory\n"); - system('$ANDROID_NDK_ROOT/ndk-build clean') eq 0 or die ('failing to clean Krait patch'); - system('$ANDROID_NDK_ROOT/ndk-build') eq 0 or die ('failing to build Krait patch'); - chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); - } - - if ($isArmArch) - { - push @configureparams, "--host=armv5-linux-androideabi"; - } - elsif ("$androidArch" eq 'x86') - { - push @configureparams, "--host=i686-linux-android"; - } - else - { - die("Unsupported android arch : $androidArch\n"); - } - - push @configureparams, "--cache-file=android-$androidArch.cache" if ($enableCacheFile); - - push @configureparams, "--disable-parallel-mark"; - push @configureparams, "--disable-shared-handles"; - push @configureparams, "--with-sigaltstack=no"; - push @configureparams, "--with-tls=pthread"; - push @configureparams, "--disable-visibility-hidden"; - push @configureparams, "mono_cv_uscore=yes"; - push @configureparams, "ac_cv_header_zlib_h=no" if($runningOnWindows); - } - elsif ($tizen) - { - if (!(-d $externalBuildDeps)) - { - die("mono build deps are required and the directory was not found : $externalBuildDeps\n"); - } - - my $sdkVersion = "2.4.0r1"; - my $isArmArch = 1; - - $isArmArch = 0 if ($tizenEmulator); - - $ENV{TIZEN_PLATFORM} = "tizen-2.4"; - - if ($tizenEmulator) - { - $ENV{TIZEN_ROOTSTRAP} = "mobile-2.4-emulator.core"; - } - else - { - $ENV{TIZEN_ROOTSTRAP} = "mobile-2.4-device.core"; - } - - if ($^O eq "linux") - { - $ENV{HOST_ENV} = "linux"; - } - elsif ($^O eq 'darwin') - { - $ENV{HOST_ENV} = "darwin"; - } - else - { - $ENV{HOST_ENV} = "windows"; - } - - print "\n"; - print(">>> Tizen Platform = $ENV{TIZEN_PLATFORM}\n"); - print(">>> Tizen SDK Version = $sdkVersion\n"); - - my $sdkName = "tizen-$sdkVersion-$ENV{HOST_ENV}.tar.bz2"; - my $depsSdkArchive = "$externalBuildDeps/$sdkName"; - my $depsSdkFinal = "$externalBuildDeps/tizen-$sdkVersion-$ENV{HOST_ENV}"; - - print(">>> Tizen SDK Archive = $depsSdkArchive\n"); - print(">>> Tizen SDK Extraction Destination = $depsSdkFinal\n"); - print("\n"); - - $ENV{TIZEN_SDK_ROOT} = "$depsSdkFinal"; - - if (-d $depsSdkFinal) - { - print(">>> Tizen SDK already extracted\n"); - } - else - { - print(">>> Tizen SDK needs to be extracted\n"); - - if ($runningOnWindows) - { - my $sevenZip = "$externalBuildDeps/7z/win64/7za.exe"; - my $winDepsSdkArchive = `cygpath -w $depsSdkArchive`; - my $winDepsSdkExtract = `cygpath -w $externalBuildDeps`; - - # clean up trailing new lines that end up in the output from cygpath. If left, they cause problems down the line - # for 7zip - $winDepsSdkArchive =~ s/\n+$//; - $winDepsSdkExtract =~ s/\n+$//; - - system($sevenZip, "x", "$winDepsSdkArchive", "-o$winDepsSdkExtract"); - } - else - { - my ($name,$path,$suffix) = fileparse($depsSdkArchive, qr/\.[^.]*/); - - print(">>> Tizen SDK Extension = $suffix\n"); - - if (lc $suffix eq '.bz2') - { chmod(0755, $depsSdkArchive); - system("tar xjf $depsSdkArchive -C $externalBuildDeps") eq 0 or die ("failed to extract Tizen SDK\n"); - } - else - { - die "Unknown file extension '" . $suffix . "'\n"; - } - } - } - - if (!(-f "$ENV{TIZEN_SDK_ROOT}/tools/sdb")) - { - die("Something went wrong with the SDK extraction\n"); - } - - my $tizenSdkRoot = $ENV{TIZEN_SDK_ROOT}; - my $tizenPlatformRoot = "$tizenSdkRoot/platforms/$ENV{TIZEN_PLATFORM}/mobile/rootstraps/$ENV{TIZEN_ROOTSTRAP}"; - my $tizenToolchain = "$tizenSdkRoot/tools/llvm-3.6/bin"; - - if ($runningOnWindows) - { - $toolChainExtension = ".exe"; - - $tizenPlatformRoot = `cygpath -w $tizenPlatformRoot`; - # clean up trailing new lines that end up in the output from cygpath. - $tizenPlatformRoot =~ s/\n+$//; - # Switch over to forward slashes. They propagate down the toolchain correctly - $tizenPlatformRoot =~ s/\\/\//g; - } - - if ($tizenEmulator) - { - $tizenToolchain = "$tizenSdkRoot/tools/i386-linux-gnueabi-gcc-4.9/bin/i386"; - $ENV{CFLAGS} = "-Os -g -march=i686 -msse2 -mfpmath=sse"; - } - else - { - $tizenToolchain = "$tizenSdkRoot/tools/arm-linux-gnueabi-gcc-4.9/bin/arm"; - $ENV{CFLAGS} = "-Os -g -march=armv7-a -mfpu=vfp -mfloat-abi=softfp -DARM_FPU_VFP=1 -DHAVE_ARMV6=1"; - $ENV{LDFLAGS} = "-Wl,-rpath-link=$tizenPlatformRoot/usr/lib -L$tizenPlatformRoot/usr/lib $ENV{LDFLAGS}"; - } - - print(">>> Tizen SDK Root = $tizenSdkRoot\n"); - print(">>> Tizen Platform Root = $tizenPlatformRoot\n"); - print(">>> Tizen Toolchain Prefix = $tizenToolchain\n"); - - if (!(-d "$tizenPlatformRoot")) - { - die("Failed to locate Tizen platform root\n"); - } - - $ENV{PATH} = "$tizenToolchain/bin:$ENV{PATH}"; - $ENV{CC} = "$tizenToolchain-linux-gnueabi-gcc --sysroot=$tizenPlatformRoot"; - $ENV{CXX} = "$tizenToolchain-linux-gnueabi-g++ --sysroot=$tizenPlatformRoot"; - $ENV{CPP} = "$tizenToolchain-linux-gnueabi-cpp"; - $ENV{CXXCPP} = "$tizenToolchain-linux-gnueabi-cpp"; - $ENV{CPATH} = "$tizenPlatformRoot/usr/include"; - $ENV{LD} = "$tizenToolchain-linux-gnueabi-ld --sysroot=$tizenPlatformRoot"; - $ENV{AS} = "$tizenToolchain-linux-gnueabi-as"; - $ENV{STRIP} = "$tizenToolchain-linux-gnueabi-strip"; - - if ($tizenEmulator) - { - $ENV{AR} = "$ENV{TIZEN_SDK_ROOT}/tools/i386-linux-gnueabi-gcc-4.9/bin/i386-linux-gnueabi-ar"; - $ENV{RANLIB} = "$ENV{TIZEN_SDK_ROOT}/tools/i386-linux-gnueabi-gcc-4.9/bin/i386-linux-gnueabi-ranlib"; - } - else - { - $ENV{AR} = "$ENV{TIZEN_SDK_ROOT}/tools/arm-linux-gnueabi-gcc-4.9/bin/arm-linux-gnueabi-ar"; - $ENV{RANLIB} = "$ENV{TIZEN_SDK_ROOT}/tools/arm-linux-gnueabi-gcc-4.9/bin/arm-linux-gnueabi-ranlib"; - } - - $ENV{CFLAGS} = "-DTIZEN -DLINUX -D__linux__ -DHAVE_USR_INCLUDE_MALLOC_H -DPAGE_SIZE=0x1000 -D_POSIX_PATH_MAX=256 -DS_IWRITE=S_IWUSR -DHAVE_PTHREAD_MUTEX_TIMEDLOCK -fpic -g -ffunction-sections -fdata-sections $ENV{CFLAGS}"; - $ENV{CXXFLAGS} = $ENV{CFLAGS}; - $ENV{CPPFLAGS} = $ENV{CFLAGS}; - $ENV{LDFLAGS} = "-Wl,--no-undefined -ldlog -shared -Xlinker --as-needed $ENV{LDFLAGS}"; - - print "\n"; - print ">>> Environment:\n"; - print ">>> \tCC = $ENV{CC}\n"; - print ">>> \tCXX = $ENV{CXX}\n"; - print ">>> \tCPP = $ENV{CPP}\n"; - print ">>> \tCXXCPP = $ENV{CXXCPP}\n"; - print ">>> \tCPATH = $ENV{CPATH}\n"; - print ">>> \tLD = $ENV{LD}\n"; - print ">>> \tAS = $ENV{AS}\n"; - print ">>> \tAR = $ENV{AR}\n"; - print ">>> \tRANLIB = $ENV{RANLIB}\n"; - print ">>> \tSTRIP = $ENV{STRIP}\n"; - print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; - print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; - print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; - print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; - - if ($tizenEmulator) - { - push @configureparams, "--host=i386-tizen-linux-gnueabi"; - } - else - { - push @configureparams, "--host=arm-tizen-linux-gnueabi"; - } - - push @configureparams, "--cache-file=tizen-cross.cache" if ($enableCacheFile); - push @configureparams, "--disable-parallel-mark"; - push @configureparams, "--disable-shared-handles"; - push @configureparams, "--with-sigaltstack=no"; - push @configureparams, "--with-tls=pthread"; - push @configureparams, "--disable-visibility-hidden"; - push @configureparams, "--disable-executables"; - push @configureparams, "--with-gnu-ld=yes"; - push @configureparams, "mono_cv_uscore=yes"; - push @configureparams, "ac_cv_header_zlib_h=no" if($runningOnWindows); - } - elsif($^O eq "linux") - { - if (!(-d $externalBuildDeps)) - { - die("mono build deps are required and the directory was not found : $externalBuildDeps\n"); - } - - if($ENV{UNITY_THISISABUILDMACHINE} || $ENV{UNITY_USE_LINUX_SDK}) - { - my $sdkVersion = '20170609'; - my $schroot = "LinuxBuildEnvironment-$sdkVersion"; - my @linuxToolchain = ('schroot', '-c', $schroot, '--'); - - print "\n"; - print(">>> Linux SDK Version = $sdkVersion\n"); - - my $sdkName = "linux-sdk-$sdkVersion.tar.bz2"; - my $depsSdkArchive = "$externalBuildDeps/$sdkName"; - my $depsSdkFinal = "$externalBuildDeps/linux-sdk-$sdkVersion"; - - print(">>> Linux SDK Archive = $depsSdkArchive\n"); - print(">>> Linux SDK Extraction Destination = $depsSdkFinal\n"); - print("\n"); - - my $linuxSdkRoot = $depsSdkFinal; - - if (-d $depsSdkFinal) - { - print(">>> Linux SDK already extracted\n"); - } - else - { - print(">>> Linux SDK needs to be extracted\n"); - system('mkdir', '-p', $depsSdkFinal); - system('tar', 'xaf', $depsSdkArchive, '-C', $depsSdkFinal) eq 0 or die ("failed to extract Linux SDK\n"); - system('sudo', 'cp', '-R', "$depsSdkFinal/linux-sdk-$sdkVersion", '/etc/schroot'); - system("sed 's,^directory=.*,directory=$depsSdkFinal/$schroot,' \"$depsSdkFinal/$schroot.conf\" | sudo tee /etc/schroot/chroot.d/$schroot.conf") eq 0 or die ("failed to deploy Linux SDK\n"); - } - - @commandPrefix = @linuxToolchain; - print(">>> Linux SDK Root = $linuxSdkRoot\n"); - print(">>> Linux Toolchain Command Prefix = " . join(' ', @commandPrefix) . "\n"); - } - - push @configureparams, "--host=$monoHostArch-pc-linux-gnu"; - - push @configureparams, "--disable-parallel-mark"; #this causes crashes - - my $archflags = ''; - if ($arch32) - { - $archflags = '-m32'; - } - else - { - $archflags = '-fPIC'; - } - - if ($debug) - { - $ENV{CFLAGS} = "$archflags -g -O0"; - } - else - { - $ENV{CFLAGS} = "$archflags -Os"; #optimize for size - } - } - elsif($^O eq 'darwin') - { - # Set up mono for bootstrapping - if ($existingMonoRootPath eq "") - { - # Find the latest mono version and use that for boostrapping - my $monoInstalls = '/Library/Frameworks/Mono.framework/Versions'; - my @monoVersions = (); - - opendir( my $DIR, $monoInstalls ); - while ( my $entry = readdir $DIR ) - { - next unless -d $monoInstalls . '/' . $entry; - next if $entry eq '.' or $entry eq '..' or $entry eq 'Current'; - push @monoVersions, $entry; - } - closedir $DIR; - @monoVersions = sort @monoVersions; - my $monoVersionToUse = pop @monoVersions; - $existingMonoRootPath = "$monoInstalls/$monoVersionToUse"; - } - - $mcs = "EXTERNAL_MCS=$existingMonoRootPath/bin/mcs"; - - $ENV{'CC'} = "$macSdkPath/../usr/bin/clang"; - $ENV{'CXX'} = "$macSdkPath/../usr/bin/clang++"; - $ENV{'CFLAGS'} = $ENV{MACSDKOPTIONS} = "-D_XOPEN_SOURCE -I$macBuildEnvDir/builds/usr/include -mmacosx-version-min=$macversion -isysroot $macSdkPath"; - - $ENV{CFLAGS} = "$ENV{CFLAGS} -g -O0" if $debug; - $ENV{CFLAGS} = "$ENV{CFLAGS} -Os" if not $debug; #optimize for size - - $ENV{CC} = "$ENV{CC} -arch $monoHostArch"; - $ENV{CXX} = "$ENV{CXX} -arch $monoHostArch"; - - # Add OSX specific autogen args - push @configureparams, "--host=$monoHostArch-apple-darwin12.2.0"; - - # Need to define because Apple's SIP gets in the way of us telling mono where to find this - push @configureparams, "--with-libgdiplus=$addtoresultsdistdir/lib/libgdiplus.dylib"; - push @configureparams, "--enable-minimal=shared_perfcounters"; - - print "\n"; - print ">>> Setting environment:\n"; - print ">>> PATH = ".$ENV{PATH}."\n"; - print ">>> C_INCLUDE_PATH = ".$ENV{C_INCLUDE_PATH}."\n"; - print ">>> CPLUS_INCLUDE_PATH = ".$ENV{CPLUS_INCLUDE_PATH}."\n"; - print ">>> CFLAGS = ".$ENV{CFLAGS}."\n"; - print ">>> CXXFLAGS = ".$ENV{CXXFLAGS}."\n"; - print ">>> CC = ".$ENV{CC}."\n"; - print ">>> CXX = ".$ENV{CXX}."\n"; - print ">>> CPP = ".$ENV{CPP}."\n"; - print ">>> CXXPP = ".$ENV{CXXPP}."\n"; - print ">>> LD = ".$ENV{LD}."\n"; - print ">>> LDFLAGS = ".$ENV{LDFLAGS}."\n"; - print "\n"; - } - else - { - push @configureparams, "--host=$monoHostArch-pc-mingw32"; - } - - if ($isDesktopBuild) - { - my $cacheArch = $arch32 ? "i386" : "x86_64"; - push @configureparams, "--cache-file=desktop-$cacheArch.cache" if ($enableCacheFile); - } - - print ">>> Existing Mono : $existingMonoRootPath\n\n"; - $ENV{'PATH'} = "$existingMonoRootPath/$existingExternalMonoBinDir:$ENV{'PATH'}"; - - print ">>> PATH before Build = $ENV{PATH}\n\n"; - - print(">>> mcs Information : \n"); - system(@commandPrefix, ("which", "mcs")); - system(@commandPrefix, ("mcs", "--version")); - print("\n"); - - print ">>> Checking on some tools...\n"; - system(@commandPrefix, ("which", "autoconf")); - system(@commandPrefix, ("autoconf", "--version")); - - system(@commandPrefix, ("which", "texi2dvi")); - system(@commandPrefix, ("texi2dvi", "--version")); - - system(@commandPrefix, ("which", "automake")); - system(@commandPrefix, ("automake", "--version")); - - system(@commandPrefix, ("which", "libtool")); - system(@commandPrefix, ("libtool", "--version")); - - system(@commandPrefix, ("which", "libtoolize")); - system(@commandPrefix, ("libtoolize", "--version")); - print("\n"); - - print ">>> LIBTOOLIZE before Build = $ENV{LIBTOOLIZE}\n"; - print ">>> LIBTOOL before Build = $ENV{LIBTOOL}\n"; - - chdir("$monoroot") eq 1 or die ("failed to chdir 2\n"); - - if (not $skipMonoMake) - { - if ($clean) - { - if (!($mcsOnly)) - { - print(">>> Cleaning $monoprefix\n"); - rmtree($monoprefix); - } - - # Avoid "source directory already configured" ... - system(@commandPrefix, ('rm', '-f', 'config.status', 'eglib/config.status', 'libgc/config.status')); - - print("\n>>> Calling autogen in mono\n"); - print("\n"); - print("\n>>> Configure parameters are : @configureparams\n"); - print("\n"); - - system(@commandPrefix, ('./autogen.sh', @configureparams)) eq 0 or die ('failing autogenning mono'); - - if ($mcsOnly) - { - print("\n>>> Calling make clean in mcs\n"); - chdir("$monoroot/mcs"); - system(@commandPrefix, ("make","clean")) eq 0 or die ("failed to make clean\n"); - chdir("$monoroot"); - } - else - { - print("\n>>> Calling make clean in mono\n"); - system(@commandPrefix, ("make","clean")) eq 0 or die ("failed to make clean\n"); - } - } - - # this step needs to run after configure - if ($iphoneCross || $iphone || $android || $tizen) - { - # This step generates the arm_dpimacros.h file, which is needed by the offset dumper - chdir("$monoroot/mono/arch/arm"); - system("make") eq 0 or die("failed to make in $monoroot/mono/arch/arm\n"); - chdir("$monoroot"); - } - - if ($iphoneCross) - { - my @monoArgs = (); - push @monoArgs, "$monoroot/tools/offsets-tool/MonoAotOffsetsDumper.exe"; - push @monoArgs, "--abi"; - push @monoArgs, "$iphoneCrossAbi"; - push @monoArgs, "--out"; - push @monoArgs, "$monoroot"; - push @monoArgs, "--mono"; - push @monoArgs, "$monoroot"; - push @monoArgs, "--maccore"; - push @monoArgs, "$monoroot"; - - $ENV{MONO_PATH} = "$externalBuildDeps/CppSharpBinaries"; - # Need to use 32bit mono because there is a native CppSharp dylib that will be used and there's only a 32bit version of it - print ">>> Running MonoAotOffsetDumper : arch -i386 $iphoneCrossMonoBinToUse/mono @monoArgs\n"; - system("arch", "-i386", "$iphoneCrossMonoBinToUse/mono", @monoArgs) eq 0 or die("failed to run MonoAotOffsetsDumper\n"); - } - - if ($mcsOnly) - { - print("\n>>> Calling make in mcs\n"); - chdir("$monoroot/mcs"); - my @makeCommand = (@commandPrefix, ('make', "-j$jobs")); - if($mcs ne '') - { - push(@makeCommand, $mcs); - } - system(@makeCommand) eq 0 or die ("Failed to make\n"); - chdir("$monoroot"); - } - else - { - print("\n>>> Calling make\n"); - my @makeCommand = (@commandPrefix, ('make', "-j$jobs")); - if($mcs ne '') - { - push(@makeCommand, $mcs); - } - system(@makeCommand) eq 0 or die ("Failed to make\n"); - } - - if ($isDesktopBuild) - { - print("\n>>> Calling make install\n"); - system(@commandPrefix, ('make', 'install')) eq 0 or die ("Failed to make install\n"); - } - else - { - if ($disableMcs) - { - print(">>> Skipping make install. We don't need to run this step when building the runtime on non-desktop platforms.\n"); - } - else - { - # Note by Mike : make install on Windows for android runtime runs into more cygwin path issues. The one I hit was related to ranlib.exe being passed cygwin linux paths - # and as a result not being able to find stuff. The previous build scripts didn't run make install for android or iOS, so I think we are fine to skip this step. - # However, if we were to build the class libs for these cases, then we probably would need to run make install. If that day comes, we'll have to figure out what to do here. - print(">>> Attempting to build class libs for a non-desktop platform. The `make install` step is probably needed, but it has cygwin path related problems on Windows for android\n"); - die("Blocking this code path until we need it. It probably should be looked at more closely before letting it proceed\n"); - } - } - } - - if ($isDesktopBuild) - { - if ($^O eq "cygwin") - { - system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--msbuildversion=$msBuildVersion", "--clean=$clean", "--debug=$debug") eq 0 or die ('failed building mono with VS\n'); - - # Copy over the VS built stuff that we want to use instead into the prefix directory - my $archNameForBuild = $arch32 ? 'Win32' : 'x64'; - my $config = $debug ? "Debug" : "Release"; - system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono.exe $monoprefix/bin/.") eq 0 or die ("failed copying mono.exe\n"); - system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono-2.0.dll $monoprefix/bin/.") eq 0 or die ("failed copying mono-2.0.dll\n"); - system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono-2.0.pdb $monoprefix/bin/.") eq 0 or die ("failed copying mono-2.0.pdb\n"); - } - - system("cp -R $addtoresultsdistdir/bin/. $monoprefix/bin/") eq 0 or die ("Failed copying $addtoresultsdistdir/bin to $monoprefix/bin\n"); - } - - if(!($disableMcs)) - { - my @additionalProfiles = (); - push @additionalProfiles, "unityjit"; - push @additionalProfiles, "unityaot"; - - chdir("$monoroot/mcs"); - foreach my $profileName(@additionalProfiles) - { - print(">>> Making profile : $profileName\n"); - system("make", "PROFILE=$profileName") eq 0 or die ("Failed to make $profileName profile in mcs\n"); - - my $profileDestDir = "$monoprefix/lib/mono/$profileName"; - print(">>> Copying $profileName to $profileDestDir directory\n"); - - print(">>> Cleaning $profileDestDir\n"); - system("rm -rf $profileDestDir"); - - system("mkdir -p $profileDestDir") eq 0 or die("failed to make directory $profileDestDir\n"); - system("mkdir -p $profileDestDir/Facades") eq 0 or die("failed to make directory $profileDestDir/Facades\n"); - - system("cp $monoroot/mcs/class/lib/$profileName/*.dll $profileDestDir") eq 0 or die("Failed copying dlls from $monoroot/mcs/class/lib/$profileName to $profileDestDir\n"); - system("cp $monoroot/mcs/class/lib/$profileName/Facades/*.dll $profileDestDir/Facades") eq 0 or die("Failed copying dlls from $monoroot/mcs/class/lib/$profileName/Facades to $profileDestDir/Facades\n"); - } - - chdir("$monoroot"); - - my $stubResult = system("perl", "$buildscriptsdir/stub_classlibs.pl"); - - if ($stubResult ne 0) - { - die("Failed to run the profile stubber\n"); - } - } -} -else -{ - print(">>> Skipping build\n"); -} - -if ($buildUsAndBoo) -{ - print(">>> Building Unity Script and Boo...\n"); - if($windowsSubsystemForLinux) - { - #boo scripts expect a bin-platform folder, but we haven't built them that way - system("ln -s $monoprefix/bin $monoprefix/bin-linux64"); - system("ln -s $monoprefix/bin $monoprefix/bin-linux32"); - } - - system(@commandPrefix, ("perl", "$buildscriptsdir/build_us_and_boo.pl", "--monoprefix=$monoprefix")) eq 0 or die ("Failed building Unity Script and Boo\n"); - - print(">>> Copying Unity Script and Boo *.Lang.dll's from 4.5 profile to unityjit profile...\n"); - system("cp $monoprefix/lib/mono/4.5/Boo*.dll $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying Boo*.dll\n"); - system("cp $monoprefix/lib/mono/4.5/UnityScript*.dll $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying UnityScript*.dll\n"); - system("cp $monoprefix/lib/mono/4.5/booc.exe $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying booc.exe\n"); - system("cp $monoprefix/lib/mono/4.5/us.exe $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying us.exe\n"); -} -else -{ - print(">>> Skipping build Unity Script and Boo\n"); -} - -if ($artifact) -{ - print(">>> Creating artifact...\n"); - - if ($artifactsCommon) - { - print(">>> Creating common artifacts...\n"); - print(">>> distribution directory = $distdir\n"); - - if (!(-d "$distdir")) - { - system("mkdir -p $distdir") eq 0 or die("failed to make directory $distdir\n"); - } - - $File::Copy::Recursive::CopyLink = 0; #make sure we copy files as files and not as symlinks, as TC unfortunately doesn't pick up symlinks. - - my $distdirlibmono = "$distdir/lib/mono"; - - print(">>> Cleaning $distdir/lib\n"); - system("rm -rf $distdir/lib"); - system("mkdir -p $distdir/lib"); - - print(">>> Creating normal profile artifacts...\n"); - system("cp -R $addtoresultsdistdir/. $distdir/") eq 0 or die ("Failed copying $addtoresultsdistdir to $distdir\n"); - - system("cp -r $monoprefix/lib/mono $distdir/lib"); - - if($^O ne 'darwin') - { - # On OSX we build a universal binary for 32-bit and 64-bit in the mono executable. The class library build - # only creates the 64-bit slice, so we don't want to end up with a single slice binary in the output. - # If we do, it will step on the universal binary produced but the OSX runtime build. - system("cp -r $monoprefix/bin $distdir/") eq 0 or die ("failed copying bin folder\n"); - } - system("cp -r $monoprefix/etc $distdir/") eq 0 or die("failed copying etc folder\n"); - - system("cp -R $externalBuildDeps/reference-assemblies/unity $distdirlibmono/unity"); - system("cp -R $externalBuildDeps/reference-assemblies/unity_web $distdirlibmono/unity_web"); - - system("cp -R $externalBuildDeps/reference-assemblies/unity/Boo*.dll $distdirlibmono/2.0-api"); - system("cp -R $externalBuildDeps/reference-assemblies/unity/UnityScript*.dll $distdirlibmono/2.0-api"); - - system("cp -R $externalBuildDeps/reference-assemblies/unity/Boo*.dll $distdirlibmono/4.0-api"); - system("cp -R $externalBuildDeps/reference-assemblies/unity/UnityScript*.dll $distdirlibmono/4.0-api"); - - system("cp -R $externalBuildDeps/reference-assemblies/unity/Boo*.dll $distdirlibmono/4.5-api"); - system("cp -R $externalBuildDeps/reference-assemblies/unity/UnityScript*.dll $distdirlibmono/4.5-api"); - - # now remove nunit from a couple places (but not all, we need some of them) - # linux tar is not happy these are removed(at least on wsl), so don't remove them for now - if(not $windowsSubsystemForLinux) - { - system("rm -rf $distdirlibmono/2.0/nunit*"); - system("rm -rf $distdirlibmono/gac/nunit*"); - } - - # Remove a self referencing sym link that causes problems - system("rm -rf $monoprefix/bin/bin"); - - if (-f "$monoroot/ZippedClasslibs.tar.gz") - { - system("rm -f $monoroot/ZippedClasslibs.tar.gz") eq 0 or die("Failed to clean existing ZippedClasslibs.tar.gz\n"); - } - - print(">>> Creating ZippedClasslibs.tar.gz\n"); - print(">>> Changing directory to : $buildsroot\n"); - chdir("$buildsroot"); - system("tar -hpczf ../ZippedClasslibs.tar.gz *") eq 0 or die("Failed to zip up classlibs\n"); - print(">>> Changing directory back to : $currentdir\n"); - chdir("$currentdir"); - } - - # Do the platform specific logic to create the builds output structure that we want - - my $embedDirRoot = "$buildsroot/embedruntimes"; - my $embedDirArchDestination = ""; - my $distDirArchBin = ""; - my $versionsOutputFile = ""; - my $crossCompilerRoot = "$buildsroot/crosscompiler"; - my $crossCompilerDestination = ""; - - if ($iphone) - { - $embedDirArchDestination = "$embedDirRoot/iphone/$iphoneArch"; - $versionsOutputFile = "$buildsroot/versions-iphone-$iphoneArch.txt"; - } - elsif ($iphoneCross) - { - $crossCompilerDestination = "$buildsroot/crosscompiler/iphone"; - $versionsOutputFile = "$buildsroot/versions-iphone-xcompiler.txt"; - } - elsif ($iphoneSimulator) - { - $embedDirArchDestination = "$embedDirRoot/iphone/$iphoneSimulatorArch"; - $versionsOutputFile = "$buildsroot/versions-iphone-$iphoneSimulatorArch.txt"; - } - elsif ($android) - { - $embedDirArchDestination = "$embedDirRoot/android/$androidArch"; - $versionsOutputFile = "$buildsroot/versions-android-$androidArch.txt"; - } - elsif ($tizenEmulator) - { - $embedDirArchDestination = "$embedDirRoot/tizenemulator/"; - $versionsOutputFile = "$buildsroot/versions-tizenemulator.txt"; - } - elsif ($tizen) - { - $embedDirArchDestination = "$embedDirRoot/tizen/"; - $versionsOutputFile = "$buildsroot/versions-tizen.txt"; - } - elsif($^O eq "linux") - { - $embedDirArchDestination = $arch32 ? "$embedDirRoot/linux32" : "$embedDirRoot/linux64"; - $distDirArchBin = $arch32 ? "$distdir/bin-linux32" : "$distdir/bin-linux64"; - $versionsOutputFile = $arch32 ? "$buildsroot/versions-linux32.txt" : "$buildsroot/versions-linux64.txt"; - } - elsif($^O eq 'darwin') - { - # Note these tmp directories will get merged into a single 'osx' directory later by a parent script - $embedDirArchDestination = "$embedDirRoot/osx-tmp-$monoHostArch"; - $distDirArchBin = "$distdir/bin-osx-tmp-$monoHostArch"; - $versionsOutputFile = $arch32 ? "$buildsroot/versions-osx32.txt" : "$buildsroot/versions-osx64.txt"; - } - else - { - $embedDirArchDestination = $arch32 ? "$embedDirRoot/win32" : "$embedDirRoot/win64"; - $distDirArchBin = $arch32 ? "$distdir/bin" : "$distdir/bin-x64"; - $versionsOutputFile = $arch32 ? "$buildsroot/versions-win32.txt" : "$buildsroot/versions-win64.txt"; - } - - # Make sure the directory for our architecture is clean before we copy stuff into it - if (-d "$embedDirArchDestination") - { - print(">>> Cleaning $embedDirArchDestination\n"); - rmtree($embedDirArchDestination); - } - - if (-d "$distDirArchBin") - { - print(">>> Cleaning $distDirArchBin\n"); - rmtree($distDirArchBin); - } - - if ($artifactsRuntime) - { - system("mkdir -p $embedDirArchDestination") if ($embedDirArchDestination ne ""); - system("mkdir -p $distDirArchBin") if ($distDirArchBin ne ""); - system("mkdir -p $crossCompilerDestination") if ($crossCompilerDestination ne ""); - - # embedruntimes directory setup - print(">>> Creating embedruntimes directory : $embedDirArchDestination\n"); - if ($iphone || $iphoneSimulator) - { - for my $file ('libmonosgen-2.0.a','libmonobdwgc-2.0.a') - { - print ">>> Copying $file\n"; - system("cp", "$monoroot/mono/mini/.libs/$file","$embedDirArchDestination/$file") eq 0 or die ("failed copying $file\n"); - } - } - elsif ($iphoneCross) - { - # Nothing to do - } - elsif ($android) - { - for my $file ('libmonosgen-2.0.so','libmonobdwgc-2.0.so') - { - print ">>> Copying $file\n"; - system("cp", "$monoroot/mono/mini/.libs/$file","$embedDirArchDestination/$file") eq 0 or die ("failed copying $file\n"); - } - print ">>> Copying libMonoPosixHelper.so\n"; - system("cp", "$monoroot/support/.libs/libMonoPosixHelper.so","$embedDirArchDestination/libMonoPosixHelper.so") eq 0 or die ("failed copying libMonoPosixHelper.so\n"); - } - elsif ($tizen || $tizenEmulator) - { - for my $file ('libmonosgen-2.0.so','libmonobdwgc-2.0.so') - { - print ">>> Copying $file\n"; - system("cp", "$monoroot/mono/mini/.libs/$file","$embedDirArchDestination/$file") eq 0 or die ("failed copying $file\n"); - } - } - elsif($^O eq "linux") - { - print ">>> Copying libmonosgen-2.0\n"; - system("cp", "$monoroot/mono/mini/.libs/libmonobdwgc-2.0.so","$embedDirArchDestination/libmonobdwgc-2.0.so") eq 0 or die ("failed copying libmonobdwgc-2.0.so\n"); - system("cp", "$monoroot/mono/mini/.libs/libmonosgen-2.0.so","$embedDirArchDestination/libmonosgen-2.0.so") eq 0 or die ("failed copying libmonosgen-2.0.so\n"); - - print ">>> Copying libMonoPosixHelper.so\n"; - system("cp", "$monoroot/support/.libs/libMonoPosixHelper.so","$embedDirArchDestination/libMonoPosixHelper.so") eq 0 or die ("failed copying libMonoPosixHelper.so\n"); - - if ($buildMachine) - { - system("strip $embedDirArchDestination/libmonobdwgc-2.0.so") eq 0 or die("failed to strip libmonobdwgc-2.0.so (shared)\n"); - system("strip $embedDirArchDestination/libmonosgen-2.0.so") eq 0 or die("failed to strip libmonosgen-2.0.so (shared)\n"); - system("strip $embedDirArchDestination/libMonoPosixHelper.so") eq 0 or die("failed to strip libMonoPosixHelper (shared)\n"); - } - } - elsif($^O eq 'darwin') - { - # embedruntimes directory setup - print ">>> Hardlinking libmonosgen-2.0\n"; - - system("ln","-f", "$monoroot/mono/mini/.libs/libmonobdwgc-2.0.dylib","$embedDirArchDestination/libmonobdwgc-2.0.dylib") eq 0 or die ("failed symlinking libmonobdwgc-2.0.dylib\n"); - system("ln","-f", "$monoroot/mono/mini/.libs/libmonosgen-2.0.dylib","$embedDirArchDestination/libmonosgen-2.0.dylib") eq 0 or die ("failed symlinking libmonosgen-2.0.dylib\n"); - - print "Hardlinking libMonoPosixHelper.dylib\n"; - system("ln","-f", "$monoroot/support/.libs/libMonoPosixHelper.dylib","$embedDirArchDestination/libMonoPosixHelper.dylib") eq 0 or die ("failed symlinking $libtarget/libMonoPosixHelper.dylib\n"); - - InstallNameTool("$embedDirArchDestination/libmonobdwgc-2.0.dylib", "\@executable_path/../Frameworks/MonoEmbedRuntime/osx/libmonobdwgc-2.0.dylib"); - InstallNameTool("$embedDirArchDestination/libmonosgen-2.0.dylib", "\@executable_path/../Frameworks/MonoEmbedRuntime/osx/libmonosgen-2.0.dylib"); - InstallNameTool("$embedDirArchDestination/libMonoPosixHelper.dylib", "\@executable_path/../Frameworks/MonoEmbedRuntime/osx/libMonoPosixHelper.dylib"); - - print ">>> Copying mono public headers\n"; - system("mkdir -p $includesroot/mono"); - system("cp -R $monoprefix/include/mono-2.0/mono $includesroot/mono"); - } - else - { - # embedruntimes directory setup - system("cp", "$monoprefix/bin/mono-2.0-bdwgc.dll", "$embedDirArchDestination/mono-2.0-bdwgc.dll") eq 0 or die ("failed copying mono-2.0-bdwgc.dll\n"); - system("cp", "$monoprefix/bin/mono-2.0-bdwgc.pdb", "$embedDirArchDestination/mono-2.0-bdwgc.pdb") eq 0 or die ("failed copying mono-2.0-bdwgc.pdb\n"); - - system("cp", "$monoprefix/bin/mono-2.0-sgen.dll", "$embedDirArchDestination/mono-2.0-sgen.dll") eq 0 or die ("failed copying mono-2.0-sgen.dll\n"); - system("cp", "$monoprefix/bin/mono-2.0-sgen.pdb", "$embedDirArchDestination/mono-2.0-sgen.pdb") eq 0 or die ("failed copying mono-2.0-sgen.pdb\n"); - } - - # monodistribution directory setup - print(">>> Creating monodistribution directory\n"); - if ($android || $iphone || $iphoneCross || $iphoneSimulator || $tizen || $tizenEmulator) - { - # Nothing to do - } - elsif($^O eq "linux") - { - my $distDirArchEtc = $arch32 ? "$distdir/etc-linux32" : "$distdir/etc-linux64"; - - if (-d "$distDirArchEtc") - { - print(">>> Cleaning $distDirArchEtc\n"); - rmtree($distDirArchEtc); - } - - system("mkdir -p $distDirArchBin"); - system("mkdir -p $distDirArchEtc"); - system("mkdir -p $distDirArchEtc/mono"); - - system("ln", "-f", "$monoroot/mono/mini/mono-sgen","$distDirArchBin/mono") eq 0 or die("failed symlinking mono executable\n"); - system("ln", "-f", "$monoroot/tools/pedump/pedump","$distDirArchBin/pedump") eq 0 or die("failed symlinking pedump executable\n"); - system('cp', "$monoroot/data/config","$distDirArchEtc/mono/config") eq 0 or die("failed to copy config\n"); - } - elsif($^O eq 'darwin') - { - system("ln", "-f", "$monoroot/mono/mini/mono","$distDirArchBin/mono") eq 0 or die("failed hardlinking mono executable\n"); - system("ln", "-f", "$monoroot/tools/pedump/pedump","$distDirArchBin/pedump") eq 0 or die("failed hardlinking pedump executable\n"); - } - else - { - system("cp", "$monoprefix/bin/mono-2.0.dll", "$distDirArchBin/mono-2.0.dll") eq 0 or die ("failed copying mono-2.0.dll\n"); - system("cp", "$monoprefix/bin/mono-2.0.pdb", "$distDirArchBin/mono-2.0.pdb") eq 0 or die ("failed copying mono-2.0.pdb\n"); - system("cp", "$monoprefix/bin/mono.exe", "$distDirArchBin/mono.exe") eq 0 or die ("failed copying mono.exe\n"); - } - } - - # cross compiler directory setup - if ($iphoneCross) - { - print ">>> Copying mono-xcompiler\n"; - if($runningOnWindows) - { - die("Not implemented\n"); - } - else - { - system("cp", "$monoroot/mono/mini/mono","$crossCompilerDestination/mono-xcompiler") eq 0 or die ("failed copying mono-xcompiler\n"); - } - } - - # Not all build configurations output to the distro dir, so only chmod it if it exists - system("chmod", "-R", "755", $distDirArchBin) if (-d "$distDirArchBin"); - - # Output version information - print(">>> Creating version file : $versionsOutputFile\n"); - system("echo \"mono-version =\" > $versionsOutputFile"); - - # Not all build configurations output to the distro dir, only try to output version info if there is a distro dir - system("$distDirArchBin/mono --version >> $versionsOutputFile") if (-d "$distDirArchBin"); - - system("echo \"unity-mono-revision = $monoRevision\" >> $versionsOutputFile"); - system("echo \"unity-mono-build-scripts-revision = $buildScriptsRevision\" >> $versionsOutputFile"); - my $tmp = `date`; - system("echo \"build-date = $tmp\" >> $versionsOutputFile"); -} -else -{ - print(">>> Skipping artifact creation\n"); -} - -if ($test) -{ - if ($runRuntimeTests) - { - my $runtimeTestsDir = "$monoroot/mono/mini"; - chdir("$runtimeTestsDir") eq 1 or die ("failed to chdir"); - print("\n>>> Calling make check in $runtimeTestsDir\n\n"); - system("make","check") eq 0 or die ("runtime tests failed\n"); - } - else - { - print(">>> Skipping runtime unit tests\n"); - } - - if ($runClasslibTests) - { - if ($disableMcs) - { - print(">>> Skipping classlib unit tests because building the class libs was disabled\n"); - } - else - { - my $classlibTestsDir = "$monoroot/mcs/class"; - chdir("$classlibTestsDir") eq 1 or die ("failed to chdir"); - print("\n>>> Calling make run-test in $runtimeTestsDir\n\n"); - system("make","run-test") eq 0 or die ("classlib tests failed\n"); - } - } - else - { - print(">>> Skipping classlib unit tests\n"); - } -} -else -{ - print(">>> Skipping unit tests\n"); -} - -chdir ($currentdir); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; +use lib ('external/buildscripts', "../../Tools/perl_lib","perl_lib", 'external/buildscripts/perl_lib'); +use Tools qw(InstallNameTool); + +print ">>> PATH in Build All = $ENV{PATH}\n\n"; + +my $currentdir = getcwd(); + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); + +my $buildscriptsdir = "$monoroot/external/buildscripts"; +my $addtoresultsdistdir = "$buildscriptsdir/add_to_build_results/monodistribution"; +my $buildsroot = "$monoroot/builds"; +my $includesroot = "$buildsroot/include"; +my $sourcesroot = "$buildsroot/source"; +my $distdir = "$buildsroot/monodistribution"; +my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; + +# This script should not be ran on windows, if it is, kindly call the wrapper +# to switch over to cygwin +if ($^O eq "MSWin32") +{ + print(">>> build.pl called from Windows. Switching over to cygwin\n"); + system("perl", "$buildscriptsdir/build_win_wrapper.pl", @ARGV) eq 0 or die("\n"); + exit 0; +} + +system("source","~/.profile"); + +my $build=0; +my $clean=0; +my $jobs=8; +my $test=0; +my $artifact=0; +my $debug=0; +my $disableMcs=0; +my $mcsOnly=0; +my $buildUsAndBoo=0; +my $artifactsCommon=0; +my $artifactsRuntime=1; +my $runRuntimeTests=1; +my $runClasslibTests=1; +my $checkoutOnTheFly=0; +my $forceDefaultBuildDeps=0; +my $existingMonoRootPath = ''; +my $sdk = ''; +my $arch32 = 0; +my $winPerl = ""; +my $winMonoRoot = ""; +my $msBuildVersion = "14.0"; +my $buildDeps = ""; +my $android=0; +my $androidArch = ""; +my $iphone=0; +my $iphoneArch = ""; +my $iphoneCross=0; +my $iphoneSimulator=0; +my $iphoneSimulatorArch=""; +my $tizen=0; +my $tizenEmulator=0; +my $windowsSubsystemForLinux=0; + +# Handy troubleshooting/niche options +my $skipMonoMake=0; + +# The prefix hack probably isn't needed anymore. Let's disable it by default and see how things go +my $shortPrefix=1; + +# Disabled by default for now. causes more problems than it's worth when actively making changes to the build scripts. +# Would be okay to turn on once the build scripts stabilize and you just want to rebuild code changes +my $enableCacheFile=0; + +# Linux toolchain setup needs this +my @commandPrefix = (); + +print(">>> Build All Args = @ARGV\n"); + +GetOptions( + 'build=i'=>\$build, + 'clean=i'=>\$clean, + 'test=i'=>\$test, + 'artifact=i'=>\$artifact, + 'artifactscommon=i'=>\$artifactsCommon, + 'artifactsruntime=i'=>\$artifactsRuntime, + 'debug=i'=>\$debug, + 'disablemcs=i'=>\$disableMcs, + 'mcsonly=i'=>\$mcsOnly, + 'buildusandboo=i'=>\$buildUsAndBoo, + 'runtimetests=i'=>\$runRuntimeTests, + 'classlibtests=i'=>\$runClasslibTests, + 'arch32=i'=>\$arch32, + 'jobs=i'=>\$jobs, + 'sdk=s'=>\$sdk, + 'existingmono=s'=>\$existingMonoRootPath, + 'skipmonomake=i'=>\$skipMonoMake, + 'shortprefix=i'=>\$shortPrefix, + 'winperl=s'=>\$winPerl, + 'winmonoroot=s'=>\$winMonoRoot, + 'msbuildversion=s'=>\$msBuildVersion, + 'checkoutonthefly=i'=>\$checkoutOnTheFly, + 'builddeps=s'=>\$buildDeps, + 'forcedefaultbuilddeps=i'=>\$forceDefaultBuildDeps, + 'android=i'=>\$android, + 'androidarch=s'=>\$androidArch, + 'iphone=i'=>\$iphone, + 'iphonearch=s'=>\$iphoneArch, + 'iphonecross=i'=>\$iphoneCross, + 'iphonesimulator=i'=>\$iphoneSimulator, + 'tizen=i'=>\$tizen, + 'tizenemulator=i'=>\$tizenEmulator, + 'windowssubsystemforlinux=i'=>\$windowsSubsystemForLinux, + 'enablecachefile=i'=>\$enableCacheFile, +) or die ("illegal cmdline options"); + +print ">>> Mono checkout = $monoroot\n"; + +print(">> System Info : \n"); +system("uname", "-a"); + +my $monoRevision = `git rev-parse HEAD`; +chdir("$buildscriptsdir") eq 1 or die ("failed to chdir : $buildscriptsdir\n"); +my $buildScriptsRevision = `git rev-parse HEAD`; +chdir("$monoroot") eq 1 or die ("failed to chdir : $monoroot\n"); + +print(">>> Mono Revision = $monoRevision\n"); +print(">>> Build Scripts Revision = $buildScriptsRevision\n"); + +if ($androidArch ne "") +{ + $android = 1; +} + +if ($iphoneArch ne "") +{ + $iphone = 1; +} + +if($iphoneSimulator) +{ + if ($arch32) + { + $iphoneSimulatorArch = "i386"; + } + else + { + $iphoneSimulatorArch = "x86_64"; + } +} + +my $isDesktopBuild = 1; +if ($android || $iphone || $iphoneCross || $iphoneSimulator || $tizen || $tizenEmulator) +{ + $isDesktopBuild = 0; + + # Disable building of the class libraries by default when building the android runtime + # since we don't care about a class library build in this situation (as of writing this at least) + # but only if the test flag is not set. If the test flag was set, we'd need to build the classlibs + # in order to run the tests + $disableMcs = 1 if(!($test)); +} + +# Do any settings agnostic per-platform stuff +my $externalBuildDeps = ""; + +if ($buildDeps ne "" && not $forceDefaultBuildDeps) +{ + $externalBuildDeps = $buildDeps; +} +else +{ + $externalBuildDeps = "$monoroot/../../mono-build-deps/build"; +} + +# Only clean up the path if the directory exists, if it doesn't exist, +# abs_path ends up returning an empty string +$externalBuildDeps = abs_path($externalBuildDeps) if (-d $externalBuildDeps); + +my $extraBuildTools = "$monoroot/../../mono-build-tools-extra/build"; + +my $existingExternalMonoRoot = "$externalBuildDeps/MonoBleedingEdge"; +my $existingExternalMono = ""; +my $existingExternalMonoBinDir = ""; +my $monoHostArch = ""; +my $monoprefix = "$monoroot/tmp"; +my $runningOnWindows=0; +if($^O eq "linux") +{ + $monoHostArch = $arch32 ? "i686" : "x86_64"; + $existingExternalMono = "$existingExternalMonoRoot"; + $existingExternalMonoBinDir = "bin-linux64"; +} +elsif($^O eq 'darwin') +{ + $monoHostArch = $arch32 ? "i386" : "x86_64"; + $existingExternalMono = "$existingExternalMonoRoot"; + $existingExternalMonoBinDir = "bin"; + + # From Massi: I was getting failures in install_name_tool about space + # for the commands being too small, and adding here things like + # $ENV{LDFLAGS} = '-headerpad_max_install_names' and + # $ENV{LDFLAGS} = '-headerpad=0x40000' did not help at all (and also + # adding them to our final gcc invocation to make the bundle). + # Lucas noticed that I was lacking a Mono prefix, and having a long + # one would give us space, so here is this silly looong prefix. + if (not $shortPrefix) + { + $monoprefix = "$monoroot/tmp/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting/scripting"; + } +} +else +{ + $monoHostArch = "i686"; + $existingExternalMono = "$existingExternalMonoRoot"; + $existingExternalMonoBinDir = "bin-x64"; + $runningOnWindows = 1; + + # We only care about an existing mono if we need to build. + # So only do this path clean up if we are building. + if ($build) + { + if ($existingMonoRootPath ne "" && not $existingMonoRootPath =~ /^\/cygdrive/) + { + $existingMonoRootPath = `cygpath -u $existingMonoRootPath`; + chomp($existingMonoRootPath); + } + + $existingMonoRootPath =~ tr/\\//d; + } +} + +if ($runningOnWindows) +{ + # Fixes a line ending issue that happens on windows when we try to run autogen.sh + $ENV{'SHELLOPTS'} = "igncr"; +} + +print(">>> Existing Mono = $existingMonoRootPath\n"); +print(">>> Mono Arch = $monoHostArch\n"); + +if ($build) +{ + my $platformflags = ''; + my $host = ''; + my $mcs = ''; + + my $iphoneCrossAbi = "arm-apple-darwin10"; + my $iphoneCrossMonoBinToUse = "$monoroot/builds/monodistribution/bin"; + + my @configureparams = (); + + push @configureparams, "--disable-mcs-build" if($disableMcs); + push @configureparams, "--with-glib=embedded"; + push @configureparams, "--disable-nls"; #this removes the dependency on gettext package + push @configureparams, "--disable-btls"; #this removes the dependency on cmake to build btls for now + push @configureparams, "--with-mcs-docs=no"; + push @configureparams, "--prefix=$monoprefix"; + + if(!($disableMcs)) + { + push @configureparams, "--with-unityjit=yes"; + push @configureparams, "--with-unityaot=yes"; + } + + if ($isDesktopBuild) + { + push @configureparams, "--with-monotouch=no"; + } + + if (!(-d "$extraBuildTools")) + { + # Check out on the fly + print(">>> Checking out mono build tools extra to : $extraBuildTools\n"); + my $repo = 'git@gitlab.internal.unity3d.com:vm/mono-build-tools-extra.git'; + print(">>> Cloning $repo at $extraBuildTools\n"); + my $checkoutResult = system("git", "clone", "--recurse-submodules", $repo, "$extraBuildTools"); + + if ($checkoutResult ne 0) + { + die("Failed to checkout mono build tools extra\n"); + } + + # Only clean up if the dir exists. Otherwise abs_path will return empty string + $extraBuildTools = abs_path($extraBuildTools) if (-d $extraBuildTools); + } + + if ($existingMonoRootPath eq "") + { + print(">>> No existing mono supplied. Checking for external...\n"); + + if (!(-d "$externalBuildDeps")) + { + if (not $checkoutonthefly) + { + print(">>> No external build deps found. Might as well try to check them out. If it fails, we'll continue and trust mono is in your PATH\n"); + } + + # Check out on the fly + print(">>> Checking out mono build dependencies to : $externalBuildDeps\n"); + my $repo = "https://ono.unity3d.com/unity-extra/mono-build-deps"; + print(">>> Cloning $repo at $externalBuildDeps\n"); + my $checkoutResult = system("hg", "clone", $repo, "$externalBuildDeps"); + + if ($checkoutOnTheFly && $checkoutResult ne 0) + { + die("failed to checkout mono build dependencies\n"); + } + + # Only clean up if the dir exists. Otherwise abs_path will return empty string + $externalBuildDeps = abs_path($externalBuildDeps) if (-d $externalBuildDeps); + } + + if (-d "$existingExternalMono") + { + print(">>> External mono found at : $existingExternalMono\n"); + + if (-d "$existingExternalMono/builds") + { + print(">>> Mono already extracted at : $existingExternalMono/builds\n"); + } + + if (!(-d "$existingExternalMono/builds")) + { + # We need to extract builds.zip + print(">>> Extracting mono builds.zip...\n"); + system("unzip", "$existingExternalMono/builds.zip", "-d", "$existingExternalMono/builds") eq 0 or die("failed to extract mono builds.zip\n"); + } + + $existingMonoRootPath = "$existingExternalMono/builds/monodistribution"; + } + else + { + print(">>> No external mono found. Trusting a new enough mono is in your PATH.\n"); + } + } + + if ($existingMonoRootPath ne "" && !(-d $existingMonoRootPath)) + { + die("Existing mono not found at : $existingMonoRootPath\n"); + } + + if ($externalBuildDeps ne "") + { + print "\n"; + print ">>> Building autoconf, texinfo, automake, and libtool if needed...\n"; + my $autoconfVersion = "2.69"; + my $texinfoVersion = "4.8"; + my $automakeVersion = "1.15"; + my $libtoolVersion = "2.4.6"; + my $autoconfDir = "$externalBuildDeps/autoconf-$autoconfVersion"; + my $texinfoDir = "$externalBuildDeps/texinfo-$texinfoVersion"; + my $automakeDir = "$externalBuildDeps/automake-$automakeVersion"; + my $libtoolDir = "$externalBuildDeps/libtool-$libtoolVersion"; + my $builtToolsDir = "$externalBuildDeps/built-tools"; + + $ENV{PATH} = "$builtToolsDir/bin:$ENV{PATH}"; + + if (!(-d "$autoconfDir")) + { + chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); + system("tar xzf autoconf-$autoconfVersion.tar.gz") eq 0 or die ("failed to extract autoconf\n"); + + chdir("$autoconfDir") eq 1 or die ("failed to chdir to autoconf directory\n"); + system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure autoconf\n"); + system("make") eq 0 or die ("failed to make autoconf\n"); + system("make install") eq 0 or die ("failed to make install autoconf\n"); + + chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); + } + + if (!(-d "$texinfoDir") and $windowsSubsystemForLinux) + { + chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); + system("tar xzf texinfo-$texinfoVersion.tar.gz") eq 0 or die ("failed to extract texinfo\n"); + + chdir($texinfoDir) eq 1 or die ("failed to chdir to texinfo directory\n"); + system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure texinfo\n"); + system("make") eq 0 or die ("failed to make texinfo\n"); + system("make install") eq 0 or die ("failed to make install texinfo\n"); + + chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); + } + + if (!(-d "$automakeDir")) + { + my $automakeMakeFlags = ""; + chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); + system("tar xzf automake-$automakeVersion.tar.gz") eq 0 or die ("failed to extract automake\n"); + + chdir("$automakeDir") eq 1 or die ("failed to chdir to automake directory\n"); + if($windowsSubsystemForLinux) + { + #Windows subsystem needs to run bootstrap, and make needs to be run with -i due to one doc failing to build + system("./bootstrap.sh") eq 0 or die ("failed to bootstrap automake\n"); + $automakeMakeFlags = "-i"; + } + system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure automake\n"); + system("make $automakeMakeFlags") eq 0 or die ("failed to make automake\n"); + system("make install"); + chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); + } + + if (!(-d "$libtoolDir")) + { + chdir("$externalBuildDeps") eq 1 or die ("failed to chdir to external directory\n"); + system("tar xzf libtool-$libtoolVersion.tar.gz") eq 0 or die ("failed to extract libtool\n"); + + chdir("$libtoolDir") eq 1 or die ("failed to chdir to libtool directory\n"); + system("./configure --prefix=$builtToolsDir") eq 0 or die ("failed to configure libtool\n"); + system("make") eq 0 or die ("failed to make libtool\n"); + system("make install") eq 0 or die ("failed to make install libtool\n"); + + chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); + } + + $ENV{'LIBTOOLIZE'} = "$builtToolsDir/bin/libtoolize"; + $ENV{'LIBTOOL'} = "$builtToolsDir/bin/libtool"; + } + + my $macSdkPath = ""; + my $macversion = '10.8'; + my $darwinVersion = "10"; + if ($^O eq 'darwin') + { + if ($sdk eq '') + { + $sdk='10.11'; + } + + my $macBuildEnvDir = "$externalBuildDeps/MacBuildEnvironment"; + $macSdkPath = "$macBuildEnvDir/builds/MacOSX$sdk.sdk"; + if (! -d $macSdkPath) + { + print(">>> Unzipping mac build toolchain\n"); + system("$externalBuildDeps/unzip", '-qd', "$macBuildEnvDir", "$macBuildEnvDir/builds.zip") eq 0 or die ("failed unzipping mac build toolchain\n"); + } + } + + if ($iphone || $iphoneSimulator) + { + if ($runningOnWindows) + { + die("This build is not supported on Windows\n"); + } + + my $iosBuildEnvDir = "$externalBuildDeps/iOSBuildEnvironment"; + my $iosXcodeDefaultToolchainRoot = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain"; + + if (! -d "$iosBuildEnvDir/builds") + { + print(">>> Unzipping ios build toolchain\n"); + system("$externalBuildDeps/unzip", '-qd', "$iosBuildEnvDir/builds", "$iosBuildEnvDir/builds.zip") eq 0 or die ("failed unzipping ios build toolchain\n"); + } + + $ENV{PATH} = "$iosXcodeDefaultToolchainRoot/usr/bin:$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/usr/bin:$ENV{PATH}"; + # Need to keep our libtool in front + $ENV{PATH} = "$externalBuildDeps/built-tools/bin:$ENV{PATH}"; + + push @configureparams, "--cache-file=iphone-$iphoneArch.cache" if ($enableCacheFile); + + my $iosMinimalCommon = "com,remoting,shared_perfcounters,appdomains"; + my $iosCFlagsCommon = "-DMONOTOUCH -DHOST_IOS -DDISABLE_POLICY_EVIDENCE=1 -DDISABLE_PROCESS_HANDLING=1"; + + push @configureparams, "--with-tls=pthread"; + push @configureparams, "--without-ikvm-native"; + push @configureparams, "--disable-executables"; + push @configureparams, "--disable-visibility-hidden"; + + if ($iphone) + { + my $iosSdkVersion = "9.3"; + my $iphoneOsMinVersion = "3.0"; + my $iosSdkRoot = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$iosSdkVersion.sdk"; + + print(">>> iOS Build Environment = $iosBuildEnvDir\n"); + print(">>> iOS SDK Version = $iosSdkVersion\n"); + print(">>> iOS SDK Root = $iosSdkRoot\n"); + print(">>> iPhone Arch = $iphoneArch\n"); + + $ENV{PATH} = "$iosSdkRoot/usr/bin:$ENV{PATH}"; + + $ENV{C_INCLUDE_PATH} = "$iosSdkRoot/usr/include"; + $ENV{CPLUS_INCLUDE_PATH} = "$iosSdkRoot/usr/include"; + + $ENV{CC} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch $iphoneArch"; + $ENV{CXX} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch $iphoneArch"; + $ENV{LD} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"; + + $ENV{CFLAGS} = "$iosCFlagsCommon -gdwarf-2 -DSMALL_CONFIG -DHAVE_LARGE_FILE_SUPPORT=1 -DHAVE_ARMV6=1 -DARM_FPU_VFP=1 -Wl,-application_extension -miphoneos-version-min=$iphoneOsMinVersion -mno-thumb -Os -isysroot $iosSdkRoot"; + + # Unity defines + $ENV{CFLAGS} = "-DPLATFORM_IPHONE $ENV{CFLAGS}"; + + $ENV{CXXFLAGS} = "$ENV{CFLAGS} -U__powerpc__ -U__i386__ -D__arm__"; + $ENV{CPPFLAGS} = $ENV{CXXFLAGS}; + + $ENV{LDFLAGS} = "-arch $iphoneArch -liconv -lobjc -lc++ -Wl,-syslibroot,$iosSdkRoot"; + + print "\n"; + print ">>> Environment:\n"; + print ">>> \tCC = $ENV{CC}\n"; + print ">>> \tCXX = $ENV{CXX}\n"; + print ">>> \tLD = $ENV{LD}\n"; + print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; + print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; + print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; + print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; + print ">>> \tCPLUS_INCLUDE_PATH = $ENV{CPLUS_INCLUDE_PATH}\n"; + print ">>> \tC_INCLUDE_PATH = $ENV{C_INCLUDE_PATH}\n"; + + push @configureparams, "--host=arm-apple-darwin$darwinVersion"; + + push @configureparams, "--with-sigaltstack=no"; + push @configureparams, "--disable-shared-handles"; + push @configureparams, "--with-monotouch"; + + push @configureparams, "--enable-llvm-runtime"; + push @configureparams, "--with-bitcode=yes"; + + push @configureparams, "--with-lazy-gc-thread-creation=yes"; + push @configureparams, "--enable-icall-export"; + push @configureparams, "--enable-dtrace=no"; + + push @configureparams, "--enable-minimal=$iosMinimalCommon,ssa,jit,reflection_emit_save,reflection_emit,portability,assembly_remapping,attach,verifier,full_messages,security,sgen_remset,sgen_marksweep_par,sgen_marksweep_fixed,sgen_marksweep_fixed_par,sgen_copying,logging"; + + push @configureparams, "mono_cv_uscore=yes"; + push @configureparams, "cv_mono_sizeof_sunpath=104"; + push @configureparams, "ac_cv_func_posix_getpwuid_r=yes"; + push @configureparams, "ac_cv_func_backtrace_symbols=no"; + push @configureparams, "ac_cv_func_finite=no"; + push @configureparams, "ac_cv_header_curses_h=no"; + } + elsif ($iphoneSimulator) + { + my $iosSdkVersion = "9.3"; + my $iosSimMinVersion = "4.3"; + my $iosSdkRoot = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$iosSdkVersion.sdk"; + + print(">>> iOS Sim Build Environment = $iosBuildEnvDir\n"); + print(">>> iOS Sim SDK Version = $iosSdkVersion\n"); + print(">>> iOS Sim SDK Root = $iosSdkRoot\n"); + print(">>> iOS Sim Arch = $iphoneSimulatorArch\n"); + + $ENV{PATH} = "$iosSdkRoot/usr/bin:$ENV{PATH}"; + + $ENV{MACSDKOPTIONS} = "$iosCFlagsCommon -D_XOPEN_SOURCE=1 -g -O0 -DTARGET_IPHONE_SIMULATOR -mios-simulator-version-min=$iosSimMinVersion -isysroot $iosSdkRoot"; + $ENV{CFLAGS} = "-arch $iphoneSimulatorArch $ENV{MACSDKOPTIONS}"; + $ENV{CXXFLAGS} = "$ENV{CFLAGS}"; + $ENV{CPPFLAGS} = "$ENV{CFLAGS}"; + $ENV{CC} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/usr/bin/gcc"; + $ENV{CXX} = "$iosBuildEnvDir/builds/Xcode.app/Contents/Developer/usr/bin/g++"; + + print "\n"; + print ">>> Environment:\n"; + print ">>> \tCC = $ENV{CC}\n"; + print ">>> \tCXX = $ENV{CXX}\n"; + print ">>> \tLD = $ENV{LD}\n"; + print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; + print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; + print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; + print ">>> \tMACSDKOPTIONS = $ENV{MACSDKOPTIONS}\n"; + + push @configureparams, "--host=$iphoneSimulatorArch-apple-darwin$darwinVersion"; + push @configureparams, "--enable-minimal=$iosMinimalCommon"; + + push @configureparams, "mono_cv_uscore=yes"; + push @configureparams, "ac_cv_func_clock_nanosleep=no"; + } + else + { + die("This should not be hit\n"); + } + } + elsif ($iphoneCross) + { + if ($runningOnWindows) + { + die("Not implemented\n"); + } + else + { + $ENV{CFLAGS} = "-DMONOTOUCH -DARM_FPU_VFP=1 -DUSE_MUNMAP -DPLATFORM_IPHONE_XCOMP -mmacosx-version-min=$macversion"; + $ENV{CXXFLAGS} = "-mmacosx-version-min=$macversion -stdlib=libc++"; + $ENV{CPPFLAGS} = "$ENV{CFLAGS} -mmacosx-version-min=$macversion"; + + $ENV{CC} = "$macSdkPath/../usr/bin/clang -arch i386"; + $ENV{CXX} = "$macSdkPath/../usr/bin/clang++ -arch i386"; + $ENV{CPP} = "$ENV{CC} -E"; + $ENV{LD} = $ENV{CC}; + $ENV{LDFLAGS} = "-stdlib=libc++"; + $ENV{MACSDKOPTIONS} = "-mmacosx-version-min=$macversion -isysroot $macSdkPath"; + + print "\n"; + print ">>> Environment:\n"; + print ">>> \tCC = $ENV{CC}\n"; + print ">>> \tCXX = $ENV{CXX}\n"; + print ">>> \tLD = $ENV{LD}\n"; + print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; + print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; + print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; + print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; + print ">>> \tMACSDKOPTIONS = $ENV{MACSDKOPTIONS}\n"; + + push @configureparams, "--cache-file=iphone-cross.cache" if ($enableCacheFile); + + push @configureparams, "--with-sigaltstack=no"; + push @configureparams, "--disable-shared-handles"; + push @configureparams, "--with-tls=pthread"; + + push @configureparams, "--target=arm-darwin"; + push @configureparams, "--with-macversion=$macversion"; + push @configureparams, "--with-cross-offsets=$iphoneCrossAbi.h"; + + push @configureparams, "--build=i386-apple-darwin10"; + push @configureparams, "--disable-libraries"; + push @configureparams, "--enable-icall-symbol-map"; + push @configureparams, "--enable-minimal=com,remoting"; + + #push @configureparams, "--enable-llvm"; + #push @configureparams, "--with-llvm=llvm/usr"; + + my @mcsArgs = (); + push @mcsArgs, "$monoroot/tools/offsets-tool/MonoAotOffsetsDumper.cs"; + push @mcsArgs, "$monoroot/mcs/class/Mono.Options/Mono.Options/Options.cs"; + push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.AST.dll"; + push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.Generator.dll"; + push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.Parser.CSharp.dll"; + push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.Parser.dll"; + push @mcsArgs, "/r:$externalBuildDeps/CppSharpBinaries/CppSharp.dll"; + push @mcsArgs, "/debug"; + push @mcsArgs, "/nowarn:0436"; + push @mcsArgs, "/out:$monoroot/tools/offsets-tool/MonoAotOffsetsDumper.exe"; + + print ">>> Compiling MonoAotOffsetDumper : $iphoneCrossMonoBinToUse/mcs @mcsArgs\n"; + system("$iphoneCrossMonoBinToUse/mcs", @mcsArgs) eq 0 or die("failed to compile MonoAotOffsetsDumper\n"); + + # clean up any pre-existing offset header just in case + if (-f "$monoroot/$iphoneCrossAbi.h") + { + system("rm", "-rf", "$iphoneCrossAbi.h"); + } + } + } + elsif ($android) + { + if (!(-d $externalBuildDeps)) + { + die("mono build deps are required and the directory was not found : $externalBuildDeps\n"); + } + + my $ndkVersion = "r13b"; + my $isArmArch = 1; + my $toolchainName = ""; + my $platformRootPostfix = ""; + my $useKraitPatch = 1; + my $kraitPatchPath = "$monoroot/../../android_krait_signal_handler/build"; + my $toolChainExtension = ""; + + $isArmArch = 0 if ($androidArch eq "x86"); + + $ENV{ANDROID_PLATFORM} = "android-9"; + $ENV{GCC_VERSION} = "4.9"; + + if ($isArmArch) + { + $ENV{GCC_PREFIX} = "arm-linux-androideabi-"; + $toolchainName = "$ENV{GCC_PREFIX}$ENV{GCC_VERSION}"; + $platformRootPostfix = "arm"; + } + else + { + $ENV{GCC_PREFIX} = "i686-linux-android-"; + $toolchainName = "x86-$ENV{GCC_VERSION}"; + $platformRootPostfix = "x86"; + $useKraitPatch = 0; + } + + if ($^O eq "linux") + { + $ENV{HOST_ENV} = "linux"; + } + elsif ($^O eq 'darwin') + { + $ENV{HOST_ENV} = "darwin"; + } + else + { + $ENV{HOST_ENV} = "windows"; + } + + print "\n"; + print(">>> Android Platform = $ENV{ANDROID_PLATFORM}\n"); + print(">>> Android NDK Version = $ndkVersion\n"); + print(">>> Android GCC Prefix = $ENV{GCC_PREFIX}\n"); + print(">>> Android GCC Version = $ENV{GCC_VERSION}\n"); + + my $ndkName = ""; + if($^O eq "linux") + { + $ndkName = "android-ndk-$ndkVersion-linux-x86_64.zip"; + } + elsif($^O eq "darwin") + { + $ndkName = "android-ndk-$ndkVersion-darwin-x86_64.zip"; + } + else + { + $ndkName = "android-ndk-$ndkVersion-windows-x86.zip"; + } + + my $depsNdkArchive = "$externalBuildDeps/$ndkName"; + my $depsNdkFinal = "$externalBuildDeps/android-ndk-$ndkVersion"; + + print(">>> Android NDK Archive = $depsNdkArchive\n"); + print(">>> Android NDK Extraction Destination = $depsNdkFinal\n"); + print("\n"); + + $ENV{ANDROID_NDK_ROOT} = "$depsNdkFinal"; + + if (-d $depsNdkFinal) + { + print(">>> Android NDK already extracted\n"); + } + else + { + print(">>> Android NDK needs to be extracted\n"); + + if ($runningOnWindows) + { + my $sevenZip = "$externalBuildDeps/7z/win64/7za.exe"; + my $winDepsNdkArchive = `cygpath -w $depsNdkArchive`; + my $winDepsNdkExtract = `cygpath -w $externalBuildDeps`; + + # clean up trailing new lines that end up in the output from cygpath. If left, they cause problems down the line + # for 7zip + $winDepsNdkArchive =~ s/\n+$//; + $winDepsNdkExtract =~ s/\n+$//; + + system($sevenZip, "x", "$winDepsNdkArchive", "-o$winDepsNdkExtract"); + } + else + { + my ($name,$path,$suffix) = fileparse($depsNdkArchive, qr/\.[^.]*/); + + print(">>> Android NDK Extension = $suffix\n"); + + # Versions after r11 use .zip extension. Currently we use r10e, but let's support the .zip extension in case + # we upgrade down the road + if (lc $suffix eq '.zip') + { + system("unzip", "-q", $depsNdkArchive, "-d", $externalBuildDeps); + } + elsif (lc $suffix eq '.bin') + { chmod(0755, $depsNdkArchive); + system($depsNdkArchive, "-o$externalBuildDeps"); + } + else + { + die "Unknown file extension '" . $suffix . "'\n"; + } + } + } + + if (!(-f "$ENV{ANDROID_NDK_ROOT}/ndk-build")) + { + die("Something went wrong with the NDK extraction\n"); + } + + my $androidNdkRoot = $ENV{ANDROID_NDK_ROOT}; + my $androidPlatformRoot = "$androidNdkRoot/platforms/$ENV{ANDROID_PLATFORM}/arch-$platformRootPostfix"; + my $androidToolchain = "$androidNdkRoot/toolchains/$toolchainName/prebuilt/$ENV{HOST_ENV}"; + + if (!(-d "$androidToolchain")) + { + if (-d "$androidToolchain-x86") + { + $androidToolchain = "$androidToolchain-x86"; + } + else + { + $androidToolchain = "$androidToolchain-x86_64"; + } + } + + if ($runningOnWindows) + { + $toolChainExtension = ".exe"; + + $androidPlatformRoot = `cygpath -w $androidPlatformRoot`; + # clean up trailing new lines that end up in the output from cygpath. + $androidPlatformRoot =~ s/\n+$//; + # Switch over to forward slashes. They propagate down the toolchain correctly + $androidPlatformRoot =~ s/\\/\//g; + + # this will get passed as a path to the linker, so we need to windows-ify the path + $kraitPatchPath = `cygpath -w $kraitPatchPath`; + $kraitPatchPath =~ s/\n+$//; + $kraitPatchPath =~ s/\\/\//g; + } + + print(">>> Android Arch = $androidArch\n"); + print(">>> Android NDK Root = $androidNdkRoot\n"); + print(">>> Android Platform Root = $androidPlatformRoot\n"); + print(">>> Android Toolchain = $androidToolchain\n"); + + if (!(-d "$androidToolchain")) + { + die("Failed to locate android toolchain\n"); + } + + if (!(-d "$androidPlatformRoot")) + { + die("Failed to locate android platform root\n"); + } + + if ("$androidArch" eq 'armv5') + { + $ENV{CFLAGS} = "-DARM_FPU_NONE=1 -march=armv5te -mtune=xscale -msoft-float"; + } + elsif ("$androidArch" eq 'armv6_vfp') + { + $ENV{CFLAGS} = "-DARM_FPU_VFP=1 -march=armv6 -mtune=xscale -msoft-float -mfloat-abi=softfp -mfpu=vfp -DHAVE_ARMV6=1"; + } + elsif ("$androidArch" eq 'armv7a') + { + $ENV{CFLAGS} = "-DARM_FPU_VFP=1 -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -DHAVE_ARMV6=1"; + $ENV{LDFLAGS} = "-Wl,--fix-cortex-a8"; + } + elsif ("$androidArch" eq 'x86') + { + $ENV{LDFLAGS} = "-lgcc" + } + else + { + die("Unsupported android arch : $androidArch\n"); + } + + if ($isArmArch) + { + $ENV{CFLAGS} = "-funwind-tables $ENV{CFLAGS}"; + $ENV{LDFLAGS} = "-Wl,-rpath-link=$androidPlatformRoot/usr/lib $ENV{LDFLAGS}"; + } + + $ENV{PATH} = "$androidToolchain/bin:$ENV{PATH}"; + $ENV{CC} = "$androidToolchain/bin/$ENV{GCC_PREFIX}gcc$toolChainExtension --sysroot=$androidPlatformRoot"; + $ENV{CXX} = "$androidToolchain/bin/$ENV{GCC_PREFIX}g++$toolChainExtension --sysroot=$androidPlatformRoot"; + $ENV{CPP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}cpp$toolChainExtension"; + $ENV{CXXCPP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}cpp$toolChainExtension"; + $ENV{CPATH} = "$androidPlatformRoot/usr/include"; + $ENV{LD} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ld$toolChainExtension"; + $ENV{AS} = "$androidToolchain/bin/$ENV{GCC_PREFIX}as$toolChainExtension"; + $ENV{AR} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ar$toolChainExtension"; + $ENV{RANLIB} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ranlib$toolChainExtension"; + $ENV{STRIP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}strip$toolChainExtension"; + + $ENV{CFLAGS} = "-DANDROID -DPLATFORM_ANDROID -DLINUX -D__linux__ -DHAVE_USR_INCLUDE_MALLOC_H -DPAGE_SIZE=0x1000 -D_POSIX_PATH_MAX=256 -DS_IWRITE=S_IWUSR -DHAVE_PTHREAD_MUTEX_TIMEDLOCK -fpic -g -ffunction-sections -fdata-sections $ENV{CFLAGS}"; + $ENV{CXXFLAGS} = $ENV{CFLAGS}; + $ENV{CPPFLAGS} = $ENV{CFLAGS}; + + if ($useKraitPatch) + { + $ENV{LDFLAGS} = "-Wl,--wrap,sigaction -L$kraitPatchPath/obj/local/armeabi -lkrait-signal-handler $ENV{LDFLAGS}"; + } + + $ENV{LDFLAGS} = "-Wl,--no-undefined -Wl,--gc-sections -ldl -lm -llog -lc $ENV{LDFLAGS}"; + + print "\n"; + print ">>> Environment:\n"; + print ">>> \tCC = $ENV{CC}\n"; + print ">>> \tCXX = $ENV{CXX}\n"; + print ">>> \tCPP = $ENV{CPP}\n"; + print ">>> \tCXXCPP = $ENV{CXXCPP}\n"; + print ">>> \tCPATH = $ENV{CPATH}\n"; + print ">>> \tLD = $ENV{LD}\n"; + print ">>> \tAS = $ENV{AS}\n"; + print ">>> \tAR = $ENV{AR}\n"; + print ">>> \tRANLIB = $ENV{RANLIB}\n"; + print ">>> \tSTRIP = $ENV{STRIP}\n"; + print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; + print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; + print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; + print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; + + if ($useKraitPatch) + { + my $kraitPatchRepo = "git://github.com/Unity-Technologies/krait-signal-handler.git"; + if (-d "$kraitPatchPath") + { + print ">>> Krait patch repository already cloned\n"; + } + else + { + system("git", "clone", "--branch", "master", "$kraitPatchRepo", "$kraitPatchPath") eq 0 or die ('failing cloning Krait patch'); + } + + chdir("$kraitPatchPath") eq 1 or die ("failed to chdir to krait patch directory\n"); + system('$ANDROID_NDK_ROOT/ndk-build clean') eq 0 or die ('failing to clean Krait patch'); + system('$ANDROID_NDK_ROOT/ndk-build') eq 0 or die ('failing to build Krait patch'); + chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); + } + + if ($isArmArch) + { + push @configureparams, "--host=armv5-linux-androideabi"; + } + elsif ("$androidArch" eq 'x86') + { + push @configureparams, "--host=i686-linux-android"; + } + else + { + die("Unsupported android arch : $androidArch\n"); + } + + push @configureparams, "--cache-file=android-$androidArch.cache" if ($enableCacheFile); + + push @configureparams, "--disable-parallel-mark"; + push @configureparams, "--disable-shared-handles"; + push @configureparams, "--with-sigaltstack=no"; + push @configureparams, "--with-tls=pthread"; + push @configureparams, "--disable-visibility-hidden"; + push @configureparams, "mono_cv_uscore=yes"; + push @configureparams, "ac_cv_header_zlib_h=no" if($runningOnWindows); + } + elsif ($tizen) + { + if (!(-d $externalBuildDeps)) + { + die("mono build deps are required and the directory was not found : $externalBuildDeps\n"); + } + + my $sdkVersion = "2.4.0r1"; + my $isArmArch = 1; + + $isArmArch = 0 if ($tizenEmulator); + + $ENV{TIZEN_PLATFORM} = "tizen-2.4"; + + if ($tizenEmulator) + { + $ENV{TIZEN_ROOTSTRAP} = "mobile-2.4-emulator.core"; + } + else + { + $ENV{TIZEN_ROOTSTRAP} = "mobile-2.4-device.core"; + } + + if ($^O eq "linux") + { + $ENV{HOST_ENV} = "linux"; + } + elsif ($^O eq 'darwin') + { + $ENV{HOST_ENV} = "darwin"; + } + else + { + $ENV{HOST_ENV} = "windows"; + } + + print "\n"; + print(">>> Tizen Platform = $ENV{TIZEN_PLATFORM}\n"); + print(">>> Tizen SDK Version = $sdkVersion\n"); + + my $sdkName = "tizen-$sdkVersion-$ENV{HOST_ENV}.tar.bz2"; + my $depsSdkArchive = "$externalBuildDeps/$sdkName"; + my $depsSdkFinal = "$externalBuildDeps/tizen-$sdkVersion-$ENV{HOST_ENV}"; + + print(">>> Tizen SDK Archive = $depsSdkArchive\n"); + print(">>> Tizen SDK Extraction Destination = $depsSdkFinal\n"); + print("\n"); + + $ENV{TIZEN_SDK_ROOT} = "$depsSdkFinal"; + + if (-d $depsSdkFinal) + { + print(">>> Tizen SDK already extracted\n"); + } + else + { + print(">>> Tizen SDK needs to be extracted\n"); + + if ($runningOnWindows) + { + my $sevenZip = "$externalBuildDeps/7z/win64/7za.exe"; + my $winDepsSdkArchive = `cygpath -w $depsSdkArchive`; + my $winDepsSdkExtract = `cygpath -w $externalBuildDeps`; + + # clean up trailing new lines that end up in the output from cygpath. If left, they cause problems down the line + # for 7zip + $winDepsSdkArchive =~ s/\n+$//; + $winDepsSdkExtract =~ s/\n+$//; + + system($sevenZip, "x", "$winDepsSdkArchive", "-o$winDepsSdkExtract"); + } + else + { + my ($name,$path,$suffix) = fileparse($depsSdkArchive, qr/\.[^.]*/); + + print(">>> Tizen SDK Extension = $suffix\n"); + + if (lc $suffix eq '.bz2') + { chmod(0755, $depsSdkArchive); + system("tar xjf $depsSdkArchive -C $externalBuildDeps") eq 0 or die ("failed to extract Tizen SDK\n"); + } + else + { + die "Unknown file extension '" . $suffix . "'\n"; + } + } + } + + if (!(-f "$ENV{TIZEN_SDK_ROOT}/tools/sdb")) + { + die("Something went wrong with the SDK extraction\n"); + } + + my $tizenSdkRoot = $ENV{TIZEN_SDK_ROOT}; + my $tizenPlatformRoot = "$tizenSdkRoot/platforms/$ENV{TIZEN_PLATFORM}/mobile/rootstraps/$ENV{TIZEN_ROOTSTRAP}"; + my $tizenToolchain = "$tizenSdkRoot/tools/llvm-3.6/bin"; + + if ($runningOnWindows) + { + $toolChainExtension = ".exe"; + + $tizenPlatformRoot = `cygpath -w $tizenPlatformRoot`; + # clean up trailing new lines that end up in the output from cygpath. + $tizenPlatformRoot =~ s/\n+$//; + # Switch over to forward slashes. They propagate down the toolchain correctly + $tizenPlatformRoot =~ s/\\/\//g; + } + + if ($tizenEmulator) + { + $tizenToolchain = "$tizenSdkRoot/tools/i386-linux-gnueabi-gcc-4.9/bin/i386"; + $ENV{CFLAGS} = "-Os -g -march=i686 -msse2 -mfpmath=sse"; + } + else + { + $tizenToolchain = "$tizenSdkRoot/tools/arm-linux-gnueabi-gcc-4.9/bin/arm"; + $ENV{CFLAGS} = "-Os -g -march=armv7-a -mfpu=vfp -mfloat-abi=softfp -DARM_FPU_VFP=1 -DHAVE_ARMV6=1"; + $ENV{LDFLAGS} = "-Wl,-rpath-link=$tizenPlatformRoot/usr/lib -L$tizenPlatformRoot/usr/lib $ENV{LDFLAGS}"; + } + + print(">>> Tizen SDK Root = $tizenSdkRoot\n"); + print(">>> Tizen Platform Root = $tizenPlatformRoot\n"); + print(">>> Tizen Toolchain Prefix = $tizenToolchain\n"); + + if (!(-d "$tizenPlatformRoot")) + { + die("Failed to locate Tizen platform root\n"); + } + + $ENV{PATH} = "$tizenToolchain/bin:$ENV{PATH}"; + $ENV{CC} = "$tizenToolchain-linux-gnueabi-gcc --sysroot=$tizenPlatformRoot"; + $ENV{CXX} = "$tizenToolchain-linux-gnueabi-g++ --sysroot=$tizenPlatformRoot"; + $ENV{CPP} = "$tizenToolchain-linux-gnueabi-cpp"; + $ENV{CXXCPP} = "$tizenToolchain-linux-gnueabi-cpp"; + $ENV{CPATH} = "$tizenPlatformRoot/usr/include"; + $ENV{LD} = "$tizenToolchain-linux-gnueabi-ld --sysroot=$tizenPlatformRoot"; + $ENV{AS} = "$tizenToolchain-linux-gnueabi-as"; + $ENV{STRIP} = "$tizenToolchain-linux-gnueabi-strip"; + + if ($tizenEmulator) + { + $ENV{AR} = "$ENV{TIZEN_SDK_ROOT}/tools/i386-linux-gnueabi-gcc-4.9/bin/i386-linux-gnueabi-ar"; + $ENV{RANLIB} = "$ENV{TIZEN_SDK_ROOT}/tools/i386-linux-gnueabi-gcc-4.9/bin/i386-linux-gnueabi-ranlib"; + } + else + { + $ENV{AR} = "$ENV{TIZEN_SDK_ROOT}/tools/arm-linux-gnueabi-gcc-4.9/bin/arm-linux-gnueabi-ar"; + $ENV{RANLIB} = "$ENV{TIZEN_SDK_ROOT}/tools/arm-linux-gnueabi-gcc-4.9/bin/arm-linux-gnueabi-ranlib"; + } + + $ENV{CFLAGS} = "-DTIZEN -DLINUX -D__linux__ -DHAVE_USR_INCLUDE_MALLOC_H -DPAGE_SIZE=0x1000 -D_POSIX_PATH_MAX=256 -DS_IWRITE=S_IWUSR -DHAVE_PTHREAD_MUTEX_TIMEDLOCK -fpic -g -ffunction-sections -fdata-sections $ENV{CFLAGS}"; + $ENV{CXXFLAGS} = $ENV{CFLAGS}; + $ENV{CPPFLAGS} = $ENV{CFLAGS}; + $ENV{LDFLAGS} = "-Wl,--no-undefined -ldlog -shared -Xlinker --as-needed $ENV{LDFLAGS}"; + + print "\n"; + print ">>> Environment:\n"; + print ">>> \tCC = $ENV{CC}\n"; + print ">>> \tCXX = $ENV{CXX}\n"; + print ">>> \tCPP = $ENV{CPP}\n"; + print ">>> \tCXXCPP = $ENV{CXXCPP}\n"; + print ">>> \tCPATH = $ENV{CPATH}\n"; + print ">>> \tLD = $ENV{LD}\n"; + print ">>> \tAS = $ENV{AS}\n"; + print ">>> \tAR = $ENV{AR}\n"; + print ">>> \tRANLIB = $ENV{RANLIB}\n"; + print ">>> \tSTRIP = $ENV{STRIP}\n"; + print ">>> \tCFLAGS = $ENV{CFLAGS}\n"; + print ">>> \tCXXFLAGS = $ENV{CXXFLAGS}\n"; + print ">>> \tCPPFLAGS = $ENV{CPPFLAGS}\n"; + print ">>> \tLDFLAGS = $ENV{LDFLAGS}\n"; + + if ($tizenEmulator) + { + push @configureparams, "--host=i386-tizen-linux-gnueabi"; + } + else + { + push @configureparams, "--host=arm-tizen-linux-gnueabi"; + } + + push @configureparams, "--cache-file=tizen-cross.cache" if ($enableCacheFile); + push @configureparams, "--disable-parallel-mark"; + push @configureparams, "--disable-shared-handles"; + push @configureparams, "--with-sigaltstack=no"; + push @configureparams, "--with-tls=pthread"; + push @configureparams, "--disable-visibility-hidden"; + push @configureparams, "--disable-executables"; + push @configureparams, "--with-gnu-ld=yes"; + push @configureparams, "mono_cv_uscore=yes"; + push @configureparams, "ac_cv_header_zlib_h=no" if($runningOnWindows); + } + elsif($^O eq "linux") + { + if (!(-d $externalBuildDeps)) + { + die("mono build deps are required and the directory was not found : $externalBuildDeps\n"); + } + + if($ENV{UNITY_THISISABUILDMACHINE} || $ENV{UNITY_USE_LINUX_SDK}) + { + my $sdkVersion = '20170609'; + my $schroot = "LinuxBuildEnvironment-$sdkVersion"; + my @linuxToolchain = ('schroot', '-c', $schroot, '--'); + + print "\n"; + print(">>> Linux SDK Version = $sdkVersion\n"); + + my $sdkName = "linux-sdk-$sdkVersion.tar.bz2"; + my $depsSdkArchive = "$externalBuildDeps/$sdkName"; + my $depsSdkFinal = "$externalBuildDeps/linux-sdk-$sdkVersion"; + + print(">>> Linux SDK Archive = $depsSdkArchive\n"); + print(">>> Linux SDK Extraction Destination = $depsSdkFinal\n"); + print("\n"); + + my $linuxSdkRoot = $depsSdkFinal; + + if (-d $depsSdkFinal) + { + print(">>> Linux SDK already extracted\n"); + } + else + { + print(">>> Linux SDK needs to be extracted\n"); + system('mkdir', '-p', $depsSdkFinal); + system('tar', 'xaf', $depsSdkArchive, '-C', $depsSdkFinal) eq 0 or die ("failed to extract Linux SDK\n"); + system('sudo', 'cp', '-R', "$depsSdkFinal/linux-sdk-$sdkVersion", '/etc/schroot'); + system("sed 's,^directory=.*,directory=$depsSdkFinal/$schroot,' \"$depsSdkFinal/$schroot.conf\" | sudo tee /etc/schroot/chroot.d/$schroot.conf") eq 0 or die ("failed to deploy Linux SDK\n"); + } + + @commandPrefix = @linuxToolchain; + print(">>> Linux SDK Root = $linuxSdkRoot\n"); + print(">>> Linux Toolchain Command Prefix = " . join(' ', @commandPrefix) . "\n"); + } + + push @configureparams, "--host=$monoHostArch-pc-linux-gnu"; + + push @configureparams, "--disable-parallel-mark"; #this causes crashes + + my $archflags = ''; + if ($arch32) + { + $archflags = '-m32'; + } + else + { + $archflags = '-fPIC'; + } + + if ($debug) + { + $ENV{CFLAGS} = "$archflags -g -O0"; + } + else + { + $ENV{CFLAGS} = "$archflags -Os"; #optimize for size + } + } + elsif($^O eq 'darwin') + { + # Set up mono for bootstrapping + if ($existingMonoRootPath eq "") + { + # Find the latest mono version and use that for boostrapping + my $monoInstalls = '/Library/Frameworks/Mono.framework/Versions'; + my @monoVersions = (); + + opendir( my $DIR, $monoInstalls ); + while ( my $entry = readdir $DIR ) + { + next unless -d $monoInstalls . '/' . $entry; + next if $entry eq '.' or $entry eq '..' or $entry eq 'Current'; + push @monoVersions, $entry; + } + closedir $DIR; + @monoVersions = sort @monoVersions; + my $monoVersionToUse = pop @monoVersions; + $existingMonoRootPath = "$monoInstalls/$monoVersionToUse"; + } + + $mcs = "EXTERNAL_MCS=$existingMonoRootPath/bin/mcs"; + + $ENV{'CC'} = "$macSdkPath/../usr/bin/clang"; + $ENV{'CXX'} = "$macSdkPath/../usr/bin/clang++"; + $ENV{'CFLAGS'} = $ENV{MACSDKOPTIONS} = "-D_XOPEN_SOURCE -I$macBuildEnvDir/builds/usr/include -mmacosx-version-min=$macversion -isysroot $macSdkPath"; + + $ENV{CFLAGS} = "$ENV{CFLAGS} -g -O0" if $debug; + $ENV{CFLAGS} = "$ENV{CFLAGS} -Os" if not $debug; #optimize for size + + $ENV{CC} = "$ENV{CC} -arch $monoHostArch"; + $ENV{CXX} = "$ENV{CXX} -arch $monoHostArch"; + + # Add OSX specific autogen args + push @configureparams, "--host=$monoHostArch-apple-darwin12.2.0"; + + # Need to define because Apple's SIP gets in the way of us telling mono where to find this + push @configureparams, "--with-libgdiplus=$addtoresultsdistdir/lib/libgdiplus.dylib"; + push @configureparams, "--enable-minimal=shared_perfcounters"; + + print "\n"; + print ">>> Setting environment:\n"; + print ">>> PATH = ".$ENV{PATH}."\n"; + print ">>> C_INCLUDE_PATH = ".$ENV{C_INCLUDE_PATH}."\n"; + print ">>> CPLUS_INCLUDE_PATH = ".$ENV{CPLUS_INCLUDE_PATH}."\n"; + print ">>> CFLAGS = ".$ENV{CFLAGS}."\n"; + print ">>> CXXFLAGS = ".$ENV{CXXFLAGS}."\n"; + print ">>> CC = ".$ENV{CC}."\n"; + print ">>> CXX = ".$ENV{CXX}."\n"; + print ">>> CPP = ".$ENV{CPP}."\n"; + print ">>> CXXPP = ".$ENV{CXXPP}."\n"; + print ">>> LD = ".$ENV{LD}."\n"; + print ">>> LDFLAGS = ".$ENV{LDFLAGS}."\n"; + print "\n"; + } + else + { + push @configureparams, "--host=$monoHostArch-pc-mingw32"; + } + + if ($isDesktopBuild) + { + my $cacheArch = $arch32 ? "i386" : "x86_64"; + push @configureparams, "--cache-file=desktop-$cacheArch.cache" if ($enableCacheFile); + } + + print ">>> Existing Mono : $existingMonoRootPath\n\n"; + $ENV{'PATH'} = "$existingMonoRootPath/$existingExternalMonoBinDir:$ENV{'PATH'}"; + + print ">>> PATH before Build = $ENV{PATH}\n\n"; + + print(">>> mcs Information : \n"); + system(@commandPrefix, ("which", "mcs")); + system(@commandPrefix, ("mcs", "--version")); + print("\n"); + + print ">>> Checking on some tools...\n"; + system(@commandPrefix, ("which", "autoconf")); + system(@commandPrefix, ("autoconf", "--version")); + + system(@commandPrefix, ("which", "texi2dvi")); + system(@commandPrefix, ("texi2dvi", "--version")); + + system(@commandPrefix, ("which", "automake")); + system(@commandPrefix, ("automake", "--version")); + + system(@commandPrefix, ("which", "libtool")); + system(@commandPrefix, ("libtool", "--version")); + + system(@commandPrefix, ("which", "libtoolize")); + system(@commandPrefix, ("libtoolize", "--version")); + print("\n"); + + print ">>> LIBTOOLIZE before Build = $ENV{LIBTOOLIZE}\n"; + print ">>> LIBTOOL before Build = $ENV{LIBTOOL}\n"; + + chdir("$monoroot") eq 1 or die ("failed to chdir 2\n"); + + if (not $skipMonoMake) + { + if ($clean) + { + if (!($mcsOnly)) + { + print(">>> Cleaning $monoprefix\n"); + rmtree($monoprefix); + } + + # Avoid "source directory already configured" ... + system(@commandPrefix, ('rm', '-f', 'config.status', 'eglib/config.status', 'libgc/config.status')); + + print("\n>>> Calling autogen in mono\n"); + print("\n"); + print("\n>>> Configure parameters are : @configureparams\n"); + print("\n"); + + system(@commandPrefix, ('./autogen.sh', @configureparams)) eq 0 or die ('failing autogenning mono'); + + if ($mcsOnly) + { + print("\n>>> Calling make clean in mcs\n"); + chdir("$monoroot/mcs"); + system(@commandPrefix, ("make","clean")) eq 0 or die ("failed to make clean\n"); + chdir("$monoroot"); + } + else + { + print("\n>>> Calling make clean in mono\n"); + system(@commandPrefix, ("make","clean")) eq 0 or die ("failed to make clean\n"); + } + } + + # this step needs to run after configure + if ($iphoneCross || $iphone || $android || $tizen) + { + # This step generates the arm_dpimacros.h file, which is needed by the offset dumper + chdir("$monoroot/mono/arch/arm"); + system("make") eq 0 or die("failed to make in $monoroot/mono/arch/arm\n"); + chdir("$monoroot"); + } + + if ($iphoneCross) + { + my @monoArgs = (); + push @monoArgs, "$monoroot/tools/offsets-tool/MonoAotOffsetsDumper.exe"; + push @monoArgs, "--abi"; + push @monoArgs, "$iphoneCrossAbi"; + push @monoArgs, "--out"; + push @monoArgs, "$monoroot"; + push @monoArgs, "--mono"; + push @monoArgs, "$monoroot"; + push @monoArgs, "--maccore"; + push @monoArgs, "$monoroot"; + + $ENV{MONO_PATH} = "$externalBuildDeps/CppSharpBinaries"; + # Need to use 32bit mono because there is a native CppSharp dylib that will be used and there's only a 32bit version of it + print ">>> Running MonoAotOffsetDumper : arch -i386 $iphoneCrossMonoBinToUse/mono @monoArgs\n"; + system("arch", "-i386", "$iphoneCrossMonoBinToUse/mono", @monoArgs) eq 0 or die("failed to run MonoAotOffsetsDumper\n"); + } + + if ($mcsOnly) + { + print("\n>>> Calling make in mcs\n"); + chdir("$monoroot/mcs"); + my @makeCommand = (@commandPrefix, ('make', "-j$jobs")); + if($mcs ne '') + { + push(@makeCommand, $mcs); + } + system(@makeCommand) eq 0 or die ("Failed to make\n"); + chdir("$monoroot"); + } + else + { + print("\n>>> Calling make\n"); + my @makeCommand = (@commandPrefix, ('make', "-j$jobs")); + if($mcs ne '') + { + push(@makeCommand, $mcs); + } + system(@makeCommand) eq 0 or die ("Failed to make\n"); + } + + if ($isDesktopBuild) + { + print("\n>>> Calling make install\n"); + system(@commandPrefix, ('make', 'install')) eq 0 or die ("Failed to make install\n"); + } + else + { + if ($disableMcs) + { + print(">>> Skipping make install. We don't need to run this step when building the runtime on non-desktop platforms.\n"); + } + else + { + # Note by Mike : make install on Windows for android runtime runs into more cygwin path issues. The one I hit was related to ranlib.exe being passed cygwin linux paths + # and as a result not being able to find stuff. The previous build scripts didn't run make install for android or iOS, so I think we are fine to skip this step. + # However, if we were to build the class libs for these cases, then we probably would need to run make install. If that day comes, we'll have to figure out what to do here. + print(">>> Attempting to build class libs for a non-desktop platform. The `make install` step is probably needed, but it has cygwin path related problems on Windows for android\n"); + die("Blocking this code path until we need it. It probably should be looked at more closely before letting it proceed\n"); + } + } + } + + if ($isDesktopBuild) + { + if ($^O eq "cygwin") + { + system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--msbuildversion=$msBuildVersion", "--clean=$clean", "--debug=$debug") eq 0 or die ('failed building mono with VS\n'); + + # Copy over the VS built stuff that we want to use instead into the prefix directory + my $archNameForBuild = $arch32 ? 'Win32' : 'x64'; + my $config = $debug ? "Debug" : "Release"; + system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono.exe $monoprefix/bin/.") eq 0 or die ("failed copying mono.exe\n"); + system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono-2.0.dll $monoprefix/bin/.") eq 0 or die ("failed copying mono-2.0.dll\n"); + system("cp $monoroot/msvc/$archNameForBuild/bin/$config/mono-2.0.pdb $monoprefix/bin/.") eq 0 or die ("failed copying mono-2.0.pdb\n"); + } + + system("cp -R $addtoresultsdistdir/bin/. $monoprefix/bin/") eq 0 or die ("Failed copying $addtoresultsdistdir/bin to $monoprefix/bin\n"); + } + + if(!($disableMcs)) + { + my @additionalProfiles = (); + push @additionalProfiles, "unityjit"; + push @additionalProfiles, "unityaot"; + + chdir("$monoroot/mcs"); + foreach my $profileName(@additionalProfiles) + { + print(">>> Making profile : $profileName\n"); + system("make", "PROFILE=$profileName") eq 0 or die ("Failed to make $profileName profile in mcs\n"); + + my $profileDestDir = "$monoprefix/lib/mono/$profileName"; + print(">>> Copying $profileName to $profileDestDir directory\n"); + + print(">>> Cleaning $profileDestDir\n"); + system("rm -rf $profileDestDir"); + + system("mkdir -p $profileDestDir") eq 0 or die("failed to make directory $profileDestDir\n"); + system("mkdir -p $profileDestDir/Facades") eq 0 or die("failed to make directory $profileDestDir/Facades\n"); + + system("cp $monoroot/mcs/class/lib/$profileName/*.dll $profileDestDir") eq 0 or die("Failed copying dlls from $monoroot/mcs/class/lib/$profileName to $profileDestDir\n"); + system("cp $monoroot/mcs/class/lib/$profileName/Facades/*.dll $profileDestDir/Facades") eq 0 or die("Failed copying dlls from $monoroot/mcs/class/lib/$profileName/Facades to $profileDestDir/Facades\n"); + } + + chdir("$monoroot"); + + my $stubResult = system("perl", "$buildscriptsdir/stub_classlibs.pl"); + + if ($stubResult ne 0) + { + die("Failed to run the profile stubber\n"); + } + } +} +else +{ + print(">>> Skipping build\n"); +} + +if ($buildUsAndBoo) +{ + print(">>> Building Unity Script and Boo...\n"); + if($windowsSubsystemForLinux) + { + #boo scripts expect a bin-platform folder, but we haven't built them that way + system("ln -s $monoprefix/bin $monoprefix/bin-linux64"); + system("ln -s $monoprefix/bin $monoprefix/bin-linux32"); + } + + system(@commandPrefix, ("perl", "$buildscriptsdir/build_us_and_boo.pl", "--monoprefix=$monoprefix")) eq 0 or die ("Failed building Unity Script and Boo\n"); + + print(">>> Copying Unity Script and Boo *.Lang.dll's from 4.5 profile to unityjit profile...\n"); + system("cp $monoprefix/lib/mono/4.5/Boo*.dll $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying Boo*.dll\n"); + system("cp $monoprefix/lib/mono/4.5/UnityScript*.dll $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying UnityScript*.dll\n"); + system("cp $monoprefix/lib/mono/4.5/booc.exe $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying booc.exe\n"); + system("cp $monoprefix/lib/mono/4.5/us.exe $monoprefix/lib/mono/unityjit/.") eq 0 or die("Failed copying us.exe\n"); +} +else +{ + print(">>> Skipping build Unity Script and Boo\n"); +} + +if ($artifact) +{ + print(">>> Creating artifact...\n"); + + if ($artifactsCommon) + { + print(">>> Creating common artifacts...\n"); + print(">>> distribution directory = $distdir\n"); + + if (!(-d "$distdir")) + { + system("mkdir -p $distdir") eq 0 or die("failed to make directory $distdir\n"); + } + + $File::Copy::Recursive::CopyLink = 0; #make sure we copy files as files and not as symlinks, as TC unfortunately doesn't pick up symlinks. + + my $distdirlibmono = "$distdir/lib/mono"; + + print(">>> Cleaning $distdir/lib\n"); + system("rm -rf $distdir/lib"); + system("mkdir -p $distdir/lib"); + + print(">>> Creating normal profile artifacts...\n"); + system("cp -R $addtoresultsdistdir/. $distdir/") eq 0 or die ("Failed copying $addtoresultsdistdir to $distdir\n"); + + system("cp -r $monoprefix/lib/mono $distdir/lib"); + + if($^O ne 'darwin') + { + # On OSX we build a universal binary for 32-bit and 64-bit in the mono executable. The class library build + # only creates the 64-bit slice, so we don't want to end up with a single slice binary in the output. + # If we do, it will step on the universal binary produced but the OSX runtime build. + system("cp -r $monoprefix/bin $distdir/") eq 0 or die ("failed copying bin folder\n"); + } + system("cp -r $monoprefix/etc $distdir/") eq 0 or die("failed copying etc folder\n"); + + system("cp -R $externalBuildDeps/reference-assemblies/unity $distdirlibmono/unity"); + system("cp -R $externalBuildDeps/reference-assemblies/unity_web $distdirlibmono/unity_web"); + + system("cp -R $externalBuildDeps/reference-assemblies/unity/Boo*.dll $distdirlibmono/2.0-api"); + system("cp -R $externalBuildDeps/reference-assemblies/unity/UnityScript*.dll $distdirlibmono/2.0-api"); + + system("cp -R $externalBuildDeps/reference-assemblies/unity/Boo*.dll $distdirlibmono/4.0-api"); + system("cp -R $externalBuildDeps/reference-assemblies/unity/UnityScript*.dll $distdirlibmono/4.0-api"); + + system("cp -R $externalBuildDeps/reference-assemblies/unity/Boo*.dll $distdirlibmono/4.5-api"); + system("cp -R $externalBuildDeps/reference-assemblies/unity/UnityScript*.dll $distdirlibmono/4.5-api"); + + # now remove nunit from a couple places (but not all, we need some of them) + # linux tar is not happy these are removed(at least on wsl), so don't remove them for now + if(not $windowsSubsystemForLinux) + { + system("rm -rf $distdirlibmono/2.0/nunit*"); + system("rm -rf $distdirlibmono/gac/nunit*"); + } + + # Remove a self referencing sym link that causes problems + system("rm -rf $monoprefix/bin/bin"); + + if (-f "$monoroot/ZippedClasslibs.tar.gz") + { + system("rm -f $monoroot/ZippedClasslibs.tar.gz") eq 0 or die("Failed to clean existing ZippedClasslibs.tar.gz\n"); + } + + print(">>> Creating ZippedClasslibs.tar.gz\n"); + print(">>> Changing directory to : $buildsroot\n"); + chdir("$buildsroot"); + system("tar -hpczf ../ZippedClasslibs.tar.gz *") eq 0 or die("Failed to zip up classlibs\n"); + print(">>> Changing directory back to : $currentdir\n"); + chdir("$currentdir"); + } + + # Do the platform specific logic to create the builds output structure that we want + + my $embedDirRoot = "$buildsroot/embedruntimes"; + my $embedDirArchDestination = ""; + my $distDirArchBin = ""; + my $versionsOutputFile = ""; + my $crossCompilerRoot = "$buildsroot/crosscompiler"; + my $crossCompilerDestination = ""; + + if ($iphone) + { + $embedDirArchDestination = "$embedDirRoot/iphone/$iphoneArch"; + $versionsOutputFile = "$buildsroot/versions-iphone-$iphoneArch.txt"; + } + elsif ($iphoneCross) + { + $crossCompilerDestination = "$buildsroot/crosscompiler/iphone"; + $versionsOutputFile = "$buildsroot/versions-iphone-xcompiler.txt"; + } + elsif ($iphoneSimulator) + { + $embedDirArchDestination = "$embedDirRoot/iphone/$iphoneSimulatorArch"; + $versionsOutputFile = "$buildsroot/versions-iphone-$iphoneSimulatorArch.txt"; + } + elsif ($android) + { + $embedDirArchDestination = "$embedDirRoot/android/$androidArch"; + $versionsOutputFile = "$buildsroot/versions-android-$androidArch.txt"; + } + elsif ($tizenEmulator) + { + $embedDirArchDestination = "$embedDirRoot/tizenemulator/"; + $versionsOutputFile = "$buildsroot/versions-tizenemulator.txt"; + } + elsif ($tizen) + { + $embedDirArchDestination = "$embedDirRoot/tizen/"; + $versionsOutputFile = "$buildsroot/versions-tizen.txt"; + } + elsif($^O eq "linux") + { + $embedDirArchDestination = $arch32 ? "$embedDirRoot/linux32" : "$embedDirRoot/linux64"; + $distDirArchBin = $arch32 ? "$distdir/bin-linux32" : "$distdir/bin-linux64"; + $versionsOutputFile = $arch32 ? "$buildsroot/versions-linux32.txt" : "$buildsroot/versions-linux64.txt"; + } + elsif($^O eq 'darwin') + { + # Note these tmp directories will get merged into a single 'osx' directory later by a parent script + $embedDirArchDestination = "$embedDirRoot/osx-tmp-$monoHostArch"; + $distDirArchBin = "$distdir/bin-osx-tmp-$monoHostArch"; + $versionsOutputFile = $arch32 ? "$buildsroot/versions-osx32.txt" : "$buildsroot/versions-osx64.txt"; + } + else + { + $embedDirArchDestination = $arch32 ? "$embedDirRoot/win32" : "$embedDirRoot/win64"; + $distDirArchBin = $arch32 ? "$distdir/bin" : "$distdir/bin-x64"; + $versionsOutputFile = $arch32 ? "$buildsroot/versions-win32.txt" : "$buildsroot/versions-win64.txt"; + } + + # Make sure the directory for our architecture is clean before we copy stuff into it + if (-d "$embedDirArchDestination") + { + print(">>> Cleaning $embedDirArchDestination\n"); + rmtree($embedDirArchDestination); + } + + if (-d "$distDirArchBin") + { + print(">>> Cleaning $distDirArchBin\n"); + rmtree($distDirArchBin); + } + + if ($artifactsRuntime) + { + system("mkdir -p $embedDirArchDestination") if ($embedDirArchDestination ne ""); + system("mkdir -p $distDirArchBin") if ($distDirArchBin ne ""); + system("mkdir -p $crossCompilerDestination") if ($crossCompilerDestination ne ""); + + # embedruntimes directory setup + print(">>> Creating embedruntimes directory : $embedDirArchDestination\n"); + if ($iphone || $iphoneSimulator) + { + for my $file ('libmonosgen-2.0.a','libmonobdwgc-2.0.a') + { + print ">>> Copying $file\n"; + system("cp", "$monoroot/mono/mini/.libs/$file","$embedDirArchDestination/$file") eq 0 or die ("failed copying $file\n"); + } + } + elsif ($iphoneCross) + { + # Nothing to do + } + elsif ($android) + { + for my $file ('libmonosgen-2.0.so','libmonobdwgc-2.0.so') + { + print ">>> Copying $file\n"; + system("cp", "$monoroot/mono/mini/.libs/$file","$embedDirArchDestination/$file") eq 0 or die ("failed copying $file\n"); + } + print ">>> Copying libMonoPosixHelper.so\n"; + system("cp", "$monoroot/support/.libs/libMonoPosixHelper.so","$embedDirArchDestination/libMonoPosixHelper.so") eq 0 or die ("failed copying libMonoPosixHelper.so\n"); + } + elsif ($tizen || $tizenEmulator) + { + for my $file ('libmonosgen-2.0.so','libmonobdwgc-2.0.so') + { + print ">>> Copying $file\n"; + system("cp", "$monoroot/mono/mini/.libs/$file","$embedDirArchDestination/$file") eq 0 or die ("failed copying $file\n"); + } + } + elsif($^O eq "linux") + { + print ">>> Copying libmonosgen-2.0\n"; + system("cp", "$monoroot/mono/mini/.libs/libmonobdwgc-2.0.so","$embedDirArchDestination/libmonobdwgc-2.0.so") eq 0 or die ("failed copying libmonobdwgc-2.0.so\n"); + system("cp", "$monoroot/mono/mini/.libs/libmonosgen-2.0.so","$embedDirArchDestination/libmonosgen-2.0.so") eq 0 or die ("failed copying libmonosgen-2.0.so\n"); + + print ">>> Copying libMonoPosixHelper.so\n"; + system("cp", "$monoroot/support/.libs/libMonoPosixHelper.so","$embedDirArchDestination/libMonoPosixHelper.so") eq 0 or die ("failed copying libMonoPosixHelper.so\n"); + + if ($buildMachine) + { + system("strip $embedDirArchDestination/libmonobdwgc-2.0.so") eq 0 or die("failed to strip libmonobdwgc-2.0.so (shared)\n"); + system("strip $embedDirArchDestination/libmonosgen-2.0.so") eq 0 or die("failed to strip libmonosgen-2.0.so (shared)\n"); + system("strip $embedDirArchDestination/libMonoPosixHelper.so") eq 0 or die("failed to strip libMonoPosixHelper (shared)\n"); + } + } + elsif($^O eq 'darwin') + { + # embedruntimes directory setup + print ">>> Hardlinking libmonosgen-2.0\n"; + + system("ln","-f", "$monoroot/mono/mini/.libs/libmonobdwgc-2.0.dylib","$embedDirArchDestination/libmonobdwgc-2.0.dylib") eq 0 or die ("failed symlinking libmonobdwgc-2.0.dylib\n"); + system("ln","-f", "$monoroot/mono/mini/.libs/libmonosgen-2.0.dylib","$embedDirArchDestination/libmonosgen-2.0.dylib") eq 0 or die ("failed symlinking libmonosgen-2.0.dylib\n"); + + print "Hardlinking libMonoPosixHelper.dylib\n"; + system("ln","-f", "$monoroot/support/.libs/libMonoPosixHelper.dylib","$embedDirArchDestination/libMonoPosixHelper.dylib") eq 0 or die ("failed symlinking $libtarget/libMonoPosixHelper.dylib\n"); + + InstallNameTool("$embedDirArchDestination/libmonobdwgc-2.0.dylib", "\@executable_path/../Frameworks/MonoEmbedRuntime/osx/libmonobdwgc-2.0.dylib"); + InstallNameTool("$embedDirArchDestination/libmonosgen-2.0.dylib", "\@executable_path/../Frameworks/MonoEmbedRuntime/osx/libmonosgen-2.0.dylib"); + InstallNameTool("$embedDirArchDestination/libMonoPosixHelper.dylib", "\@executable_path/../Frameworks/MonoEmbedRuntime/osx/libMonoPosixHelper.dylib"); + + print ">>> Copying mono public headers\n"; + system("mkdir -p $includesroot/mono"); + system("cp -R $monoprefix/include/mono-2.0/mono $includesroot/mono"); + } + else + { + # embedruntimes directory setup + system("cp", "$monoprefix/bin/mono-2.0-bdwgc.dll", "$embedDirArchDestination/mono-2.0-bdwgc.dll") eq 0 or die ("failed copying mono-2.0-bdwgc.dll\n"); + system("cp", "$monoprefix/bin/mono-2.0-bdwgc.pdb", "$embedDirArchDestination/mono-2.0-bdwgc.pdb") eq 0 or die ("failed copying mono-2.0-bdwgc.pdb\n"); + + system("cp", "$monoprefix/bin/mono-2.0-sgen.dll", "$embedDirArchDestination/mono-2.0-sgen.dll") eq 0 or die ("failed copying mono-2.0-sgen.dll\n"); + system("cp", "$monoprefix/bin/mono-2.0-sgen.pdb", "$embedDirArchDestination/mono-2.0-sgen.pdb") eq 0 or die ("failed copying mono-2.0-sgen.pdb\n"); + } + + # monodistribution directory setup + print(">>> Creating monodistribution directory\n"); + if ($android || $iphone || $iphoneCross || $iphoneSimulator || $tizen || $tizenEmulator) + { + # Nothing to do + } + elsif($^O eq "linux") + { + my $distDirArchEtc = $arch32 ? "$distdir/etc-linux32" : "$distdir/etc-linux64"; + + if (-d "$distDirArchEtc") + { + print(">>> Cleaning $distDirArchEtc\n"); + rmtree($distDirArchEtc); + } + + system("mkdir -p $distDirArchBin"); + system("mkdir -p $distDirArchEtc"); + system("mkdir -p $distDirArchEtc/mono"); + + system("ln", "-f", "$monoroot/mono/mini/mono-sgen","$distDirArchBin/mono") eq 0 or die("failed symlinking mono executable\n"); + system("ln", "-f", "$monoroot/tools/pedump/pedump","$distDirArchBin/pedump") eq 0 or die("failed symlinking pedump executable\n"); + system('cp', "$monoroot/data/config","$distDirArchEtc/mono/config") eq 0 or die("failed to copy config\n"); + } + elsif($^O eq 'darwin') + { + system("ln", "-f", "$monoroot/mono/mini/mono","$distDirArchBin/mono") eq 0 or die("failed hardlinking mono executable\n"); + system("ln", "-f", "$monoroot/tools/pedump/pedump","$distDirArchBin/pedump") eq 0 or die("failed hardlinking pedump executable\n"); + } + else + { + system("cp", "$monoprefix/bin/mono-2.0.dll", "$distDirArchBin/mono-2.0.dll") eq 0 or die ("failed copying mono-2.0.dll\n"); + system("cp", "$monoprefix/bin/mono-2.0.pdb", "$distDirArchBin/mono-2.0.pdb") eq 0 or die ("failed copying mono-2.0.pdb\n"); + system("cp", "$monoprefix/bin/mono.exe", "$distDirArchBin/mono.exe") eq 0 or die ("failed copying mono.exe\n"); + } + } + + # cross compiler directory setup + if ($iphoneCross) + { + print ">>> Copying mono-xcompiler\n"; + if($runningOnWindows) + { + die("Not implemented\n"); + } + else + { + system("cp", "$monoroot/mono/mini/mono","$crossCompilerDestination/mono-xcompiler") eq 0 or die ("failed copying mono-xcompiler\n"); + } + } + + # Not all build configurations output to the distro dir, so only chmod it if it exists + system("chmod", "-R", "755", $distDirArchBin) if (-d "$distDirArchBin"); + + # Output version information + print(">>> Creating version file : $versionsOutputFile\n"); + system("echo \"mono-version =\" > $versionsOutputFile"); + + # Not all build configurations output to the distro dir, only try to output version info if there is a distro dir + system("$distDirArchBin/mono --version >> $versionsOutputFile") if (-d "$distDirArchBin"); + + system("echo \"unity-mono-revision = $monoRevision\" >> $versionsOutputFile"); + system("echo \"unity-mono-build-scripts-revision = $buildScriptsRevision\" >> $versionsOutputFile"); + my $tmp = `date`; + system("echo \"build-date = $tmp\" >> $versionsOutputFile"); +} +else +{ + print(">>> Skipping artifact creation\n"); +} + +if ($test) +{ + if ($runRuntimeTests) + { + my $runtimeTestsDir = "$monoroot/mono/mini"; + chdir("$runtimeTestsDir") eq 1 or die ("failed to chdir"); + print("\n>>> Calling make check in $runtimeTestsDir\n\n"); + system("make","check") eq 0 or die ("runtime tests failed\n"); + } + else + { + print(">>> Skipping runtime unit tests\n"); + } + + if ($runClasslibTests) + { + if ($disableMcs) + { + print(">>> Skipping classlib unit tests because building the class libs was disabled\n"); + } + else + { + my $classlibTestsDir = "$monoroot/mcs/class"; + chdir("$classlibTestsDir") eq 1 or die ("failed to chdir"); + print("\n>>> Calling make run-test in $runtimeTestsDir\n\n"); + system("make","run-test") eq 0 or die ("classlib tests failed\n"); + } + } + else + { + print(">>> Skipping classlib unit tests\n"); + } +} +else +{ + print(">>> Skipping unit tests\n"); +} + +chdir ($currentdir); diff --git a/external/buildscripts/build_all_linux.pl b/external/buildscripts/build_all_linux.pl index d124f2b19cce..a975f5e7b668 100644 --- a/external/buildscripts/build_all_linux.pl +++ b/external/buildscripts/build_all_linux.pl @@ -1,27 +1,27 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $currentdir = getcwd(); - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildscriptsdir = "$monoroot/external/buildscripts"; - -my @passAlongArgs = (); -foreach my $arg (@ARGV) -{ - # Filter out --clean if someone uses it. We have to clean since we are doing two builds - if (not $arg =~ /^--clean=/) - { - push @passAlongArgs, $arg; - } -} - -print(">>> Building i386\n"); -system("perl", "$buildscriptsdir/build.pl", "--arch32=1", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building i386'); - -print(">>> Building x86_64\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $currentdir = getcwd(); + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildscriptsdir = "$monoroot/external/buildscripts"; + +my @passAlongArgs = (); +foreach my $arg (@ARGV) +{ + # Filter out --clean if someone uses it. We have to clean since we are doing two builds + if (not $arg =~ /^--clean=/) + { + push @passAlongArgs, $arg; + } +} + +print(">>> Building i386\n"); +system("perl", "$buildscriptsdir/build.pl", "--arch32=1", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building i386'); + +print(">>> Building x86_64\n"); system("perl", "$buildscriptsdir/build.pl", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building x86_64'); \ No newline at end of file diff --git a/external/buildscripts/build_all_win.pl b/external/buildscripts/build_all_win.pl index 3c282f5f9993..65e099b4bec2 100644 --- a/external/buildscripts/build_all_win.pl +++ b/external/buildscripts/build_all_win.pl @@ -1,27 +1,27 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $currentdir = getcwd(); - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildscriptsdir = "$monoroot/external/buildscripts"; - -my @passAlongArgs = (); -foreach my $arg (@ARGV) -{ - # Filter out --clean if someone uses it. We have to clean since we are doing two builds - if (not $arg =~ /^--clean=/) - { - push @passAlongArgs, $arg; - } -} - -print(">>> Building i686\n"); -system("perl", "$buildscriptsdir/build_win_wrapper.pl", "--arch32=1", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building win32'); - -print(">>> Building x86_64\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $currentdir = getcwd(); + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildscriptsdir = "$monoroot/external/buildscripts"; + +my @passAlongArgs = (); +foreach my $arg (@ARGV) +{ + # Filter out --clean if someone uses it. We have to clean since we are doing two builds + if (not $arg =~ /^--clean=/) + { + push @passAlongArgs, $arg; + } +} + +print(">>> Building i686\n"); +system("perl", "$buildscriptsdir/build_win_wrapper.pl", "--arch32=1", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building win32'); + +print(">>> Building x86_64\n"); system("perl", "$buildscriptsdir/build_win_wrapper.pl", "--clean=1", "--classlibtests=0", @passAlongArgs) eq 0 or die ('failing building x64'); \ No newline at end of file diff --git a/external/buildscripts/build_classlibs_osx.pl b/external/buildscripts/build_classlibs_osx.pl index b1a47d9fef8d..fa96cc74cf32 100644 --- a/external/buildscripts/build_classlibs_osx.pl +++ b/external/buildscripts/build_classlibs_osx.pl @@ -1,40 +1,40 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -my $build = 1; -my $clean = 1; -my $mcsOnly = 0; -my $skipMonoMake = 0; - -# Handy troubleshooting/niche options - -# The prefix hack probably isn't needed anymore. Let's disable it by default and see how things go -my $shortPrefix = 1; - -GetOptions( - "build=i"=>\$build, - "clean=i"=>\$clean, - "mcsOnly=i"=>\$mcsOnly, - 'skipmonomake=i'=>\$skipMonoMake, - 'shortprefix=i'=>\$shortPrefix, -) or die ("illegal cmdline options"); - -system( - "perl", - "$buildScriptsRoot/build.pl", - "--build=$build", - "--clean=$clean", - "--mcsonly=$mcsOnly", - "--skipmonomake=$skipMonoMake", - "--artifact=1", - "--artifactscommon=1", - "--buildusandboo=1", - "--forcedefaultbuilddeps=1", - "--shortprefix=$shortPrefix") eq 0 or die ("Failed building mono\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $build = 1; +my $clean = 1; +my $mcsOnly = 0; +my $skipMonoMake = 0; + +# Handy troubleshooting/niche options + +# The prefix hack probably isn't needed anymore. Let's disable it by default and see how things go +my $shortPrefix = 1; + +GetOptions( + "build=i"=>\$build, + "clean=i"=>\$clean, + "mcsOnly=i"=>\$mcsOnly, + 'skipmonomake=i'=>\$skipMonoMake, + 'shortprefix=i'=>\$shortPrefix, +) or die ("illegal cmdline options"); + +system( + "perl", + "$buildScriptsRoot/build.pl", + "--build=$build", + "--clean=$clean", + "--mcsonly=$mcsOnly", + "--skipmonomake=$skipMonoMake", + "--artifact=1", + "--artifactscommon=1", + "--buildusandboo=1", + "--forcedefaultbuilddeps=1", + "--shortprefix=$shortPrefix") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_classlibs_wsl.pl b/external/buildscripts/build_classlibs_wsl.pl index 750b21d646f6..9d65f1b7e2b3 100644 --- a/external/buildscripts/build_classlibs_wsl.pl +++ b/external/buildscripts/build_classlibs_wsl.pl @@ -1,53 +1,53 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -my $build = 1; -my $clean = 1; -my $mcsOnly = 0; -my $skipMonoMake = 0; - -# Handy troubleshooting/niche options - -# The prefix hack probably isn't needed anymore. Let's disable it by default and see how things go -my $shortPrefix = 1; - -# This script should not be ran on windows, if it is, kindly switch over to wsl -if ($^O eq "MSWin32") -{ - print(">>> Called from Windows. Switching over to wsl\n"); - my $monoRootInBash = `bash -c pwd`; - chomp $monoRootInBash; - print(">>> monoRootInBash = $monoRootInBash\n"); - my $cmdForBash = "$monoRootInBash/external/buildscripts/build_classlibs_wsl.pl @ARGV"; - system("bash", "-c", "\"perl $cmdForBash\"") eq 0 or die("\n"); - exit 0; -} - -GetOptions( - "build=i"=>\$build, - "clean=i"=>\$clean, - "mcsOnly=i"=>\$mcsOnly, - 'skipmonomake=i'=>\$skipMonoMake, - 'shortprefix=i'=>\$shortPrefix, -) or die ("illegal cmdline options"); - -system( - "perl", - "$buildScriptsRoot/build.pl", - "--build=$build", - "--clean=$clean", - "--mcsonly=$mcsOnly", - "--skipmonomake=$skipMonoMake", - "--artifact=1", - "--artifactscommon=1", - "--buildusandboo=1", - "--forcedefaultbuilddeps=1", - "--windowssubsystemforlinux=1", - "--shortprefix=$shortPrefix") eq 0 or die ("Failed building mono\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $build = 1; +my $clean = 1; +my $mcsOnly = 0; +my $skipMonoMake = 0; + +# Handy troubleshooting/niche options + +# The prefix hack probably isn't needed anymore. Let's disable it by default and see how things go +my $shortPrefix = 1; + +# This script should not be ran on windows, if it is, kindly switch over to wsl +if ($^O eq "MSWin32") +{ + print(">>> Called from Windows. Switching over to wsl\n"); + my $monoRootInBash = `bash -c pwd`; + chomp $monoRootInBash; + print(">>> monoRootInBash = $monoRootInBash\n"); + my $cmdForBash = "$monoRootInBash/external/buildscripts/build_classlibs_wsl.pl @ARGV"; + system("bash", "-c", "\"perl $cmdForBash\"") eq 0 or die("\n"); + exit 0; +} + +GetOptions( + "build=i"=>\$build, + "clean=i"=>\$clean, + "mcsOnly=i"=>\$mcsOnly, + 'skipmonomake=i'=>\$skipMonoMake, + 'shortprefix=i'=>\$shortPrefix, +) or die ("illegal cmdline options"); + +system( + "perl", + "$buildScriptsRoot/build.pl", + "--build=$build", + "--clean=$clean", + "--mcsonly=$mcsOnly", + "--skipmonomake=$skipMonoMake", + "--artifact=1", + "--artifactscommon=1", + "--buildusandboo=1", + "--forcedefaultbuilddeps=1", + "--windowssubsystemforlinux=1", + "--shortprefix=$shortPrefix") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_ios_xwin.pl b/external/buildscripts/build_ios_xwin.pl index d20844d1ef25..a8d2cde8ec22 100644 --- a/external/buildscripts/build_ios_xwin.pl +++ b/external/buildscripts/build_ios_xwin.pl @@ -1,18 +1,18 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -my $clean = 1; - -GetOptions( - "clean=i"=>\$clean, -) or die ("illegal cmdline options"); - - -system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphonecross=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building iphone cross compiler\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $clean = 1; + +GetOptions( + "clean=i"=>\$clean, +) or die ("illegal cmdline options"); + + +system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphonecross=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building iphone cross compiler\n"); diff --git a/external/buildscripts/build_runtime_android.pl b/external/buildscripts/build_runtime_android.pl index b827b191968e..baf687dc9034 100644 --- a/external/buildscripts/build_runtime_android.pl +++ b/external/buildscripts/build_runtime_android.pl @@ -1,32 +1,32 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -my $androidArch = ""; -my $clean = 1; -my $windowsSubsystemForLinux = 0; - -GetOptions( - "androidarch=s"=>\$androidArch, - "clean=i"=>\$clean, - "windowssubsystemforlinux=i"=>\$windowsSubsystemForLinux, -) or die ("illegal cmdline options"); - -# By default, build runtime for all the variants we need. But allow something to specify an individual variation to build -if ($androidArch eq "") -{ - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv5", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv5\n"); - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv6_vfp", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv6_vfp\n"); - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv7a", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv7a\n"); - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=x86", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for x86\n"); -} -else -{ - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--androidarch=$androidArch", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for $androidArch\n"); -} +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $androidArch = ""; +my $clean = 1; +my $windowsSubsystemForLinux = 0; + +GetOptions( + "androidarch=s"=>\$androidArch, + "clean=i"=>\$clean, + "windowssubsystemforlinux=i"=>\$windowsSubsystemForLinux, +) or die ("illegal cmdline options"); + +# By default, build runtime for all the variants we need. But allow something to specify an individual variation to build +if ($androidArch eq "") +{ + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv5", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv5\n"); + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv6_vfp", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv6_vfp\n"); + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv7a", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv7a\n"); + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=x86", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for x86\n"); +} +else +{ + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--androidarch=$androidArch", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for $androidArch\n"); +} diff --git a/external/buildscripts/build_runtime_iphone.pl b/external/buildscripts/build_runtime_iphone.pl index 7c0b93e9df2e..0c4b5bce4568 100644 --- a/external/buildscripts/build_runtime_iphone.pl +++ b/external/buildscripts/build_runtime_iphone.pl @@ -1,67 +1,67 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -my $clean = 1; -my $runtime = 0; -my $xcomp = 0; -my $simulator = 0; - -GetOptions( - "clean=i"=>\$clean, - "runtime=i"=>\$runtime, - "xcomp=i"=>\$xcomp, - "simulator=i"=>\$simulator, -) or die ("illegal cmdline options"); - -# Build everything by default -if ($runtime == 0 && $xcomp == 0 && $simulator == 0) -{ - print ">>> All iphone related builds will be ran\n"; - $runtime = 1; - $xcomp = 1; - $simulator = 1; -} - -if ($runtime) -{ - print ">>> Building iphone runtime\n"; - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphoneArch=armv7", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for iphone\n"); -} - -if ($xcomp) -{ - # TODO : This is a horrible waste of time, and we should fix it, but for now it gets things working. - # The mono we have in the build deps for bootstrapping doesn't have a 32bit slice, which we need in order to run the MonoAotOffsetsDumper. - # To get around this for the moment, we'll build the runtime & classlibs first, and then use that to run the MonoAotOffsetsDumper. - # Once we update the mono in the build deps, we can remove this. - if(!(-f "$monoroot/builds/monodistribution/bin/mono")) - { - print ">>> Building mono to use for bootstrapping. The version in mono build deps is missing the 32bit slice and we need a 32bit version to run the MonoAotOffsetsDumper\n"; - #system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--arch32=1", "--clean=$clean", "--classlibtests=0", "--artifact=1", "--artifactscommon=1", "--forcedefaultbuilddeps=1") eq 0 or die ("failing building mono 32bit for bootstrapping\n"); - #system("perl", "$buildScriptsRoot/build_all_osx.pl", "--build=1", "--artifact=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--artifactscommon=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); - - system("cp", "$monoroot/builds/monodistribution/bin-osx-tmp-i386/mono", "$monoroot/builds/monodistribution/bin/.") eq 0 or die ("failed to copy mono over from bin-osx-tmp-i386 to bin\n"); - system("chmod", "+x", "$monoroot/builds/monodistribution/bin/mono") eq 0 or die("Failed to chmod mono\n"); - - # Need to clean up the tmp build folder so that we don't pollute the final artifact - rmtree("$monoroot/builds/monodistribution/bin-osx-tmp-i386"); - rmtree("$monoroot/builds/embedruntimes/osx-tmp-i386"); - } - - print ">>> Building iphone cross compiler\n"; - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphonecross=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building iphone cross compiler\n"); -} - -if ($simulator) -{ - print ">>> Building iphone simulator\n"; - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphonesimulator=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building iphone simulator\n"); -} +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $clean = 1; +my $runtime = 0; +my $xcomp = 0; +my $simulator = 0; + +GetOptions( + "clean=i"=>\$clean, + "runtime=i"=>\$runtime, + "xcomp=i"=>\$xcomp, + "simulator=i"=>\$simulator, +) or die ("illegal cmdline options"); + +# Build everything by default +if ($runtime == 0 && $xcomp == 0 && $simulator == 0) +{ + print ">>> All iphone related builds will be ran\n"; + $runtime = 1; + $xcomp = 1; + $simulator = 1; +} + +if ($runtime) +{ + print ">>> Building iphone runtime\n"; + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphoneArch=armv7", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono for iphone\n"); +} + +if ($xcomp) +{ + # TODO : This is a horrible waste of time, and we should fix it, but for now it gets things working. + # The mono we have in the build deps for bootstrapping doesn't have a 32bit slice, which we need in order to run the MonoAotOffsetsDumper. + # To get around this for the moment, we'll build the runtime & classlibs first, and then use that to run the MonoAotOffsetsDumper. + # Once we update the mono in the build deps, we can remove this. + if(!(-f "$monoroot/builds/monodistribution/bin/mono")) + { + print ">>> Building mono to use for bootstrapping. The version in mono build deps is missing the 32bit slice and we need a 32bit version to run the MonoAotOffsetsDumper\n"; + #system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--arch32=1", "--clean=$clean", "--classlibtests=0", "--artifact=1", "--artifactscommon=1", "--forcedefaultbuilddeps=1") eq 0 or die ("failing building mono 32bit for bootstrapping\n"); + #system("perl", "$buildScriptsRoot/build_all_osx.pl", "--build=1", "--artifact=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--artifactscommon=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); + + system("cp", "$monoroot/builds/monodistribution/bin-osx-tmp-i386/mono", "$monoroot/builds/monodistribution/bin/.") eq 0 or die ("failed to copy mono over from bin-osx-tmp-i386 to bin\n"); + system("chmod", "+x", "$monoroot/builds/monodistribution/bin/mono") eq 0 or die("Failed to chmod mono\n"); + + # Need to clean up the tmp build folder so that we don't pollute the final artifact + rmtree("$monoroot/builds/monodistribution/bin-osx-tmp-i386"); + rmtree("$monoroot/builds/embedruntimes/osx-tmp-i386"); + } + + print ">>> Building iphone cross compiler\n"; + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphonecross=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building iphone cross compiler\n"); +} + +if ($simulator) +{ + print ">>> Building iphone simulator\n"; + system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=$clean", "--artifact=1", "--arch32=1", "--iphonesimulator=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building iphone simulator\n"); +} diff --git a/external/buildscripts/build_runtime_linux.pl b/external/buildscripts/build_runtime_linux.pl index 073b6fb5ea76..836b7407d10a 100644 --- a/external/buildscripts/build_runtime_linux.pl +++ b/external/buildscripts/build_runtime_linux.pl @@ -1,23 +1,23 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -my $build64 = 0; - -GetOptions( - "build64=i"=>\$build64, -) or die ("illegal cmdline options"); - -my $arch32 = 1; -if ($build64) -{ - $arch32 = 0; -} - -system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--arch32=$arch32", "--classlibtests=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +my $build64 = 0; + +GetOptions( + "build64=i"=>\$build64, +) or die ("illegal cmdline options"); + +my $arch32 = 1; +if ($build64) +{ + $arch32 = 0; +} + +system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--arch32=$arch32", "--classlibtests=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_runtime_osx.pl b/external/buildscripts/build_runtime_osx.pl index 42009e295b51..82b9d5f64b3b 100644 --- a/external/buildscripts/build_runtime_osx.pl +++ b/external/buildscripts/build_runtime_osx.pl @@ -1,11 +1,11 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -system("perl", "$buildScriptsRoot/build_all_osx.pl", "--build=1", "--artifact=1", "--test=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +system("perl", "$buildScriptsRoot/build_all_osx.pl", "--build=1", "--artifact=1", "--test=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_runtime_vs.pl b/external/buildscripts/build_runtime_vs.pl index ee41343ede20..5460b34408ba 100644 --- a/external/buildscripts/build_runtime_vs.pl +++ b/external/buildscripts/build_runtime_vs.pl @@ -1,52 +1,52 @@ -sub CompileVCProj; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Spec; -use File::Basename; -use File::Copy; -use File::Path; - -print ">>> PATH in Build VS = $ENV{PATH}\n\n"; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildsroot = "$monoroot/builds"; -my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; - -my $build = 0; -my $clean = 0; -my $arch32 = 0; -my $debug = 0; -my $gc = "bdwgc"; -my $msBuildVersion = ""; - -GetOptions( - 'build=i'=>\$build, - 'clean=i'=>\$clean, - 'arch32=i'=>\$arch32, - 'debug=i'=>\$debug, - 'msbuildversion=s'=>\$msBuildVersion, - 'gc=s'=>\$gc, -) or die ("illegal cmdline options"); - -if ($build) -{ - CompileVCProj("$monoroot/msvc/mono.sln"); -} - -sub CompileVCProj -{ - my $sln = shift; - my $config; - - my $msbuild = $ENV{"ProgramFiles(x86)"}."/MSBuild/$msBuildVersion/Bin/MSBuild.exe"; - - $config = $debug ? "Debug" : "Release"; - my $arch = $arch32 ? "Win32" : "x64"; - my $target = $clean ? "/t:Clean,Build" :"/t:Build"; - my $properties = "/p:Configuration=$config;Platform=$arch;MONO_TARGET_GC=$gc"; - - print ">>> $msbuild $properties $target $sln\n\n"; - system($msbuild, $properties, $target, $sln) eq 0 - or die("MSBuild failed to build $sln\n"); -} +sub CompileVCProj; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Spec; +use File::Basename; +use File::Copy; +use File::Path; + +print ">>> PATH in Build VS = $ENV{PATH}\n\n"; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildsroot = "$monoroot/builds"; +my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; + +my $build = 0; +my $clean = 0; +my $arch32 = 0; +my $debug = 0; +my $gc = "bdwgc"; +my $msBuildVersion = ""; + +GetOptions( + 'build=i'=>\$build, + 'clean=i'=>\$clean, + 'arch32=i'=>\$arch32, + 'debug=i'=>\$debug, + 'msbuildversion=s'=>\$msBuildVersion, + 'gc=s'=>\$gc, +) or die ("illegal cmdline options"); + +if ($build) +{ + CompileVCProj("$monoroot/msvc/mono.sln"); +} + +sub CompileVCProj +{ + my $sln = shift; + my $config; + + my $msbuild = $ENV{"ProgramFiles(x86)"}."/MSBuild/$msBuildVersion/Bin/MSBuild.exe"; + + $config = $debug ? "Debug" : "Release"; + my $arch = $arch32 ? "Win32" : "x64"; + my $target = $clean ? "/t:Clean,Build" :"/t:Build"; + my $properties = "/p:Configuration=$config;Platform=$arch;MONO_TARGET_GC=$gc"; + + print ">>> $msbuild $properties $target $sln\n\n"; + system($msbuild, $properties, $target, $sln) eq 0 + or die("MSBuild failed to build $sln\n"); +} diff --git a/external/buildscripts/build_runtime_win.pl b/external/buildscripts/build_runtime_win.pl index f8dda725c262..9022ed3f5413 100644 --- a/external/buildscripts/build_runtime_win.pl +++ b/external/buildscripts/build_runtime_win.pl @@ -1,14 +1,14 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -# Note : Ideally we can switch back to this build approach once the random cygwin hangs on the build machines are sorted out -#system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--arch32=1", "--classlibtests=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); - -system("perl", "$buildScriptsRoot/build_win_no_cygwin.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +# Note : Ideally we can switch back to this build approach once the random cygwin hangs on the build machines are sorted out +#system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--arch32=1", "--classlibtests=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); + +system("perl", "$buildScriptsRoot/build_win_no_cygwin.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_runtime_win64.pl b/external/buildscripts/build_runtime_win64.pl index fd36d86bfd35..24bf9821282d 100644 --- a/external/buildscripts/build_runtime_win64.pl +++ b/external/buildscripts/build_runtime_win64.pl @@ -1,14 +1,14 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -# Note : Ideally we can switch back to this build approach once the random cygwin hangs on the build machines are sorted out -#system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--classlibtests=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); - -system("perl", "$buildScriptsRoot/build_win_no_cygwin.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +# Note : Ideally we can switch back to this build approach once the random cygwin hangs on the build machines are sorted out +#system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--classlibtests=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); + +system("perl", "$buildScriptsRoot/build_win_no_cygwin.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=0", "--forcedefaultbuilddeps=1") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_runtime_wsl.pl b/external/buildscripts/build_runtime_wsl.pl index fabedcff1774..ba8169be68e9 100644 --- a/external/buildscripts/build_runtime_wsl.pl +++ b/external/buildscripts/build_runtime_wsl.pl @@ -1,13 +1,13 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; - -#Windows Subsystem for Linux currently does not support 32-bit, so the option is 64-bit only - -system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--arch32=0", "--classlibtests=0", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=1") eq 0 or die ("Failed building mono\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; + +#Windows Subsystem for Linux currently does not support 32-bit, so the option is 64-bit only + +system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--test=1", "--artifact=1", "--arch32=0", "--classlibtests=0", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=1") eq 0 or die ("Failed building mono\n"); diff --git a/external/buildscripts/build_unityscript_bareminimum_win.pl b/external/buildscripts/build_unityscript_bareminimum_win.pl index 753cf408dd62..8214e906a8dd 100644 --- a/external/buildscripts/build_unityscript_bareminimum_win.pl +++ b/external/buildscripts/build_unityscript_bareminimum_win.pl @@ -1,159 +1,159 @@ -use lib ('.', 'perl_lib', 'external/buildscripts/perl_lib'); -use Cwd; -use File::Path; - -use File::Copy::Recursive qw(dircopy); -use Getopt::Long; -use File::Basename; - -my $root = getcwd(); - -my $monodistro = "$root/builds/monodistribution"; -my $libmono = "$monodistro/lib/mono"; - -sub AddDotNetFolderToPath() { - - my @netFrameworkLocations = ( - $ENV{"SYSTEMROOT"}."/Microsoft.NET/Framework/v4.0.30319", - $ENV{"SYSTEMROOT"}."/Microsoft.NET/Framework/v3.5" - ); - - my $netFrameworkLocation = ""; - my $checkedLocations = ""; - - find_framework: - foreach my $current (@netFrameworkLocations) - { - if (-e $current) { - $netFrameworkLocation = $current; - last find_framework; - } - - $checkedLocations = $checkedLocations . ", " . $current; - } - - if ($netFrameworkLocation eq '') { - die("Could not find dotnet framework folder. Checked: $checkedLocations"); - } - - print("Using .Net framework: $netFrameworkLocation"); - $ENV{PATH} = "$netFrameworkLocation;$ENV{PATH}"; -} - -AddDotNetFolderToPath(); - -my $output = Win32::GetLongPathName("$ENV{TEMP}") . "/output/BareMinimum"; - -print("\nEnvironment Path: $ENV{PATH}\n"); - -my $booCheckout = "$root/../../boo/build"; -my $usCheckout = "$root/../../unityscript/build"; - -my $skipbuild=0; -GetOptions( - "skipbuild=i"=>\$skipbuild, -) or die ("illegal cmdline options"); - -my $monodistroLibMono = "$monodistro/lib/mono"; -my $monodistroUnity = "$monodistroLibMono/unity"; - -sub UnityBooc -{ - my $commandLine = shift; - system("$output/wsa/booc -debug- $commandLine") eq 0 or die("booc failed to execute: $commandLine"); -} - -sub BuildUnityScriptForUnity -{ - # Build system is handling this - if (!$ENV{UNITY_THISISABUILDMACHINE}) { - GitClone("git://github.com/Unity-Technologies/boo.git", $booCheckout); - } - - my $commonDefines = "NO_SERIALIZATION_INFO,NO_SYSTEM_PROCESS,NO_ICLONEABLE,MSBUILD,IGNOREKEYFILE"; - - Build("$booCheckout/src/booc/Booc.csproj", undef, "/property:TargetFrameworkVersion=4.0 /property:DefineConstants=\"" . $commonDefines . "\" /property:OutputPath=$output/wp8"); - Build("$booCheckout/src/booc/Booc.csproj", undef, "/property:TargetFrameworkVersion=4.0 /property:DefineConstants=\"" . $commonDefines . ",NO_SYSTEM_REFLECTION_EMIT\" /property:OutputPath=$output/wsa"); - - if (!$ENV{UNITY_THISISABUILDMACHINE}) { - GitClone("git://github.com/Unity-Technologies/unityscript.git", $usCheckout); - } - - UnityBooc("-out:$output/wsa/Boo.Lang.Extensions.dll -srcdir:$booCheckout/src/Boo.Lang.Extensions -r:$output/wsa/Boo.Lang.dll -r:$output/wsa/Boo.Lang.Compiler.dll"); - UnityBooc("-out:$output/wsa/Boo.Lang.Useful.dll -srcdir:$booCheckout/src/Boo.Lang.Useful -r:$output/wsa/Boo.Lang.Parser"); - UnityBooc("-out:$output/wsa/Boo.Lang.PatternMatching.dll -srcdir:$booCheckout/src/Boo.Lang.PatternMatching"); - - my $UnityScriptLangDLL = "$output/UnityScript.Lang.dll"; - UnityBooc("-out:$UnityScriptLangDLL -srcdir:$usCheckout/src/UnityScript.Lang -r:$output/wsa/Boo.Lang.Extensions.dll"); -} - -sub Build -{ - my $projectFile = shift; - - my $optionalConfiguration = shift; - my $configuration = defined($optionalConfiguration) ? $optionalConfiguration : "Release"; - - my $optionalCustomArguments = shift; - my $customArguments = defined($optionalCustomArguments) ? $optionalCustomArguments : ""; - - my $target = "Rebuild"; - my $commandLine = "MSBuild $projectFile /p:AssemblyOriginatorKeyFile= /p:SignAssembly=false /p:MonoTouch=True /t:$target /p:Configuration=$configuration $customArguments"; - - system($commandLine) eq 0 or die("Failed to xbuild '$projectFile' for unity"); -} - -sub GitClone -{ - my $repo = shift; - my $localFolder = shift; - my $branch = shift; - $branch = defined($branch)?$branch:master; - - if (-d $localFolder) { - return; - } - system("git clone --branch $branch $repo $localFolder") eq 0 or die("git clone $repo $localFolder failed!"); -} - -sub NormalizePath { - my $path = shift; - $path =~ s/\//\\/g; - - return $path; -} - -sub cp -{ - my $cmdLine = shift; - $cmdLine = NormalizePath($cmdLine); - - system("xcopy $cmdLine /s /y") eq 0 or die("failed to copy '$cmdLine'"); - print "Copied: $cmdLine\n"; -} - -rmtree("$root/builds"); -rmtree("$output"); - -BuildUnityScriptForUnity(); - -cp("$output/wsa/Boo.Lang.dll $libmono/bare-minimum/wsa/Boo.Lang.dll*"); -cp("$output/wsa/Boo.Lang.pdb $libmono/bare-minimum/wsa/Boo.Lang.pdb*"); -cp("$output/wp8/Boo.Lang.dll $libmono/bare-minimum/wp8/Boo.Lang.dll*"); -cp("$output/wp8/Boo.Lang.pdb $libmono/bare-minimum/wp8/Boo.Lang.pdb*"); -cp("$output/UnityScript.Lang.* $libmono/bare-minimum/UnityScript.Lang.*"); - -if($ENV{UNITY_THISISABUILDMACHINE}) -{ - my %checkouts = ( - 'mono-classlibs' => 'BUILD_VCS_NUMBER_Mono____Mono2_6_x_Unity3_x', - 'boo' => 'BUILD_VCS_NUMBER_Boo', - 'unityscript' => 'BUILD_VCS_NUMBER_UnityScript', - 'cecil' => 'BUILD_VCS_NUMBER_Cecil' - ); - - system("echo '' > $root/builds/versions.txt"); - for my $key (keys %checkouts) { - system("echo \"$key = $ENV{$checkouts{$key}}\" >> $root/builds/versions.txt"); - } -} +use lib ('.', 'perl_lib', 'external/buildscripts/perl_lib'); +use Cwd; +use File::Path; + +use File::Copy::Recursive qw(dircopy); +use Getopt::Long; +use File::Basename; + +my $root = getcwd(); + +my $monodistro = "$root/builds/monodistribution"; +my $libmono = "$monodistro/lib/mono"; + +sub AddDotNetFolderToPath() { + + my @netFrameworkLocations = ( + $ENV{"SYSTEMROOT"}."/Microsoft.NET/Framework/v4.0.30319", + $ENV{"SYSTEMROOT"}."/Microsoft.NET/Framework/v3.5" + ); + + my $netFrameworkLocation = ""; + my $checkedLocations = ""; + + find_framework: + foreach my $current (@netFrameworkLocations) + { + if (-e $current) { + $netFrameworkLocation = $current; + last find_framework; + } + + $checkedLocations = $checkedLocations . ", " . $current; + } + + if ($netFrameworkLocation eq '') { + die("Could not find dotnet framework folder. Checked: $checkedLocations"); + } + + print("Using .Net framework: $netFrameworkLocation"); + $ENV{PATH} = "$netFrameworkLocation;$ENV{PATH}"; +} + +AddDotNetFolderToPath(); + +my $output = Win32::GetLongPathName("$ENV{TEMP}") . "/output/BareMinimum"; + +print("\nEnvironment Path: $ENV{PATH}\n"); + +my $booCheckout = "$root/../../boo/build"; +my $usCheckout = "$root/../../unityscript/build"; + +my $skipbuild=0; +GetOptions( + "skipbuild=i"=>\$skipbuild, +) or die ("illegal cmdline options"); + +my $monodistroLibMono = "$monodistro/lib/mono"; +my $monodistroUnity = "$monodistroLibMono/unity"; + +sub UnityBooc +{ + my $commandLine = shift; + system("$output/wsa/booc -debug- $commandLine") eq 0 or die("booc failed to execute: $commandLine"); +} + +sub BuildUnityScriptForUnity +{ + # Build system is handling this + if (!$ENV{UNITY_THISISABUILDMACHINE}) { + GitClone("git://github.com/Unity-Technologies/boo.git", $booCheckout); + } + + my $commonDefines = "NO_SERIALIZATION_INFO,NO_SYSTEM_PROCESS,NO_ICLONEABLE,MSBUILD,IGNOREKEYFILE"; + + Build("$booCheckout/src/booc/Booc.csproj", undef, "/property:TargetFrameworkVersion=4.0 /property:DefineConstants=\"" . $commonDefines . "\" /property:OutputPath=$output/wp8"); + Build("$booCheckout/src/booc/Booc.csproj", undef, "/property:TargetFrameworkVersion=4.0 /property:DefineConstants=\"" . $commonDefines . ",NO_SYSTEM_REFLECTION_EMIT\" /property:OutputPath=$output/wsa"); + + if (!$ENV{UNITY_THISISABUILDMACHINE}) { + GitClone("git://github.com/Unity-Technologies/unityscript.git", $usCheckout); + } + + UnityBooc("-out:$output/wsa/Boo.Lang.Extensions.dll -srcdir:$booCheckout/src/Boo.Lang.Extensions -r:$output/wsa/Boo.Lang.dll -r:$output/wsa/Boo.Lang.Compiler.dll"); + UnityBooc("-out:$output/wsa/Boo.Lang.Useful.dll -srcdir:$booCheckout/src/Boo.Lang.Useful -r:$output/wsa/Boo.Lang.Parser"); + UnityBooc("-out:$output/wsa/Boo.Lang.PatternMatching.dll -srcdir:$booCheckout/src/Boo.Lang.PatternMatching"); + + my $UnityScriptLangDLL = "$output/UnityScript.Lang.dll"; + UnityBooc("-out:$UnityScriptLangDLL -srcdir:$usCheckout/src/UnityScript.Lang -r:$output/wsa/Boo.Lang.Extensions.dll"); +} + +sub Build +{ + my $projectFile = shift; + + my $optionalConfiguration = shift; + my $configuration = defined($optionalConfiguration) ? $optionalConfiguration : "Release"; + + my $optionalCustomArguments = shift; + my $customArguments = defined($optionalCustomArguments) ? $optionalCustomArguments : ""; + + my $target = "Rebuild"; + my $commandLine = "MSBuild $projectFile /p:AssemblyOriginatorKeyFile= /p:SignAssembly=false /p:MonoTouch=True /t:$target /p:Configuration=$configuration $customArguments"; + + system($commandLine) eq 0 or die("Failed to xbuild '$projectFile' for unity"); +} + +sub GitClone +{ + my $repo = shift; + my $localFolder = shift; + my $branch = shift; + $branch = defined($branch)?$branch:master; + + if (-d $localFolder) { + return; + } + system("git clone --branch $branch $repo $localFolder") eq 0 or die("git clone $repo $localFolder failed!"); +} + +sub NormalizePath { + my $path = shift; + $path =~ s/\//\\/g; + + return $path; +} + +sub cp +{ + my $cmdLine = shift; + $cmdLine = NormalizePath($cmdLine); + + system("xcopy $cmdLine /s /y") eq 0 or die("failed to copy '$cmdLine'"); + print "Copied: $cmdLine\n"; +} + +rmtree("$root/builds"); +rmtree("$output"); + +BuildUnityScriptForUnity(); + +cp("$output/wsa/Boo.Lang.dll $libmono/bare-minimum/wsa/Boo.Lang.dll*"); +cp("$output/wsa/Boo.Lang.pdb $libmono/bare-minimum/wsa/Boo.Lang.pdb*"); +cp("$output/wp8/Boo.Lang.dll $libmono/bare-minimum/wp8/Boo.Lang.dll*"); +cp("$output/wp8/Boo.Lang.pdb $libmono/bare-minimum/wp8/Boo.Lang.pdb*"); +cp("$output/UnityScript.Lang.* $libmono/bare-minimum/UnityScript.Lang.*"); + +if($ENV{UNITY_THISISABUILDMACHINE}) +{ + my %checkouts = ( + 'mono-classlibs' => 'BUILD_VCS_NUMBER_Mono____Mono2_6_x_Unity3_x', + 'boo' => 'BUILD_VCS_NUMBER_Boo', + 'unityscript' => 'BUILD_VCS_NUMBER_UnityScript', + 'cecil' => 'BUILD_VCS_NUMBER_Cecil' + ); + + system("echo '' > $root/builds/versions.txt"); + for my $key (keys %checkouts) { + system("echo \"$key = $ENV{$checkouts{$key}}\" >> $root/builds/versions.txt"); + } +} diff --git a/external/buildscripts/build_us_and_boo.pl b/external/buildscripts/build_us_and_boo.pl index ecbbd0da07e9..3242a6430d6e 100644 --- a/external/buildscripts/build_us_and_boo.pl +++ b/external/buildscripts/build_us_and_boo.pl @@ -1,158 +1,158 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; -use File::Copy; -use lib ('.', 'perl_lib', 'external/buildscripts/perl_lib'); -use Tools qw(GitClone); - -system("source","~/.profile"); -print ">>> My Path: $ENV{PATH}\n"; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildscriptsdir = "$monoroot/external/buildscripts"; -my $monoprefix = "$monoroot/tmp/monoprefix"; -my $buildsroot = "$monoroot/builds"; -my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; - -GetOptions( - 'monoprefix=s'=>\$monoprefix, -) or die ("illegal cmdline options"); - -my $xbuildPath = "$monoprefix/bin/xbuild"; -my $monoprefix45 = "$monoprefix/lib/mono/4.5"; - -if (!(-f "$xbuildPath")) -{ - die("Unable to locate xbuild at : $xbuildPath\n"); -} - -BuildUnityScriptFor45(); - -sub XBuild -{ - print(">>> Running : $monoprefix/bin/xbuild @_\n"); - system("$monoprefix/bin/xbuild", @_) eq 0 or die("Failed to xbuild @_\n"); -} - -sub Booc45 -{ - my $commandLine = shift; - - system("$monoprefix/bin/mono $monoprefix45/booc.exe -debug- $commandLine") eq 0 or die("booc failed to execute: $monoprefix/bin/booc -debug- $commandLine\n"); -} - -sub BuildUnityScriptFor45 -{ - my $booCheckout = "$monoroot/../../boo/build"; - print(">>> Using mono prefix $monoprefix45\n"); - - # Build host is handling this - if (!$buildMachine) - { - if (!(-d "$booCheckout")) - { - print(">>> Checking out boo\n"); - GitClone("git://github.com/Unity-Technologies/boo.git", $booCheckout, "unity-trunk"); - } - } - - my $usCheckout = "$monoroot/../../unityscript/build"; - if (!$buildMachine) - { - if (!(-d "$usCheckout")) - { - print(">>> Checking out unity script\n"); - GitClone("git://github.com/Unity-Technologies/unityscript.git", $usCheckout, "unity-trunk"); - } - } - - my $boocCsproj = "$booCheckout/src/booc/booc.csproj"; - if (!(-f "$boocCsproj")) - { - die("Unable to locate : $boocCsproj\n"); - } - - XBuild("$boocCsproj", "/t:Rebuild"); - - print(">>> Mono Prefix 4.5 = $monoprefix45\n"); - foreach my $file (glob "$booCheckout/ide-build/Boo.Lang*.dll") - { - print(">>> Copying $file to $monoprefix45\n"); - copy($file, "$monoprefix45/."); - } - - copy("$booCheckout/ide-build/booc.exe", "$monoprefix45/."); - - foreach my $file (glob "$buildscriptsdir/add_to_build_results/monodistribution/lib/mono/4.5/*") - { - print(">>> Copying $file to $monoprefix45\n"); - copy($file, "$monoprefix45/."); - my $nameOnly = basename($file); - system("chmod", "755", "$monoprefix45/$nameOnly"); - } - - Booc45("-out:$monoprefix45/Boo.Lang.Extensions.dll -noconfig -nostdlib -srcdir:$booCheckout/src/Boo.Lang.Extensions -r:System.dll -r:System.Core.dll -r:mscorlib.dll -r:Boo.Lang.dll -r:Boo.Lang.Compiler.dll"); - Booc45("-out:$monoprefix45/Boo.Lang.Useful.dll -srcdir:$booCheckout/src/Boo.Lang.Useful -r:Boo.Lang.Parser"); - Booc45("-out:$monoprefix45/Boo.Lang.PatternMatching.dll -srcdir:$booCheckout/src/Boo.Lang.PatternMatching"); - - my $UnityScriptLangDLL = "$monoprefix45/UnityScript.Lang.dll"; - Booc45("-out:$UnityScriptLangDLL -srcdir:$usCheckout/src/UnityScript.Lang"); - - my $UnityScriptDLL = "$monoprefix45/UnityScript.dll"; - Booc45("-out:$UnityScriptDLL -srcdir:$usCheckout/src/UnityScript -r:$UnityScriptLangDLL -r:Boo.Lang.Parser.dll -r:Boo.Lang.PatternMatching.dll"); - Booc45("-out:$monoprefix45/us.exe -srcdir:$usCheckout/src/us -r:$UnityScriptLangDLL -r:$UnityScriptDLL -r:Boo.Lang.Useful.dll"); - - # # unityscript test suite - # my $UnityScriptTestsCSharpDLL = "$usCheckout/src/UnityScript.Tests.CSharp/bin/Debug/UnityScript.Tests.CSharp.dll"; - # XBuild("$usCheckout/src/UnityScript.Tests.CSharp/UnityScript.Tests.CSharp.csproj", "/t:Rebuild"); - - my $usBuildDir = "$usCheckout/build"; - - if (!(-d "$usBuildDir")) - { - rmtree($usBuildDir); - } - - mkdir($usBuildDir); - - # my $UnityScriptTestsDLL = <$usBuildDir/UnityScript.Tests.dll>; - # Booc("-out:$UnityScriptTestsDLL -srcdir:$usCheckout/src/UnityScript.Tests -r:$UnityScriptLangDLL -r:$UnityScriptDLL -r:$UnityScriptTestsCSharpDLL -r:Boo.Lang.Compiler.dll -r:Boo.Lang.Useful.dll"); - - # cp("$UnityScriptTestsCSharpDLL $usBuildDir/"); - print(">>> Populating Unity Script Build Directory : $usBuildDir\n"); - foreach my $file (glob "$monoprefix45/Boo.*") - { - print(">>> Copying $file to $usBuildDir\n"); - copy($file, "$usBuildDir/."); - } - - foreach my $file (glob "$monoprefix45/UnityScript.*") - { - print(">>> Copying $file to $usBuildDir\n"); - copy($file, "$usBuildDir/."); - } - - print(">>> Copying $monoprefix45/us.exe to $usBuildDir\n"); - copy("$monoprefix45/us.exe", "$usBuildDir/."); - print(">>> Copying $monoprefix45/booc.exe to $usBuildDir\n"); - copy("$monoprefix45/booc.exe", "$usBuildDir/."); - # put unityscript and boo into their own directories that we can reference for compilation only in Unity - my $usLibDir = "$monoprefix/lib/mono/unityscript"; - - if (!(-d "$usLibDir")) - { - print(">>> Removing directory $usLibDir\n"); - rmtree($usLibDir); - } - - mkdir($usLibDir); - - foreach my $file (glob "$usBuildDir/*") - { - print(">>> Copying $file to $usLibDir\n"); - copy($file, "$usLibDir/."); - } -} +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; +use File::Copy; +use lib ('.', 'perl_lib', 'external/buildscripts/perl_lib'); +use Tools qw(GitClone); + +system("source","~/.profile"); +print ">>> My Path: $ENV{PATH}\n"; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildscriptsdir = "$monoroot/external/buildscripts"; +my $monoprefix = "$monoroot/tmp/monoprefix"; +my $buildsroot = "$monoroot/builds"; +my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; + +GetOptions( + 'monoprefix=s'=>\$monoprefix, +) or die ("illegal cmdline options"); + +my $xbuildPath = "$monoprefix/bin/xbuild"; +my $monoprefix45 = "$monoprefix/lib/mono/4.5"; + +if (!(-f "$xbuildPath")) +{ + die("Unable to locate xbuild at : $xbuildPath\n"); +} + +BuildUnityScriptFor45(); + +sub XBuild +{ + print(">>> Running : $monoprefix/bin/xbuild @_\n"); + system("$monoprefix/bin/xbuild", @_) eq 0 or die("Failed to xbuild @_\n"); +} + +sub Booc45 +{ + my $commandLine = shift; + + system("$monoprefix/bin/mono $monoprefix45/booc.exe -debug- $commandLine") eq 0 or die("booc failed to execute: $monoprefix/bin/booc -debug- $commandLine\n"); +} + +sub BuildUnityScriptFor45 +{ + my $booCheckout = "$monoroot/../../boo/build"; + print(">>> Using mono prefix $monoprefix45\n"); + + # Build host is handling this + if (!$buildMachine) + { + if (!(-d "$booCheckout")) + { + print(">>> Checking out boo\n"); + GitClone("git://github.com/Unity-Technologies/boo.git", $booCheckout, "unity-trunk"); + } + } + + my $usCheckout = "$monoroot/../../unityscript/build"; + if (!$buildMachine) + { + if (!(-d "$usCheckout")) + { + print(">>> Checking out unity script\n"); + GitClone("git://github.com/Unity-Technologies/unityscript.git", $usCheckout, "unity-trunk"); + } + } + + my $boocCsproj = "$booCheckout/src/booc/booc.csproj"; + if (!(-f "$boocCsproj")) + { + die("Unable to locate : $boocCsproj\n"); + } + + XBuild("$boocCsproj", "/t:Rebuild"); + + print(">>> Mono Prefix 4.5 = $monoprefix45\n"); + foreach my $file (glob "$booCheckout/ide-build/Boo.Lang*.dll") + { + print(">>> Copying $file to $monoprefix45\n"); + copy($file, "$monoprefix45/."); + } + + copy("$booCheckout/ide-build/booc.exe", "$monoprefix45/."); + + foreach my $file (glob "$buildscriptsdir/add_to_build_results/monodistribution/lib/mono/4.5/*") + { + print(">>> Copying $file to $monoprefix45\n"); + copy($file, "$monoprefix45/."); + my $nameOnly = basename($file); + system("chmod", "755", "$monoprefix45/$nameOnly"); + } + + Booc45("-out:$monoprefix45/Boo.Lang.Extensions.dll -noconfig -nostdlib -srcdir:$booCheckout/src/Boo.Lang.Extensions -r:System.dll -r:System.Core.dll -r:mscorlib.dll -r:Boo.Lang.dll -r:Boo.Lang.Compiler.dll"); + Booc45("-out:$monoprefix45/Boo.Lang.Useful.dll -srcdir:$booCheckout/src/Boo.Lang.Useful -r:Boo.Lang.Parser"); + Booc45("-out:$monoprefix45/Boo.Lang.PatternMatching.dll -srcdir:$booCheckout/src/Boo.Lang.PatternMatching"); + + my $UnityScriptLangDLL = "$monoprefix45/UnityScript.Lang.dll"; + Booc45("-out:$UnityScriptLangDLL -srcdir:$usCheckout/src/UnityScript.Lang"); + + my $UnityScriptDLL = "$monoprefix45/UnityScript.dll"; + Booc45("-out:$UnityScriptDLL -srcdir:$usCheckout/src/UnityScript -r:$UnityScriptLangDLL -r:Boo.Lang.Parser.dll -r:Boo.Lang.PatternMatching.dll"); + Booc45("-out:$monoprefix45/us.exe -srcdir:$usCheckout/src/us -r:$UnityScriptLangDLL -r:$UnityScriptDLL -r:Boo.Lang.Useful.dll"); + + # # unityscript test suite + # my $UnityScriptTestsCSharpDLL = "$usCheckout/src/UnityScript.Tests.CSharp/bin/Debug/UnityScript.Tests.CSharp.dll"; + # XBuild("$usCheckout/src/UnityScript.Tests.CSharp/UnityScript.Tests.CSharp.csproj", "/t:Rebuild"); + + my $usBuildDir = "$usCheckout/build"; + + if (!(-d "$usBuildDir")) + { + rmtree($usBuildDir); + } + + mkdir($usBuildDir); + + # my $UnityScriptTestsDLL = <$usBuildDir/UnityScript.Tests.dll>; + # Booc("-out:$UnityScriptTestsDLL -srcdir:$usCheckout/src/UnityScript.Tests -r:$UnityScriptLangDLL -r:$UnityScriptDLL -r:$UnityScriptTestsCSharpDLL -r:Boo.Lang.Compiler.dll -r:Boo.Lang.Useful.dll"); + + # cp("$UnityScriptTestsCSharpDLL $usBuildDir/"); + print(">>> Populating Unity Script Build Directory : $usBuildDir\n"); + foreach my $file (glob "$monoprefix45/Boo.*") + { + print(">>> Copying $file to $usBuildDir\n"); + copy($file, "$usBuildDir/."); + } + + foreach my $file (glob "$monoprefix45/UnityScript.*") + { + print(">>> Copying $file to $usBuildDir\n"); + copy($file, "$usBuildDir/."); + } + + print(">>> Copying $monoprefix45/us.exe to $usBuildDir\n"); + copy("$monoprefix45/us.exe", "$usBuildDir/."); + print(">>> Copying $monoprefix45/booc.exe to $usBuildDir\n"); + copy("$monoprefix45/booc.exe", "$usBuildDir/."); + # put unityscript and boo into their own directories that we can reference for compilation only in Unity + my $usLibDir = "$monoprefix/lib/mono/unityscript"; + + if (!(-d "$usLibDir")) + { + print(">>> Removing directory $usLibDir\n"); + rmtree($usLibDir); + } + + mkdir($usLibDir); + + foreach my $file (glob "$usBuildDir/*") + { + print(">>> Copying $file to $usLibDir\n"); + copy($file, "$usLibDir/."); + } +} diff --git a/external/buildscripts/build_win_no_cygwin.pl b/external/buildscripts/build_win_no_cygwin.pl index 17c0d6927a92..3249c10c959b 100644 --- a/external/buildscripts/build_win_no_cygwin.pl +++ b/external/buildscripts/build_win_no_cygwin.pl @@ -1,281 +1,281 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; -use File::Copy; -use lib ('external/buildscripts', "../../Tools/perl_lib","perl_lib", 'external/buildscripts/perl_lib'); -use Tools qw(InstallNameTool); - -print ">>> PATH in Build All = $ENV{PATH}\n\n"; - -my $currentdir = getcwd(); - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); - -$monoroot =~ tr{/}{\\}; - -print ">>> monoroot = $monoroot\n"; - -my $buildscriptsdir = "$monoroot\\external\\buildscripts"; -my $addtoresultsdistdir = "$buildscriptsdir\\add_to_build_results\\monodistribution"; -my $monoprefix = "$monoroot\\tmp\\monoprefix"; -my $buildsroot = "$monoroot\\builds"; -my $distdir = "$buildsroot\\monodistribution"; -my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; - -my $build=0; -my $clean=0; -my $artifact=0; -my $debug=0; -my $checkoutOnTheFly=0; -my $forceDefaultBuildDeps=0; -my $existingMonoRootPath = ''; -my $arch32 = 0; -my $winPerl = "perl"; -my $winMonoRoot = $monoroot; -my $msBuildVersion = "14.0"; -my $buildDeps = ""; - -print(">>> Build All Args = @ARGV\n"); - -GetOptions( - 'build=i'=>\$build, - 'clean=i'=>\$clean, - 'artifact=i'=>\$artifact, - 'debug=i'=>\$debug, - 'arch32=i'=>\$arch32, - 'existingmono=s'=>\$existingMonoRootPath, - 'winperl=s'=>\$winPerl, - 'winmonoroot=s'=>\$winMonoRoot, - 'msbuildversion=s'=>\$msBuildVersion, - 'checkoutonthefly=i'=>\$checkoutOnTheFly, - 'builddeps=s'=>\$buildDeps, - 'forcedefaultbuilddeps=i'=>\$forceDefaultBuildDeps, -) or die ("illegal cmdline options"); - -my $monoRevision = `git rev-parse HEAD`; -chdir("$buildscriptsdir") eq 1 or die ("failed to chdir : $buildscriptsdir\n"); -my $buildScriptsRevision = `git rev-parse HEAD`; -chdir("$monoroot") eq 1 or die ("failed to chdir : $monoroot\n"); - -print(">>> Mono Revision = $monoRevision\n"); -print(">>> Build Scripts Revision = $buildScriptsRevision\n"); - -# Do any settings agnostic per-platform stuff -my $externalBuildDeps = ""; - -if ($buildDeps ne "" && not $forceDefaultBuildDeps) -{ - $externalBuildDeps = $buildDeps; -} -else -{ - $externalBuildDeps = "$monoroot/../../mono-build-deps/build"; -} - -my $existingExternalMonoRoot = "$externalBuildDeps\\mono"; -my $existingExternalMono = "$existingExternalMonoRoot\\win"; - -if ($clean) -{ - print(">>> Cleaning $monoprefix\n"); - rmtree($monoprefix); -} - -# ******************* Build Stage ************************** - -if ($build) -{ - if ($existingMonoRootPath eq "") - { - print(">>> No existing mono supplied. Checking for external...\n"); - - if (!(-d "$externalBuildDeps")) - { - if (not $checkoutonthefly) - { - print(">>> No external build deps found. Might as well try to check them out. If it fails, we'll continue and trust mono is in your PATH\n"); - } - - # Check out on the fly - print(">>> Checking out mono build dependencies to : $externalBuildDeps\n"); - my $repo = "https://ono.unity3d.com/unity-extra/mono-build-deps"; - print(">>> Cloning $repo at $externalBuildDeps\n"); - my $checkoutResult = system("hg", "clone", $repo, "$externalBuildDeps"); - - if ($checkoutOnTheFly && $checkoutResult ne 0) - { - die("failed to checkout mono build dependencies\n"); - } - } - - if (-d "$existingExternalMono") - { - print(">>> External mono found at : $existingExternalMono\n"); - - if (-d "$existingExternalMono/builds") - { - print(">>> Mono already extracted at : $existingExternalMono/builds\n"); - } - - if (!(-d "$existingExternalMono/builds")) - { - # We need to extract builds.zip - print(">>> Extracting mono builds.zip...\n"); - my $SevenZip = "$externalBuildDeps/7z/win64/7za.exe"; - print(">>> Using 7z : $SevenZip\n"); - system("$SevenZip", "x", "$existingExternalMono/builds.zip", "-o$existingExternalMono") eq 0 or die("Failed extracting mono builds.zip\n"); - } - - $existingMonoRootPath = "$existingExternalMono/builds"; - } - else - { - print(">>> No external mono found. Trusting a new enough mono is in your PATH.\n"); - } - } - - if ($existingMonoRootPath ne "" && !(-d $existingMonoRootPath)) - { - die("Existing mono not found at : $existingMonoRootPath\n"); - } - - system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--msbuildversion=$msBuildVersion", "--clean=$clean", "--debug=$debug", "--gc=bdwgc") eq 0 or die ('failed building mono bdwgc with VS\n'); - system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--msbuildversion=$msBuildVersion", "--clean=$clean", "--debug=$debug", "--gc=sgen") eq 0 or die ('failed building mono sgen with VS\n'); - - if (!(-d "$monoroot\\tmp")) - { - print(">>> Creating directory $monoroot\\tmp\n"); - system("mkdir $monoroot\\tmp") eq 0 or die ("failing creating $monoroot\\tmp\n");; - } - - if (!(-d "$monoprefix")) - { - print(">>> Creating directory $monoprefix\n"); - system("mkdir $monoprefix") eq 0 or die ("failing creating $monoprefix\n");; - } - - if (!(-d "$monoprefix\\bin")) - { - print(">>> Creating directory $monoprefix\\bin\n"); - system("mkdir $monoprefix\\bin") eq 0 or die ("failing creating $monoprefix\\bin\n");; - } - - # Copy over the VS built stuff that we want to use instead into the prefix directory - my $archNameForBuild = $arch32 ? 'Win32' : 'x64'; - my $configDirName = $debug ? "Debug" : "Release"; - - copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/mono-bdwgc.exe", "$monoprefix/bin/.") or die ("failed copying mono-bdwgc.exe\n"); - copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/mono-2.0-bdwgc.dll", "$monoprefix/bin/.") or die ("failed copying mono-2.0-bdwgc.dll\n"); - copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/mono-2.0-bdwgc.pdb", "$monoprefix/bin/.") or die ("failed copying mono-2.0-bdwgc.pdb\n"); - - copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-sgen.exe", "$monoprefix/bin/.") or die ("failed copying mono-sgen.exe\n"); - copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-2.0-sgen.dll", "$monoprefix/bin/.") or die ("failed copying mono-2.0-sgen.dll\n"); - copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-2.0-sgen.pdb", "$monoprefix/bin/.") or die ("failed copying mono-2.0-sgen.pdb\n"); - - # sgen as default exe - copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-sgen.exe", "$monoprefix/bin/mono.exe") or die ("failed copying mono-sgen.exe to mono.exe\n"); - - copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/MonoPosixHelper.dll", "$monoprefix/bin/.") or die ("failed copying MonoPosixHelper.dll\n"); - copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/MonoPosixHelper.pdb", "$monoprefix/bin/.") or die ("failed copying MonoPosixHelper.pdb\n"); - - system("xcopy /y /f $addtoresultsdistdir\\bin\\*.* $monoprefix\\bin\\") eq 0 or die ("Failed copying $addtoresultsdistdir/bin to $monoprefix/bin\n"); -} - -# ******************* Artifact Stage ************************** - -if ($artifact) -{ - print(">>> Creating artifact...\n"); - - # Do the platform specific logic to create the builds output structure that we want - - my $embedDirRoot = "$buildsroot\\embedruntimes"; - - my $embedDirArchDestination = $arch32 ? "$embedDirRoot\\win32" : "$embedDirRoot\\win64"; - my $distDirArchBin = $arch32 ? "$distdir\\bin" : "$distdir\\bin-x64"; - my $versionsOutputFile = $arch32 ? "$buildsroot\\versions-win32.txt" : "$buildsroot\\versions-win64.txt"; - - # Make sure the directory for our architecture is clean before we copy stuff into it - if (-d "$embedDirArchDestination") - { - print(">>> Cleaning $embedDirArchDestination\n"); - rmtree($embedDirArchDestination); - } - - if (-d "$distDirArchBin") - { - print(">>> Cleaning $distDirArchBin\n"); - rmtree($distDirArchBin); - } - - if (!(-d "$buildsroot")) - { - print(">>> Creating directory $buildsroot\n"); - system("mkdir $buildsroot") eq 0 or die("failed to create directory $buildsroot\n"); - } - - if (!(-d "$embedDirRoot")) - { - print(">>> Creating directory $embedDirRoot\n"); - system("mkdir $embedDirRoot") eq 0 or die("failed to create directory $embedDirRoot\n"); - } - - if (!(-d "$distdir")) - { - print(">>> Creating directory $distdir\n"); - system("mkdir $distdir") eq 0 or die("failed to create directory $distdir\n"); - } - - print(">>> Creating directory $embedDirArchDestination\n"); - system("mkdir $embedDirArchDestination") eq 0 or die("failed to create directory $embedDirArchDestination\n"); - - print(">>> Creating directory $distDirArchBin\n"); - system("mkdir $distDirArchBin") eq 0 or die("failed to create directory $distDirArchBin\n"); - - # embedruntimes directory setup - print(">>> Creating embedruntimes directory : $embedDirArchDestination\n"); - - copy("$monoprefix/bin/mono-2.0-bdwgc.dll", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-bdwgc.dll\n"); - copy("$monoprefix/bin/mono-2.0-bdwgc.pdb", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-bdwgc.pdb\n"); - - copy("$monoprefix/bin/mono-2.0-sgen.dll", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-sgen.dll\n"); - copy("$monoprefix/bin/mono-2.0-sgen.pdb", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-sgen.pdb\n"); - - copy("$monoprefix/bin/MonoPosixHelper.dll", "$embedDirArchDestination/.") or die ("failed copying MonoPosixHelper.dll\n"); - copy("$monoprefix/bin/MonoPosixHelper.pdb", "$embedDirArchDestination/.") or die ("failed copying MonoPosixHelper.pdb\n"); - - # monodistribution directory setup - print(">>> Creating monodistribution directory\n"); - copy("$monoprefix/bin/mono-2.0-bdwgc.dll", "$distDirArchBin/.") or die ("failed copying mono-2.0-bdwgc.dll\n"); - copy("$monoprefix/bin/mono-2.0-bdwgc.pdb", "$distDirArchBin/.") or die ("failed copying mono-2.0-bdwgc.pdb\n"); - - copy("$monoprefix/bin/mono-2.0-sgen.dll", "$distDirArchBin/.") or die ("failed copying mono-2.0-sgen.dll\n"); - copy("$monoprefix/bin/mono-2.0-sgen.pdb", "$distDirArchBin/.") or die ("failed copying mono-2.0-sgen.pdb\n"); - - copy("$monoprefix/bin/mono-sgen.exe", "$distDirArchBin/.") or die ("failed copying mono-sgen.exe\n"); - copy("$monoprefix/bin/mono-bdwgc.exe", "$distDirArchBin/.") or die ("failed copying mono-bdwgc.exe\n"); - copy("$monoprefix/bin/mono.exe", "$distDirArchBin/.") or die ("failed copying mono.exe\n"); - - copy("$monoprefix/bin/MonoPosixHelper.dll", "$distDirArchBin/.") or die ("failed copying MonoPosixHelper.dll\n"); - copy("$monoprefix/bin/MonoPosixHelper.pdb", "$distDirArchBin/.") or die ("failed copying MonoPosixHelper.pdb\n"); - - - # Output version information - print(">>> Creating version file : $versionsOutputFile\n"); - open(my $fh, '>', $versionsOutputFile) or die "Could not open file '$versionsOutputFile' $!"; - say $fh "mono-version ="; - my $monoVersionInfo = `$distDirArchBin\\mono --version`; - say $fh "$monoVersionInfo"; - say $fh "unity-mono-revision = $monoRevision"; - say $fh "unity-mono-build-scripts-revision = $buildScriptsRevision"; - my $tmp = `date /T`; - say $fh "$tmp"; - close $fh; -} -else -{ - print(">>> Skipping artifact creation\n"); -} +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; +use File::Copy; +use lib ('external/buildscripts', "../../Tools/perl_lib","perl_lib", 'external/buildscripts/perl_lib'); +use Tools qw(InstallNameTool); + +print ">>> PATH in Build All = $ENV{PATH}\n\n"; + +my $currentdir = getcwd(); + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); + +$monoroot =~ tr{/}{\\}; + +print ">>> monoroot = $monoroot\n"; + +my $buildscriptsdir = "$monoroot\\external\\buildscripts"; +my $addtoresultsdistdir = "$buildscriptsdir\\add_to_build_results\\monodistribution"; +my $monoprefix = "$monoroot\\tmp\\monoprefix"; +my $buildsroot = "$monoroot\\builds"; +my $distdir = "$buildsroot\\monodistribution"; +my $buildMachine = $ENV{UNITY_THISISABUILDMACHINE}; + +my $build=0; +my $clean=0; +my $artifact=0; +my $debug=0; +my $checkoutOnTheFly=0; +my $forceDefaultBuildDeps=0; +my $existingMonoRootPath = ''; +my $arch32 = 0; +my $winPerl = "perl"; +my $winMonoRoot = $monoroot; +my $msBuildVersion = "14.0"; +my $buildDeps = ""; + +print(">>> Build All Args = @ARGV\n"); + +GetOptions( + 'build=i'=>\$build, + 'clean=i'=>\$clean, + 'artifact=i'=>\$artifact, + 'debug=i'=>\$debug, + 'arch32=i'=>\$arch32, + 'existingmono=s'=>\$existingMonoRootPath, + 'winperl=s'=>\$winPerl, + 'winmonoroot=s'=>\$winMonoRoot, + 'msbuildversion=s'=>\$msBuildVersion, + 'checkoutonthefly=i'=>\$checkoutOnTheFly, + 'builddeps=s'=>\$buildDeps, + 'forcedefaultbuilddeps=i'=>\$forceDefaultBuildDeps, +) or die ("illegal cmdline options"); + +my $monoRevision = `git rev-parse HEAD`; +chdir("$buildscriptsdir") eq 1 or die ("failed to chdir : $buildscriptsdir\n"); +my $buildScriptsRevision = `git rev-parse HEAD`; +chdir("$monoroot") eq 1 or die ("failed to chdir : $monoroot\n"); + +print(">>> Mono Revision = $monoRevision\n"); +print(">>> Build Scripts Revision = $buildScriptsRevision\n"); + +# Do any settings agnostic per-platform stuff +my $externalBuildDeps = ""; + +if ($buildDeps ne "" && not $forceDefaultBuildDeps) +{ + $externalBuildDeps = $buildDeps; +} +else +{ + $externalBuildDeps = "$monoroot/../../mono-build-deps/build"; +} + +my $existingExternalMonoRoot = "$externalBuildDeps\\mono"; +my $existingExternalMono = "$existingExternalMonoRoot\\win"; + +if ($clean) +{ + print(">>> Cleaning $monoprefix\n"); + rmtree($monoprefix); +} + +# ******************* Build Stage ************************** + +if ($build) +{ + if ($existingMonoRootPath eq "") + { + print(">>> No existing mono supplied. Checking for external...\n"); + + if (!(-d "$externalBuildDeps")) + { + if (not $checkoutonthefly) + { + print(">>> No external build deps found. Might as well try to check them out. If it fails, we'll continue and trust mono is in your PATH\n"); + } + + # Check out on the fly + print(">>> Checking out mono build dependencies to : $externalBuildDeps\n"); + my $repo = "https://ono.unity3d.com/unity-extra/mono-build-deps"; + print(">>> Cloning $repo at $externalBuildDeps\n"); + my $checkoutResult = system("hg", "clone", $repo, "$externalBuildDeps"); + + if ($checkoutOnTheFly && $checkoutResult ne 0) + { + die("failed to checkout mono build dependencies\n"); + } + } + + if (-d "$existingExternalMono") + { + print(">>> External mono found at : $existingExternalMono\n"); + + if (-d "$existingExternalMono/builds") + { + print(">>> Mono already extracted at : $existingExternalMono/builds\n"); + } + + if (!(-d "$existingExternalMono/builds")) + { + # We need to extract builds.zip + print(">>> Extracting mono builds.zip...\n"); + my $SevenZip = "$externalBuildDeps/7z/win64/7za.exe"; + print(">>> Using 7z : $SevenZip\n"); + system("$SevenZip", "x", "$existingExternalMono/builds.zip", "-o$existingExternalMono") eq 0 or die("Failed extracting mono builds.zip\n"); + } + + $existingMonoRootPath = "$existingExternalMono/builds"; + } + else + { + print(">>> No external mono found. Trusting a new enough mono is in your PATH.\n"); + } + } + + if ($existingMonoRootPath ne "" && !(-d $existingMonoRootPath)) + { + die("Existing mono not found at : $existingMonoRootPath\n"); + } + + system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--msbuildversion=$msBuildVersion", "--clean=$clean", "--debug=$debug", "--gc=bdwgc") eq 0 or die ('failed building mono bdwgc with VS\n'); + system("$winPerl", "$winMonoRoot/external/buildscripts/build_runtime_vs.pl", "--build=$build", "--arch32=$arch32", "--msbuildversion=$msBuildVersion", "--clean=$clean", "--debug=$debug", "--gc=sgen") eq 0 or die ('failed building mono sgen with VS\n'); + + if (!(-d "$monoroot\\tmp")) + { + print(">>> Creating directory $monoroot\\tmp\n"); + system("mkdir $monoroot\\tmp") eq 0 or die ("failing creating $monoroot\\tmp\n");; + } + + if (!(-d "$monoprefix")) + { + print(">>> Creating directory $monoprefix\n"); + system("mkdir $monoprefix") eq 0 or die ("failing creating $monoprefix\n");; + } + + if (!(-d "$monoprefix\\bin")) + { + print(">>> Creating directory $monoprefix\\bin\n"); + system("mkdir $monoprefix\\bin") eq 0 or die ("failing creating $monoprefix\\bin\n");; + } + + # Copy over the VS built stuff that we want to use instead into the prefix directory + my $archNameForBuild = $arch32 ? 'Win32' : 'x64'; + my $configDirName = $debug ? "Debug" : "Release"; + + copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/mono-bdwgc.exe", "$monoprefix/bin/.") or die ("failed copying mono-bdwgc.exe\n"); + copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/mono-2.0-bdwgc.dll", "$monoprefix/bin/.") or die ("failed copying mono-2.0-bdwgc.dll\n"); + copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/mono-2.0-bdwgc.pdb", "$monoprefix/bin/.") or die ("failed copying mono-2.0-bdwgc.pdb\n"); + + copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-sgen.exe", "$monoprefix/bin/.") or die ("failed copying mono-sgen.exe\n"); + copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-2.0-sgen.dll", "$monoprefix/bin/.") or die ("failed copying mono-2.0-sgen.dll\n"); + copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-2.0-sgen.pdb", "$monoprefix/bin/.") or die ("failed copying mono-2.0-sgen.pdb\n"); + + # sgen as default exe + copy("$monoroot/msvc/build/sgen/$archNameForBuild/bin/$configDirName/mono-sgen.exe", "$monoprefix/bin/mono.exe") or die ("failed copying mono-sgen.exe to mono.exe\n"); + + copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/MonoPosixHelper.dll", "$monoprefix/bin/.") or die ("failed copying MonoPosixHelper.dll\n"); + copy("$monoroot/msvc/build/bdwgc/$archNameForBuild/bin/$configDirName/MonoPosixHelper.pdb", "$monoprefix/bin/.") or die ("failed copying MonoPosixHelper.pdb\n"); + + system("xcopy /y /f $addtoresultsdistdir\\bin\\*.* $monoprefix\\bin\\") eq 0 or die ("Failed copying $addtoresultsdistdir/bin to $monoprefix/bin\n"); +} + +# ******************* Artifact Stage ************************** + +if ($artifact) +{ + print(">>> Creating artifact...\n"); + + # Do the platform specific logic to create the builds output structure that we want + + my $embedDirRoot = "$buildsroot\\embedruntimes"; + + my $embedDirArchDestination = $arch32 ? "$embedDirRoot\\win32" : "$embedDirRoot\\win64"; + my $distDirArchBin = $arch32 ? "$distdir\\bin" : "$distdir\\bin-x64"; + my $versionsOutputFile = $arch32 ? "$buildsroot\\versions-win32.txt" : "$buildsroot\\versions-win64.txt"; + + # Make sure the directory for our architecture is clean before we copy stuff into it + if (-d "$embedDirArchDestination") + { + print(">>> Cleaning $embedDirArchDestination\n"); + rmtree($embedDirArchDestination); + } + + if (-d "$distDirArchBin") + { + print(">>> Cleaning $distDirArchBin\n"); + rmtree($distDirArchBin); + } + + if (!(-d "$buildsroot")) + { + print(">>> Creating directory $buildsroot\n"); + system("mkdir $buildsroot") eq 0 or die("failed to create directory $buildsroot\n"); + } + + if (!(-d "$embedDirRoot")) + { + print(">>> Creating directory $embedDirRoot\n"); + system("mkdir $embedDirRoot") eq 0 or die("failed to create directory $embedDirRoot\n"); + } + + if (!(-d "$distdir")) + { + print(">>> Creating directory $distdir\n"); + system("mkdir $distdir") eq 0 or die("failed to create directory $distdir\n"); + } + + print(">>> Creating directory $embedDirArchDestination\n"); + system("mkdir $embedDirArchDestination") eq 0 or die("failed to create directory $embedDirArchDestination\n"); + + print(">>> Creating directory $distDirArchBin\n"); + system("mkdir $distDirArchBin") eq 0 or die("failed to create directory $distDirArchBin\n"); + + # embedruntimes directory setup + print(">>> Creating embedruntimes directory : $embedDirArchDestination\n"); + + copy("$monoprefix/bin/mono-2.0-bdwgc.dll", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-bdwgc.dll\n"); + copy("$monoprefix/bin/mono-2.0-bdwgc.pdb", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-bdwgc.pdb\n"); + + copy("$monoprefix/bin/mono-2.0-sgen.dll", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-sgen.dll\n"); + copy("$monoprefix/bin/mono-2.0-sgen.pdb", "$embedDirArchDestination/.") or die ("failed copying mono-2.0-sgen.pdb\n"); + + copy("$monoprefix/bin/MonoPosixHelper.dll", "$embedDirArchDestination/.") or die ("failed copying MonoPosixHelper.dll\n"); + copy("$monoprefix/bin/MonoPosixHelper.pdb", "$embedDirArchDestination/.") or die ("failed copying MonoPosixHelper.pdb\n"); + + # monodistribution directory setup + print(">>> Creating monodistribution directory\n"); + copy("$monoprefix/bin/mono-2.0-bdwgc.dll", "$distDirArchBin/.") or die ("failed copying mono-2.0-bdwgc.dll\n"); + copy("$monoprefix/bin/mono-2.0-bdwgc.pdb", "$distDirArchBin/.") or die ("failed copying mono-2.0-bdwgc.pdb\n"); + + copy("$monoprefix/bin/mono-2.0-sgen.dll", "$distDirArchBin/.") or die ("failed copying mono-2.0-sgen.dll\n"); + copy("$monoprefix/bin/mono-2.0-sgen.pdb", "$distDirArchBin/.") or die ("failed copying mono-2.0-sgen.pdb\n"); + + copy("$monoprefix/bin/mono-sgen.exe", "$distDirArchBin/.") or die ("failed copying mono-sgen.exe\n"); + copy("$monoprefix/bin/mono-bdwgc.exe", "$distDirArchBin/.") or die ("failed copying mono-bdwgc.exe\n"); + copy("$monoprefix/bin/mono.exe", "$distDirArchBin/.") or die ("failed copying mono.exe\n"); + + copy("$monoprefix/bin/MonoPosixHelper.dll", "$distDirArchBin/.") or die ("failed copying MonoPosixHelper.dll\n"); + copy("$monoprefix/bin/MonoPosixHelper.pdb", "$distDirArchBin/.") or die ("failed copying MonoPosixHelper.pdb\n"); + + + # Output version information + print(">>> Creating version file : $versionsOutputFile\n"); + open(my $fh, '>', $versionsOutputFile) or die "Could not open file '$versionsOutputFile' $!"; + say $fh "mono-version ="; + my $monoVersionInfo = `$distDirArchBin\\mono --version`; + say $fh "$monoVersionInfo"; + say $fh "unity-mono-revision = $monoRevision"; + say $fh "unity-mono-build-scripts-revision = $buildScriptsRevision"; + my $tmp = `date /T`; + say $fh "$tmp"; + close $fh; +} +else +{ + print(">>> Skipping artifact creation\n"); +} diff --git a/external/buildscripts/build_win_wrapper.pl b/external/buildscripts/build_win_wrapper.pl index bbe16f80b94b..1b40fc71af15 100644 --- a/external/buildscripts/build_win_wrapper.pl +++ b/external/buildscripts/build_win_wrapper.pl @@ -1,218 +1,218 @@ -use Cwd; -use Cwd 'abs_path'; -use Getopt::Long; -use File::Basename; -use File::Path; -use Config; - -print ">>> My Path: $ENV{PATH}\n\n"; - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); -my $buildScriptsRoot = "$monoroot/external/buildscripts"; -print ">>> Mono checkout found in $monoroot\n\n"; - -my $cygwinRootWindows = ""; -my $monoInstallLinux = ""; -my $checkoutOnTheFly=0; -my $buildDeps = ""; -my $forceDefaultBuildDeps = 0; - -my @thisScriptArgs = (); -my @passAlongArgs = (); -foreach my $arg (@ARGV) -{ - push @backupArgs, $arg; - - if ($arg =~ /^--cygwin=/) - { - push @thisScriptArgs, $arg; - } - elsif ($arg =~ /^--existingmono=/) - { - push @thisScriptArgs, $arg; - } - elsif ($arg =~ /^--checkoutonthefly=/) - { - push @thisScriptArgs, $arg; - push @passAlongArgs, $arg; - } - elsif ($arg =~ /^--builddeps=/) - { - push @thisScriptArgs, $arg; - push @passAlongArgs, $arg; - } - elsif ($arg =~ /^--forcedefaultbuilddeps=/) - { - push @thisScriptArgs, $arg; - push @passAlongArgs, $arg; - } - else - { - push @passAlongArgs, $arg; - } -} - -print(">>> This Script Args = @thisScriptArgs\n"); -print(">>> Pass Along Args = @passAlongArgs\n"); - -@ARGV = @thisScriptArgs; -GetOptions( - 'cygwin=s'=>\$cygwinRootWindows, - 'existingmono=s'=>\$monoInstallLinux, - 'checkoutonthefly=i'=>\$checkoutOnTheFly, - 'builddeps=s'=>\$buildDeps, - 'forcedefaultbuilddeps=i'=>\$forceDefaultBuildDeps, -); - -my $externalBuildDeps = ""; - -if ($buildDeps ne "") -{ - $externalBuildDeps = $buildDeps; -} -else -{ - if (-d "$monoroot/../../mono-build-deps/build" || $forceDefaultBuildDeps) - { - $externalBuildDeps = "$monoroot/../../mono-build-deps/build"; - } - - if (!(-d "$externalBuildDeps")) - { - if (not $checkoutonthefly && $cygwinRootWindows eq "") - { - print(">>> No external build deps found and --cygwin not used. Might as well try to check them out. If the checkout fails, we'll continue, but the build will probably fail\n"); - } - - # Check out on the fly - print(">>> Checking out mono build dependencies to : $externalBuildDeps\n"); - my $repo = "https://ono.unity3d.com/unity-extra/mono-build-deps"; - print(">>> Cloning $repo at $externalBuildDeps\n"); - my $checkoutResult = system("hg", "clone", $repo, "$externalBuildDeps"); - - if ($checkoutOnTheFly && $checkoutResult ne 0) - { - die("failed to checkout mono build dependencies\n"); - } - } -} - -print(">>> externalBuildDeps = $externalBuildDeps\n"); - -my $SevenZip = "$externalBuildDeps/7z/win64/7za.exe"; - -# Attempt to find common default cygwin install locations -if ($cygwinRootWindows eq "") -{ - print(">>> No cygwin install specified. Looking for defaults...\n"); - - my $externalCygwin = "$externalBuildDeps/cygwin64/builds"; - my $externalCygwinZip = "$externalBuildDeps/cygwin64/builds.zip"; - - if (-d "$externalCygwin") - { - $cygwinRootWindows = $externalCygwin; - print(">>> Found Cygwin at : $cygwinRootWindows\n"); - } - elsif(-f "$externalCygwinZip") - { - print(">>> Found unextracted cygwin builds.zip : $externalCygwinZip\n"); - print(">>> Using 7z : $SevenZip\n"); - print(">>> Extracting...\n"); - system("$SevenZip", "x", "$externalCygwinZip", "-o$externalBuildDeps/cygwin64") eq 0 or die("Failed extracting cygwin\n"); - $cygwinRootWindows = $externalCygwin; - } - else - { - if ($forceDefaultBuildDeps) - { - die("\nCould not fined Cygwin in default external build deps location : $externalBuildDeps\n") - } - else - { - if (-d "C:\\Cygwin64") - { - $cygwinRootWindows = "C:\\Cygwin64"; - print(">>> Found Cygwin at : $cygwinRootWindows\n"); - } - elsif (-d "C:\\Cygwin") - { - $cygwinRootWindows = "C:\\Cygwin"; - print(">>> Found Cygwin at : $cygwinRootWindows\n"); - } - else - { - die("\nCould not fined Cygwin. Define path using --cygwin=\n") - } - } - } -} -else -{ - print(">>> Cygwin Path = $cygwinRootWindows\n"); -} - -if ($monoInstallLinux eq "") -{ - print(">>> No mono install specified. Looking for defaults...\n"); - - my $externalMono = "$externalBuildDeps/mono/win/builds"; - my $externalMonoZip = "$externalBuildDeps/mono/win/builds.zip"; - - if (-d "$externalMono") - { - $monoInstallLinux = $externalMono; - $monoInstallLinux =~ s/\\/\//g; - print(">>> Found Mono at : $monoInstallLinux\n"); - } - elsif(-f "$externalMonoZip") - { - print(">>> Found unextracted mono builds.zip : $externalMonoZip\n"); - print(">>> Using 7z : $SevenZip\n"); - print(">>> Extracting...\n"); - system("$SevenZip", "x", "$externalMonoZip", "-o$externalBuildDeps/mono/win") eq 0 or die("Failed extracting mono\n"); - $monoInstallLinux = $externalMono; - $monoInstallLinux =~ s/\\/\//g; - print(">>> Found Mono at : $monoInstallLinux\n"); - } - else - { - if ($forceDefaultBuildDeps) - { - die("\nCould not fined mono in default external build deps location : $externalBuildDeps\n") - } - else - { - if (-d "C:\\Program Files (x86)\\Mono") - { - # Pass over the cygwin format since I already have it escaped correctly to survive - # crossing over the shell - $monoInstallLinux = "/cygdrive/c/Program\\ Files\\ \\(x86\\)/Mono"; - print(">>> Found Mono at : $monoInstallLinux\n"); - } - else - { - die("\n--existingmono= is required and should be in the cygwin path format\n"); - } - } - } -} -else -{ - $monoInstallLinux =~ s/\\/\//g; - print(">>> Linux Mono Path = $monoInstallLinux\n"); -} - -push @passAlongArgs, "--existingmono=$monoInstallLinux" if $monoInstallLinux ne ""; - -my $windowsPerl = $Config{perlpath}; -print ">>> Perl Exe = $windowsPerl\n"; -push @passAlongArgs, "--winperl=$windowsPerl"; -push @passAlongArgs, "--winmonoroot=$monoroot"; - -# In some cases the file gets windowsified, use SHELLOPTS to avoid issues instead of dos2unixing the file, which will cause it to show up as modified by source control -$ENV{'SHELLOPTS'} = "igncr"; - -print ">>> Calling $cygwinRootWindows\\bin\\sh.exe with @passAlongArgs"; -system("$cygwinRootWindows\\bin\\sh.exe", "$monoroot/external/buildscripts/build_win_wrapper.sh", @passAlongArgs) eq 0 or die("failed building mono\n"); +use Cwd; +use Cwd 'abs_path'; +use Getopt::Long; +use File::Basename; +use File::Path; +use Config; + +print ">>> My Path: $ENV{PATH}\n\n"; + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); +my $buildScriptsRoot = "$monoroot/external/buildscripts"; +print ">>> Mono checkout found in $monoroot\n\n"; + +my $cygwinRootWindows = ""; +my $monoInstallLinux = ""; +my $checkoutOnTheFly=0; +my $buildDeps = ""; +my $forceDefaultBuildDeps = 0; + +my @thisScriptArgs = (); +my @passAlongArgs = (); +foreach my $arg (@ARGV) +{ + push @backupArgs, $arg; + + if ($arg =~ /^--cygwin=/) + { + push @thisScriptArgs, $arg; + } + elsif ($arg =~ /^--existingmono=/) + { + push @thisScriptArgs, $arg; + } + elsif ($arg =~ /^--checkoutonthefly=/) + { + push @thisScriptArgs, $arg; + push @passAlongArgs, $arg; + } + elsif ($arg =~ /^--builddeps=/) + { + push @thisScriptArgs, $arg; + push @passAlongArgs, $arg; + } + elsif ($arg =~ /^--forcedefaultbuilddeps=/) + { + push @thisScriptArgs, $arg; + push @passAlongArgs, $arg; + } + else + { + push @passAlongArgs, $arg; + } +} + +print(">>> This Script Args = @thisScriptArgs\n"); +print(">>> Pass Along Args = @passAlongArgs\n"); + +@ARGV = @thisScriptArgs; +GetOptions( + 'cygwin=s'=>\$cygwinRootWindows, + 'existingmono=s'=>\$monoInstallLinux, + 'checkoutonthefly=i'=>\$checkoutOnTheFly, + 'builddeps=s'=>\$buildDeps, + 'forcedefaultbuilddeps=i'=>\$forceDefaultBuildDeps, +); + +my $externalBuildDeps = ""; + +if ($buildDeps ne "") +{ + $externalBuildDeps = $buildDeps; +} +else +{ + if (-d "$monoroot/../../mono-build-deps/build" || $forceDefaultBuildDeps) + { + $externalBuildDeps = "$monoroot/../../mono-build-deps/build"; + } + + if (!(-d "$externalBuildDeps")) + { + if (not $checkoutonthefly && $cygwinRootWindows eq "") + { + print(">>> No external build deps found and --cygwin not used. Might as well try to check them out. If the checkout fails, we'll continue, but the build will probably fail\n"); + } + + # Check out on the fly + print(">>> Checking out mono build dependencies to : $externalBuildDeps\n"); + my $repo = "https://ono.unity3d.com/unity-extra/mono-build-deps"; + print(">>> Cloning $repo at $externalBuildDeps\n"); + my $checkoutResult = system("hg", "clone", $repo, "$externalBuildDeps"); + + if ($checkoutOnTheFly && $checkoutResult ne 0) + { + die("failed to checkout mono build dependencies\n"); + } + } +} + +print(">>> externalBuildDeps = $externalBuildDeps\n"); + +my $SevenZip = "$externalBuildDeps/7z/win64/7za.exe"; + +# Attempt to find common default cygwin install locations +if ($cygwinRootWindows eq "") +{ + print(">>> No cygwin install specified. Looking for defaults...\n"); + + my $externalCygwin = "$externalBuildDeps/cygwin64/builds"; + my $externalCygwinZip = "$externalBuildDeps/cygwin64/builds.zip"; + + if (-d "$externalCygwin") + { + $cygwinRootWindows = $externalCygwin; + print(">>> Found Cygwin at : $cygwinRootWindows\n"); + } + elsif(-f "$externalCygwinZip") + { + print(">>> Found unextracted cygwin builds.zip : $externalCygwinZip\n"); + print(">>> Using 7z : $SevenZip\n"); + print(">>> Extracting...\n"); + system("$SevenZip", "x", "$externalCygwinZip", "-o$externalBuildDeps/cygwin64") eq 0 or die("Failed extracting cygwin\n"); + $cygwinRootWindows = $externalCygwin; + } + else + { + if ($forceDefaultBuildDeps) + { + die("\nCould not fined Cygwin in default external build deps location : $externalBuildDeps\n") + } + else + { + if (-d "C:\\Cygwin64") + { + $cygwinRootWindows = "C:\\Cygwin64"; + print(">>> Found Cygwin at : $cygwinRootWindows\n"); + } + elsif (-d "C:\\Cygwin") + { + $cygwinRootWindows = "C:\\Cygwin"; + print(">>> Found Cygwin at : $cygwinRootWindows\n"); + } + else + { + die("\nCould not fined Cygwin. Define path using --cygwin=\n") + } + } + } +} +else +{ + print(">>> Cygwin Path = $cygwinRootWindows\n"); +} + +if ($monoInstallLinux eq "") +{ + print(">>> No mono install specified. Looking for defaults...\n"); + + my $externalMono = "$externalBuildDeps/mono/win/builds"; + my $externalMonoZip = "$externalBuildDeps/mono/win/builds.zip"; + + if (-d "$externalMono") + { + $monoInstallLinux = $externalMono; + $monoInstallLinux =~ s/\\/\//g; + print(">>> Found Mono at : $monoInstallLinux\n"); + } + elsif(-f "$externalMonoZip") + { + print(">>> Found unextracted mono builds.zip : $externalMonoZip\n"); + print(">>> Using 7z : $SevenZip\n"); + print(">>> Extracting...\n"); + system("$SevenZip", "x", "$externalMonoZip", "-o$externalBuildDeps/mono/win") eq 0 or die("Failed extracting mono\n"); + $monoInstallLinux = $externalMono; + $monoInstallLinux =~ s/\\/\//g; + print(">>> Found Mono at : $monoInstallLinux\n"); + } + else + { + if ($forceDefaultBuildDeps) + { + die("\nCould not fined mono in default external build deps location : $externalBuildDeps\n") + } + else + { + if (-d "C:\\Program Files (x86)\\Mono") + { + # Pass over the cygwin format since I already have it escaped correctly to survive + # crossing over the shell + $monoInstallLinux = "/cygdrive/c/Program\\ Files\\ \\(x86\\)/Mono"; + print(">>> Found Mono at : $monoInstallLinux\n"); + } + else + { + die("\n--existingmono= is required and should be in the cygwin path format\n"); + } + } + } +} +else +{ + $monoInstallLinux =~ s/\\/\//g; + print(">>> Linux Mono Path = $monoInstallLinux\n"); +} + +push @passAlongArgs, "--existingmono=$monoInstallLinux" if $monoInstallLinux ne ""; + +my $windowsPerl = $Config{perlpath}; +print ">>> Perl Exe = $windowsPerl\n"; +push @passAlongArgs, "--winperl=$windowsPerl"; +push @passAlongArgs, "--winmonoroot=$monoroot"; + +# In some cases the file gets windowsified, use SHELLOPTS to avoid issues instead of dos2unixing the file, which will cause it to show up as modified by source control +$ENV{'SHELLOPTS'} = "igncr"; + +print ">>> Calling $cygwinRootWindows\\bin\\sh.exe with @passAlongArgs"; +system("$cygwinRootWindows\\bin\\sh.exe", "$monoroot/external/buildscripts/build_win_wrapper.sh", @passAlongArgs) eq 0 or die("failed building mono\n"); diff --git a/external/buildscripts/collect_allbuilds.pl b/external/buildscripts/collect_allbuilds.pl index d6316e937504..1dbb19dd7987 100644 --- a/external/buildscripts/collect_allbuilds.pl +++ b/external/buildscripts/collect_allbuilds.pl @@ -1,66 +1,66 @@ -use lib ('external/buildscripts/perl_lib'); -use Cwd 'abs_path'; -use File::Basename; -use File::Copy::Recursive qw(dircopy rmove); -use File::Path; -use Tools qw(InstallNameTool); - - -my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); -my $monoroot = abs_path($monoroot); - -my $path = "incomingbuilds/"; - -rmtree("collectedbuilds"); -mkpath("collectedbuilds"); - -my @folders = (); -opendir(DIR, $path) or die "cant find $path: $!"; -# Sort the directories alphabetically so that classlibs comes before the -# OSX universal runtime (in the osx-i386 directory). Both builds produce the same -# files in some cases (notably libMonoPosixHelper.dylib), and we need the -# universal runtime build to be second, since it produces a universal binary -# and the classlibs build produces a 32-bit binary only. -my @files = sort readdir(DIR); -while (defined(my $file = shift @files)) { - - next if $file =~ /^\.\.?$/; - if (-d "$path$file"){ - if (-f "$path$file/versions.txt") { - system("cat $path$file/versions.txt >> collectedbuilds/versions-aggregated.txt"); - } - dircopy("$path$file","collectedbuilds/") or die ("failed copying $path$file"); - push @folders,"$path$file"; - } -} -closedir(DIR); - -system("find collectedbuilds -type f -name mono -exec chmod +x {} \\;") eq 0 or die("Failed chmodding"); -system("find collectedbuilds -type f -name mono-sgen -exec chmod +x {} \\;") eq 0 or die("Failed chmodding"); -system("find collectedbuilds -type f -name pedump -exec chmod +x {} \\;") eq 0 or die("Failed chmodding"); - -chdir("collectedbuilds"); - -rmove('versions-aggregated.txt', 'versions.txt'); - -open(MYFILE,">built_by_teamcity.txt"); -print MYFILE "These builds were created by teamcity from svn revision $ENV{BUILD_VCS_NUMBER}\n"; -print MYFILE "TC projectname was: $ENV{TEAMCITY_PROJECT_NAME}\n"; -print MYFILE "TC buildconfigname was: $ENV{TEAMCITY_BUILDCONF_NAME}\n"; -close(MYFILE); - -system("zip -r builds.zip *") eq 0 or die("failed zipping up builds"); - -if($^O eq "linux") -{ - system("$monoroot/../../mono-build-deps/build/7z/linux64/7za a builds.7z * -x!builds.zip") eq 0 or die("failed 7z up builds"); -} -elsif($^O eq 'darwin') -{ - system("$monoroot/../../mono-build-deps/build/7z/osx/7za a builds.7z * -x!builds.zip") eq 0 or die("failed 7z up builds"); -} -else -{ - die("Unsupported platform for build collection.") -} - +use lib ('external/buildscripts/perl_lib'); +use Cwd 'abs_path'; +use File::Basename; +use File::Copy::Recursive qw(dircopy rmove); +use File::Path; +use Tools qw(InstallNameTool); + + +my $monoroot = File::Spec->rel2abs(dirname(__FILE__) . "/../.."); +my $monoroot = abs_path($monoroot); + +my $path = "incomingbuilds/"; + +rmtree("collectedbuilds"); +mkpath("collectedbuilds"); + +my @folders = (); +opendir(DIR, $path) or die "cant find $path: $!"; +# Sort the directories alphabetically so that classlibs comes before the +# OSX universal runtime (in the osx-i386 directory). Both builds produce the same +# files in some cases (notably libMonoPosixHelper.dylib), and we need the +# universal runtime build to be second, since it produces a universal binary +# and the classlibs build produces a 32-bit binary only. +my @files = sort readdir(DIR); +while (defined(my $file = shift @files)) { + + next if $file =~ /^\.\.?$/; + if (-d "$path$file"){ + if (-f "$path$file/versions.txt") { + system("cat $path$file/versions.txt >> collectedbuilds/versions-aggregated.txt"); + } + dircopy("$path$file","collectedbuilds/") or die ("failed copying $path$file"); + push @folders,"$path$file"; + } +} +closedir(DIR); + +system("find collectedbuilds -type f -name mono -exec chmod +x {} \\;") eq 0 or die("Failed chmodding"); +system("find collectedbuilds -type f -name mono-sgen -exec chmod +x {} \\;") eq 0 or die("Failed chmodding"); +system("find collectedbuilds -type f -name pedump -exec chmod +x {} \\;") eq 0 or die("Failed chmodding"); + +chdir("collectedbuilds"); + +rmove('versions-aggregated.txt', 'versions.txt'); + +open(MYFILE,">built_by_teamcity.txt"); +print MYFILE "These builds were created by teamcity from svn revision $ENV{BUILD_VCS_NUMBER}\n"; +print MYFILE "TC projectname was: $ENV{TEAMCITY_PROJECT_NAME}\n"; +print MYFILE "TC buildconfigname was: $ENV{TEAMCITY_BUILDCONF_NAME}\n"; +close(MYFILE); + +system("zip -r builds.zip *") eq 0 or die("failed zipping up builds"); + +if($^O eq "linux") +{ + system("$monoroot/../../mono-build-deps/build/7z/linux64/7za a builds.7z * -x!builds.zip") eq 0 or die("failed 7z up builds"); +} +elsif($^O eq 'darwin') +{ + system("$monoroot/../../mono-build-deps/build/7z/osx/7za a builds.7z * -x!builds.zip") eq 0 or die("failed 7z up builds"); +} +else +{ + die("Unsupported platform for build collection.") +} + From 336490f2683748d2aaf498dec57de6ca022a325d Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Wed, 15 Aug 2018 23:23:10 -0400 Subject: [PATCH 286/582] Properly inflate pointer types in inflate_generic_type. Generic pointer types are encountered with 'unmanaged' constraint. --- mono/metadata/class.c | 8 ++++++++ mono/tests/Makefile.am | 5 +++-- mono/tests/generic-unmanaged-constraint.cs | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 mono/tests/generic-unmanaged-constraint.cs diff --git a/mono/metadata/class.c b/mono/metadata/class.c index b19c0e04b16f..b4199592dec7 100644 --- a/mono/metadata/class.c +++ b/mono/metadata/class.c @@ -817,6 +817,14 @@ inflate_generic_type (MonoImage *image, MonoType *type, MonoGenericContext *cont nt->data.generic_class = gclass; return nt; } + case MONO_TYPE_PTR: { + MonoType *nt, *inflated = inflate_generic_type (image, type->data.type, context, error); + if (!inflated || !mono_error_ok (error)) + return NULL; + nt = mono_metadata_type_dup (image, type); + nt->data.type = inflated; + return nt; + } default: return NULL; } diff --git a/mono/tests/Makefile.am b/mono/tests/Makefile.am index 8464b3f5c22d..367c62462deb 100755 --- a/mono/tests/Makefile.am +++ b/mono/tests/Makefile.am @@ -76,7 +76,7 @@ MCS_NO_UNSAFE = $(TOOLS_RUNTIME) $(CSC) -debug:portable \ -noconfig -nologo \ -nowarn:0162 -nowarn:0168 -nowarn:0219 -nowarn:0414 -nowarn:0618 \ -nowarn:0169 -nowarn:1690 -nowarn:0649 -nowarn:0612 -nowarn:3021 \ - -nowarn:0197 $(PROFILE_MCS_FLAGS) + -nowarn:0197 -langversion:7.3 $(PROFILE_MCS_FLAGS) MCS_NO_LIB = $(MCS_NO_UNSAFE) -unsafe MCS = $(MCS_NO_LIB) @@ -530,7 +530,8 @@ TESTS_CS_SRC= \ bug-59281.cs \ init_array_with_lazy_type.cs \ weak-fields.cs \ - threads-leak.cs + threads-leak.cs \ + generic-unmanaged-constraint.cs if AMD64 TESTS_CS_SRC += async-exc-compilation.cs finally_guard.cs finally_block_ending_in_dead_bb.cs diff --git a/mono/tests/generic-unmanaged-constraint.cs b/mono/tests/generic-unmanaged-constraint.cs new file mode 100644 index 000000000000..0718ec0c8980 --- /dev/null +++ b/mono/tests/generic-unmanaged-constraint.cs @@ -0,0 +1,17 @@ +using System; + +unsafe class Program +{ + public static int Main(string[] args) + { + return (int)(IntPtr)Generic.GetPtr(); + } +} + +unsafe class Generic where T : unmanaged +{ + public static T* GetPtr() + { + return (T*)null; + } +} From 987b67005223e5ee7f8a684c06583a67dd157c32 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Mon, 20 Aug 2018 16:51:18 -0400 Subject: [PATCH 287/582] Don't try to access metadata for dynamic method added to non-dynamic image. Fixes issue #10201. --- mono/metadata/loader.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mono/metadata/loader.c b/mono/metadata/loader.c index c2a959705486..8c7a8b7b9235 100644 --- a/mono/metadata/loader.c +++ b/mono/metadata/loader.c @@ -2159,6 +2159,10 @@ mono_method_get_marshal_info (MonoMethod *method, MonoMarshalSpec **mspecs) return; } + /* dynamic method added to non-dynamic image */ + if (method->dynamic) + return; + mono_class_init (klass); methodt = &klass->image->tables [MONO_TABLE_METHOD]; From acf07dc95def07e0346c669b6ebc38f4a08a3190 Mon Sep 17 00:00:00 2001 From: andreasr Date: Wed, 22 Aug 2018 17:09:36 +0200 Subject: [PATCH 288/582] [tls] Fixed ignoring error code when numBytesRead/Written is 0 in read/write --- .../System/Mono.UnityTls/UnityTlsContext.cs | 48 ++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index a9b21ce79b54..cdc7d632a660 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -172,7 +172,6 @@ public override void Flush () public override (int ret, bool wantMore) Read (byte[] buffer, int offset, int count) { - bool wantMore = false; int numBytesRead = 0; lastException = null; @@ -183,19 +182,27 @@ public override (int ret, bool wantMore) Read (byte[] buffer, int offset, int co if (lastException != null) throw lastException; - if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK || numBytesRead < count) // In contrast to some other APIs (like Apple security) WOULD_BLOCK is not set if we did a partial read - wantMore = true; - else if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_STREAM_CLOSED) - return (0, false); // According to Apple and Btls implementation this is how we should handle gracefully closed connections. - else - Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to read data from TLS context"); + switch (errorState.code) + { + case UnityTls.unitytls_error_code.UNITYTLS_SUCCESS: + // In contrast to some other APIs (like Apple security) WOULD_BLOCK is not set if we did a partial write. + // The Mono Api however requires us to set the wantMore flag also if we didn't read all the data. + return (numBytesRead, numBytesRead < count); + + case UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK: + return (numBytesRead, true); + + case UnityTls.unitytls_error_code.UNITYTLS_STREAM_CLOSED: + return (0, false); // According to Apple and Btls implementation this is how we should handle gracefully closed connections. - return (numBytesRead, wantMore); + default: + Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to read data to TLS context"); + return (0, false); + } } public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int count) { - bool wantMore = false; int numBytesWritten = 0; lastException = null; @@ -206,14 +213,23 @@ public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int c if (lastException != null) throw lastException; - if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK || numBytesWritten < count) // In contrast to some other APIs (like Apple security) WOULD_BLOCK is not set if we did a partial write - wantMore = true; - else if (errorState.code == UnityTls.unitytls_error_code.UNITYTLS_STREAM_CLOSED) - return (0, false); // According to Apple and Btls implementation this is how we should handle gracefully closed connections. - else - Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to write data to TLS context"); + switch (errorState.code) + { + case UnityTls.unitytls_error_code.UNITYTLS_SUCCESS: + // In contrast to some other APIs (like Apple security) WOULD_BLOCK is not set if we did a partial write. + // The Mono Api however requires us to set the wantMore flag also if we didn't write all the data. + return (numBytesWritten, numBytesWritten < count); + + case UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK: + return (numBytesWritten, true); + + case UnityTls.unitytls_error_code.UNITYTLS_STREAM_CLOSED: + return (0, false); // According to Apple and Btls implementation this is how we should handle gracefully closed connections. - return (numBytesWritten, wantMore); + default: + Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to write data to TLS context"); + return (0, false); + } } public override void Shutdown () From 28e179a18a35fd10210f8bf67539e6bba655e6c2 Mon Sep 17 00:00:00 2001 From: andreasr Date: Mon, 18 Jun 2018 17:12:37 +0200 Subject: [PATCH 289/582] UnityTls server no longer throws an exception if there is no client cert during client authentication --- mcs/class/System/Mono.UnityTls/UnityTlsContext.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index cdc7d632a660..fa93a69959c3 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -304,18 +304,17 @@ public override bool ProcessHandshake () if (lastException != null) throw lastException; - // Not done is not an error if we are server and don't ask for ClientCertificate - if (result == UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_NOT_DONE && IsServer && !AskForClientCertificate) + // Not done is only an error if we are a client. Even servers with AskForClientCertificate should ignore it since .Net client authentification is always optional. + if (IsServer && result == UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_NOT_DONE) { Unity.Debug.CheckAndThrow (errorState, "Handshake failed", AlertDescription.HandshakeFailure); - else - Unity.Debug.CheckAndThrow (errorState, result, "Handshake failed", AlertDescription.HandshakeFailure); - - // .Net implementation gives the server a verification callback (with null cert) even if AskForClientCertificate is false. - // We stick to this behavior here. - if (IsServer && !AskForClientCertificate) { + + // .Net implementation gives the server a verification callback (with null cert) even if AskForClientCertificate is false. + // We stick to this behavior here. if (!ValidateCertificate (null, null)) throw new TlsException (AlertDescription.HandshakeFailure, "Verification failure during handshake"); } + else + Unity.Debug.CheckAndThrow (errorState, result, "Handshake failed", AlertDescription.HandshakeFailure); return true; } From 34959e6809287b58d385f083150f586b3f29c68a Mon Sep 17 00:00:00 2001 From: Brian Raderman Date: Thu, 23 Aug 2018 16:13:35 -0400 Subject: [PATCH 290/582] Increasing sync for i2cpp debugger stack frames (case 1064723) The thread local storage of sequence points and method execution contexts between IL2CPP and the mono debugger code was only being synchronized at certain times, mainly when breakpoints were processed. This could lead to a loss of synchronization after functions are exited and debugger frame commands accessing invalid stack data. This change adds synchronization for these data structures right before any managed method exit, when the method execution context for that method is destroyed. Also optimizing memory allocations by only allocating when the stack grows and just reusing the memory otherwise. --- mono/mini/debugger-agent.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 3a8b7271a9d4..069f69ea0ff0 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -1149,7 +1149,8 @@ mono_debugger_run_debugger_thread_func(void* arg) } typedef struct { - void(*il2cpp_debugger_save_thread_context)(Il2CppThreadUnwindState* context); + void(*il2cpp_debugger_save_thread_context)(Il2CppThreadUnwindState* context, int frameCountAdjust); + void(*il2cpp_debugger_free_thread_context)(Il2CppThreadUnwindState* context); } MonoDebuggerRuntimeCallbacks; static MonoDebuggerRuntimeCallbacks callbacks; @@ -2679,7 +2680,7 @@ save_thread_context (MonoContext *ctx) else mono_thread_state_init_from_current (&tls->context); #else - callbacks.il2cpp_debugger_save_thread_context(&tls->il2cpp_context); + callbacks.il2cpp_debugger_save_thread_context(&tls->il2cpp_context, 0); #endif // !RUNTIME_IL2CPP } @@ -4213,6 +4214,8 @@ thread_end (MonoProfiler *prof, uintptr_t tid) /* Can't remove from tid_to_thread, as that would defeat the check in thread_start () */ #ifndef RUNTIME_IL2CPP MONO_GC_UNREGISTER_ROOT (tls->thread); +#else + callbacks.il2cpp_debugger_free_thread_context(&tls->il2cpp_context); #endif tls->thread = NULL; } @@ -12321,6 +12324,19 @@ gboolean unity_sequence_point_active(Il2CppSequencePoint *seqPoint) return FALSE; } +void il2cpp_save_current_thread_context_func_exit() +{ + DebuggerTlsData *tls; + + MonoInternalThread *thread = mono_thread_internal_current(); + + mono_loader_lock(); + tls = (DebuggerTlsData *)mono_g_hash_table_lookup(thread_to_tls, thread); + mono_loader_unlock(); + + callbacks.il2cpp_debugger_save_thread_context(&tls->il2cpp_context, -1); +} + #endif // RUNTIME_IL2CPP #else /* DISABLE_DEBUGGER_AGENT */ From 35d07480d75949346b07849b58530473ca541378 Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Thu, 9 Aug 2018 17:27:23 -0400 Subject: [PATCH 291/582] cleanup the threadinfo before shutdown to fix crash in pthread_key_clean_all --- mono/metadata/domain.c | 2 ++ mono/utils/mono-threads.c | 7 +++++++ mono/utils/mono-threads.h | 3 +++ 3 files changed, 12 insertions(+) diff --git a/mono/metadata/domain.c b/mono/metadata/domain.c index 2c680e952341..1045d9bee0d9 100644 --- a/mono/metadata/domain.c +++ b/mono/metadata/domain.c @@ -853,6 +853,8 @@ mono_cleanup (void) { mono_close_exe_image (); + mono_thread_info_cleanup (); + mono_defaults.corlib = NULL; mono_config_cleanup (); diff --git a/mono/utils/mono-threads.c b/mono/utils/mono-threads.c index d41724d7a6f9..bb4b730bbab5 100644 --- a/mono/utils/mono-threads.c +++ b/mono/utils/mono-threads.c @@ -738,6 +738,13 @@ thread_info_key_dtor (void *arg) } #endif +void +mono_thread_info_cleanup () +{ + mono_native_tls_free (thread_info_key); + mono_native_tls_free (thread_exited_key); +} + void mono_thread_info_init (size_t info_size) { diff --git a/mono/utils/mono-threads.h b/mono/utils/mono-threads.h index a25973253512..4011d1b1cb48 100644 --- a/mono/utils/mono-threads.h +++ b/mono/utils/mono-threads.h @@ -310,6 +310,9 @@ mono_thread_info_set_tid (THREAD_INFO_TYPE *info, MonoNativeThreadId tid) ((MonoThreadInfo*) info)->node.key = (uintptr_t) MONO_NATIVE_THREAD_ID_TO_UINT (tid); } +void +mono_thread_info_cleanup (void); + /* * @thread_info_size is sizeof (GcThreadInfo), a struct the GC defines to make it possible to have * a single block with info from both camps. From ba92569a0421c9d54584a323fd47e57352f2b585 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 28 Aug 2018 14:58:56 -0400 Subject: [PATCH 292/582] Implement mono_unity_backtrace_from_context same as old mono for now (case 1074280) --- mono/metadata/unity-utils.c | 7 ------- mono/mini/mini-exceptions.c | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/mono/metadata/unity-utils.c b/mono/metadata/unity-utils.c index 63d078e9ffc7..e35255672bbb 100644 --- a/mono/metadata/unity-utils.c +++ b/mono/metadata/unity-utils.c @@ -1098,13 +1098,6 @@ mono_unity_domain_set_config (MonoDomain *domain, const char *base_dir, const ch mono_domain_set_config (domain, base_dir, config_file_name); } -// only needed on OSX -MONO_API int -mono_unity_backtrace_from_context (void* context, void* array[], int count) -{ - return 0; -} - MONO_API MonoException* mono_unity_loader_get_last_error_and_error_prepare_exception () { diff --git a/mono/mini/mini-exceptions.c b/mono/mini/mini-exceptions.c index fa050c7d79f6..4d14312d406d 100644 --- a/mono/mini/mini-exceptions.c +++ b/mono/mini/mini-exceptions.c @@ -2712,6 +2712,33 @@ static void print_process_map (void) static gboolean handle_crash_loop = FALSE; +MONO_API int +mono_unity_backtrace_from_context (void* context, void* array[], int count) +{ +#ifdef MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX + MonoContext mctx; + void* ip = 0; + void** bp = 0; + int idx = 0; + + mono_sigctx_to_monoctx(context, &mctx); + + ip = (void*)MONO_CONTEXT_GET_IP(&mctx); + bp = (void**)MONO_CONTEXT_GET_BP(&mctx); + + while(ip && bp && count-- > 0) + { + array[idx++] = ip; + + ip = bp[1]; + bp = (void**)bp[0]; + } + + return idx; +#else + return 0; +#endif +} /* * mono_handle_native_crash: * From 32ff312d2bcd3e6f6a3f01ecee46184d5b94c2a1 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 28 Aug 2018 16:35:50 -0400 Subject: [PATCH 293/582] Get underlying method in case wrapper method is exposed to user code (case 1073634) --- mono/metadata/icall.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c index baf16bd07fbf..aeff0d4114dc 100644 --- a/mono/metadata/icall.c +++ b/mono/metadata/icall.c @@ -1878,6 +1878,10 @@ ves_icall_System_Reflection_MonoMethodInfo_get_parameter_info (MonoMethod *metho MonoClass *klass = NULL; if (!MONO_HANDLE_IS_NULL (reftype)) klass = mono_class_from_mono_type (MONO_HANDLE_GETVAL (reftype, type)); + + /* UNITY: handle wrapper methods leaking into call stacks. case 1073634 */ + method = mono_marshal_method_from_wrapper (method); + return mono_param_get_objects_internal (domain, method, klass, error); } From 58f92114704b41420db8ac7a6166808c8c156c95 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Mon, 20 Aug 2018 11:29:42 -0400 Subject: [PATCH 294/582] Build Mono for Android with NDK r16b Change the compiler used to build Mono for Android from gcc to clang, and update the NDK to version r16b. Also, remove some unused ARM architectures. --- external/buildscripts/build.pl | 113 ++++++------------ .../buildscripts/build_runtime_android.pl | 2 - mono/utils/mono-compiler.h | 2 +- 3 files changed, 38 insertions(+), 79 deletions(-) diff --git a/external/buildscripts/build.pl b/external/buildscripts/build.pl index 3578d474d357..fa3b5e163fbb 100644 --- a/external/buildscripts/build.pl +++ b/external/buildscripts/build.pl @@ -652,32 +652,31 @@ die("mono build deps are required and the directory was not found : $externalBuildDeps\n"); } - my $ndkVersion = "r13b"; - my $isArmArch = 1; - my $toolchainName = ""; + my $ndkVersion = "r16b"; + my $apiLevel = 16; + my $hostTriple = ""; my $platformRootPostfix = ""; my $useKraitPatch = 1; my $kraitPatchPath = "$monoroot/../../android_krait_signal_handler/build"; my $toolChainExtension = ""; - $isArmArch = 0 if ($androidArch eq "x86"); - - $ENV{ANDROID_PLATFORM} = "android-9"; - $ENV{GCC_VERSION} = "4.9"; + $ENV{ANDROID_PLATFORM} = "android-$apiLevel"; - if ($isArmArch) + if ($androidArch eq "armv7a") { - $ENV{GCC_PREFIX} = "arm-linux-androideabi-"; - $toolchainName = "$ENV{GCC_PREFIX}$ENV{GCC_VERSION}"; + $hostTriple = "arm-linux-androideabi"; $platformRootPostfix = "arm"; } - else + elsif ($androidArch eq "x86") { - $ENV{GCC_PREFIX} = "i686-linux-android-"; - $toolchainName = "x86-$ENV{GCC_VERSION}"; + $hostTriple = "i686-linux-android"; $platformRootPostfix = "x86"; $useKraitPatch = 0; } + else + { + die("Unsupported android architecture: $androidArch\n"); + } if ($^O eq "linux") { @@ -695,8 +694,6 @@ print "\n"; print(">>> Android Platform = $ENV{ANDROID_PLATFORM}\n"); print(">>> Android NDK Version = $ndkVersion\n"); - print(">>> Android GCC Prefix = $ENV{GCC_PREFIX}\n"); - print(">>> Android GCC Version = $ENV{GCC_VERSION}\n"); my $ndkName = ""; if($^O eq "linux") @@ -772,19 +769,11 @@ my $androidNdkRoot = $ENV{ANDROID_NDK_ROOT}; my $androidPlatformRoot = "$androidNdkRoot/platforms/$ENV{ANDROID_PLATFORM}/arch-$platformRootPostfix"; - my $androidToolchain = "$androidNdkRoot/toolchains/$toolchainName/prebuilt/$ENV{HOST_ENV}"; - if (!(-d "$androidToolchain")) - { - if (-d "$androidToolchain-x86") - { - $androidToolchain = "$androidToolchain-x86"; - } - else - { - $androidToolchain = "$androidToolchain-x86_64"; - } - } + my $androidToolchain = "$androidNdkRoot/toolchains/$hostTriple-clang"; + + print(">>> Generating android toolchain\n"); + system("$androidNdkRoot/build/tools/make_standalone_toolchain.py --arch $platformRootPostfix --api $apiLevel --install-dir $androidToolchain"); if ($runningOnWindows) { @@ -817,56 +806,39 @@ die("Failed to locate android platform root\n"); } - if ("$androidArch" eq 'armv5') - { - $ENV{CFLAGS} = "-DARM_FPU_NONE=1 -march=armv5te -mtune=xscale -msoft-float"; - } - elsif ("$androidArch" eq 'armv6_vfp') + if ($androidArch eq "armv7a") { - $ENV{CFLAGS} = "-DARM_FPU_VFP=1 -march=armv6 -mtune=xscale -msoft-float -mfloat-abi=softfp -mfpu=vfp -DHAVE_ARMV6=1"; - } - elsif ("$androidArch" eq 'armv7a') - { - $ENV{CFLAGS} = "-DARM_FPU_VFP=1 -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -DHAVE_ARMV6=1"; - $ENV{LDFLAGS} = "-Wl,--fix-cortex-a8"; - } - elsif ("$androidArch" eq 'x86') - { - $ENV{LDFLAGS} = "-lgcc" - } - else - { - die("Unsupported android arch : $androidArch\n"); + $ENV{CFLAGS} = "-DARM_FPU_VFP=1 -march=armv7-a -target armv7-none-linux-androideabi -DHAVE_ARMV6=1 -funwind-tables $ENV{CFLAGS}"; + $ENV{LDFLAGS} = "-Wl,--fix-cortex-a8 -Wl,-rpath-link=$androidPlatformRoot/usr/lib $ENV{LDFLAGS}"; } - if ($isArmArch) - { - $ENV{CFLAGS} = "-funwind-tables $ENV{CFLAGS}"; - $ENV{LDFLAGS} = "-Wl,-rpath-link=$androidPlatformRoot/usr/lib $ENV{LDFLAGS}"; - } + my $compilerSysroot = "$androidNdkRoot/sysroot"; + my $archISystem = "$compilerSysroot/usr/include/$hostTriple"; + my $unifiedISystem = "$compilerSysroot/usr/include"; + + $ENV{CC} = "$androidToolchain/bin/clang -v -isystem $archISystem -isystem $unifiedISystem"; + $ENV{CXX} = "$androidToolchain/bin/clang++ -isystem $archISystem -isystem $unifiedISystem"; + $ENV{CPP} = "$androidToolchain/bin/clang -E -isystem $archISystem -isystem $unifiedISystem"; + $ENV{CXXCPP} = "$androidToolchain/bin/clang++ -E -isystem $archISystem -isystem $unifiedISystem"; - $ENV{PATH} = "$androidToolchain/bin:$ENV{PATH}"; - $ENV{CC} = "$androidToolchain/bin/$ENV{GCC_PREFIX}gcc$toolChainExtension --sysroot=$androidPlatformRoot"; - $ENV{CXX} = "$androidToolchain/bin/$ENV{GCC_PREFIX}g++$toolChainExtension --sysroot=$androidPlatformRoot"; - $ENV{CPP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}cpp$toolChainExtension"; - $ENV{CXXCPP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}cpp$toolChainExtension"; $ENV{CPATH} = "$androidPlatformRoot/usr/include"; - $ENV{LD} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ld$toolChainExtension"; - $ENV{AS} = "$androidToolchain/bin/$ENV{GCC_PREFIX}as$toolChainExtension"; - $ENV{AR} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ar$toolChainExtension"; - $ENV{RANLIB} = "$androidToolchain/bin/$ENV{GCC_PREFIX}ranlib$toolChainExtension"; - $ENV{STRIP} = "$androidToolchain/bin/$ENV{GCC_PREFIX}strip$toolChainExtension"; - $ENV{CFLAGS} = "-DANDROID -DPLATFORM_ANDROID -DLINUX -D__linux__ -DHAVE_USR_INCLUDE_MALLOC_H -DPAGE_SIZE=0x1000 -D_POSIX_PATH_MAX=256 -DS_IWRITE=S_IWUSR -DHAVE_PTHREAD_MUTEX_TIMEDLOCK -fpic -g -ffunction-sections -fdata-sections $ENV{CFLAGS}"; + $ENV{LD} = "$androidToolchain/bin/$hostTriple-ld"; + $ENV{AS} = "$androidToolchain/bin/$hostTriple-as"; + $ENV{AR} = "$androidToolchain/bin/$hostTriple-ar"; + $ENV{RANLIB} = "$androidToolchain/bin/$hostTriple-ranlib"; + $ENV{STRIP} = "$androidToolchain/bin/$hostTriple-strip"; + + $ENV{CFLAGS} = "-DANDROID -D__ANDROID_API__=16 -DPLATFORM_ANDROID -DLINUX -D__linux__ -DHAVE_USR_INCLUDE_MALLOC_H -D_POSIX_PATH_MAX=256 -DS_IWRITE=S_IWUSR -DHAVE_PTHREAD_MUTEX_TIMEDLOCK -fpic -g -ffunction-sections -fdata-sections $ENV{CFLAGS}"; $ENV{CXXFLAGS} = $ENV{CFLAGS}; $ENV{CPPFLAGS} = $ENV{CFLAGS}; if ($useKraitPatch) { - $ENV{LDFLAGS} = "-Wl,--wrap,sigaction -L$kraitPatchPath/obj/local/armeabi -lkrait-signal-handler $ENV{LDFLAGS}"; + $ENV{LDFLAGS} = "-Wl,--wrap,sigaction -L$kraitPatchPath/obj/local/armeabi-v7a -lkrait-signal-handler $ENV{LDFLAGS}"; } - $ENV{LDFLAGS} = "-Wl,--no-undefined -Wl,--gc-sections -ldl -lm -llog -lc $ENV{LDFLAGS}"; + $ENV{LDFLAGS} = "--sysroot=$androidPlatformRoot -Wl,--no-undefined -Wl,--gc-sections -ldl -lm -llog -lc $ENV{LDFLAGS}"; print "\n"; print ">>> Environment:\n"; @@ -903,18 +875,7 @@ chdir("$monoroot") eq 1 or die ("failed to chdir to $monoroot\n"); } - if ($isArmArch) - { - push @configureparams, "--host=armv5-linux-androideabi"; - } - elsif ("$androidArch" eq 'x86') - { - push @configureparams, "--host=i686-linux-android"; - } - else - { - die("Unsupported android arch : $androidArch\n"); - } + push @configureparams, "--host=$hostTriple"; push @configureparams, "--cache-file=android-$androidArch.cache" if ($enableCacheFile); diff --git a/external/buildscripts/build_runtime_android.pl b/external/buildscripts/build_runtime_android.pl index baf687dc9034..285c6b748977 100644 --- a/external/buildscripts/build_runtime_android.pl +++ b/external/buildscripts/build_runtime_android.pl @@ -21,8 +21,6 @@ # By default, build runtime for all the variants we need. But allow something to specify an individual variation to build if ($androidArch eq "") { - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv5", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv5\n"); - system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv6_vfp", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv6_vfp\n"); system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=armv7a", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for armv7a\n"); system("perl", "$buildScriptsRoot/build.pl", "--build=1", "--clean=1", "--artifact=1", "--arch32=1", "--androidarch=x86", "--forcedefaultbuilddeps=1", "--windowssubsystemforlinux=$windowsSubsystemForLinux") eq 0 or die ("Failed building mono for x86\n"); } diff --git a/mono/utils/mono-compiler.h b/mono/utils/mono-compiler.h index 51439b5f6d67..c53dc8b7dc4d 100644 --- a/mono/utils/mono-compiler.h +++ b/mono/utils/mono-compiler.h @@ -178,7 +178,7 @@ typedef int32_t __mono_off32_t; * we must carefully declare the 32-bit mmap here without changing the ABI along the way. Carefully because * in this instance off_t is redeclared to be 64-bit and that's not what we want. */ -void* mmap (void*, size_t, int, int, int, __mono_off32_t); +//void* mmap (void*, size_t, int, int, int, __mono_off32_t); #endif /* !mmap */ #ifdef HAVE_SYS_SENDFILE_H From edccc3b8d88b3c389cfa300f47ca71c49230f7d7 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Wed, 29 Aug 2018 12:23:20 -0400 Subject: [PATCH 295/582] Don't define mmap for the clang toolchain. The `mmap` definition problem only occurs with the GCC toolchain. With the clang toolchain we should not redefine `mmap`, and instead use the definition from the NDK headers. --- mono/utils/mono-compiler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mono/utils/mono-compiler.h b/mono/utils/mono-compiler.h index c53dc8b7dc4d..7bdf1e256a1e 100644 --- a/mono/utils/mono-compiler.h +++ b/mono/utils/mono-compiler.h @@ -171,14 +171,14 @@ typedef int32_t __mono_off32_t; #include #endif -#if !defined(mmap) +#if !defined(mmap) && !defined(__clang__) /* Unified headers before API 21 do not declare mmap when LARGE_FILES are used (via -D_FILE_OFFSET_BITS=64) * which is always the case when Mono build targets Android. The problem here is that the unified headers * map `mmap` to `mmap64` if large files are enabled but this api exists only in API21 onwards. Therefore * we must carefully declare the 32-bit mmap here without changing the ABI along the way. Carefully because * in this instance off_t is redeclared to be 64-bit and that's not what we want. */ -//void* mmap (void*, size_t, int, int, int, __mono_off32_t); +void* mmap (void*, size_t, int, int, int, __mono_off32_t); #endif /* !mmap */ #ifdef HAVE_SYS_SENDFILE_H From b597755c32ac7738ceea4a77f314f82e66fc51b1 Mon Sep 17 00:00:00 2001 From: andreasr Date: Sat, 1 Sep 2018 01:16:26 +0200 Subject: [PATCH 296/582] Fixed SslStream/UnityTlsContext not reporting gracefully closed Streams on read Due to the way MobileAuthenticatedStream.InteralRead sets the "wouldBlock" the previous checks would falsely not report a closed stream, which led to ReadAsync becoming stuck indefinitely (no hangs have been observed/reported with "normal" Read, but I can't exclude that this might have happend as well with unlucky timing) --- .../System/Mono.UnityTls/UnityTlsContext.cs | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index fa93a69959c3..fc6babc1807f 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -41,6 +41,7 @@ unsafe internal class UnityTlsContext : MobileTlsContext MonoTlsConnectionInfo connectioninfo; bool isAuthenticated = false; bool hasContext = false; + bool closedGraceful = false; // Memory-buffer byte [] writeBuffer; @@ -196,7 +197,9 @@ public override (int ret, bool wantMore) Read (byte[] buffer, int offset, int co return (0, false); // According to Apple and Btls implementation this is how we should handle gracefully closed connections. default: - Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to read data to TLS context"); + if (!closedGraceful) { + Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to read data to TLS context"); + } return (0, false); } } @@ -387,17 +390,28 @@ private size_t ReadCallback (byte* buffer, size_t bufferLen, UnityTls.unitytls_e bool wouldBlock; int numBytesRead = Parent.InternalRead (readBuffer, 0, bufferLen, out wouldBlock); - if (wouldBlock) { - UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK); - return 0; - } + + // Non graceful exit. if (numBytesRead < 0) { UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_READ_FAILED); - return 0; + } else if (numBytesRead > 0) { + Marshal.Copy (readBuffer, 0, (IntPtr)buffer, bufferLen); + } else { // numBytesRead == 0 + // careful when rearranging this: wouldBlock might be true even if stream was closed abruptly. + if (wouldBlock) { + UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WOULD_BLOCK); + } + // indicates graceful exit. + // UnityTls only accepts an exit as gracful, if it was closed via a special TLS protocol message. + // Both .Net and MobileTlsContext have a different idea of this concept though! + else { + closedGraceful = true; + UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_READ_FAILED); + } } - Marshal.Copy (readBuffer, 0, (IntPtr)buffer, bufferLen); - return numBytesRead; + // Note that UnityTls ignores this number when raising an error. + return numBytesRead; } catch (Exception ex) { // handle all exceptions and store them for later since we don't want to let them go through native code. UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); if (lastException == null) From dcf1bb0d78dc7f96dfdda621989db48896b78dda Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Tue, 4 Sep 2018 10:50:44 +0200 Subject: [PATCH 297/582] Export bdwgc symbols we need to patch --- external/bdwgc | 2 +- msvc/libmono-dynamic.def | 10 ++++++++++ msvc/libmono-dynamic.vcxproj | 16 ++++++++-------- 3 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 msvc/libmono-dynamic.def diff --git a/external/bdwgc b/external/bdwgc index f40bf2ab729f..df5606e8c065 160000 --- a/external/bdwgc +++ b/external/bdwgc @@ -1 +1 @@ -Subproject commit f40bf2ab729fa043a20e400839aae1ffce03e2ca +Subproject commit df5606e8c0655de80ee339c932f2878fd23b0981 diff --git a/msvc/libmono-dynamic.def b/msvc/libmono-dynamic.def new file mode 100644 index 000000000000..f344e2b0f945 --- /dev/null +++ b/msvc/libmono-dynamic.def @@ -0,0 +1,10 @@ +LIBRARY mono-2.0-bdwgc.dll +EXPORTS +GC_dirty_inner +GC_malloc +GC_malloc_uncollectable +GC_malloc_kind +GC_malloc_atomic +GC_gcj_malloc +GC_make_descriptor +GC_free diff --git a/msvc/libmono-dynamic.vcxproj b/msvc/libmono-dynamic.vcxproj index d63cc408b1e6..97d84b96c17a 100644 --- a/msvc/libmono-dynamic.vcxproj +++ b/msvc/libmono-dynamic.vcxproj @@ -122,8 +122,8 @@ $(GC_LIB);%(AdditionalDependencies) %(AdditionalLibraryDirectories) - - + /WHOLEARCHIVE:libgcbdwgc.lib + libmono-dynamic.def $(MONO_BUILD_DIR_PREFIX)$(Platform)\lib\$(Configuration)\$(TargetName).lib @@ -162,8 +162,8 @@ $(GC_LIB);%(AdditionalDependencies) %(AdditionalLibraryDirectories) - - + /WHOLEARCHIVE:libgcbdwgc.lib + libmono-dynamic.def $(MONO_BUILD_DIR_PREFIX)$(Platform)\lib\$(Configuration)\$(TargetName).lib @@ -194,8 +194,8 @@ $(GC_LIB);%(AdditionalDependencies) %(AdditionalLibraryDirectories) - - + /WHOLEARCHIVE:libgcbdwgc.lib + libmono-dynamic.def $(MONO_BUILD_DIR_PREFIX)$(Platform)\lib\$(Configuration)\$(TargetName).lib @@ -234,8 +234,8 @@ $(GC_LIB);%(AdditionalDependencies) %(AdditionalLibraryDirectories) - - + /WHOLEARCHIVE:libgcbdwgc.lib + libmono-dynamic.def $(MONO_BUILD_DIR_PREFIX)$(Platform)\lib\$(Configuration)\$(TargetName).lib From b9868e5d590dc56d08cc92b639a1fd104f5c64a9 Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Tue, 4 Sep 2018 16:24:26 +0200 Subject: [PATCH 298/582] switch bdwgc repo to unity-master branch --- external/bdwgc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/bdwgc b/external/bdwgc index df5606e8c065..395d3e4b972d 160000 --- a/external/bdwgc +++ b/external/bdwgc @@ -1 +1 @@ -Subproject commit df5606e8c0655de80ee339c932f2878fd23b0981 +Subproject commit 395d3e4b972d7b6f80d10325dfd5267ecd6208eb From 4d1bc5d17563eb244bf50619ff9207d2697b367e Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 4 Sep 2018 13:23:26 -0400 Subject: [PATCH 299/582] Avoid deadlock during GC. Check for GC_DONT_GC environment variable at startup rather than during collection with world stopped since g_hasenv may take OS locks and encounter deadlock. (case 1077203) --- mono/metadata/boehm-gc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index 4f875a22961e..05cf8b1643d4 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -60,6 +60,7 @@ void *pthread_get_stackaddr_np(pthread_t); static gboolean gc_initialized = FALSE; static gboolean gc_strict_wbarriers = FALSE; +static gboolean gc_dont_gc_env = FALSE; static mono_mutex_t mono_gc_lock; typedef void (*GC_push_other_roots_proc)(void); @@ -208,6 +209,9 @@ mono_gc_base_init (void) g_free (debug_opts); } + /* cache value rather than calling during collection since g_hasenv may take locks and can deadlock */ + gc_dont_gc_env = g_hasenv ("GC_DONT_GC"); + GC_init (); GC_set_warn_proc (mono_gc_warning); @@ -1539,7 +1543,7 @@ mono_gc_is_moving (void) gboolean mono_gc_is_disabled (void) { - if (GC_dont_gc || g_hasenv ("GC_DONT_GC")) + if (GC_dont_gc || gc_dont_gc_env) return TRUE; else return FALSE; From db4b2f5efcd9555f183c753b1ee0e6026da10822 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Mon, 10 Sep 2018 14:14:23 -0400 Subject: [PATCH 300/582] Revert "Get underlying method in case wrapper method is exposed to user code (case 1073634)" This reverts commit 32ff312d2bcd3e6f6a3f01ecee46184d5b94c2a1. --- mono/metadata/icall.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c index aeff0d4114dc..baf16bd07fbf 100644 --- a/mono/metadata/icall.c +++ b/mono/metadata/icall.c @@ -1878,10 +1878,6 @@ ves_icall_System_Reflection_MonoMethodInfo_get_parameter_info (MonoMethod *metho MonoClass *klass = NULL; if (!MONO_HANDLE_IS_NULL (reftype)) klass = mono_class_from_mono_type (MONO_HANDLE_GETVAL (reftype, type)); - - /* UNITY: handle wrapper methods leaking into call stacks. case 1073634 */ - method = mono_marshal_method_from_wrapper (method); - return mono_param_get_objects_internal (domain, method, klass, error); } From 2eaf5ba3268662a797e2dc0d74fb73a603fac8f3 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Fri, 7 Sep 2018 13:37:28 -0400 Subject: [PATCH 301/582] Don't assume an Invoke method (case 1075581) The delegate begin invoke implementation needs to determine whether it should invoke a method or a delegate. Previously, it assumed the presence of a method named `Invoke` on the declaring type of the method meant that type was a delegate. Of course, the user can name a method `Invoke`! If that happened, the method was never really called, because that `Invoke` method was called instead. --- mono/metadata/threadpool.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mono/metadata/threadpool.c b/mono/metadata/threadpool.c index 7bf9a28edaf7..ebc915b8497f 100644 --- a/mono/metadata/threadpool.c +++ b/mono/metadata/threadpool.c @@ -432,7 +432,11 @@ mono_threadpool_begin_invoke (MonoDomain *domain, MonoObject *target, MonoMethod error_init (error); - message = mono_method_call_message_new (method, params, mono_get_delegate_invoke (method->klass), (params != NULL) ? (&async_callback) : NULL, (params != NULL) ? (&state) : NULL, error); + MonoMethod* invoke = NULL; + if (mono_class_is_delegate(method->klass->parent)) + invoke = mono_get_delegate_invoke (method->klass); + + message = mono_method_call_message_new (method, params, invoke, (params != NULL) ? (&async_callback) : NULL, (params != NULL) ? (&state) : NULL, error); return_val_if_nok (error, NULL); async_call = (MonoAsyncCall*) mono_object_new_checked (domain, async_call_klass, error); From 436a869c9d8b77cac6f9cd6402a3e14d6636fb3e Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Thu, 13 Sep 2018 10:40:15 -0400 Subject: [PATCH 302/582] Only link bdwgc related libraries when targeting bdwgc --- msvc/libmono-dynamic.vcxproj | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/msvc/libmono-dynamic.vcxproj b/msvc/libmono-dynamic.vcxproj index 97d84b96c17a..e893d77c6f2a 100644 --- a/msvc/libmono-dynamic.vcxproj +++ b/msvc/libmono-dynamic.vcxproj @@ -122,8 +122,8 @@ $(GC_LIB);%(AdditionalDependencies) %(AdditionalLibraryDirectories) - /WHOLEARCHIVE:libgcbdwgc.lib - libmono-dynamic.def + /WHOLEARCHIVE:libgcbdwgc.lib + libmono-dynamic.def $(MONO_BUILD_DIR_PREFIX)$(Platform)\lib\$(Configuration)\$(TargetName).lib @@ -162,8 +162,8 @@ $(GC_LIB);%(AdditionalDependencies) %(AdditionalLibraryDirectories) - /WHOLEARCHIVE:libgcbdwgc.lib - libmono-dynamic.def + /WHOLEARCHIVE:libgcbdwgc.lib + libmono-dynamic.def $(MONO_BUILD_DIR_PREFIX)$(Platform)\lib\$(Configuration)\$(TargetName).lib @@ -194,8 +194,8 @@ $(GC_LIB);%(AdditionalDependencies) %(AdditionalLibraryDirectories) - /WHOLEARCHIVE:libgcbdwgc.lib - libmono-dynamic.def + /WHOLEARCHIVE:libgcbdwgc.lib + libmono-dynamic.def $(MONO_BUILD_DIR_PREFIX)$(Platform)\lib\$(Configuration)\$(TargetName).lib @@ -234,8 +234,8 @@ $(GC_LIB);%(AdditionalDependencies) %(AdditionalLibraryDirectories) - /WHOLEARCHIVE:libgcbdwgc.lib - libmono-dynamic.def + /WHOLEARCHIVE:libgcbdwgc.lib + libmono-dynamic.def $(MONO_BUILD_DIR_PREFIX)$(Platform)\lib\$(Configuration)\$(TargetName).lib From d76f307a863228bfbbebc970e3756742d4cdf94d Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 4 Sep 2018 21:37:43 -0400 Subject: [PATCH 303/582] Handle ref returns in runtime invoke wrappers (case 1076527) Indirectly load ref return values in invoke wrappers and return by value. Don't share wrappers with ref returns since indirect load is used. Add soft debugger support for methods with ref returns. --- .../Mono.Debugger.Soft/Test/dtest-app.cs | 16 +++++++++ mcs/class/Mono.Debugger.Soft/Test/dtest.cs | 36 +++++++++++++------ mono/metadata/marshal.c | 11 ++++-- mono/mini/debugger-agent.c | 15 ++++++-- 4 files changed, 64 insertions(+), 14 deletions(-) diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs index 20df95287288..76cf1d6624a8 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs @@ -350,6 +350,7 @@ public static int Main (String[] args) { set_ip (); step_filters (); pointers (); + ref_return (); if (args.Length > 0 && args [0] == "local-reflect") local_reflect (); if (args.Length > 0 && args [0] == "domain-test") @@ -1739,6 +1740,21 @@ public static unsafe void pointers () { fixed (int* pa = a) pointer_arguments (pa, &s); } + + [MethodImplAttribute (MethodImplOptions.NoInlining)] + public static void ref_return () { + + } + + static int ret_val = 1; + public static ref int get_ref_int() { + return ref ret_val; + } + + static string ref_return_string = "byref"; + public static ref string get_ref_string() { + return ref ref_return_string; + } } public class SentinelClass : MarshalByRefObject { diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs index 3d0c5e3d43f7..4539e17dbf67 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs @@ -4398,15 +4398,31 @@ public void Pointer_GetValue () { } [Test] - public void InvokeGenericMethod () { - Event e = run_until ("bp1"); - StackFrame frame = e.Thread.GetFrames()[0]; - TypeMirror t = frame.Method.DeclaringType; - MethodMirror m; - m = t.GetMethod ("generic_method"); - AssertThrows (delegate { - t.InvokeMethod (e.Thread, m, null); - }); - } + public void InvokeGenericMethod () { + Event e = run_until ("bp1"); + StackFrame frame = e.Thread.GetFrames()[0]; + TypeMirror t = frame.Method.DeclaringType; + MethodMirror m; + m = t.GetMethod ("generic_method"); + AssertThrows (delegate { + t.InvokeMethod (e.Thread, m, null); + }); + } + + [Test] + public void InvokeRefReturnMethod () { + Event e = run_until ("ref_return"); + StackFrame frame = e.Thread.GetFrames()[0]; + TypeMirror t = frame.Method.DeclaringType; + MethodMirror m; + + m = t.GetMethod ("get_ref_int"); + var v = t.InvokeMethod (e.Thread, m, null); + AssertValue (1, v); + + m = t.GetMethod ("get_ref_string"); + v = t.InvokeMethod (e.Thread, m, null); + AssertValue ("byref", v); + } } // class DebuggerTests } // namespace diff --git a/mono/metadata/marshal.c b/mono/metadata/marshal.c index f95f51cb79c8..5bc1a06240e0 100644 --- a/mono/metadata/marshal.c +++ b/mono/metadata/marshal.c @@ -3936,6 +3936,11 @@ get_runtime_invoke_type (MonoType *t, gboolean ret) if (t->byref) { if (t->type == MONO_TYPE_GENERICINST && mono_class_is_nullable (mono_class_from_mono_type (t))) return t; + + /* The result needs loaded indirectly */ + if (ret) + return t; + /* Can't share this with 'I' as that needs another indirection */ return &mono_defaults.int_class->this_arg; } @@ -4143,8 +4148,10 @@ emit_invoke_call (MonoMethodBuilder *mb, MonoMethod *method, } if (sig->ret->byref) { - /* fixme: */ - g_assert_not_reached (); + /* perform indirect load and return by value */ + MonoType* ret_byval = &mono_class_from_mono_type (sig->ret)->byval_arg; + g_assert (!ret_byval->byref); + mono_mb_emit_byte (mb, mono_type_to_ldind (ret_byval)); } switch (sig->ret->type) { diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 069f69ea0ff0..4b8a559aca5d 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -8366,7 +8366,12 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 buffer_add_value (buf, &VM_DEFAULTS_VOID_CLASS->byval_arg, NULL, domain); } } else if (MONO_TYPE_IS_REFERENCE (sig->ret)) { - buffer_add_value (buf, sig->ret, &res, domain); + if (sig->ret->byref) { + MonoType* ret_byval = &mono_class_from_mono_type (sig->ret)->byval_arg; + buffer_add_value (buf, ret_byval, &res, domain); + } else { + buffer_add_value (buf, sig->ret, &res, domain); + } } else if (mono_class_from_mono_type (sig->ret)->valuetype || sig->ret->type == MONO_TYPE_PTR || sig->ret->type == MONO_TYPE_FNPTR) { if (mono_class_is_nullable (mono_class_from_mono_type (sig->ret))) { MonoClass *k = mono_class_from_mono_type (sig->ret); @@ -8377,7 +8382,13 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 buffer_add_value (buf, sig->ret, nullable_buf, domain); } else { g_assert (res); - buffer_add_value (buf, sig->ret, mono_object_unbox (res), domain); + + if (sig->ret->byref) { + MonoType* ret_byval = &mono_class_from_mono_type (sig->ret)->byval_arg; + buffer_add_value (buf, ret_byval, mono_object_unbox (res), domain); + } else { + buffer_add_value (buf, sig->ret, mono_object_unbox (res), domain); + } } } else { NOT_IMPLEMENTED; From 580df2e36fbd7102b2b9d0768ead5fd6ef825969 Mon Sep 17 00:00:00 2001 From: andreasr Date: Thu, 20 Sep 2018 14:51:53 +0200 Subject: [PATCH 304/582] Fixed potential issue with garbage collection of delegates in UnityTls binding Before it might have happend that the garbage collector destroys delegates that we pass to native code. --- .../System/Mono.UnityTls/UnityTlsContext.cs | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index fc6babc1807f..442a2480adf6 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -35,6 +35,13 @@ unsafe internal class UnityTlsContext : MobileTlsContext UnityTls.unitytls_x509list* requestedClientCertChain = null; UnityTls.unitytls_key* requestedClientKey = null; + // Delegates we passed to native to ensure they are not garbage collected + UnityTls.unitytls_tlsctx_read_callback readCallback; + UnityTls.unitytls_tlsctx_write_callback writeCallback; + UnityTls.unitytls_tlsctx_trace_callback traceCallback; + UnityTls.unitytls_tlsctx_certificate_callback certificateCallback; + UnityTls.unitytls_tlsctx_x509verify_callback verifyCallback; + // States and certificates X509Certificate localClientCertificate; X509Certificate remoteCertificate; @@ -68,9 +75,11 @@ public UnityTlsContext ( max = UnityTlsConversions.GetMaxProtocol (enabledProtocols), }; + readCallback = ReadCallback; + writeCallback = WriteCallback; UnityTls.unitytls_tlsctx_callbacks callbacks = new UnityTls.unitytls_tlsctx_callbacks { - write = WriteCallback, - read = ReadCallback, + write = writeCallback, + read = readCallback, data = (void*)(IntPtr)handle, }; @@ -104,15 +113,18 @@ public UnityTlsContext ( tlsContext = UnityTls.NativeInterface.unitytls_tlsctx_create_client (protocolRange, callbacks, targetHostUtf8Ptr, targetHostUtf8.Length, &errorState); } - UnityTls.NativeInterface.unitytls_tlsctx_set_certificate_callback (tlsContext, CertificateCallback, (void*)(IntPtr)handle, &errorState); + certificateCallback = CertificateCallback; + UnityTls.NativeInterface.unitytls_tlsctx_set_certificate_callback (tlsContext, certificateCallback, (void*)(IntPtr)handle, &errorState); } - UnityTls.NativeInterface.unitytls_tlsctx_set_x509verify_callback (tlsContext, VerifyCallback, (void*)(IntPtr)handle, &errorState); + verifyCallback = VerifyCallback; + UnityTls.NativeInterface.unitytls_tlsctx_set_x509verify_callback (tlsContext, verifyCallback, (void*)(IntPtr)handle, &errorState); Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to create UnityTls context"); if (ActivateTracing) { - UnityTls.NativeInterface.unitytls_tlsctx_set_trace_callback (tlsContext, TraceCallback, null, &errorState); + traceCallback = TraceCallback; + UnityTls.NativeInterface.unitytls_tlsctx_set_trace_callback (tlsContext, traceCallback, null, &errorState); Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to set trace callback"); } From 045076f3bfa1f5fa52145b3e16654f0a2022dff6 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Thu, 20 Sep 2018 12:40:11 -0400 Subject: [PATCH 305/582] Use the latest BDWGC code --- external/bdwgc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/bdwgc b/external/bdwgc index 395d3e4b972d..edd22913569d 160000 --- a/external/bdwgc +++ b/external/bdwgc @@ -1 +1 @@ -Subproject commit 395d3e4b972d7b6f80d10325dfd5267ecd6208eb +Subproject commit edd22913569d3f31a45229099ebea3b9162128d6 From 0ad9d148b4112f5e89935352a201c630657c2b47 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 25 Sep 2018 11:10:51 -0400 Subject: [PATCH 306/582] Sync il2cpp revision 0a4be6a188cca18caa45d5baad5da037235c1f66 --- mono/sgen/sgen-gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mono/sgen/sgen-gc.c b/mono/sgen/sgen-gc.c index 1a823a12e5b9..6eb3cedf0a86 100644 --- a/mono/sgen/sgen-gc.c +++ b/mono/sgen/sgen-gc.c @@ -2573,7 +2573,7 @@ typedef struct { static SgenGcRequest gc_request; -#include +#include static void gc_pump_callback (void) From a662ff6b6bf71f4224dfb35976895480fa1802cf Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 25 Sep 2018 11:12:43 -0400 Subject: [PATCH 307/582] Sync il2cpp revision 1a7f010a556c76a28ba09668920363191b8ebe29 --- mono/mini/il2cpp-compat.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index 5cd1dc0a2d20..b8d9bed372c4 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -12,7 +12,9 @@ #ifdef RUNTIME_IL2CPP +#ifndef THREAD_STATIC_FIELD_OFFSET #define THREAD_STATIC_FIELD_OFFSET -1 +#endif #define VM_DOMAIN_GET_AGENT_INFO(domain) il2cpp_domain_get_agent_info(domain) #define VM_DOMAIN_SET_AGENT_INFO(domain, value) il2cpp_domain_set_agent_info(domain, value) From 845e7555b92e602a02ebc9c882f71c8a388d921a Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 25 Sep 2018 11:14:00 -0400 Subject: [PATCH 308/582] Sync il2cpp revision 37915d6211cbce909d8338c8bf5cd7a75af6343e --- mono/utils/mono-hwcap-web.c | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 mono/utils/mono-hwcap-web.c diff --git a/mono/utils/mono-hwcap-web.c b/mono/utils/mono-hwcap-web.c new file mode 100644 index 000000000000..fc322b94a904 --- /dev/null +++ b/mono/utils/mono-hwcap-web.c @@ -0,0 +1,6 @@ +#include "mono/utils/mono-hwcap.h" + +void +mono_hwcap_arch_init (void) +{ +} From 9d0be9873065d770496e8baf9e9247c8483e7c9f Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 25 Sep 2018 11:16:24 -0400 Subject: [PATCH 309/582] Sync il2cpp a20072651ca630bd791734da60fc561260d1c46c --- mono/utils/mono-threads-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mono/utils/mono-threads-posix.c b/mono/utils/mono-threads-posix.c index e89c9504c037..cf20ff5c9609 100644 --- a/mono/utils/mono-threads-posix.c +++ b/mono/utils/mono-threads-posix.c @@ -32,7 +32,7 @@ extern int tkill (pid_t tid, int signal); #endif -#if defined(_POSIX_VERSION) && !defined (TARGET_WASM) +#if (defined(_POSIX_VERSION) && !defined (TARGET_WASM)) || (defined(TARGET_WASM) && defined(__EMSCRIPTEN_PTHREADS__)) #include From 4e9c005cc073ac69020f21bd23338e19f38ce447 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 25 Sep 2018 11:19:20 -0400 Subject: [PATCH 310/582] Sync il2cpp revision 2e4b359d645856654955f175c11bdfc733005222 --- mono/arch/arm64/arm64-codegen.h | 6 +++--- mono/utils/mono-context.c | 16 ++++++++++++++++ mono/utils/mono-context.h | 5 +++++ mono/utils/mono-sigcontext.h | 4 +++- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/mono/arch/arm64/arm64-codegen.h b/mono/arch/arm64/arm64-codegen.h index 0156b110c06d..9bee54852143 100644 --- a/mono/arch/arm64/arm64-codegen.h +++ b/mono/arch/arm64/arm64-codegen.h @@ -170,7 +170,7 @@ arm_is_bl_disp (void *code, void *target) static G_GNUC_UNUSED inline unsigned int arm_get_disp (void *p, void *target) { - unsigned int disp = ((char*)target - (char*)p) / 4; + unsigned int disp = (unsigned int)(((char*)target - (char*)p) / 4); if (target) g_assert (arm_is_bl_disp (p, target)); @@ -196,7 +196,7 @@ arm_is_disp19 (void *code, void *target) static G_GNUC_UNUSED inline unsigned int arm_get_disp19 (void *p, void *target) { - unsigned int disp = ((char*)target - (char*)p) / 4; + unsigned int disp = (unsigned int)(((char*)target - (char*)p) / 4); if (target) g_assert (arm_is_disp19 (p, target)); @@ -224,7 +224,7 @@ arm_get_disp19 (void *p, void *target) static G_GNUC_UNUSED inline unsigned int arm_get_disp15 (void *p, void *target) { - unsigned int disp = ((char*)target - (char*)p) / 4; + unsigned int disp = (unsigned int)(((char*)target - (char*)p) / 4); return (disp & 0x7fff); } diff --git a/mono/utils/mono-context.c b/mono/utils/mono-context.c index f4266854876f..a6f02e421641 100644 --- a/mono/utils/mono-context.c +++ b/mono/utils/mono-context.c @@ -458,11 +458,21 @@ mono_monoctx_to_sigctx (MonoContext *mctx, void *ctx) #include +#ifdef HOST_WIN32 +#include +#endif + void mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx) { #ifdef MONO_CROSS_COMPILE g_assert_not_reached (); +#elif defined(HOST_WIN32) + CONTEXT *context = (CONTEXT*)sigctx; + + mctx->pc = context->Pc; + memcpy(&mctx->regs, &context->X0, sizeof(mgreg_t) * 31); + memcpy(&mctx->fregs, &context->V, sizeof(MonoContextSimdReg) * 32); #else memcpy (mctx->regs, UCONTEXT_GREGS (sigctx), sizeof (mgreg_t) * 31); mctx->pc = UCONTEXT_REG_PC (sigctx); @@ -484,6 +494,12 @@ mono_monoctx_to_sigctx (MonoContext *mctx, void *sigctx) { #ifdef MONO_CROSS_COMPILE g_assert_not_reached (); +#elif defined(HOST_WIN32) + CONTEXT *context = (CONTEXT*)sigctx; + + context->Pc = mctx->pc; + memcpy(&context->X0, &mctx->regs, sizeof(mgreg_t) * 31); + memcpy(&context->V, &mctx->fregs, sizeof(MonoContextSimdReg) * 32); #else memcpy (UCONTEXT_GREGS (sigctx), mctx->regs, sizeof (mgreg_t) * 31); UCONTEXT_REG_PC (sigctx) = mctx->pc; diff --git a/mono/utils/mono-context.h b/mono/utils/mono-context.h index 10f6fc1df46a..ff0e525d865c 100644 --- a/mono/utils/mono-context.h +++ b/mono/utils/mono-context.h @@ -41,8 +41,13 @@ typedef struct _libc_xmmreg MonoContextSimdReg; typedef __m128d MonoContextSimdReg; #endif #elif defined(TARGET_ARM64) +#if defined(HOST_WIN32) +#include +typedef __n128 MonoContextSimdReg; +#else typedef __uint128_t MonoContextSimdReg; #endif +#endif /* * General notes about mono-context. diff --git a/mono/utils/mono-sigcontext.h b/mono/utils/mono-sigcontext.h index 91bb0be37e53..98d45211232b 100644 --- a/mono/utils/mono-sigcontext.h +++ b/mono/utils/mono-sigcontext.h @@ -461,7 +461,9 @@ typedef struct ucontext { #define UCONTEXT_REG_R0(ctx) (((ucontext64_t*)(ctx))->uc_mcontext64->__ss.__x [ARMREG_R0]) #define UCONTEXT_GREGS(ctx) (&(((ucontext64_t*)(ctx))->uc_mcontext64->__ss.__x)) #else -#include +# if HAVE_UCONTEXT_H +# include +# endif #define UCONTEXT_REG_PC(ctx) (((ucontext_t*)(ctx))->uc_mcontext.pc) #define UCONTEXT_REG_SP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.sp) #define UCONTEXT_REG_R0(ctx) (((ucontext_t*)(ctx))->uc_mcontext.regs [ARMREG_R0]) From ada06d4201878a0e59c09341cf7009a7f3062526 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 25 Sep 2018 11:23:34 -0400 Subject: [PATCH 311/582] Sync il2cpp revision 3176daa483ca4da5a5b38f62018b80f7b511efea --- mono/mini/debugger-agent.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 4b8a559aca5d..c586c3b14fcd 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -4178,7 +4178,11 @@ thread_startup (MonoProfiler *prof, uintptr_t tid) tls = g_new0 (DebuggerTlsData, 1); #endif MONO_GC_REGISTER_ROOT_SINGLE (tls->thread, MONO_ROOT_SOURCE_DEBUGGER, NULL, "Debugger Thread Reference"); +#ifdef RUNTIME_IL2CPP + il2cpp_gc_wbarrier_set_field(tls, (void**)&tls->thread, thread); +#else tls->thread = thread; +#endif mono_native_tls_set_value (debugger_tls_id, tls); DEBUG_PRINTF (1, "[%p] Thread started, obj=%p, tls=%p.\n", (gpointer)tid, thread, tls); @@ -4214,10 +4218,12 @@ thread_end (MonoProfiler *prof, uintptr_t tid) /* Can't remove from tid_to_thread, as that would defeat the check in thread_start () */ #ifndef RUNTIME_IL2CPP MONO_GC_UNREGISTER_ROOT (tls->thread); -#else - callbacks.il2cpp_debugger_free_thread_context(&tls->il2cpp_context); #endif +#ifdef RUNTIME_IL2CPP + il2cpp_gc_wbarrier_set_field(tls, (void**)&tls->thread, NULL); +#else tls->thread = NULL; +#endif } } mono_loader_unlock (); From a098bd243090e9d6e8b6a8932e2134a688fb117b Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Tue, 2 Oct 2018 09:46:22 +0200 Subject: [PATCH 312/582] Revert accidental commit --- mono/metadata/boehm-gc.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index 05cf8b1643d4..8c4f5a77322f 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -773,10 +773,6 @@ mono_gc_alloc_obj (MonoVTable *vtable, size_t size) { MonoObject *obj; - if (strcmp(vtable->klass->name, "RuntimeTestInfo") == 0) - { - printf("hello"); - } if (!vtable->klass->has_references) { obj = (MonoObject *)GC_MALLOC_ATOMIC (size); if (G_UNLIKELY (!obj)) From 79a5689990b650cbf10f8ae5eaccbf2c6f73f717 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 2 Oct 2018 16:58:32 -0400 Subject: [PATCH 313/582] Use empty array for wrapper methods (case 1073634) Wrapper methods should not be exposed to user code but in some cases they end up in StackFrame's. Return empty parameter array in these cases since metadata code cannot handle wrapper methods. --- mono/metadata/reflection.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mono/metadata/reflection.c b/mono/metadata/reflection.c index e6e369e3af73..3bc5145f333c 100644 --- a/mono/metadata/reflection.c +++ b/mono/metadata/reflection.c @@ -1087,6 +1087,15 @@ mono_param_get_objects_internal (MonoDomain *domain, MonoMethod *method, MonoCla return res; } + /* UNITY: wrapper methods are being captured in callstacks, even thought users should not encounter them. + * The logic in param_objects_construct cannot handle this. Just return empty array (case 1073634) */ + if (method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE) { + MonoArrayHandle res = mono_array_new_handle (domain, mono_class_get_mono_parameter_info_class (), 0, error); + goto_if_nok (error, fail); + + return res; + } + /* Note: the cache is based on the address of the signature into the method * since we already cache MethodInfos with the method as keys. */ From f31396135d4739f53c755ed3290d0780f0715e22 Mon Sep 17 00:00:00 2001 From: Michael DeRoy Date: Tue, 2 Oct 2018 17:14:11 -0400 Subject: [PATCH 314/582] pull in fix for 1066693 from upstream --- .../Collections/Generic/LargeArrayBuilder.cs | 390 ++++++++++++++++++ .../common_System.Core.dll.sources | 2 +- 2 files changed, 391 insertions(+), 1 deletion(-) create mode 100644 external/corefx-bugfix/src/Common/src/System/Collections/Generic/LargeArrayBuilder.cs diff --git a/external/corefx-bugfix/src/Common/src/System/Collections/Generic/LargeArrayBuilder.cs b/external/corefx-bugfix/src/Common/src/System/Collections/Generic/LargeArrayBuilder.cs new file mode 100644 index 000000000000..80c9a1734f12 --- /dev/null +++ b/external/corefx-bugfix/src/Common/src/System/Collections/Generic/LargeArrayBuilder.cs @@ -0,0 +1,390 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics; +using System.Runtime.CompilerServices; + +namespace System.Collections.Generic +{ + /// + /// Represents a position within a . + /// + [DebuggerDisplay("{DebuggerDisplay,nq}")] + internal struct CopyPosition + { + /// + /// Constructs a new . + /// + /// The index of the buffer to select. + /// The index within the buffer to select. + internal CopyPosition(int row, int column) + { + Debug.Assert(row >= 0); + Debug.Assert(column >= 0); + + Row = row; + Column = column; + } + + /// + /// Represents a position at the start of a . + /// + public static CopyPosition Start => default(CopyPosition); + + /// + /// The index of the buffer to select. + /// + internal int Row { get; } + + /// + /// The index within the buffer to select. + /// + internal int Column { get; } + + /// + /// If this position is at the end of the current buffer, returns the position + /// at the start of the next buffer. Otherwise, returns this position. + /// + /// The length of the current buffer. + public CopyPosition Normalize(int endColumn) + { + Debug.Assert(Column <= endColumn); + + return Column == endColumn ? + new CopyPosition(Row + 1, 0) : + this; + } + + /// + /// Gets a string suitable for display in the debugger. + /// + private string DebuggerDisplay => $"[{Row}, {Column}]"; + } + + /// + /// Helper type for building dynamically-sized arrays while minimizing allocations and copying. + /// + /// The element type. + internal struct LargeArrayBuilder + { + private const int StartingCapacity = 4; + private const int ResizeLimit = 8; + + private readonly int _maxCapacity; // The maximum capacity this builder can have. + private T[] _first; // The first buffer we store items in. Resized until ResizeLimit. + private ArrayBuilder _buffers; // After ResizeLimit * 2, we store previous buffers we've filled out here. + private T[] _current; // Current buffer we're reading into. If _count <= ResizeLimit, this is _first. + private int _index; // Index into the current buffer. + private int _count; // Count of all of the items in this builder. + + /// + /// Constructs a new builder. + /// + /// Pass true. + public LargeArrayBuilder(bool initialize) + : this(maxCapacity: int.MaxValue) + { + // This is a workaround for C# not having parameterless struct constructors yet. + // Once it gets them, replace this with a parameterless constructor. + Debug.Assert(initialize); + } + + /// + /// Constructs a new builder with the specified maximum capacity. + /// + /// The maximum capacity this builder can have. + /// + /// Do not add more than items to this builder. + /// + public LargeArrayBuilder(int maxCapacity) + : this() + { + Debug.Assert(maxCapacity >= 0); + + _first = _current = Array.Empty(); + _maxCapacity = maxCapacity; + } + + /// + /// Gets the number of items added to the builder. + /// + public int Count => _count; + + /// + /// Adds an item to this builder. + /// + /// The item to add. + /// + /// Use if adding to the builder is a bottleneck for your use case. + /// Otherwise, use . + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Add(T item) + { + Debug.Assert(_maxCapacity > _count); + + if (_index == _current.Length) + { + AllocateBuffer(); + } + + _current[_index++] = item; + _count++; + } + + /// + /// Adds a range of items to this builder. + /// + /// The sequence to add. + /// + /// It is the caller's responsibility to ensure that adding + /// does not cause the builder to exceed its maximum capacity. + /// + public void AddRange(IEnumerable items) + { + Debug.Assert(items != null); + + using (IEnumerator enumerator = items.GetEnumerator()) + { + T[] destination = _current; + int index = _index; + + // Continuously read in items from the enumerator, updating _count + // and _index when we run out of space. + + while (enumerator.MoveNext()) + { + if (index == destination.Length) + { + // No more space in this buffer. Resize. + _count += index - _index; + _index = index; + AllocateBuffer(); + destination = _current; + index = _index; // May have been reset to 0 + } + + destination[index++] = enumerator.Current; + } + + // Final update to _count and _index. + _count += index - _index; + _index = index; + } + } + + /// + /// Copies the contents of this builder to the specified array. + /// + /// The destination array. + /// The index in to start copying to. + /// The number of items to copy. + public void CopyTo(T[] array, int arrayIndex, int count) + { + Debug.Assert(arrayIndex >= 0); + Debug.Assert(count >= 0 && count <= Count); + Debug.Assert(array?.Length - arrayIndex >= count); + + for (int i = 0; count > 0; i++) + { + // Find the buffer we're copying from. + T[] buffer = GetBuffer(index: i); + + // Copy until we satisfy count, or we reach the end of the buffer. + int toCopy = Math.Min(count, buffer.Length); + Array.Copy(buffer, 0, array, arrayIndex, toCopy); + + // Increment variables to that position. + count -= toCopy; + arrayIndex += toCopy; + } + } + + /// + /// Copies the contents of this builder to the specified array. + /// + /// The position in this builder to start copying from. + /// The destination array. + /// The index in to start copying to. + /// The number of items to copy. + /// The position in this builder that was copied up to. + public CopyPosition CopyTo(CopyPosition position, T[] array, int arrayIndex, int count) + { + Debug.Assert(array != null); + Debug.Assert(arrayIndex >= 0); + Debug.Assert(count > 0 && count <= Count); + Debug.Assert(array.Length - arrayIndex >= count); + + // Go through each buffer, which contains one 'row' of items. + // The index in each buffer is referred to as the 'column'. + + /* + * Visual representation: + * + * C0 C1 C2 .. C31 .. C63 + * R0: [0] [1] [2] .. [31] + * R1: [32] [33] [34] .. [63] + * R2: [64] [65] [66] .. [95] .. [127] + */ + + int row = position.Row; + int column = position.Column; + + T[] buffer = GetBuffer(row); + int copied = +#if __MonoCS__ + CopyToCore(buffer, column, array, arrayIndex, count); +#else + CopyToCore(buffer, column); +#endif + + if (count == 0) + { + return new CopyPosition(row, column + copied).Normalize(buffer.Length); + } + + do + { + buffer = GetBuffer(++row); + copied = +#if __MonoCS__ + CopyToCore(buffer, 0, array, arrayIndex, count); +#else + CopyToCore(buffer, 0); +#endif + } while (count > 0); + + return new CopyPosition(row, copied).Normalize(buffer.Length); + +#if __MonoCS__ + } + + static int CopyToCore(T[] sourceBuffer, int sourceIndex, T[] array, int arrayIndex, int count) +#else + int CopyToCore(T[] sourceBuffer, int sourceIndex) +#endif + { + Debug.Assert(sourceBuffer.Length > sourceIndex); + + // Copy until we satisfy `count` or reach the end of the current buffer. + int copyCount = Math.Min(sourceBuffer.Length - sourceIndex, count); + Array.Copy(sourceBuffer, sourceIndex, array, arrayIndex, copyCount); + + arrayIndex += copyCount; + count -= copyCount; + + return copyCount; + } + +#if !__MonoCS__ + } +#endif + + /// + /// Retrieves the buffer at the specified index. + /// + /// The index of the buffer. + public T[] GetBuffer(int index) + { + Debug.Assert(index >= 0 && index < _buffers.Count + 2); + + return index == 0 ? _first : + index <= _buffers.Count ? _buffers[index - 1] : + _current; + } + + /// + /// Adds an item to this builder. + /// + /// The item to add. + /// + /// Use if adding to the builder is a bottleneck for your use case. + /// Otherwise, use . + /// + [MethodImpl(MethodImplOptions.NoInlining)] + public void SlowAdd(T item) => Add(item); + + /// + /// Creates an array from the contents of this builder. + /// + public T[] ToArray() + { + if (TryMove(out T[] array)) + { + // No resizing to do. + return array; + } + + array = new T[_count]; + CopyTo(array, 0, _count); + return array; + } + + /// + /// Attempts to transfer this builder into an array without copying. + /// + /// The transferred array, if the operation succeeded. + /// true if the operation succeeded; otherwise, false. + public bool TryMove(out T[] array) + { + array = _first; + return _count == _first.Length; + } + + private void AllocateBuffer() + { + // - On the first few adds, simply resize _first. + // - When we pass ResizeLimit, allocate ResizeLimit elements for _current + // and start reading into _current. Set _index to 0. + // - When _current runs out of space, add it to _buffers and repeat the + // above step, except with _current.Length * 2. + // - Make sure we never pass _maxCapacity in all of the above steps. + + Debug.Assert((uint)_maxCapacity > (uint)_count); + Debug.Assert(_index == _current.Length, $"{nameof(AllocateBuffer)} was called, but there's more space."); + + // If _count is int.MinValue, we want to go down the other path which will raise an exception. + if ((uint)_count < (uint)ResizeLimit) + { + // We haven't passed ResizeLimit. Resize _first, copying over the previous items. + Debug.Assert(_current == _first && _count == _first.Length); + + int nextCapacity = Math.Min(_count == 0 ? StartingCapacity : _count * 2, _maxCapacity); + + _current = new T[nextCapacity]; + Array.Copy(_first, 0, _current, 0, _count); + _first = _current; + } + else + { + Debug.Assert(_maxCapacity > ResizeLimit); + Debug.Assert(_count == ResizeLimit ^ _current != _first); + + int nextCapacity; + if (_count == ResizeLimit) + { + nextCapacity = ResizeLimit; + } + else + { + // Example scenario: Let's say _count == 64. + // Then our buffers look like this: | 8 | 8 | 16 | 32 | + // As you can see, our count will be just double the last buffer. + // Now, say _maxCapacity is 100. We will find the right amount to allocate by + // doing min(64, 100 - 64). The lhs represents double the last buffer, + // the rhs the limit minus the amount we've already allocated. + + Debug.Assert(_count >= ResizeLimit * 2); + Debug.Assert(_count == _current.Length * 2); + + _buffers.Add(_current); + nextCapacity = Math.Min(_count, _maxCapacity - _count); + } + + _current = new T[nextCapacity]; + _index = 0; + } + } + } +} diff --git a/mcs/class/System.Core/common_System.Core.dll.sources b/mcs/class/System.Core/common_System.Core.dll.sources index 6d2f6aaf34ef..7a83de3eb8f6 100644 --- a/mcs/class/System.Core/common_System.Core.dll.sources +++ b/mcs/class/System.Core/common_System.Core.dll.sources @@ -278,7 +278,7 @@ System.Security.Cryptography/SHA512CryptoServiceProvider.cs ../../../external/corefx/src/Common/src/System/Collections/Generic/ArrayBuilder.cs ../../../external/corefx/src/Common/src/System/Collections/Generic/EnumerableHelpers.cs ../../../external/corefx/src/Common/src/System/Collections/Generic/EnumerableHelpers.Linq.cs -../../../external/corefx/src/Common/src/System/Collections/Generic/LargeArrayBuilder.cs +../../../external/corefx-bugfix/src/Common/src/System/Collections/Generic/LargeArrayBuilder.cs ../../../external/corefx/src/Common/src/System/Collections/Generic/SparseArrayBuilder.cs ../../../external/corefx/src/System.Linq.Expressions/src/System/Dynamic/Utils/CacheDict.cs From 1dafe55e4e111ce1f50ffa87c75fae850e737ca6 Mon Sep 17 00:00:00 2001 From: andreasr Date: Thu, 4 Oct 2018 10:14:52 +0200 Subject: [PATCH 315/582] Replaced size_t class in UnityTls and replaced with simple aliases to IntPtr Since compiler handle structs differently on function calls this may have caused issues when passing arguments between managed and native code. Even if not, we're clearly safer with the explicit casts now. --- mcs/class/System/Mono.UnityTls/CertHelper.cs | 12 +++--- mcs/class/System/Mono.UnityTls/UnityTls.cs | 18 +------- .../System/Mono.UnityTls/UnityTlsContext.cs | 41 ++++++++++--------- .../System/Mono.UnityTls/UnityTlsProvider.cs | 6 ++- 4 files changed, 34 insertions(+), 43 deletions(-) diff --git a/mcs/class/System/Mono.UnityTls/CertHelper.cs b/mcs/class/System/Mono.UnityTls/CertHelper.cs index d669ca3cdafa..a72a76b1eda5 100644 --- a/mcs/class/System/Mono.UnityTls/CertHelper.cs +++ b/mcs/class/System/Mono.UnityTls/CertHelper.cs @@ -1,6 +1,8 @@ #if SECURITY_DEP using System.Security.Cryptography.X509Certificates; +using size_t = System.IntPtr; + namespace Mono.Unity { internal unsafe static class CertHelper @@ -16,7 +18,7 @@ public static void AddCertificateToNativeChain (UnityTls.unitytls_x509list* nati { byte[] certDer = certificate.GetRawCertData (); fixed(byte* certDerPtr = certDer) { - UnityTls.NativeInterface.unitytls_x509list_append_der (nativeCertificateChain, certDerPtr, certDer.Length, errorState); + UnityTls.NativeInterface.unitytls_x509list_append_der (nativeCertificateChain, certDerPtr, (size_t)certDer.Length, errorState); } var certificateImpl2 = certificate.Impl as X509Certificate2Impl; @@ -34,16 +36,16 @@ public static X509CertificateCollection NativeChainToManagedCollection (UnityTls { X509CertificateCollection certificates = new X509CertificateCollection (); - var cert = UnityTls.NativeInterface.unitytls_x509list_get_x509 (nativeCertificateChain, 0, errorState); + var cert = UnityTls.NativeInterface.unitytls_x509list_get_x509 (nativeCertificateChain, (size_t)0, errorState); for (int i = 0; cert.handle != UnityTls.NativeInterface.UNITYTLS_INVALID_HANDLE; ++i) { - size_t certBufferSize = UnityTls.NativeInterface.unitytls_x509_export_der (cert, null, 0, errorState); - var certBuffer = new byte[certBufferSize]; // Need to reallocate every time since X509Certificate constructor takes no length but only a byte array. + size_t certBufferSize = UnityTls.NativeInterface.unitytls_x509_export_der (cert, null, (size_t)0, errorState); + var certBuffer = new byte[(int)certBufferSize]; // Need to reallocate every time since X509Certificate constructor takes no length but only a byte array. fixed(byte* certBufferPtr = certBuffer) { UnityTls.NativeInterface.unitytls_x509_export_der (cert, certBufferPtr, certBufferSize, errorState); } certificates.Add (new X509Certificate (certBuffer)); - cert = UnityTls.NativeInterface.unitytls_x509list_get_x509 (nativeCertificateChain, i, errorState); + cert = UnityTls.NativeInterface.unitytls_x509list_get_x509 (nativeCertificateChain, (size_t)i, errorState); } return certificates; diff --git a/mcs/class/System/Mono.UnityTls/UnityTls.cs b/mcs/class/System/Mono.UnityTls/UnityTls.cs index a7cd4b5b5860..09d16daa461e 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTls.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTls.cs @@ -9,23 +9,7 @@ namespace Mono.Unity // The aliases here are just there to keep the semantic in the interface and make it more similar to the c original. using UInt8 = Byte; using Int8 = Byte; - - [StructLayout (LayoutKind.Sequential)] - internal struct size_t - { - public size_t(uint i) { - value = new IntPtr(i); - } - - public static implicit operator size_t(int d) { - return new size_t((uint)d); - } - public static implicit operator int(size_t s) { - return s.value.ToInt32(); - } - - public IntPtr value; - } + using size_t = IntPtr; unsafe internal static partial class UnityTls { diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs index 442a2480adf6..17be4c3366e2 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsContext.cs @@ -23,6 +23,7 @@ using Mono.Util; using Int8 = System.Byte; +using size_t = System.IntPtr; namespace Mono.Unity { @@ -110,7 +111,7 @@ public UnityTlsContext ( else { byte [] targetHostUtf8 = Encoding.UTF8.GetBytes (targetHost); fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { - tlsContext = UnityTls.NativeInterface.unitytls_tlsctx_create_client (protocolRange, callbacks, targetHostUtf8Ptr, targetHostUtf8.Length, &errorState); + tlsContext = UnityTls.NativeInterface.unitytls_tlsctx_create_client (protocolRange, callbacks, targetHostUtf8Ptr, (size_t)targetHostUtf8.Length, &errorState); } certificateCallback = CertificateCallback; @@ -121,12 +122,14 @@ public UnityTlsContext ( UnityTls.NativeInterface.unitytls_tlsctx_set_x509verify_callback (tlsContext, verifyCallback, (void*)(IntPtr)handle, &errorState); Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to create UnityTls context"); - + + #pragma warning disable CS0162 // Disable unreachable code warning if (ActivateTracing) { traceCallback = TraceCallback; UnityTls.NativeInterface.unitytls_tlsctx_set_trace_callback (tlsContext, traceCallback, null, &errorState); Mono.Unity.Debug.CheckAndThrow (errorState, "Failed to set trace callback"); } + #pragma warning restore CS0162 // Reenable unreachable code warning. hasContext = true; } @@ -147,7 +150,7 @@ static private void ExtractNativeKeyAndChainFromManagedCertificate(X509Certifica byte[] privateKeyDer = PKCS8.PrivateKeyInfo.Encode (cert2.PrivateKey); fixed(byte* privateKeyDerPtr = privateKeyDer) { - nativeKey = UnityTls.NativeInterface.unitytls_key_parse_der (privateKeyDerPtr, privateKeyDer.Length, null, 0, errorState); + nativeKey = UnityTls.NativeInterface.unitytls_key_parse_der (privateKeyDerPtr, (size_t)privateKeyDer.Length, null, (size_t)0, errorState); } } catch { UnityTls.NativeInterface.unitytls_x509list_free (nativeCertChain); @@ -190,7 +193,7 @@ public override (int ret, bool wantMore) Read (byte[] buffer, int offset, int co lastException = null; var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); fixed (byte* bufferPtr = buffer) { - numBytesRead = UnityTls.NativeInterface.unitytls_tlsctx_read (tlsContext, bufferPtr + offset, count, &errorState); + numBytesRead = (int)UnityTls.NativeInterface.unitytls_tlsctx_read (tlsContext, bufferPtr + offset, (size_t)count, &errorState); } if (lastException != null) throw lastException; @@ -223,7 +226,7 @@ public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int c lastException = null; var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); fixed (byte* bufferPtr = buffer) { - numBytesWritten = UnityTls.NativeInterface.unitytls_tlsctx_write (tlsContext, bufferPtr + offset, count, &errorState); + numBytesWritten = (int)UnityTls.NativeInterface.unitytls_tlsctx_write (tlsContext, bufferPtr + offset, (size_t)count, &errorState); } if (lastException != null) throw lastException; @@ -304,7 +307,7 @@ public override void StartHandshake () var errorState = UnityTls.NativeInterface.unitytls_errorstate_create (); fixed (UnityTls.unitytls_ciphersuite* ciphersPtr = ciphers) - UnityTls.NativeInterface.unitytls_tlsctx_set_supported_ciphersuites (tlsContext, ciphersPtr, ciphers.Length, &errorState); + UnityTls.NativeInterface.unitytls_tlsctx_set_supported_ciphersuites (tlsContext, ciphersPtr, (size_t)ciphers.Length, &errorState); Unity.Debug.CheckAndThrow (errorState, "Failed to set list of supported ciphers", AlertDescription.HandshakeFailure); } } @@ -368,13 +371,13 @@ static private size_t WriteCallback (void* userData, byte* data, size_t bufferLe private size_t WriteCallback (byte* data, size_t bufferLen, UnityTls.unitytls_errorstate* errorState) { try { - if (writeBuffer == null || writeBuffer.Length < bufferLen) - writeBuffer = new byte[bufferLen]; - Marshal.Copy ((IntPtr)data, writeBuffer, 0, bufferLen); + if (writeBuffer == null || writeBuffer.Length < (int)bufferLen) + writeBuffer = new byte[(int)bufferLen]; + Marshal.Copy ((IntPtr)data, writeBuffer, 0, (int)bufferLen); - if (!Parent.InternalWrite (writeBuffer, 0, bufferLen)) { + if (!Parent.InternalWrite (writeBuffer, 0, (int)bufferLen)) { UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_WRITE_FAILED); - return 0; + return (size_t)0; } return bufferLen; @@ -382,7 +385,7 @@ private size_t WriteCallback (byte* data, size_t bufferLen, UnityTls.unitytls_er UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); if (lastException == null) lastException = ex; - return 0; + return (size_t)0; } } @@ -397,17 +400,17 @@ static private size_t ReadCallback (void* userData, byte* buffer, size_t bufferL private size_t ReadCallback (byte* buffer, size_t bufferLen, UnityTls.unitytls_errorstate* errorState) { try { - if (readBuffer == null || readBuffer.Length < bufferLen) - readBuffer = new byte [bufferLen]; + if (readBuffer == null || readBuffer.Length < (int)bufferLen) + readBuffer = new byte [(int)bufferLen]; bool wouldBlock; - int numBytesRead = Parent.InternalRead (readBuffer, 0, bufferLen, out wouldBlock); + int numBytesRead = Parent.InternalRead (readBuffer, 0, (int)bufferLen, out wouldBlock); // Non graceful exit. if (numBytesRead < 0) { UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_READ_FAILED); } else if (numBytesRead > 0) { - Marshal.Copy (readBuffer, 0, (IntPtr)buffer, bufferLen); + Marshal.Copy (readBuffer, 0, (IntPtr)buffer, (int)bufferLen); } else { // numBytesRead == 0 // careful when rearranging this: wouldBlock might be true even if stream was closed abruptly. if (wouldBlock) { @@ -423,12 +426,12 @@ private size_t ReadCallback (byte* buffer, size_t bufferLen, UnityTls.unitytls_e } // Note that UnityTls ignores this number when raising an error. - return numBytesRead; + return (size_t)numBytesRead; } catch (Exception ex) { // handle all exceptions and store them for later since we don't want to let them go through native code. UnityTls.NativeInterface.unitytls_errorstate_raise_error (errorState, UnityTls.unitytls_error_code.UNITYTLS_USER_UNKNOWN_ERROR); if (lastException == null) lastException = ex; - return 0; + return (size_t)0; } } @@ -498,7 +501,7 @@ private void CertificateCallback (UnityTls.unitytls_tlsctx* ctx, Int8* cn, size_ [MonoPInvokeCallback (typeof (UnityTls.unitytls_tlsctx_trace_callback))] static private void TraceCallback (void* userData, UnityTls.unitytls_tlsctx* ctx, byte* traceMessage, size_t traceMessageLen) { - string message = Encoding.UTF8.GetString (traceMessage, traceMessageLen); + string message = Encoding.UTF8.GetString (traceMessage, (int)traceMessageLen); System.Console.Write (message); } } diff --git a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs index 78c637c86803..0dc8b1497d0c 100644 --- a/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs +++ b/mcs/class/System/Mono.UnityTls/UnityTlsProvider.cs @@ -17,6 +17,8 @@ using Mono.Security.Interface; #endif +using size_t = System.IntPtr; + namespace Mono.Unity { unsafe internal class UnityTlsProvider : MonoTlsProvider @@ -93,13 +95,13 @@ internal override bool ValidateCertificate ( var trustCAnativeRef = UnityTls.NativeInterface.unitytls_x509list_get_ref (certificatesNative, &errorState); fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { - result = UnityTls.NativeInterface.unitytls_x509verify_explicit_ca (certificatesNativeRef, trustCAnativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); + result = UnityTls.NativeInterface.unitytls_x509verify_explicit_ca (certificatesNativeRef, trustCAnativeRef, targetHostUtf8Ptr, (size_t)targetHostUtf8.Length, null, null, &errorState); } UnityTls.NativeInterface.unitytls_x509list_free (trustCAnative); } else { fixed (byte* targetHostUtf8Ptr = targetHostUtf8) { - result = UnityTls.NativeInterface.unitytls_x509verify_default_ca (certificatesNativeRef, targetHostUtf8Ptr, targetHostUtf8.Length, null, null, &errorState); + result = UnityTls.NativeInterface.unitytls_x509verify_default_ca (certificatesNativeRef, targetHostUtf8Ptr, (size_t)targetHostUtf8.Length, null, null, &errorState); } } } From d063d2b6e55cd3d7847ec507ec2b72f4e52fe69d Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Thu, 4 Oct 2018 14:48:59 +0200 Subject: [PATCH 316/582] Expose incremental gc time slice in mono API --- mono/metadata/boehm-gc.c | 12 ++++++++++++ mono/metadata/mono-gc.h | 2 ++ mono/metadata/null-gc.c | 11 +++++++++++ mono/metadata/sgen-mono.c | 11 +++++++++++ 4 files changed, 36 insertions(+) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index 8c4f5a77322f..a12143d6ab94 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -419,6 +419,18 @@ mono_gc_get_heap_size (void) return GC_get_heap_size (); } +int64_t +mono_get_max_time_slice_ns() +{ + return GC_get_time_limit() * 1000000; +} + +void +mono_set_max_time_slice_ns(int64_t maxTimeSlice) +{ + GC_set_time_limit(maxTimeSlice / 1000000); +} + gboolean mono_gc_is_gc_thread (void) { diff --git a/mono/metadata/mono-gc.h b/mono/metadata/mono-gc.h index 455209aa8dc3..4509fbba828c 100644 --- a/mono/metadata/mono-gc.h +++ b/mono/metadata/mono-gc.h @@ -109,6 +109,8 @@ MONO_API int mono_gc_get_generation (MonoObject *object); MONO_API int mono_gc_collection_count (int generation); MONO_API int64_t mono_gc_get_used_size (void); MONO_API int64_t mono_gc_get_heap_size (void); +MONO_API int64_t mono_get_max_time_slice_ns (); +MONO_API void mono_set_max_time_slice_ns (int64_t maxTimeSlice); MONO_API MonoBoolean mono_gc_pending_finalizers (void); MONO_API void mono_gc_finalize_notify (void); MONO_API int mono_gc_invoke_finalizers (void); diff --git a/mono/metadata/null-gc.c b/mono/metadata/null-gc.c index 4304f039904d..b44bc8a033ed 100644 --- a/mono/metadata/null-gc.c +++ b/mono/metadata/null-gc.c @@ -91,6 +91,17 @@ mono_gc_get_heap_size (void) return 2*1024*1024; } +int64_t +mono_get_max_time_slice_ns() +{ + return 0; +} + +void +mono_set_max_time_slice_ns(int64_t maxTimeSlice) +{ +} + gboolean mono_gc_is_gc_thread (void) { diff --git a/mono/metadata/sgen-mono.c b/mono/metadata/sgen-mono.c index 1477057d27b0..b6b62ed0fc63 100644 --- a/mono/metadata/sgen-mono.c +++ b/mono/metadata/sgen-mono.c @@ -2831,6 +2831,17 @@ mono_gc_get_heap_size (void) return (int64_t)sgen_gc_get_total_heap_allocation (); } +int64_t +mono_get_max_time_slice_ns() +{ + return 0; +} + +void +mono_set_max_time_slice_ns(int64_t maxTimeSlice) +{ +} + MonoGCDescriptor mono_gc_make_root_descr_user (MonoGCRootMarkFunc marker) { From dc58c2b862e226617246e373d1224687fea504e2 Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Fri, 5 Oct 2018 08:02:48 +0200 Subject: [PATCH 317/582] Add mono_gc_is_incremental --- mono/metadata/boehm-gc.c | 10 ++++++++-- mono/metadata/mono-gc.h | 5 +++-- mono/metadata/null-gc.c | 10 ++++++++-- mono/metadata/sgen-mono.c | 10 ++++++++-- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index a12143d6ab94..34d6ba4eed09 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -420,17 +420,23 @@ mono_gc_get_heap_size (void) } int64_t -mono_get_max_time_slice_ns() +mono_gc_get_max_time_slice_ns() { return GC_get_time_limit() * 1000000; } void -mono_set_max_time_slice_ns(int64_t maxTimeSlice) +mono_gc_set_max_time_slice_ns(int64_t maxTimeSlice) { GC_set_time_limit(maxTimeSlice / 1000000); } +MonoBoolean +mono_gc_is_incremental() +{ + return GC_is_incremental_mode(); +} + gboolean mono_gc_is_gc_thread (void) { diff --git a/mono/metadata/mono-gc.h b/mono/metadata/mono-gc.h index 4509fbba828c..0bacfc882ed1 100644 --- a/mono/metadata/mono-gc.h +++ b/mono/metadata/mono-gc.h @@ -109,9 +109,10 @@ MONO_API int mono_gc_get_generation (MonoObject *object); MONO_API int mono_gc_collection_count (int generation); MONO_API int64_t mono_gc_get_used_size (void); MONO_API int64_t mono_gc_get_heap_size (void); -MONO_API int64_t mono_get_max_time_slice_ns (); -MONO_API void mono_set_max_time_slice_ns (int64_t maxTimeSlice); +MONO_API int64_t mono_gc_get_max_time_slice_ns (); +MONO_API void mono_gc_set_max_time_slice_ns (int64_t maxTimeSlice); MONO_API MonoBoolean mono_gc_pending_finalizers (void); +MONO_API MonoBoolean mono_gc_is_incremental (void); MONO_API void mono_gc_finalize_notify (void); MONO_API int mono_gc_invoke_finalizers (void); /* heap walking is only valid in the pre-stop-world event callback */ diff --git a/mono/metadata/null-gc.c b/mono/metadata/null-gc.c index b44bc8a033ed..6fd1f57fb55a 100644 --- a/mono/metadata/null-gc.c +++ b/mono/metadata/null-gc.c @@ -92,16 +92,22 @@ mono_gc_get_heap_size (void) } int64_t -mono_get_max_time_slice_ns() +mono_gc_get_max_time_slice_ns() { return 0; } void -mono_set_max_time_slice_ns(int64_t maxTimeSlice) +mono_gc_set_max_time_slice_ns(int64_t maxTimeSlice) { } +MonoBoolean +mono_gc_is_incremental() +{ + return FALSE; +} + gboolean mono_gc_is_gc_thread (void) { diff --git a/mono/metadata/sgen-mono.c b/mono/metadata/sgen-mono.c index b6b62ed0fc63..1c60625e6d76 100644 --- a/mono/metadata/sgen-mono.c +++ b/mono/metadata/sgen-mono.c @@ -2832,13 +2832,19 @@ mono_gc_get_heap_size (void) } int64_t -mono_get_max_time_slice_ns() +mono_gc_get_max_time_slice_ns() { return 0; } +MonoBoolean +mono_gc_is_incremental() +{ + return FALSE; +} + void -mono_set_max_time_slice_ns(int64_t maxTimeSlice) +mono_gc_set_max_time_slice_ns(int64_t maxTimeSlice) { } From 6de57970bac84a241192f9e95a1b06c96dab8a1f Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Fri, 5 Oct 2018 10:17:50 +0200 Subject: [PATCH 318/582] Update bdwgc --- external/bdwgc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/bdwgc b/external/bdwgc index edd22913569d..abf08ceb08d2 160000 --- a/external/bdwgc +++ b/external/bdwgc @@ -1 +1 @@ -Subproject commit edd22913569d3f31a45229099ebea3b9162128d6 +Subproject commit abf08ceb08d2fce113f44cfe6be2661e4e8a1935 From dc145eaf4d5c452edfe948780243267f4c7e3fde Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Mon, 8 Oct 2018 10:02:05 +0200 Subject: [PATCH 319/582] Update bdwgc, this time with fixed version --- external/bdwgc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/bdwgc b/external/bdwgc index abf08ceb08d2..33b5da352750 160000 --- a/external/bdwgc +++ b/external/bdwgc @@ -1 +1 @@ -Subproject commit abf08ceb08d2fce113f44cfe6be2661e4e8a1935 +Subproject commit 33b5da352750ce094ea11cf8c0634b51ba2539b6 From efa4871ad9b9ede18a11bbe31500fbda57cf21f5 Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Mon, 8 Oct 2018 11:54:56 +0200 Subject: [PATCH 320/582] Fix building mono with old boehm --- mono/metadata/boehm-gc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index 34d6ba4eed09..11b3eb8116f7 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -422,19 +422,29 @@ mono_gc_get_heap_size (void) int64_t mono_gc_get_max_time_slice_ns() { +#if HAVE_BDWGC_GC return GC_get_time_limit() * 1000000; +#else + return 0; +#endif } void mono_gc_set_max_time_slice_ns(int64_t maxTimeSlice) { +#if HAVE_BDWGC_GC GC_set_time_limit(maxTimeSlice / 1000000); +#endif } MonoBoolean mono_gc_is_incremental() { +#if HAVE_BDWGC_GC return GC_is_incremental_mode(); +#else + return FALSE; +#endif } gboolean From 0ca440541ccfa05002370e6d738e83aa4e776ef4 Mon Sep 17 00:00:00 2001 From: alexandru Date: Mon, 8 Oct 2018 12:21:15 +0200 Subject: [PATCH 321/582] * fixed incorrect offsetting in mono_mempool_foreach_block * removed start/stop loop when capturing heap sections in order to prevent data inconsistencies * moved stop/start world calls to the start/end of the capture function, we should always be stopped when collecting meta information * added waiting for currently running GC op --- mono/metadata/mempool.c | 2 +- mono/metadata/unity-memory-info.c | 39 +++++++++++-------------------- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/mono/metadata/mempool.c b/mono/metadata/mempool.c index 154b0213738f..c8b79af882cf 100644 --- a/mono/metadata/mempool.c +++ b/mono/metadata/mempool.c @@ -443,7 +443,7 @@ mono_mempool_foreach_block(MonoMemPool* pool, mono_mempool_block_proc callback, while (current) { gpointer start = (guint8*)current + SIZEOF_MEM_POOL; - gpointer end = (guint8*)start + current->size; + gpointer end = (guint8*)current + current->size; callback(start, end, user_data); current = current->next; diff --git a/mono/metadata/unity-memory-info.c b/mono/metadata/unity-memory-info.c index a81b0a28711f..ab539b370ec3 100644 --- a/mono/metadata/unity-memory-info.c +++ b/mono/metadata/unity-memory-info.c @@ -305,9 +305,7 @@ static void AllocateMemoryForMemPool(MonoMemPool* pool, void *user_data) static void AllocateMemoryForImageMemPool(MonoImage *image, gpointer value, void *user_data) { - mono_image_lock(image); AllocateMemoryForMemPool(image->mempool, user_data); - mono_image_unlock(image); } static void CopyMemPool(MonoMemPool *pool, SectionIterationContext *context) @@ -317,26 +315,17 @@ static void CopyMemPool(MonoMemPool *pool, SectionIterationContext *context) static void CopyImageMemPool(MonoImage *image, gpointer value, SectionIterationContext *context) { - mono_image_lock(image); CopyMemPool(image->mempool, context); - mono_image_unlock(image); } static void AllocateMemoryForImageClassCache(MonoImage *image, gpointer *value, void *user_data) { - mono_image_lock(image); - AllocateMemoryForSection(user_data, image->class_cache.table, ((uint8_t*)image->class_cache.table) + image->class_cache.size); - mono_image_unlock(image); } static void CopyImageClassCache(MonoImage *image, gpointer value, SectionIterationContext *context) { - mono_image_lock(image); - CopyHeapSection(context, image->class_cache.table, ((uint8_t*)image->class_cache.table) + image->class_cache.size); - - mono_image_unlock(image); } static void IncrementCountForImageSetMemPoolNumChunks(MonoImageSet *imageSet, void *user_data) @@ -491,18 +480,7 @@ static void CaptureManagedHeap(MonoManagedHeap* heap, GHashTable* monoImages) data.heap = heap; data.monoImages = monoImages; - while (TRUE) - { - GC_call_with_alloc_lock(CaptureHeapInfo, &data); - GC_stop_world_external(); - - if (MonoManagedHeapStillValid(heap, monoImages)) - break; - - GC_start_world_external(); - - FreeMonoManagedHeap(heap); - } + CaptureHeapInfo(&data); iterationContext.currentSection = heap->sections; @@ -512,8 +490,6 @@ static void CaptureManagedHeap(MonoManagedHeap* heap, GHashTable* monoImages) g_hash_table_foreach(monoImages, (GHFunc)CopyImageMemPool, &iterationContext); g_hash_table_foreach(monoImages, (GHFunc)CopyImageClassCache, &iterationContext); mono_metadata_image_set_foreach(CopyImageSetMemPool, &iterationContext); - - GC_start_world_external(); } static void GCHandleIterationCallback(MonoObject* managedObject, GList** managedObjects) @@ -638,6 +614,15 @@ static void CollectMonoImageFromAssembly(MonoAssembly *assembly, void *user_data MonoManagedMemorySnapshot* mono_unity_capture_memory_snapshot() { + int wasDisabled = GC_is_disabled(); + if (!wasDisabled) + GC_disable(); + + if (GC_collection_in_progress() == TRUE) + GC_wait_for_gc_completion(); + + GC_stop_world_external(); + MonoManagedMemorySnapshot* snapshot; snapshot = g_new0(MonoManagedMemorySnapshot, 1); @@ -656,6 +641,10 @@ MonoManagedMemorySnapshot* mono_unity_capture_memory_snapshot() g_hash_table_destroy(monoImages); + if (!wasDisabled) + GC_enable(); + + GC_start_world_external(); return snapshot; } From cdb817fa09d603756802ff5cdb209c37f3b5288b Mon Sep 17 00:00:00 2001 From: alexandru Date: Mon, 8 Oct 2018 17:10:48 +0200 Subject: [PATCH 322/582] removed redundant checks to GC_enable/disable, as the state is ref counted --- mono/metadata/unity-memory-info.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mono/metadata/unity-memory-info.c b/mono/metadata/unity-memory-info.c index ab539b370ec3..40ad93c1ec83 100644 --- a/mono/metadata/unity-memory-info.c +++ b/mono/metadata/unity-memory-info.c @@ -614,9 +614,7 @@ static void CollectMonoImageFromAssembly(MonoAssembly *assembly, void *user_data MonoManagedMemorySnapshot* mono_unity_capture_memory_snapshot() { - int wasDisabled = GC_is_disabled(); - if (!wasDisabled) - GC_disable(); + GC_disable(); if (GC_collection_in_progress() == TRUE) GC_wait_for_gc_completion(); @@ -641,10 +639,9 @@ MonoManagedMemorySnapshot* mono_unity_capture_memory_snapshot() g_hash_table_destroy(monoImages); - if (!wasDisabled) - GC_enable(); - GC_start_world_external(); + GC_enable(); + return snapshot; } From eb953459c7f2466f7d1b3a0dc3675362111d05f1 Mon Sep 17 00:00:00 2001 From: alexandru Date: Mon, 8 Oct 2018 17:40:13 +0200 Subject: [PATCH 323/582] removed redundant check for gc state as this is already handled by GC_wait_for_gc_completion --- mono/metadata/unity-memory-info.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mono/metadata/unity-memory-info.c b/mono/metadata/unity-memory-info.c index 40ad93c1ec83..dc125a56c389 100644 --- a/mono/metadata/unity-memory-info.c +++ b/mono/metadata/unity-memory-info.c @@ -615,9 +615,7 @@ static void CollectMonoImageFromAssembly(MonoAssembly *assembly, void *user_data MonoManagedMemorySnapshot* mono_unity_capture_memory_snapshot() { GC_disable(); - - if (GC_collection_in_progress() == TRUE) - GC_wait_for_gc_completion(); + GC_wait_for_gc_completion(TRUE); GC_stop_world_external(); From 0ae57f3ac29afe6364d39763e4ef56ffec16148d Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Wed, 10 Oct 2018 11:06:43 +0200 Subject: [PATCH 324/582] expose GC_collect_a_little --- mono/metadata/boehm-gc.c | 7 +++++++ mono/metadata/mono-gc.h | 1 + 2 files changed, 8 insertions(+) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index 11b3eb8116f7..12a74eea93d3 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -332,6 +332,13 @@ mono_gc_collect (int generation) GC_gcollect (); } + +int +mono_gc_collect_a_little() +{ + return GC_collect_a_little(); +} + /** * mono_gc_max_generation: * diff --git a/mono/metadata/mono-gc.h b/mono/metadata/mono-gc.h index 0bacfc882ed1..4908626761bb 100644 --- a/mono/metadata/mono-gc.h +++ b/mono/metadata/mono-gc.h @@ -104,6 +104,7 @@ typedef enum { } MonoGCHandleType; MONO_API void mono_gc_collect (int generation); +MONO_API int mono_gc_collect_a_little (); MONO_API int mono_gc_max_generation (void); MONO_API int mono_gc_get_generation (MonoObject *object); MONO_API int mono_gc_collection_count (int generation); From b8aac3e4324b100c2841cfdf10640c59cc0e14c7 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Wed, 10 Oct 2018 12:54:51 -0400 Subject: [PATCH 325/582] Allow the debugger to build with the Tiny runtime These changes are mirrored from the IL2CPP repo. --- mono/metadata/appdomain.h | 3 + mono/metadata/class-inlines.h | 6 + mono/metadata/domain.c | 6 + mono/metadata/metadata.c | 7 + mono/metadata/metadata.h | 3 + mono/mini/debugger-agent.c | 303 +++++++++--------- mono/mini/il2cpp-c-types.h | 8 + mono/mini/il2cpp-compat.h | 24 +- mono/mini/il2cpp-stubs.cpp | 581 +++++++++++++++++++++++++++++++++- 9 files changed, 788 insertions(+), 153 deletions(-) diff --git a/mono/metadata/appdomain.h b/mono/metadata/appdomain.h index 6885044693a2..6cbe6000c71b 100644 --- a/mono/metadata/appdomain.h +++ b/mono/metadata/appdomain.h @@ -86,6 +86,9 @@ mono_domain_get_id (MonoDomain *domain); MONO_API const char * mono_domain_get_friendly_name (MonoDomain *domain); +MonoAssembly* +m_domain_get_corlib (MonoDomain *domain); + MONO_API mono_bool mono_domain_set (MonoDomain *domain, mono_bool force); diff --git a/mono/metadata/class-inlines.h b/mono/metadata/class-inlines.h index d57d5310cc5a..4b4fb2eb518d 100644 --- a/mono/metadata/class-inlines.h +++ b/mono/metadata/class-inlines.h @@ -93,4 +93,10 @@ mono_class_has_static_metadata (MonoClass *klass) return klass->type_token && !klass->image->dynamic && !mono_class_is_ginst (klass); } +static inline gboolean +m_class_is_initialized (MonoClass* klass) +{ + return klass->inited; +} + #endif diff --git a/mono/metadata/domain.c b/mono/metadata/domain.c index 2dbfa916396f..aa10ceb9f652 100644 --- a/mono/metadata/domain.c +++ b/mono/metadata/domain.c @@ -1321,6 +1321,12 @@ mono_domain_get_friendly_name (MonoDomain *domain) return domain->friendly_name; } +MonoAssembly* +m_domain_get_corlib (MonoDomain *domain) +{ + return domain->domain->mbr.obj.vtable->klass->image->assembly; +} + /* * mono_domain_alloc: * diff --git a/mono/metadata/metadata.c b/mono/metadata/metadata.c index 40356de15092..89635ffc53a7 100644 --- a/mono/metadata/metadata.c +++ b/mono/metadata/metadata.c @@ -6720,6 +6720,13 @@ mono_type_get_class (MonoType *type) return type->data.klass; } +MonoGenericClass* +m_type_get_generic_class (MonoType *type) +{ + /* FIXME: review the runtime users before adding the assert here */ + return type->data.generic_class; +} + /** * mono_type_get_array_type: * \param type the \c MonoType operated on diff --git a/mono/metadata/metadata.h b/mono/metadata/metadata.h index 83db7315919c..b4a75a2ff051 100644 --- a/mono/metadata/metadata.h +++ b/mono/metadata/metadata.h @@ -351,6 +351,9 @@ mono_type_get_signature (MonoType *type); MONO_API MonoClass* mono_type_get_class (MonoType *type); +MonoGenericClass* +m_type_get_generic_class (MonoType *type); + MONO_API MonoArrayType* mono_type_get_array_type (MonoType *type); diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index c586c3b14fcd..96402dccbf08 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -203,7 +203,7 @@ typedef struct { MonoThreadUnwindState context; #ifdef RUNTIME_IL2CPP - Il2CppThreadUnwindState il2cpp_context; + Il2CppThreadUnwindState* il2cpp_context; #endif /* This is computed on demand when it is requested using the wire protocol */ @@ -2680,7 +2680,7 @@ save_thread_context (MonoContext *ctx) else mono_thread_state_init_from_current (&tls->context); #else - callbacks.il2cpp_debugger_save_thread_context(&tls->il2cpp_context, 0); + callbacks.il2cpp_debugger_save_thread_context(tls->il2cpp_context, 0); #endif // !RUNTIME_IL2CPP } @@ -3427,15 +3427,15 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls) mono_walk_stack_with_state (process_frame, &tls->context, opts, &user_data); #endif // RUNTIME_IL2CPP #ifdef RUNTIME_IL2CPP - } else if (tls->il2cpp_context.frameCount > 0) { - for (int frame_index = tls->il2cpp_context.frameCount - 1; frame_index >= 0; --frame_index) + } else if (tls->il2cpp_context->frameCount > 0) { + for (int frame_index = tls->il2cpp_context->frameCount - 1; frame_index >= 0; --frame_index) { - Il2CppSequencePoint* seq_point = tls->il2cpp_context.sequencePoints[frame_index]; + Il2CppSequencePoint* seq_point = tls->il2cpp_context->executionContexts[frame_index]->currentSequencePoint; StackFrame* frame = g_new0(StackFrame, 1); MonoMethod *sp_method = il2cpp_get_seq_point_method(seq_point); frame->method = sp_method; - frame->actual_method = tls->il2cpp_context.executionContexts[frame_index]->method; - frame->frame_context = tls->il2cpp_context.executionContexts[frame_index]; + frame->actual_method = tls->il2cpp_context->executionContexts[frame_index]->method; + frame->frame_context = tls->il2cpp_context->executionContexts[frame_index]; frame->api_method = sp_method; frame->il_offset = seq_point->ilOffset; frame->native_offset = 0; @@ -3704,9 +3704,9 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv if (mod->data.thread != mono_thread_internal_current ()) filtered = TRUE; } else if (mod->kind == MOD_KIND_EXCEPTION_ONLY && ei) { - if (mod->data.exc_class && mod->subclasses && !mono_class_is_assignable_from (mod->data.exc_class, ei->exc->vtable->klass)) + if (mod->data.exc_class && mod->subclasses && !mono_class_is_assignable_from (mod->data.exc_class, mono_object_get_class (ei->exc))) filtered = TRUE; - if (mod->data.exc_class && !mod->subclasses && mod->data.exc_class != ei->exc->vtable->klass) + if (mod->data.exc_class && !mod->subclasses && mod->data.exc_class != mono_object_get_class (ei->exc)) filtered = TRUE; if (ei->caught && !mod->caught) filtered = TRUE; @@ -3721,7 +3721,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv for (k = 0; assemblies [k]; ++k) #ifdef RUNTIME_IL2CPP { - if (assemblies[k] == sp_method->klass->image->assembly) + if (assemblies[k] == mono_image_get_assembly (mono_class_get_image (mono_method_get_class (sp_method)))) found = TRUE; } #else @@ -3777,7 +3777,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, DebuggerEv } else if (mod->kind == MOD_KIND_TYPE_NAME_ONLY && ei && ei->klass) { char *s; - s = mono_type_full_name (&ei->klass->byval_arg); + s = mono_type_full_name (mono_class_get_type(ei->klass)); if (!g_hash_table_lookup (mod->data.type_names, s)) filtered = TRUE; g_free (s); @@ -4180,6 +4180,7 @@ thread_startup (MonoProfiler *prof, uintptr_t tid) MONO_GC_REGISTER_ROOT_SINGLE (tls->thread, MONO_ROOT_SOURCE_DEBUGGER, NULL, "Debugger Thread Reference"); #ifdef RUNTIME_IL2CPP il2cpp_gc_wbarrier_set_field(tls, (void**)&tls->thread, thread); + tls->il2cpp_context = il2cpp_debugger_get_thread_context (); #else tls->thread = thread; #endif @@ -4629,6 +4630,14 @@ remove_breakpoint (BreakpointInstance *inst) #endif // !RUNTIME_IL2CPP +#if RUNTIME_IL2CPP + +int32_t il2cpp_mono_methods_match(const MethodInfo* left, const MethodInfo* right); +MonoImage* il2cpp_mono_assembly_get_image(MonoAssembly* assembly); +void il2cpp_mono_free_method_signatures(void); + +#endif // RUNTIME_IL2CPP + /* * This doesn't take any locks. */ @@ -5205,7 +5214,7 @@ ss_update_il2cpp(SingleStepReq *req, DebuggerTlsData *tls, MonoContext *ctx, Il2 // Because functions can call themselves recursively, we need to make sure we're stopping at the right stack depth. // In case of step out, the target is the frame *enclosing* the one where the request was made. int target_frames = req->nframes + (is_step_out ? -1 : 0); - if (req->nframes > 0 && tls->il2cpp_context.frameCount > 0 && tls->il2cpp_context.frameCount > target_frames) + if (req->nframes > 0 && tls->il2cpp_context->frameCount > 0 && tls->il2cpp_context->frameCount > target_frames) { /* Hit the breakpoint in a recursive call, don't halt */ DEBUG_PRINTF(1, "[%p] Breakpoint at lower frame while stepping %s, continuing single stepping.\n", (gpointer)(gsize)mono_native_thread_id_get(), is_step_out ? "out" : "over"); @@ -5226,7 +5235,7 @@ ss_update_il2cpp(SingleStepReq *req, DebuggerTlsData *tls, MonoContext *ctx, Il2 } else if (sequencePoint->lineEnd >= 0 && sp_method == ss_req->last_method && sequencePoint->lineEnd == ss_req->last_line) { - if (tls->il2cpp_context.frameCount == req->nframes) + if (tls->il2cpp_context->frameCount == req->nframes) { // If the frame has changed we're clearly not on the same source line. DEBUG_PRINTF(1, "[%p] Same source line (%d), continuing single stepping.\n", (gpointer)(gsize)mono_native_thread_id_get(), sequencePoint->lineEnd); hit = FALSE; @@ -5246,7 +5255,7 @@ ss_update_il2cpp(SingleStepReq *req, DebuggerTlsData *tls, MonoContext *ctx, Il2 static gboolean breakpoint_matches_assembly (MonoBreakpoint *bp, MonoAssembly *assembly) { - return bp->method && bp->method->klass->image->assembly == assembly; + return bp->method && mono_image_get_assembly (mono_class_get_image (mono_method_get_class (bp->method))) == assembly; } static gpointer @@ -5309,12 +5318,12 @@ get_async_method_builder (StackFrame *frame) if (!this_addr) return NULL; - if (frame->method->klass->valuetype) { + if (mono_class_is_valuetype (frame->method->klass)) { guint8 *vtaddr = *(guint8**)this_addr; - builder = (char*)vtaddr + builder_field->offset - sizeof (MonoObject); + builder = (char*)vtaddr + mono_field_get_offset (builder_field) - sizeof (MonoObject); } else { this_obj = *(MonoObject**)this_addr; - builder = (char*)this_obj + builder_field->offset; + builder = (char*)this_obj + mono_field_get_offset (builder_field); } return builder; @@ -5351,7 +5360,7 @@ get_this_async_id (StackFrame *frame) tls->disable_breakpoints = TRUE; } - method = get_object_id_for_debugger_method (mono_class_from_mono_type (builder_field->type)); + method = get_object_id_for_debugger_method (mono_class_from_mono_type (mono_field_get_type (builder_field))); obj = mono_runtime_try_invoke (method, builder, NULL, &ex, &error); mono_error_assert_ok (&error); @@ -5373,7 +5382,7 @@ set_set_notification_for_wait_completion_flag (StackFrame *frame) gboolean arg = TRUE; MonoError error; args [0] = &arg; - mono_runtime_invoke_checked (get_set_notification_method (mono_class_from_mono_type (builder_field->type)), builder, args, &error); + mono_runtime_invoke_checked (get_set_notification_method (mono_class_from_mono_type (mono_field_get_type (builder_field))), builder, args, &error); mono_error_assert_ok (&error); } @@ -5382,6 +5391,9 @@ static MonoMethod* notify_debugger_of_wait_completion_method_cache = NULL; static MonoMethod* get_notify_debugger_of_wait_completion_method (void) { +#if UNITY_TINY + return NULL; +#else if (notify_debugger_of_wait_completion_method_cache != NULL) return notify_debugger_of_wait_completion_method_cache; MonoError error; @@ -5392,6 +5404,7 @@ get_notify_debugger_of_wait_completion_method (void) notify_debugger_of_wait_completion_method_cache = (MonoMethod *)g_ptr_array_index (array, 0); g_ptr_array_free (array, TRUE); return notify_debugger_of_wait_completion_method_cache; +#endif // UNITY_TINY } #ifndef RUNTIME_IL2CPP @@ -5847,7 +5860,7 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, int seque #ifndef RUNTIME_IL2CPP process_event (EVENT_KIND_STEP, jinfo_get_method (ji), il_offset, ctx, events, suspend_policy); #else - Il2CppSequencePoint* sequence_pt = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]; + Il2CppSequencePoint* sequence_pt = tls->il2cpp_context->executionContexts[tls->il2cpp_context->frameCount - 1]->currentSequencePoint; MonoMethod *sp_method = il2cpp_get_seq_point_method(sequence_pt); /* @@ -5859,7 +5872,7 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal, int seque gboolean found = FALSE; for (int k = 0; ss_req->user_assemblies[k]; k++) { - if (ss_req->user_assemblies[k] == sp_method->klass->image->assembly) + if (ss_req->user_assemblies[k] == mono_image_get_assembly (mono_class_get_image (mono_method_get_class (sp_method)))) { found = TRUE; break; @@ -6436,7 +6449,7 @@ ss_start_il2cpp(SingleStepReq *ss_req, DebuggerTlsData *tls, Il2CppSequencePoint } else { if (ss_req->depth == STEP_DEPTH_OVER) { - MonoMethod* currentMethod = il2cpp_get_seq_point_method(tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]); + MonoMethod* currentMethod = il2cpp_get_seq_point_method(tls->il2cpp_context->executionContexts[tls->il2cpp_context->frameCount - 1]->currentSequencePoint); void *seqPointIter = NULL; Il2CppSequencePoint *seqPoint; @@ -6450,9 +6463,9 @@ ss_start_il2cpp(SingleStepReq *ss_req, DebuggerTlsData *tls, Il2CppSequencePoint } } - if (tls->il2cpp_context.frameCount > 1) + if (tls->il2cpp_context->frameCount > 1) { - Il2CppSequencePoint* sequencePointForStepOut = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 2]; + Il2CppSequencePoint* sequencePointForStepOut = tls->il2cpp_context->executionContexts[tls->il2cpp_context->frameCount - 2]->currentSequencePoint; g_assert(sequencePointForStepOut->kind == kSequencePointKind_StepOut); ss_bp_add_one_il2cpp(ss_req, &ss_req_bp_count, &ss_req_bp_cache, sequencePointForStepOut); } @@ -6541,12 +6554,12 @@ ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilte g_assert (tls); #ifdef RUNTIME_IL2CPP - ss_req->nframes = tls->il2cpp_context.frameCount; + ss_req->nframes = tls->il2cpp_context->frameCount; Il2CppSequencePoint *catchFrameSp = NULL; - if (tls->il2cpp_context.frameCount > 0) + if (tls->il2cpp_context->frameCount > 0) { - Il2CppSequencePoint* seq_point = tls->il2cpp_context.sequencePoints[tls->il2cpp_context.frameCount - 1]; + Il2CppSequencePoint* seq_point = tls->il2cpp_context->executionContexts[tls->il2cpp_context->frameCount - 1]->currentSequencePoint; MonoMethod *sp_method = il2cpp_get_seq_point_method(seq_point); ss_req->start_method = sp_method; ss_req->last_method = sp_method; @@ -6769,7 +6782,7 @@ static Il2CppSequencePoint* il2cpp_find_catch_sequence_point_in_method(Il2CppSeq while (sp = il2cpp_get_method_sequence_points(method, &seqPointIter)) { MonoClass *catchType = il2cpp_get_class_from_index(sp->catchTypeIndex); - if (sp->tryDepth == tryDepth && sp->ilOffset > ilOffset && catchType != NULL && mono_class_is_assignable_from(catchType, exc->object.vtable->klass)) + if (sp->tryDepth == tryDepth && sp->ilOffset > ilOffset && catchType != NULL && mono_class_is_assignable_from (catchType, mono_object_get_class (&exc->object))) return sp; } @@ -6778,10 +6791,10 @@ static Il2CppSequencePoint* il2cpp_find_catch_sequence_point_in_method(Il2CppSeq static Il2CppSequencePoint* il2cpp_find_catch_sequence_point(DebuggerTlsData *tls) { - int frameIndex = tls->il2cpp_context.frameCount - 1; + int frameIndex = tls->il2cpp_context->frameCount - 1; while (frameIndex >= 0) { - Il2CppSequencePoint* sp = il2cpp_find_catch_sequence_point_in_method(tls->il2cpp_context.sequencePoints[frameIndex], tls->exception); + Il2CppSequencePoint* sp = il2cpp_find_catch_sequence_point_in_method(tls->il2cpp_context->executionContexts[frameIndex]->currentSequencePoint, tls->exception); if (sp) return sp; @@ -6802,10 +6815,10 @@ static Il2CppSequencePoint* il2cpp_find_catch_sequence_point_from_exeption(Debug return sp; } - int frameIndex = tls->il2cpp_context.frameCount - 1; + int frameIndex = tls->il2cpp_context->frameCount - 1; while (frameIndex >= 0) { - sp = il2cpp_find_catch_sequence_point_in_method(tls->il2cpp_context.sequencePoints[frameIndex], exc); + sp = il2cpp_find_catch_sequence_point_in_method(tls->il2cpp_context->executionContexts[frameIndex]->currentSequencePoint, exc); if (sp) return sp; @@ -6874,7 +6887,7 @@ unity_debugger_agent_handle_exception(MonoException *exc, Il2CppSequencePoint *s if (assemblies) { for (k = 0; assemblies[k]; ++k) - if (assemblies[k] == sp_method->klass->image->assembly) + if (assemblies[k] == mono_image_get_assembly (mono_class_get_image (mono_method_get_class (sp_method)))) found = TRUE; } if (!found) @@ -6956,7 +6969,7 @@ mono_debugger_agent_handle_exception (MonoException *exc, MonoContext *throw_ctx for (l = agent_config.onthrow; l; l = l->next) { char *ex_type = (char *)l->data; - char *f = mono_type_full_name (&exc->object.vtable->klass->byval_arg); + char *f = mono_type_full_name (mono_class_get_type (mono_object_get_class (&exc->object))); if (!strcmp (ex_type, "") || !strcmp (ex_type, f)) found = TRUE; @@ -7011,7 +7024,7 @@ mono_debugger_agent_handle_exception (MonoException *exc, MonoContext *throw_ctx if (assemblies) { for (k = 0; assemblies [k]; ++k) - if (assemblies [k] == jinfo_get_method (catch_ji)->klass->image->assembly) + if (assemblies [k] == mono_image_get_assembly (mono_class_get_image (mono_method_get_class (jinfo_get_method (catch_ji))))) found = TRUE; } if (!found) @@ -7197,7 +7210,7 @@ static void buffer_add_value_full (Buffer *buf, MonoType *t, void *addr, MonoDom if (!obj) { buffer_add_byte (buf, VALUE_TYPE_ID_NULL); } else { - if (obj->vtable->klass->valuetype) { + if (mono_class_is_valuetype (mono_object_get_class (obj))) { t = &obj->vtable->klass->byval_arg; addr = mono_object_unbox (obj); boxed_vtype = TRUE; @@ -7447,14 +7460,14 @@ static void buffer_add_value_full(Buffer *buf, MonoType *t, void *addr, MonoDoma } buffer_add_byte(buf, MONO_TYPE_VALUETYPE); - buffer_add_byte(buf, klass->enumtype); + buffer_add_byte(buf, mono_class_is_enum (klass)); buffer_add_typeid(buf, domain, klass); nfields = 0; iter = NULL; while ((f = mono_class_get_fields(klass, &iter))) { - if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) + if (mono_type_get_attrs (mono_field_get_type (f)) & FIELD_ATTRIBUTE_STATIC) continue; if (mono_field_is_deleted(f)) continue; @@ -7465,11 +7478,11 @@ static void buffer_add_value_full(Buffer *buf, MonoType *t, void *addr, MonoDoma iter = NULL; while ((f = mono_class_get_fields(klass, &iter))) { - if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) + if (mono_type_get_attrs (mono_field_get_type (f)) & FIELD_ATTRIBUTE_STATIC) continue; if (mono_field_is_deleted(f)) continue; - buffer_add_value_full(buf, f->type, (guint8*)addr + f->offset - sizeof(MonoObject), domain, FALSE, parent_vtypes); + buffer_add_value_full(buf, mono_field_get_type (f), (guint8*)addr + mono_field_get_offset (f) - sizeof(MonoObject), domain, FALSE, parent_vtypes); } if (boxed_vtype) @@ -7508,7 +7521,7 @@ buffer_add_value (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain) static gboolean obj_is_of_type (MonoObject *obj, MonoType *t) { - MonoClass *klass = obj->vtable->klass; + MonoClass *klass = mono_object_get_class (obj); if (!mono_class_is_assignable_from (mono_class_from_mono_type (t), klass)) { if (mono_class_is_transparent_proxy (klass)) { klass = ((MonoTransparentProxy *)obj)->remote_class->proxy_class; @@ -7554,11 +7567,11 @@ decode_vtype (MonoType *t, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8 nfields = decode_int (buf, &buf, limit); while ((f = mono_class_get_fields (klass, &iter))) { - if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) + if (mono_type_get_attrs (mono_field_get_type (f)) & FIELD_ATTRIBUTE_STATIC) continue; if (mono_field_is_deleted(f)) continue; - err = decode_value (f->type, domain, (guint8*)addr + f->offset - sizeof (MonoObject), buf, &buf, limit); + err = decode_value (mono_field_get_type (f), domain, (guint8*)addr + mono_field_get_offset (f) - sizeof (MonoObject), buf, &buf, limit); if (err != ERR_NONE) return err; nfields --; @@ -7655,11 +7668,11 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr, return err; if (!obj) return ERR_INVALID_ARGUMENT; - if (obj->vtable->klass != mono_class_from_mono_type (t)) { - DEBUG_PRINTF (1, "Expected type '%s', got object '%s'\n", mono_type_full_name (t), obj->vtable->klass->name); + if (mono_object_get_class (obj) != mono_class_from_mono_type (t)) { + DEBUG_PRINTF (1, "Expected type '%s', got object '%s'\n", mono_type_full_name (t), mono_class_get_name (mono_object_get_class (obj))); return ERR_INVALID_ARGUMENT; } - memcpy (addr, mono_object_unbox (obj), mono_class_value_size (obj->vtable->klass, NULL)); + memcpy (addr, mono_object_unbox (obj), mono_class_value_size (mono_object_get_class (obj), NULL)); } else { err = decode_vtype (t, domain, addr, buf, &buf, limit); if (err != ERR_NONE) @@ -7680,7 +7693,7 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr, if (obj) { if (!obj_is_of_type (obj, t)) { - DEBUG_PRINTF (1, "Expected type '%s', got '%s'\n", mono_type_full_name (t), obj->vtable->klass->name); + DEBUG_PRINTF (1, "Expected type '%s', got '%s'\n", mono_type_full_name (t), mono_class_get_name (mono_object_get_class (obj))); return ERR_INVALID_ARGUMENT; } } @@ -7723,7 +7736,11 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr, g_free (vtype_buf); return err; } +#ifdef RUNTIME_IL2CPP + il2cpp_gc_wbarrier_set_field(NULL, (void**)addr, mono_value_box_checked (d, klass, vtype_buf, &error)); +#else *(MonoObject**)addr = mono_value_box_checked (d, klass, vtype_buf, &error); +#endif mono_error_cleanup (&error); g_free (vtype_buf); } else { @@ -7751,7 +7768,7 @@ decode_value (MonoType *t, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8 int type = decode_byte (buf, &buf, limit); if (t->type == MONO_TYPE_GENERICINST && mono_class_is_nullable (mono_class_from_mono_type (t))) { - MonoType *targ = t->data.generic_class->context.class_inst->type_argv[0]; + MonoType *targ = mono_generic_class_get_context (m_type_get_generic_class (t))->class_inst->type_argv[0]; guint8 *nullable_buf; /* @@ -8034,7 +8051,7 @@ clear_assembly_from_modifier (EventRequest *req, Modifier *m, MonoAssembly *asse { int i; - if (m->kind == MOD_KIND_EXCEPTION_ONLY && m->data.exc_class && m->data.exc_class->image->assembly == assembly) + if (m->kind == MOD_KIND_EXCEPTION_ONLY && m->data.exc_class && mono_image_get_assembly (mono_class_get_image (m->data.exc_class) == assembly)) m->kind = MOD_KIND_NONE; if (m->kind == MOD_KIND_ASSEMBLY_ONLY && m->data.assemblies) { int count = 0, match_count = 0, pos; @@ -8176,7 +8193,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 * Invoke this method directly, currently only Environment.Exit () is supported. */ this_arg = NULL; - DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (invoke->method, TRUE), this_arg ? this_arg->vtable->klass->name : ""); + DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (invoke->method, TRUE), this_arg ? mono_class_get_name (mono_object_get_class (this_arg)) : ""); mono_runtime_try_invoke (invoke->method, NULL, invoke->args, &exc, &error); mono_error_assert_ok (&error); @@ -8189,7 +8206,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 return err; sig = mono_method_signature (m); - if (m->klass->valuetype) + if (mono_class_is_valuetype (m->klass)) this_buf = (guint8 *)g_alloca (mono_class_instance_size (m->klass)); else this_buf = (guint8 *)g_alloca (sizeof (MonoObject*)); @@ -8197,7 +8214,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 if (m->is_generic) { DEBUG_PRINTF (1, "[%p] Error: Attemtping to invoke uninflated generic method %s.\n", (gpointer)(gsize)mono_native_thread_id_get (), mono_method_full_name (m, TRUE)); return ERR_INVALID_ARGUMENT; - } else if (m->klass->valuetype && (m->flags & METHOD_ATTRIBUTE_STATIC)) { + } else if (mono_class_is_valuetype (m->klass) && (m->flags & METHOD_ATTRIBUTE_STATIC)) { /* Should be null */ int type = decode_byte (p, &p, end); if (type != VALUE_TYPE_ID_NULL) { @@ -8205,7 +8222,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 return ERR_INVALID_ARGUMENT; } memset (this_buf, 0, mono_class_instance_size (m->klass)); - } else if (m->klass->valuetype && !strcmp (m->name, ".ctor")) { + } else if (mono_class_is_valuetype(m->klass) && !strcmp (m->name, ".ctor")) { /* Could be null */ guint8 *tmp_p; @@ -8214,19 +8231,19 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 memset (this_buf, 0, mono_class_instance_size (m->klass)); p = tmp_p; } else { - err = decode_value(&m->klass->byval_arg, domain, this_buf, p, &p, end); + err = decode_value(mono_class_get_type (m->klass), domain, this_buf, p, &p, end); if (err != ERR_NONE) return err; } } else { - err = decode_value (&m->klass->byval_arg, domain, this_buf, p, &p, end); + err = decode_value (mono_class_get_type (m->klass), domain, this_buf, p, &p, end); if (err != ERR_NONE) return err; } - if (!m->klass->valuetype) + if (!mono_class_is_valuetype (m->klass)) this_arg = *(MonoObject**)this_buf; else this_arg = NULL; @@ -8238,28 +8255,28 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 } m = mono_object_get_virtual_method (this_arg, m); /* Transform this to the format the rest of the code expects it to be */ - if (m->klass->valuetype) { + if (mono_class_is_valuetype (m->klass)) { this_buf = (guint8 *)g_alloca (mono_class_instance_size (m->klass)); memcpy (this_buf, mono_object_unbox (this_arg), mono_class_instance_size (m->klass)); } - } else if ((m->flags & METHOD_ATTRIBUTE_VIRTUAL) && !m->klass->valuetype && invoke->flags & INVOKE_FLAG_VIRTUAL) { + } else if ((m->flags & METHOD_ATTRIBUTE_VIRTUAL) && !mono_class_is_valuetype (m->klass) && invoke->flags & INVOKE_FLAG_VIRTUAL) { if (!this_arg) { DEBUG_PRINTF (1, "[%p] Error: invoke with INVOKE_FLAG_VIRTUAL flag set without this argument.\n", (gpointer) (gsize) mono_native_thread_id_get ()); return ERR_INVALID_ARGUMENT; } m = mono_object_get_virtual_method (this_arg, m); - if (m->klass->valuetype) { + if (mono_class_is_valuetype (m->klass)) { this_buf = (guint8 *)g_alloca (mono_class_instance_size (m->klass)); memcpy (this_buf, mono_object_unbox (this_arg), mono_class_instance_size (m->klass)); } } - DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (m, TRUE), this_arg ? this_arg->vtable->klass->name : ""); + DEBUG_PRINTF (1, "[%p] Invoking method '%s' on receiver '%s'.\n", (gpointer) (gsize) mono_native_thread_id_get (), mono_method_full_name (m, TRUE), this_arg ? mono_class_get_name (mono_object_get_class (this_arg)): ""); if (this_arg && VM_OBJECT_GET_DOMAIN(this_arg) != domain) NOT_IMPLEMENTED; - if (!m->klass->valuetype && !(m->flags & METHOD_ATTRIBUTE_STATIC) && !this_arg) { + if (!mono_class_is_valuetype (m->klass) && !(m->flags & METHOD_ATTRIBUTE_STATIC) && !this_arg) { if (!strcmp (m->name, ".ctor")) { if (mono_class_is_abstract (m->klass)) return ERR_INVALID_ARGUMENT; @@ -8273,7 +8290,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 } } - if (this_arg && !obj_is_of_type (this_arg, &m->klass->byval_arg)) + if (this_arg && !obj_is_of_type (this_arg, mono_class_get_type (m->klass))) return ERR_INVALID_ARGUMENT; nargs = decode_int (p, &p, end); @@ -8340,17 +8357,17 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 #endif mono_stopwatch_start (&watch); - res = mono_runtime_try_invoke (m, m->klass->valuetype ? (gpointer)this_buf : (gpointer)this_arg, args, &exc, &error); + res = mono_runtime_try_invoke (m, mono_class_is_valuetype (m->klass) ? (gpointer)this_buf : (gpointer)this_arg, args, &exc, &error); if (!mono_error_ok (&error) && exc == NULL) { exc = (MonoObject*) mono_error_convert_to_exception (&error); } else { mono_error_cleanup (&error); /* FIXME report error */ } mono_stopwatch_stop (&watch); - DEBUG_PRINTF (1, "[%p] Invoke result: %p, exc: %s, time: %ld ms.\n", (gpointer) (gsize) mono_native_thread_id_get (), res, exc ? exc->vtable->klass->name : NULL, (long)mono_stopwatch_elapsed_ms (&watch)); + DEBUG_PRINTF (1, "[%p] Invoke result: %p, exc: %s, time: %ld ms.\n", (gpointer) (gsize) mono_native_thread_id_get (), res, exc ? mono_class_get_name (mono_object_get_class (exc)) : NULL, (long)mono_stopwatch_elapsed_ms (&watch)); if (exc) { buffer_add_byte (buf, 0); - buffer_add_value (buf, &VM_DEFAULTS_OBJECT_CLASS->byval_arg, &exc, domain); + buffer_add_value (buf, mono_class_get_type (VM_DEFAULTS_OBJECT_CLASS), &exc, domain); } else { gboolean out_this = FALSE; gboolean out_args = FALSE; @@ -8361,24 +8378,24 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 out_args = TRUE; buffer_add_byte (buf, 1 + (out_this ? 2 : 0) + (out_args ? 4 : 0)); if (VM_METHOD_IS_STRING_CTOR(m)) { - buffer_add_value (buf, &mono_get_string_class ()->byval_arg, &res, domain); + buffer_add_value (buf, mono_class_get_type (mono_get_string_class ()), &res, domain); } else if ( sig->ret->type == MONO_TYPE_VOID && !VM_METHOD_IS_STRING_CTOR(m)) { if (!strcmp (m->name, ".ctor")) { - if (!m->klass->valuetype) - buffer_add_value (buf, &VM_DEFAULTS_OBJECT_CLASS->byval_arg, &this_arg, domain); + if (!mono_class_is_valuetype (m->klass)) + buffer_add_value (buf, mono_class_get_type (VM_DEFAULTS_OBJECT_CLASS), &this_arg, domain); else - buffer_add_value (buf, &m->klass->byval_arg, this_buf, domain); + buffer_add_value (buf, mono_class_get_type (m->klass), this_buf, domain); } else { - buffer_add_value (buf, &VM_DEFAULTS_VOID_CLASS->byval_arg, NULL, domain); + buffer_add_value (buf, mono_class_get_type (VM_DEFAULTS_VOID_CLASS), NULL, domain); } } else if (MONO_TYPE_IS_REFERENCE (sig->ret)) { if (sig->ret->byref) { - MonoType* ret_byval = &mono_class_from_mono_type (sig->ret)->byval_arg; + MonoType* ret_byval = mono_class_get_type (mono_class_from_mono_type (sig->ret)); buffer_add_value (buf, ret_byval, &res, domain); } else { buffer_add_value (buf, sig->ret, &res, domain); } - } else if (mono_class_from_mono_type (sig->ret)->valuetype || sig->ret->type == MONO_TYPE_PTR || sig->ret->type == MONO_TYPE_FNPTR) { + } else if (mono_class_is_valuetype (mono_class_from_mono_type (sig->ret)) || sig->ret->type == MONO_TYPE_PTR || sig->ret->type == MONO_TYPE_FNPTR) { if (mono_class_is_nullable (mono_class_from_mono_type (sig->ret))) { MonoClass *k = mono_class_from_mono_type (sig->ret); guint8 *nullable_buf = (guint8 *)g_alloca (mono_class_value_size (k, NULL)); @@ -8390,7 +8407,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 g_assert (res); if (sig->ret->byref) { - MonoType* ret_byval = &mono_class_from_mono_type (sig->ret)->byval_arg; + MonoType* ret_byval = mono_class_get_type (mono_class_from_mono_type (sig->ret)); buffer_add_value (buf, ret_byval, mono_object_unbox (res), domain); } else { buffer_add_value (buf, sig->ret, mono_object_unbox (res), domain); @@ -8401,7 +8418,7 @@ do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, guint8 } if (out_this) /* Return the new value of the receiver after the call */ - buffer_add_value (buf, &m->klass->byval_arg, this_buf, domain); + buffer_add_value (buf, mono_class_get_type (m->klass), this_buf, domain); if (out_args) { buffer_add_int (buf, nargs); for (i = 0; i < nargs; ++i) { @@ -9088,7 +9105,7 @@ event_commands (int command, guint8 *p, guint8 *end, Buffer *buf) req->modifiers [i].subclasses = decode_byte (p, &p, end); else req->modifiers [i].subclasses = TRUE; - DEBUG_PRINTF (1, "[dbg] \tEXCEPTION_ONLY filter (%s%s%s%s).\n", exc_class ? exc_class->name : "all", req->modifiers [i].caught ? ", caught" : "", req->modifiers [i].uncaught ? ", uncaught" : "", req->modifiers [i].subclasses ? ", include-subclasses" : ""); + DEBUG_PRINTF (1, "[dbg] \tEXCEPTION_ONLY filter (%s%s%s%s).\n", exc_class ? mono_class_get_name (exc_class) : "all", req->modifiers [i].caught ? ", caught" : "", req->modifiers [i].uncaught ? ", uncaught" : "", req->modifiers [i].subclasses ? ", include-subclasses" : ""); if (exc_class) { req->modifiers [i].data.exc_class = exc_class; @@ -9170,7 +9187,7 @@ event_commands (int command, guint8 *p, guint8 *end, Buffer *buf) tls = (DebuggerTlsData *)mono_g_hash_table_lookup(thread_to_tls, THREAD_TO_INTERNAL(step_thread)); mono_loader_unlock(); - if (tls->il2cpp_context.frameCount == 1 && depth == STEP_DEPTH_OUT) + if (tls->il2cpp_context->frameCount == 1 && depth == STEP_DEPTH_OUT) { g_free(req); return ERR_NONE; @@ -9328,7 +9345,7 @@ domain_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (err != ERR_NONE) return err; - buffer_add_assemblyid (buf, domain, domain->domain->mbr.obj.vtable->klass->image->assembly); + buffer_add_assemblyid (buf, domain, m_domain_get_corlib (domain)); break; } case CMD_APPDOMAIN_CREATE_STRING: { @@ -9429,7 +9446,7 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) guint32 token; MonoMethod *m; - if (ass->image->dynamic) { + if (mono_image_is_dynamic (ass->image)) { buffer_add_id (buf, 0); } else { #ifdef RUNTIME_IL2CPP @@ -9538,12 +9555,12 @@ module_commands (int command, guint8 *p, guint8 *end, Buffer *buf) MonoImage *image = decode_moduleid (p, &p, end, &domain, &err); char *basename; - basename = g_path_get_basename (image->name); + basename = g_path_get_basename (mono_image_get_filename (image)); buffer_add_string (buf, basename); // name buffer_add_string (buf, VM_IMAGE_GET_MODULE_NAME(image)); // scopename - buffer_add_string (buf, image->name); // fqname + buffer_add_string (buf, mono_image_get_filename (image)); // fqname buffer_add_string (buf, mono_image_get_guid (image)); // guid - buffer_add_assemblyid (buf, domain, image->assembly); // assembly + buffer_add_assemblyid (buf, domain, mono_image_get_assembly (image)); // assembly g_free (basename); break; } @@ -9564,10 +9581,10 @@ field_commands (int command, guint8 *p, guint8 *end, Buffer *buf) case CMD_FIELD_GET_INFO: { MonoClassField *f = decode_fieldid (p, &p, end, &domain, &err); - buffer_add_string (buf, f->name); - buffer_add_typeid (buf, domain, f->parent); - buffer_add_typeid (buf, domain, mono_class_from_mono_type (f->type)); - buffer_add_int (buf, f->type->attrs); + buffer_add_string (buf, mono_field_get_name (f)); + buffer_add_typeid (buf, domain, mono_field_get_parent (f)); + buffer_add_typeid (buf, domain, mono_class_from_mono_type (mono_field_get_type (f))); + buffer_add_int (buf, mono_type_get_attrs (mono_field_get_type (f))); break; } default: @@ -9580,7 +9597,7 @@ field_commands (int command, guint8 *p, guint8 *end, Buffer *buf) static void buffer_add_cattr_arg (Buffer *buf, MonoType *t, MonoDomain *domain, MonoObject *val) { - if (val && val->vtable->klass == mono_defaults.runtimetype_class) { + if (val && mono_object_get_class(val) == mono_defaults.runtimetype_class) { /* Special case these so the client doesn't have to handle Type objects */ buffer_add_byte (buf, VALUE_TYPE_ID_TYPE); @@ -9762,7 +9779,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint int count, i; if (mono_class_is_ginst (klass)) { - MonoGenericInst *inst = mono_class_get_generic_class(klass)->context.class_inst; + MonoGenericInst *inst = mono_generic_class_get_context (mono_class_get_generic_class (klass))->class_inst; count = inst->type_argc; buffer_add_int (buf, count); @@ -9815,9 +9832,9 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint while ((f = mono_class_get_fields (klass, &iter))) { buffer_add_fieldid (buf, domain, f); - buffer_add_string (buf, f->name); - buffer_add_typeid (buf, domain, mono_class_from_mono_type (mono_field_get_type(f))); - buffer_add_int (buf, mono_field_get_type(f)->attrs); + buffer_add_string (buf, mono_field_get_name (f)); + buffer_add_typeid (buf, domain, mono_class_from_mono_type (mono_field_get_type (f))); + buffer_add_int (buf, mono_type_get_attrs (mono_field_get_type (f))); i ++; } g_assert (i == nfields); @@ -9835,10 +9852,10 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint while ((p = mono_class_get_properties (klass, &iter))) { buffer_add_propertyid (buf, domain, p); - buffer_add_string (buf, p->name); - buffer_add_methodid (buf, domain, p->get); - buffer_add_methodid (buf, domain, p->set); - buffer_add_int (buf, p->attrs); + buffer_add_string (buf, mono_property_get_name (p)); + buffer_add_methodid (buf, domain, mono_property_get_get_method (p)); + buffer_add_methodid (buf, domain, mono_property_get_set_method (p)); + buffer_add_int (buf, mono_type_get_attrs (mono_property_get_parent (p))); i ++; } g_assert (i == nprops); @@ -9954,11 +9971,11 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint if (err != ERR_NONE) return err; - if (!(f->type->attrs & FIELD_ATTRIBUTE_STATIC)) + if (!(mono_type_get_attrs (mono_field_get_type (f)) & FIELD_ATTRIBUTE_STATIC)) return ERR_INVALID_FIELDID; #ifdef RUNTIME_IL2CPP - if (!thread && f->offset == THREAD_STATIC_FIELD_OFFSET) + if (!thread && mono_field_get_offset (f) == THREAD_STATIC_FIELD_OFFSET) return ERR_INVALID_FIELDID; #else special_static_type = mono_class_field_get_special_static_type (f); @@ -9969,8 +9986,8 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint #endif /* Check that the field belongs to the object */ found = FALSE; - for (k = klass; k; k = k->parent) { - if (k == f->parent) { + for (k = klass; k; k = mono_class_get_parent(k)) { + if (k == mono_field_get_parent(f)) { found = TRUE; break; } @@ -9978,12 +9995,12 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint if (!found) return ERR_INVALID_FIELDID; - vtable = mono_class_vtable (domain, f->parent); - val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type))); + vtable = mono_class_vtable (domain, mono_field_get_parent (f)); + val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (mono_field_get_type (f)))); mono_field_static_get_value_for_thread (thread ? thread : mono_thread_internal_current (), vtable, f, val, &error); if (!is_ok (&error)) return ERR_INVALID_FIELDID; - buffer_add_value (buf, f->type, val, domain); + buffer_add_value (buf, mono_field_get_type (f), val, domain); g_free (val); } break; @@ -10002,7 +10019,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint if (err != ERR_NONE) return err; - if (!(mono_field_get_type(f)->attrs & FIELD_ATTRIBUTE_STATIC)) + if (!(mono_type_get_attrs (mono_field_get_type (f)) & FIELD_ATTRIBUTE_STATIC)) return ERR_INVALID_FIELDID; if (mono_class_field_is_special_static (f)) return ERR_INVALID_FIELDID; @@ -10108,7 +10125,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint tclass = klass; - for (parent = tclass; parent; parent = parent->parent) { + for (parent = tclass; parent; parent = mono_class_get_parent (parent)) { mono_class_setup_interfaces (parent, &error); if (!mono_error_ok (&error)) return ERR_LOADER_ERROR; @@ -10169,7 +10186,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint #ifndef RUNTIME_IL2CPP buffer_add_int (buf, (vtable->initialized || vtable->init_failed) ? 1 : 0); #else - buffer_add_int (buf, klass->initialized ? 1 : 0); + buffer_add_int (buf, m_class_is_initialized (klass) ? 1 : 0); #endif else buffer_add_int (buf, 0); @@ -10695,7 +10712,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g MonoString *s; char *s2; - s = mono_ldstr_checked (domain, method->klass->image, mono_metadata_token_index (token), &error); + s = mono_ldstr_checked (domain, mono_class_get_image (method->klass), mono_metadata_token_index (token), &error); mono_error_assert_ok (&error); /* FIXME don't swallow the error */ s2 = mono_string_to_utf8_checked (s, &error); @@ -10721,7 +10738,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g break; } } else { - val = mono_ldtoken_checked (method->klass->image, token, &handle_class, NULL, &error); + val = mono_ldtoken_checked (mono_class_get_image (method->klass), token, &handle_class, NULL, &error); if (!val) g_error ("Could not load token due to %s", mono_error_get_message (&error)); } @@ -10806,7 +10823,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g } ginst = mono_metadata_get_generic_inst (type_argc, type_argv); g_free (type_argv); - tmp_context.class_inst = mono_class_is_ginst (method->klass) ? mono_class_get_generic_class (method->klass)->context.class_inst : NULL; + tmp_context.class_inst = mono_class_is_ginst (method->klass) ? mono_generic_class_get_context (mono_class_get_generic_class (method->klass))->class_inst : NULL; tmp_context.method_inst = ginst; inflated = mono_class_inflate_generic_method_checked (method, &tmp_context, &error); @@ -11171,10 +11188,10 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) case CMD_STACK_FRAME_GET_THIS: { if (frame->method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE) return ERR_ABSENT_INFORMATION; - if (frame->api_method->klass->valuetype) { + if (mono_class_is_valuetype (frame->api_method->klass)) { if (!sig->hasthis) { MonoObject *p = NULL; - buffer_add_value (buf, &VM_DEFAULTS_OBJECT_CLASS->byval_arg, &p, frame->domain); + buffer_add_value (buf, mono_class_get_type (VM_DEFAULTS_OBJECT_CLASS), &p, frame->domain); } else { #ifndef RUNTIME_IL2CPP if (frame->ji->is_interp) { @@ -11187,14 +11204,14 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) add_var (buf, jit, &frame->actual_method->klass->this_arg, jit->this_var, &frame->ctx, frame->domain, TRUE); } #else - buffer_add_value_full (buf, &frame->actual_method->klass->this_arg, *frame->frame_context->thisArg, frame->domain, FALSE, NULL); + buffer_add_value_full (buf, mono_class_get_byref_type (frame->actual_method->klass), *frame->frame_context->thisArg, frame->domain, FALSE, NULL); break; #endif } } else { if (!sig->hasthis) { MonoObject *p = NULL; - buffer_add_value (buf, &frame->actual_method->klass->byval_arg, &p, frame->domain); + buffer_add_value (buf, mono_class_get_type (frame->actual_method->klass), &p, frame->domain); } else { #ifndef RUNTIME_IL2CPP if (frame->ji->is_interp) { @@ -11207,7 +11224,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) add_var (buf, jit, &frame->api_method->klass->byval_arg, jit->this_var, &frame->ctx, frame->domain, TRUE); } #else - buffer_add_value_full (buf, &frame->actual_method->klass->byval_arg, *frame->frame_context->thisArg, frame->domain, FALSE, NULL); + buffer_add_value_full (buf, mono_class_get_type (frame->actual_method->klass), *frame->frame_context->thisArg, frame->domain, FALSE, NULL); #endif } } @@ -11307,7 +11324,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) void *var; #endif - t = &frame->actual_method->klass->byval_arg; + t = mono_class_get_type (frame->actual_method->klass); /* Checked by the sender */ g_assert (MONO_TYPE_ISSTRUCT (t)); @@ -11329,7 +11346,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) set_var (&frame->actual_method->klass->this_arg, var, &frame->ctx, frame->domain, val_buf, frame->reg_locations, &tls->restore_state.ctx); } #else - il2cpp_set_var(val_buf, *frame->frame_context->thisArg, &frame->actual_method->klass->this_arg); + il2cpp_set_var(val_buf, *frame->frame_context->thisArg, mono_class_get_byref_type (frame->actual_method->klass)); #endif break; } @@ -11355,12 +11372,12 @@ array_commands (int command, guint8 *p, guint8 *end, Buffer *buf) switch (command) { case CMD_ARRAY_REF_GET_LENGTH: - buffer_add_int (buf, arr->obj.vtable->klass->rank); + buffer_add_int (buf, mono_class_get_rank (mono_object_get_class (&arr->obj))); if (!arr->bounds) { buffer_add_int (buf, arr->max_length); buffer_add_int (buf, 0); } else { - for (i = 0; i < arr->obj.vtable->klass->rank; ++i) { + for (i = 0; i < mono_class_get_rank (mono_object_get_class (&arr->obj)); ++i) { buffer_add_int (buf, arr->bounds[i].length); buffer_add_int (buf, arr->bounds[i].lower_bound); } @@ -11374,10 +11391,10 @@ array_commands (int command, guint8 *p, guint8 *end, Buffer *buf) // Reordered to avoid integer overflow g_assert (!(index > arr->max_length - len)); - esize = mono_array_element_size (arr->obj.vtable->klass); + esize = mono_array_element_size (mono_object_get_class (&arr->obj)); for (i = index; i < index + len; ++i) { elem = (gpointer*)((char*)arr->vector + (i * esize)); - buffer_add_value (buf, &arr->obj.vtable->klass->element_class->byval_arg, elem, VM_OBJECT_GET_DOMAIN(arr)); + buffer_add_value (buf, mono_class_get_type (mono_class_get_element_class (mono_object_get_class (&arr->obj))), elem, VM_OBJECT_GET_DOMAIN(arr)); } break; case CMD_ARRAY_REF_SET_VALUES: @@ -11388,10 +11405,10 @@ array_commands (int command, guint8 *p, guint8 *end, Buffer *buf) // Reordered to avoid integer overflow g_assert (!(index > arr->max_length - len)); - esize = mono_array_element_size (arr->obj.vtable->klass); + esize = mono_array_element_size (mono_object_get_class (&arr->obj)); for (i = index; i < index + len; ++i) { elem = (gpointer*)((char*)arr->vector + (i * esize)); - decode_value (&arr->obj.vtable->klass->element_class->byval_arg, VM_OBJECT_GET_DOMAIN(arr), (guint8 *)elem, p, &p, end); + decode_value (mono_class_get_type (mono_class_get_element_class (mono_object_get_class (&arr->obj))), VM_OBJECT_GET_DOMAIN(arr), (guint8 *)elem, p, &p, end); } break; default: @@ -11476,10 +11493,10 @@ pointer_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (err != ERR_NONE) return err; - if (klass->byval_arg.type != MONO_TYPE_PTR) + if (mono_class_get_type (klass)->type != MONO_TYPE_PTR) return ERR_INVALID_ARGUMENT; - buffer_add_value (buf, &klass->element_class->byval_arg, (gpointer)addr, domain); + buffer_add_value (buf, mono_class_get_type (mono_class_get_element_class (klass)), (gpointer)addr, domain); break; default: @@ -11519,7 +11536,7 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) MonoClass *obj_type; gboolean remote_obj = FALSE; - obj_type = obj->vtable->klass; + obj_type = mono_object_get_class (obj); if (mono_class_is_transparent_proxy (obj_type)) { obj_type = ((MonoTransparentProxy *)obj)->remote_class->proxy_class; remote_obj = TRUE; @@ -11533,7 +11550,7 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) /* This handles transparent proxies too */ buffer_add_typeid (buf, VM_OBJECT_GET_DOMAIN(obj), mono_class_from_mono_type (((MonoReflectionType*)obj->vtable->type)->type)); #else - buffer_add_typeid (buf, VM_OBJECT_GET_DOMAIN(obj), obj->vtable->klass); + buffer_add_typeid (buf, VM_OBJECT_GET_DOMAIN(obj), mono_object_get_class (obj)); #endif //RUNTIME_IL2CPP break; case CMD_OBJECT_REF_GET_VALUES: @@ -11546,8 +11563,8 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) /* Check that the field belongs to the object */ found = FALSE; - for (k = obj_type; k; k = k->parent) { - if (k == f->parent) { + for (k = obj_type; k; k = mono_class_get_parent (k)) { + if (k == mono_field_get_parent (f)) { found = TRUE; break; } @@ -11555,22 +11572,22 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (!found) return ERR_INVALID_FIELDID; - if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) { + if (mono_type_get_attrs (mono_field_get_type (f)) & FIELD_ATTRIBUTE_STATIC) { guint8 *val; MonoVTable *vtable; if (mono_class_field_is_special_static (f)) return ERR_INVALID_FIELDID; - g_assert (f->type->attrs & FIELD_ATTRIBUTE_STATIC); - vtable = mono_class_vtable (VM_OBJECT_GET_DOMAIN(obj), f->parent); - val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type))); + g_assert (mono_type_get_attrs (mono_field_get_type (f)) & FIELD_ATTRIBUTE_STATIC); + vtable = mono_class_vtable (VM_OBJECT_GET_DOMAIN(obj), mono_field_get_parent (f)); + val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (mono_field_get_type (f)))); mono_field_static_get_value_checked (vtable, f, val, &error); if (!is_ok (&error)) { mono_error_cleanup (&error); /* FIXME report the error */ return ERR_INVALID_OBJECT; } - buffer_add_value (buf, f->type, val, VM_OBJECT_GET_DOMAIN(obj)); + buffer_add_value (buf, mono_field_get_type (f), val, VM_OBJECT_GET_DOMAIN(obj)); g_free (val); } else { guint8 *field_value = NULL; @@ -11588,9 +11605,9 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) #endif } else - field_value = (guint8*)(obj) + f->offset; + field_value = (guint8*)(obj) + mono_field_get_offset (f); - buffer_add_value (buf, f->type, field_value, VM_OBJECT_GET_DOMAIN(obj)); + buffer_add_value (buf, mono_field_get_type (f), field_value, VM_OBJECT_GET_DOMAIN(obj)); } } break; @@ -11604,8 +11621,8 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) /* Check that the field belongs to the object */ found = FALSE; - for (k = obj_type; k; k = k->parent) { - if (k == f->parent) { + for (k = obj_type; k; k = mono_class_get_parent (k)) { + if (k == mono_field_get_parent (f)) { found = TRUE; break; } @@ -11613,18 +11630,18 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) if (!found) return ERR_INVALID_FIELDID; - if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) { + if (mono_type_get_attrs (mono_field_get_type (f)) & FIELD_ATTRIBUTE_STATIC) { guint8 *val; MonoVTable *vtable; if (mono_class_field_is_special_static (f)) return ERR_INVALID_FIELDID; - g_assert (f->type->attrs & FIELD_ATTRIBUTE_STATIC); - vtable = mono_class_vtable (VM_OBJECT_GET_DOMAIN(obj), f->parent); + g_assert (mono_type_get_attrs (mono_field_get_type (f)) & FIELD_ATTRIBUTE_STATIC); + vtable = mono_class_vtable (VM_OBJECT_GET_DOMAIN(obj), mono_field_get_parent (f)); - val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (f->type))); - err = decode_value (f->type, VM_OBJECT_GET_DOMAIN(obj), val, p, &p, end); + val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type (mono_field_get_type (f)))); + err = decode_value (mono_field_get_type (f), VM_OBJECT_GET_DOMAIN(obj), val, p, &p, end); if (err != ERR_NONE) { g_free (val); return err; @@ -11632,7 +11649,7 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf) mono_field_static_set_value (vtable, f, val); g_free (val); } else { - err = decode_value (f->type, VM_OBJECT_GET_DOMAIN(obj), (guint8*)obj + f->offset, p, &p, end); + err = decode_value (mono_field_get_type (f), VM_OBJECT_GET_DOMAIN(obj), (guint8*)obj + mono_field_get_offset (f), p, &p, end); if (err != ERR_NONE) return err; } @@ -12195,8 +12212,8 @@ unity_process_breakpoint_inner(DebuggerTlsData *tls, gboolean from_signal, Il2Cp SingleStepReq *ss_req = (SingleStepReq *)bp->req->info; gboolean validFrame = FALSE; validFrame |= ss_req->depth == STEP_DEPTH_INTO; - validFrame |= ss_req->depth == STEP_DEPTH_OVER && tls->il2cpp_context.frameCount <= ss_req->nframes; - validFrame |= ss_req->depth == STEP_DEPTH_OUT && tls->il2cpp_context.frameCount < ss_req->nframes; + validFrame |= ss_req->depth == STEP_DEPTH_OVER && tls->il2cpp_context->frameCount <= ss_req->nframes; + validFrame |= ss_req->depth == STEP_DEPTH_OUT && tls->il2cpp_context->frameCount < ss_req->nframes; if (!validFrame) continue; } diff --git a/mono/mini/il2cpp-c-types.h b/mono/mini/il2cpp-c-types.h index fc50bb51d7ab..46ff4b3161e5 100644 --- a/mono/mini/il2cpp-c-types.h +++ b/mono/mini/il2cpp-c-types.h @@ -107,6 +107,10 @@ typedef void (*Il2CppDomainFunc) (MonoDomain *domain, void* user_data); typedef void (*emit_assembly_load_callback)(void*, void*); typedef void(*emit_type_load_callback)(void*, void*, void*); +#ifdef __cplusplus +extern "C" { +#endif + void il2cpp_set_thread_state_background(MonoThread* thread); void* il2cpp_domain_get_agent_info(MonoAppDomain* domain); void il2cpp_domain_set_agent_info(MonoAppDomain* domain, void* agentInfo); @@ -115,4 +119,8 @@ void* il2cpp_gc_alloc_fixed(size_t size); void il2cpp_gc_free_fixed(void* address); const char* il2cpp_domain_get_name(MonoDomain* domain); +#ifdef __cplusplus +} +#endif + #endif diff --git a/mono/mini/il2cpp-compat.h b/mono/mini/il2cpp-compat.h index b8d9bed372c4..e034dd416c21 100644 --- a/mono/mini/il2cpp-compat.h +++ b/mono/mini/il2cpp-compat.h @@ -58,7 +58,9 @@ #define mono_image_get_entry_point il2cpp_mono_image_get_entry_point #define mono_image_get_filename il2cpp_mono_image_get_filename #define mono_image_get_guid il2cpp_mono_image_get_guid +#define mono_image_is_dynamic il2cpp_mono_image_is_dynamic #define mono_type_get_class il2cpp_mono_type_get_class +#define m_type_get_generic_class il2cpp_m_type_get_generic_class #define mono_type_is_struct il2cpp_mono_type_is_struct #define mono_type_is_reference il2cpp_mono_type_is_reference #define mono_metadata_free_mh il2cpp_mono_metadata_free_mh @@ -147,7 +149,8 @@ #define mono_class_is_nullable il2cpp_mono_class_is_nullable #define mono_class_get_generic_container il2cpp_mono_class_get_generic_container #define mono_class_setup_interfaces il2cpp_mono_class_setup_interfaces -#define mono_class_get_methods_by_name il2cpp_mono_class_get_methods_by_name +#define mono_class_get_methods_by_name il2cpp_mono_class_get_methods_by_name +#define mono_class_is_valuetype il2cpp_class_is_valuetype #define mono_ldtoken_checked il2cpp_mono_ldtoken_checked #define mono_class_from_generic_parameter_internal il2cpp_mono_class_from_generic_parameter_internal #define mono_class_load_from_name il2cpp_mono_class_load_from_name @@ -167,6 +170,7 @@ #define mono_field_static_get_value_checked il2cpp_mono_field_static_get_value_checked #define mono_field_static_get_value_for_thread il2cpp_mono_field_static_get_value_for_thread #define mono_field_get_value_object_checked il2cpp_mono_field_get_value_object_checked +#define mono_field_get_offset il2cpp_field_get_offset #define mono_object_new_checked il2cpp_mono_object_new_checked #define mono_ldstr_checked il2cpp_mono_ldstr_checked #define mono_runtime_try_invoke il2cpp_mono_runtime_try_invoke @@ -238,6 +242,7 @@ #define mono_field_get_type il2cpp_field_get_type #define mono_method_get_name il2cpp_method_get_name #define mono_class_get_type il2cpp_class_get_type +#define mono_class_get_byref_type il2cpp_mono_class_get_byref_type #define mono_method_get_class il2cpp_method_get_class #define mono_class_get_image il2cpp_class_get_image #define mono_class_get_interfaces il2cpp_class_get_interfaces @@ -259,6 +264,14 @@ #undef mono_field_is_deleted #define mono_field_is_deleted il2cpp_field_is_deleted #define mono_domain_get_assemblies_iter il2cpp_domain_get_assemblies_iter +#define mono_property_get_name il2cpp_property_get_name +#define mono_property_get_set_method il2cpp_property_get_set_method +#define mono_property_get_get_method il2cpp_property_get_get_method +#define mono_property_get_parent il2cpp_property_get_parent +#define m_domain_get_corlib il2cpp_m_domain_get_corlib +#define mono_generic_class_get_context il2cpp_mono_generic_class_get_context + +#define m_class_is_initialized il2cpp_m_class_is_initialized #undef mono_domain_assemblies_lock #define mono_domain_assemblies_lock @@ -464,5 +477,12 @@ const MonoType* il2cpp_get_type_from_index(int index); const MonoType* il2cpp_get_type_from_method_context(MonoType* type, const MonoMethod* method); const MonoType* il2cpp_type_inflate(MonoType* type, const MonoGenericContext* context); void il2cpp_debugger_get_method_execution_context_and_header_Info(const MonoMethod* method, uint32_t* executionContextInfoCount, const Il2CppMethodExecutionContextInfo **executionContextInfo, const Il2CppMethodHeaderInfo **headerInfo, const Il2CppMethodScope **scopes); - +Il2CppThreadUnwindState* il2cpp_debugger_get_thread_context (); +MonoGenericContext* il2cpp_mono_generic_class_get_context (MonoGenericClass *gclass); +MonoType* il2cpp_mono_class_get_byref_type (MonoClass *klass); +mono_bool il2cpp_mono_image_is_dynamic(MonoImage *image); +MonoGenericClass* il2cpp_m_type_get_generic_class(MonoType* type); +const MonoAssembly* il2cpp_m_method_get_assembly(MonoMethod* method); +const MonoAssembly* il2cpp_m_domain_get_corlib (MonoDomain *domain); +mono_bool il2cpp_m_class_is_initialized (MonoClass* klass); #endif // RUNTIME_IL2CPP diff --git a/mono/mini/il2cpp-stubs.cpp b/mono/mini/il2cpp-stubs.cpp index 271bafdabdca..bccc70309921 100644 --- a/mono/mini/il2cpp-stubs.cpp +++ b/mono/mini/il2cpp-stubs.cpp @@ -6,7 +6,9 @@ #include "gc/GarbageCollector.h" #include "gc/WriteBarrier.h" #include "gc/gc_wrapper.h" +#if !UNITY_TINY #include "metadata/FieldLayout.h" +#include "metadata/GenericMetadata.h" #include "vm/Assembly.h" #include "vm/AssemblyName.h" #include "vm/Class.h" @@ -19,15 +21,13 @@ #include "vm/Object.h" #include "vm/Profiler.h" #include "vm/Reflection.h" -#include "vm/Runtime.h" -#include "vm/String.h" #include "vm/Thread.h" #include "vm/ThreadPoolMs.h" #include "vm/Type.h" +#endif +#include "vm/Runtime.h" +#include "vm/String.h" #include "vm-utils/Debugger.h" -#include "metadata/GenericMetadata.h" - -extern "C" { #include #include @@ -41,8 +41,11 @@ extern "C" { #include #include #include + #include "il2cpp-c-types.h" +extern "C" { + Il2CppMonoDefaults il2cpp_mono_defaults; Il2CppMonoDebugOptions il2cpp_mono_debug_options; @@ -50,18 +53,30 @@ Il2CppMonoDebugOptions il2cpp_mono_debug_options; static MonoGHashTable *method_signatures; +#if !UNITY_TINY static il2cpp::os::Mutex s_il2cpp_mono_loader_lock(false); +#endif static uint64_t s_il2cpp_mono_loader_lock_tid = 0; MonoMethod* il2cpp_mono_image_get_entry_point (MonoImage *image) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoMethod*)il2cpp::vm::Image::GetEntryPoint((Il2CppImage*)image); +#endif } const char* il2cpp_mono_image_get_filename (MonoImage *monoImage) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else Il2CppImage *image = (Il2CppImage*)monoImage; return image->name; +#endif } const char* il2cpp_mono_image_get_guid (MonoImage *image) @@ -71,17 +86,32 @@ const char* il2cpp_mono_image_get_guid (MonoImage *image) MonoClass* il2cpp_mono_type_get_class (MonoType *type) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoClass*) il2cpp::vm::Type::GetClass((Il2CppType*)type); +#endif } mono_bool il2cpp_mono_type_is_struct (MonoType *type) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else return il2cpp::vm::Type::IsStruct((Il2CppType*)type); +#endif } mono_bool il2cpp_mono_type_is_reference (MonoType *type) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else return il2cpp::vm::Type::IsReference((Il2CppType*)type); +#endif } void il2cpp_mono_metadata_free_mh (MonoMethodHeader *mh) @@ -91,6 +121,10 @@ void il2cpp_mono_metadata_free_mh (MonoMethodHeader *mh) Il2CppMonoMethodSignature* il2cpp_mono_method_signature (MonoMethod *m) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else MethodInfo* method = (MethodInfo*)m; if (method_signatures == NULL) @@ -129,6 +163,7 @@ Il2CppMonoMethodSignature* il2cpp_mono_method_signature (MonoMethod *m) mono_g_hash_table_insert(method_signatures, method, sig); return sig; +#endif } static void il2cpp_mono_free_method_signature(gpointer unused1, gpointer value, gpointer unused2) @@ -150,18 +185,27 @@ void il2cpp_mono_free_method_signatures() void il2cpp_mono_method_get_param_names (MonoMethod *m, const char **names) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else MethodInfo* method = (MethodInfo*)m; uint32_t numberOfParameters = il2cpp::vm::Method::GetParamCount(method); for (int i = 0; i < numberOfParameters; ++i) names[i] = il2cpp::vm::Method::GetParamName(method, i); +#endif } mono_bool il2cpp_mono_type_generic_inst_is_valuetype (MonoType *monoType) { + #if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else static const int kBitIsValueType = 1; Il2CppType *type = (Il2CppType*)monoType; const Il2CppTypeDefinition *typeDef = il2cpp::vm::MetadataCache::GetTypeDefinitionFromIndex(type->data.generic_class->typeDefinitionIndex); return (typeDef->bitfield >> (kBitIsValueType - 1)) & 0x1; +#endif } MonoMethodHeader* il2cpp_mono_method_get_header_checked (MonoMethod *method, MonoError *error) @@ -177,7 +221,12 @@ gboolean il2cpp_mono_class_init (MonoClass *klass) MonoVTable* il2cpp_mono_class_vtable (MonoDomain *domain, MonoClass *klass) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoVTable*)((Il2CppClass*)klass)->vtable; +#endif } MonoClassField* il2cpp_mono_class_get_field_from_name (MonoClass *klass, const char *name) @@ -188,63 +237,123 @@ MonoClassField* il2cpp_mono_class_get_field_from_name (MonoClass *klass, const c int32_t il2cpp_mono_array_element_size (MonoClass *monoClass) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else Il2CppClass *klass = (Il2CppClass*)monoClass; return klass->element_size; +#endif } int32_t il2cpp_mono_class_instance_size (MonoClass *klass) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else return il2cpp::vm::Class::GetInstanceSize((Il2CppClass*)klass); +#endif } int32_t il2cpp_mono_class_value_size (MonoClass *klass, uint32_t *align) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else return il2cpp::vm::Class::GetValueSize((Il2CppClass*)klass, align); +#endif } gboolean il2cpp_mono_class_is_assignable_from (MonoClass *klass, MonoClass *oklass) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else return il2cpp::vm::Class::IsAssignableFrom((Il2CppClass*)klass, (Il2CppClass*)oklass); +#endif } MonoClass* il2cpp_mono_class_from_mono_type (MonoType *type) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoClass*)il2cpp::vm::Class::FromIl2CppType((Il2CppType*)type); +#endif } int il2cpp_mono_class_num_fields (MonoClass *klass) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else return il2cpp::vm::Class::GetNumFields((Il2CppClass*)klass); +#endif } int il2cpp_mono_class_num_methods (MonoClass *klass) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else return il2cpp::vm::Class::GetNumMethods((Il2CppClass*)klass); +#endif } int il2cpp_mono_class_num_properties (MonoClass *klass) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else return il2cpp::vm::Class::GetNumProperties((Il2CppClass*)klass); +#endif } MonoClassField* il2cpp_mono_class_get_fields (MonoClass* klass, gpointer *iter) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoClassField*)il2cpp::vm::Class::GetFields((Il2CppClass*)klass, iter); +#endif } MonoMethod* il2cpp_mono_class_get_methods (MonoClass* klass, gpointer *iter) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoMethod*)il2cpp::vm::Class::GetMethods((Il2CppClass*)klass, iter); +#endif } MonoProperty* il2cpp_mono_class_get_properties (MonoClass* klass, gpointer *iter) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoProperty*)il2cpp::vm::Class::GetProperties((Il2CppClass*)klass, iter); +#endif } const char* il2cpp_mono_field_get_name (MonoClassField *field) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return il2cpp::vm::Field::GetName((FieldInfo*)field); +#endif } mono_unichar2* il2cpp_mono_string_chars (MonoString *monoStr) @@ -273,7 +382,12 @@ uintptr_t il2cpp_mono_array_length (MonoArray *array) MonoString* il2cpp_mono_string_new (MonoDomain *domain, const char *text) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoString*)il2cpp::vm::String::New(text); +#endif } @@ -285,10 +399,15 @@ MonoString* il2cpp_mono_string_new_checked (MonoDomain *domain, const char *text char* il2cpp_mono_string_to_utf8_checked (MonoString *string_obj, MonoError *error) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else error_init(error); Il2CppString *str = (Il2CppString*)string_obj; std::string s = il2cpp::utils::StringUtils::Utf16ToUtf8(str->chars, str->length); return g_strdup(s.c_str()); +#endif } int il2cpp_mono_object_hash (MonoObject* obj) @@ -298,8 +417,13 @@ int il2cpp_mono_object_hash (MonoObject* obj) void* il2cpp_mono_object_unbox (MonoObject *monoObj) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else Il2CppObject *obj = (Il2CppObject*)monoObj; return il2cpp::vm::Object::Unbox(obj); +#endif } void il2cpp_mono_field_set_value (MonoObject *obj, MonoClassField *field, void *value) @@ -309,12 +433,20 @@ void il2cpp_mono_field_set_value (MonoObject *obj, MonoClassField *field, void * void il2cpp_mono_field_static_set_value (MonoVTable *vt, MonoClassField *field, void *value) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else il2cpp::vm::Field::StaticSetValue((FieldInfo*)field, value); +#endif } uint32_t il2cpp_mono_gchandle_new_weakref (MonoObject *obj, mono_bool track_resurrection) { +#if UNITY_TINY + return il2cpp::gc::GCHandle::NewWeakref((Il2CppObject*)obj); +#else return il2cpp::gc::GCHandle::NewWeakref((Il2CppObject*)obj, track_resurrection == 0 ? false : true); +#endif } MonoObject* il2cpp_mono_gchandle_get_target (uint32_t gchandle) @@ -334,6 +466,10 @@ void il2cpp_mono_gc_wbarrier_generic_store (void* ptr, MonoObject* value) int il2cpp_mono_reflection_parse_type_checked (char *name, Il2CppMonoTypeNameParse *monoInfo, MonoError *error) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else error_init(error); il2cpp::vm::TypeNameParseInfo *pInfo = new il2cpp::vm::TypeNameParseInfo(); std::string nameStr = name; @@ -342,16 +478,26 @@ int il2cpp_mono_reflection_parse_type_checked (char *name, Il2CppMonoTypeNamePar monoInfo->assembly.name = NULL; monoInfo->il2cppTypeNameParseInfo = pInfo; return parser.Parse(); +#endif } void il2cpp_mono_reflection_free_type_info (Il2CppMonoTypeNameParse *info) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else delete (il2cpp::vm::TypeNameParseInfo*)info->il2cppTypeNameParseInfo; +#endif } MonoDomain* il2cpp_mono_get_root_domain (void) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoDomain*)il2cpp::vm::Domain::GetCurrent(); +#endif } void il2cpp_mono_runtime_quit (void) @@ -361,7 +507,12 @@ void il2cpp_mono_runtime_quit (void) gboolean il2cpp_mono_runtime_is_shutting_down (void) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else return il2cpp::vm::Runtime::IsShuttingDown() ? TRUE : FALSE; +#endif } MonoDomain* il2cpp_mono_domain_get (void) @@ -407,8 +558,13 @@ void il2cpp_mono_set_is_debugger_attached(gboolean attached) char* il2cpp_mono_type_full_name(MonoType* type) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else std::string name = il2cpp::vm::Type::GetName((Il2CppType*)type, IL2CPP_TYPE_NAME_FORMAT_FULL_NAME); return g_strdup(name.c_str()); +#endif } char* il2cpp_mono_method_full_name(MonoMethod* method, gboolean signature) @@ -418,22 +574,41 @@ char* il2cpp_mono_method_full_name(MonoMethod* method, gboolean signature) MonoThread* il2cpp_mono_thread_current() { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoThread*)il2cpp::vm::Thread::Current(); +#endif } MonoThread* il2cpp_mono_thread_get_main() { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoThread*)il2cpp::vm::Thread::Main(); +#endif } MonoThread* il2cpp_mono_thread_attach(MonoDomain* domain) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoThread*)il2cpp::vm::Thread::Attach((Il2CppDomain*)domain); +#endif } void il2cpp_mono_thread_detach(MonoThread* thread) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else il2cpp::vm::Thread::Detach((Il2CppThread*)thread); +#endif } void il2cpp_mono_domain_lock(MonoDomain* domain) @@ -457,7 +632,12 @@ guint il2cpp_mono_aligned_addr_hash(gconstpointer ptr) MonoGenericInst* il2cpp_mono_metadata_get_generic_inst(int type_argc, MonoType** type_argv) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoGenericInst*)il2cpp::vm::MetadataCache::GetGenericInst((Il2CppType**)type_argv, type_argc); +#endif } MonoMethod* il2cpp_mono_get_method_checked(MonoImage* image, guint32 token, MonoClass* klass, MonoGenericContext* context, MonoError* error) @@ -473,8 +653,13 @@ SgenDescriptor il2cpp_mono_gc_make_root_descr_all_refs(int numbits) int il2cpp_mono_gc_register_root_wbarrier (char *start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, void *key, const char *msg) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else il2cpp::gc::GarbageCollector::RegisterRoot(start, size); return 1; +#endif } MonoGCDescriptor il2cpp_mono_gc_make_vector_descr (void) @@ -495,17 +680,30 @@ void il2cpp_mono_class_setup_supertypes(MonoClass* klass) void il2cpp_mono_class_setup_vtable(MonoClass* klass) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else il2cpp::vm::Class::Init((Il2CppClass*)klass); +#endif } void il2cpp_mono_class_setup_methods(MonoClass* klass) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else il2cpp::vm::Class::SetupMethods((Il2CppClass*)klass); +#endif } gboolean il2cpp_mono_class_field_is_special_static(MonoClassField* field) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else return il2cpp::vm::Field::IsNormalStatic((FieldInfo*)field) ? FALSE : TRUE; +#endif } guint32 il2cpp_mono_class_field_get_special_static_type(MonoClassField* field) @@ -516,51 +714,84 @@ guint32 il2cpp_mono_class_field_get_special_static_type(MonoClassField* field) MonoGenericContext* il2cpp_mono_class_get_context(MonoClass* klass) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoGenericContext*)&((Il2CppClass*)klass)->generic_class->context; +#endif } MonoGenericContext* il2cpp_mono_method_get_context(MonoMethod* monoMethod) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else MethodInfo * method = (MethodInfo*)monoMethod; if (!method->is_inflated || method->is_generic) return NULL; return (MonoGenericContext*) &((MethodInfo*)method)->genericMethod->context; +#endif } MonoGenericContainer* il2cpp_mono_method_get_generic_container(MonoMethod* monoMethod) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else MethodInfo * method = (MethodInfo*)monoMethod; if (method->is_inflated || !method->is_generic) return NULL; return (MonoGenericContainer*) method->genericContainer; +#endif } MonoMethod* il2cpp_mono_class_inflate_generic_method_full_checked(MonoMethod* method, MonoClass* klass_hint, MonoGenericContext* context, MonoError* error) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else error_init(error); return (MonoMethod*) il2cpp::metadata::GenericMetadata::Inflate((MethodInfo*)method, (Il2CppClass*)klass_hint, (Il2CppGenericContext*)context); +#endif } MonoMethod* il2cpp_mono_class_inflate_generic_method_checked(MonoMethod* method, MonoGenericContext* context, MonoError* error) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else error_init(error); return (MonoMethod*)il2cpp::metadata::GenericMetadata::Inflate((MethodInfo*)method, NULL, (Il2CppGenericContext*)context); +#endif } void il2cpp_mono_loader_lock() { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else s_il2cpp_mono_loader_lock.Lock(); s_il2cpp_mono_loader_lock_tid = il2cpp::os::Thread::CurrentThreadId(); +#endif } void il2cpp_mono_loader_unlock() { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else s_il2cpp_mono_loader_lock_tid = 0; s_il2cpp_mono_loader_lock.Unlock(); +#endif } void il2cpp_mono_loader_lock_track_ownership(gboolean track) @@ -569,7 +800,12 @@ void il2cpp_mono_loader_lock_track_ownership(gboolean track) gboolean il2cpp_mono_loader_lock_is_owned_by_self() { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else return s_il2cpp_mono_loader_lock_tid == il2cpp::os::Thread::CurrentThreadId(); +#endif } gpointer il2cpp_mono_method_get_wrapper_data(MonoMethod* method, guint32 id) @@ -580,24 +816,43 @@ gpointer il2cpp_mono_method_get_wrapper_data(MonoMethod* method, guint32 id) char* il2cpp_mono_type_get_name_full(MonoType* type, MonoTypeNameFormat format) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else std::string name = il2cpp::vm::Type::GetName((Il2CppType*)type, (Il2CppTypeNameFormat)format); return g_strdup(name.c_str()); +#endif } gboolean il2cpp_mono_class_is_nullable(MonoClass* klass) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else return il2cpp::vm::Class::IsNullable((Il2CppClass*)klass); +#endif } MonoGenericContainer* il2cpp_mono_class_get_generic_container(MonoClass* klass) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoGenericContainer*)il2cpp::vm::Class::GetGenericContainer((Il2CppClass*)klass); +#endif } void il2cpp_mono_class_setup_interfaces(MonoClass* klass, MonoError* error) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else error_init(error); il2cpp::vm::Class::SetupInterfaces((Il2CppClass*)klass); +#endif } enum { @@ -622,6 +877,10 @@ enum { static gboolean method_nonpublic (MethodInfo* method, gboolean start_klass) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else switch (method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) { case METHOD_ATTRIBUTE_ASSEM: return (start_klass || il2cpp_defaults.generic_ilist_class); @@ -632,10 +891,15 @@ method_nonpublic (MethodInfo* method, gboolean start_klass) default: return TRUE; } +#endif } GPtrArray* il2cpp_mono_class_get_methods_by_name(MonoClass* il2cppMonoKlass, const char* name, guint32 bflags, gboolean ignore_case, gboolean allow_ctors, MonoError* error) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else GPtrArray *array; Il2CppClass *klass = (Il2CppClass*)il2cppMonoKlass; Il2CppClass *startklass; @@ -719,6 +983,7 @@ GPtrArray* il2cpp_mono_class_get_methods_by_name(MonoClass* il2cppMonoKlass, con g_free (method_slots);*/ return array; +#endif } gpointer il2cpp_mono_ldtoken_checked(MonoImage* image, guint32 token, MonoClass** handle_class, MonoGenericContext* context, MonoError* error) @@ -729,7 +994,12 @@ gpointer il2cpp_mono_ldtoken_checked(MonoImage* image, guint32 token, MonoClass* MonoClass* il2cpp_mono_class_from_generic_parameter_internal(MonoGenericParam* param) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoClass*)il2cpp::vm::Class::FromGenericParameter((Il2CppGenericParameter*)param); +#endif } MonoClass* il2cpp_mono_class_load_from_name(MonoImage* image, const char* name_space, const char* name) @@ -740,8 +1010,13 @@ MonoClass* il2cpp_mono_class_load_from_name(MonoImage* image, const char* name_s MonoGenericClass* il2cpp_mono_class_get_generic_class(MonoClass* monoClass) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else Il2CppClass *klass = (Il2CppClass*)monoClass; return (MonoGenericClass*)klass->generic_class; +#endif } MonoInternalThread* il2cpp_mono_thread_internal_current() @@ -756,16 +1031,28 @@ gboolean il2cpp_mono_thread_internal_is_current(MonoInternalThread* thread) void il2cpp_mono_thread_internal_abort(MonoInternalThread* thread, gboolean appdomain_unload) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else il2cpp::vm::Thread::RequestAbort((Il2CppInternalThread*)thread); +#endif } void il2cpp_mono_thread_internal_reset_abort(MonoInternalThread* thread) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else il2cpp::vm::Thread::ResetAbort((Il2CppInternalThread*)thread); +#endif } gunichar2* il2cpp_mono_thread_get_name(MonoInternalThread* this_obj, guint32* name_len) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else std::string name = il2cpp::vm::Thread::GetName((Il2CppInternalThread*)this_obj); if (name_len != NULL) @@ -774,12 +1061,17 @@ gunichar2* il2cpp_mono_thread_get_name(MonoInternalThread* this_obj, guint32* na if (name.empty()) return NULL; return g_utf8_to_utf16(name.c_str(), name.size(), NULL, NULL, NULL); +#endif } void il2cpp_mono_thread_set_name_internal(MonoInternalThread* this_obj, MonoString* name, gboolean permanent, gboolean reset, MonoError* error) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else il2cpp::vm::Thread::SetName((Il2CppInternalThread*)this_obj, (Il2CppString*)name); error_init(error); +#endif } void il2cpp_mono_thread_suspend_all_other_threads() @@ -800,25 +1092,42 @@ Il2CppMonoRuntimeExceptionHandlingCallbacks* il2cpp_mono_get_eh_callbacks() void il2cpp_mono_nullable_init(guint8* buf, MonoObject* value, MonoClass* klass) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else il2cpp::vm::Object::NullableInit(buf, (Il2CppObject*)value, (Il2CppClass*)klass); +#endif } MonoObject* il2cpp_mono_value_box_checked(MonoDomain* domain, MonoClass* klass, gpointer value, MonoError* error) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else error_init(error); return (MonoObject*)il2cpp::vm::Object::Box((Il2CppClass*)klass, value); +#endif } void il2cpp_mono_field_static_get_value_checked(MonoVTable* vt, MonoClassField* field, void* value, MonoError* error) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else error_init(error); il2cpp::vm::Field::StaticGetValue((FieldInfo*)field, value); +#endif } void il2cpp_mono_field_static_get_value_for_thread(MonoInternalThread* thread, MonoVTable* vt, MonoClassField* field, void* value, MonoError* error) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else error_init(error); il2cpp::vm::Field::StaticGetValueForThread((FieldInfo*)field, value, (Il2CppInternalThread*)thread); +#endif } MonoObject* il2cpp_mono_field_get_value_object_checked(MonoDomain* domain, MonoClassField* field, MonoObject* obj, MonoError* error) @@ -829,8 +1138,13 @@ MonoObject* il2cpp_mono_field_get_value_object_checked(MonoDomain* domain, MonoC MonoObject* il2cpp_mono_object_new_checked(MonoDomain* domain, MonoClass* klass, MonoError* error) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else error_init(error); return (MonoObject*)il2cpp::vm::Object::New((Il2CppClass*)klass); +#endif } MonoString* il2cpp_mono_ldstr_checked(MonoDomain* domain, MonoImage* image, guint32 idx, MonoError* error) @@ -841,12 +1155,17 @@ MonoString* il2cpp_mono_ldstr_checked(MonoDomain* domain, MonoImage* image, guin MonoObject* il2cpp_mono_runtime_try_invoke(MonoMethod* method, void* obj, void** params, MonoObject** exc, MonoError* error) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else error_init(error); if (((MethodInfo*)method)->klass->valuetype) obj = static_cast(obj) - 1; return (MonoObject*)il2cpp::vm::Runtime::Invoke((MethodInfo*)method, obj, params, (Il2CppException**)exc); +#endif } MonoObject* il2cpp_mono_runtime_invoke_checked(MonoMethod* method, void* obj, void** params, MonoError* error) @@ -859,16 +1178,28 @@ void il2cpp_mono_gc_base_init() { } +#if !UNITY_TINY static il2cpp::os::Mutex s_il2cpp_gc_root_lock(false); +#endif + int il2cpp_mono_gc_register_root(char* start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, const char* msg) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else il2cpp::gc::GarbageCollector::RegisterRoot(start, size); return 1; +#endif } void il2cpp_mono_gc_deregister_root(char* addr) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else il2cpp::gc::GarbageCollector::UnregisterRoot(addr); +#endif } #ifndef HOST_WIN32 @@ -886,7 +1217,12 @@ gboolean il2cpp_mono_gc_is_moving() gint32 il2cpp_mono_environment_exitcode_get() { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else return il2cpp::vm::Runtime::GetExitCode(); +#endif } void il2cpp_mono_environment_exitcode_set(gint32 value) @@ -896,31 +1232,53 @@ void il2cpp_mono_environment_exitcode_set(gint32 value) void il2cpp_mono_threadpool_suspend() { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else #if NET_4_0 il2cpp::vm::ThreadPoolMs::Suspend(); #endif // NET_4_0 +#endif } void il2cpp_mono_threadpool_resume() { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else #if NET_4_0 il2cpp::vm::ThreadPoolMs::Resume(); #endif // NET_4_0 +#endif } MonoImage* il2cpp_mono_assembly_get_image(MonoAssembly* assembly) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoImage*)il2cpp::vm::Assembly::GetImage((Il2CppAssembly*)assembly); +#endif } gboolean il2cpp_mono_runtime_try_shutdown() { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else il2cpp::vm::Runtime::Shutdown(); return TRUE; +#endif } gboolean il2cpp_mono_verifier_is_method_valid_generic_instantiation(MonoMethod* method) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else if (!method) return FALSE; @@ -928,10 +1286,15 @@ gboolean il2cpp_mono_verifier_is_method_valid_generic_instantiation(MonoMethod* return TRUE; return FALSE; +#endif } MonoType* il2cpp_mono_reflection_get_type_checked(MonoImage* rootimage, MonoImage* image, Il2CppMonoTypeNameParse* info, gboolean ignorecase, gboolean* type_resolve, MonoError* error) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else error_init(error); Il2CppClass *klass = il2cpp::vm::Image::FromTypeNameParseInfo((Il2CppImage*)image, *((il2cpp::vm::TypeNameParseInfo*)info->il2cppTypeNameParseInfo), ignorecase); @@ -939,17 +1302,28 @@ MonoType* il2cpp_mono_reflection_get_type_checked(MonoImage* rootimage, MonoImag return NULL; return (MonoType*)il2cpp::vm::Class::GetType(klass); +#endif } MonoReflectionAssemblyHandle il2cpp_mono_assembly_get_object_handle(MonoDomain* domain, MonoAssembly* assembly, MonoError* error) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoReflectionAssemblyHandle)il2cpp::vm::Reflection::GetAssemblyObject((const Il2CppAssembly *)assembly); +#endif } MonoReflectionType* il2cpp_mono_type_get_object_checked(MonoDomain* domain, MonoType* type, MonoError* error) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else error_init(error); return (MonoReflectionType*)il2cpp::vm::Reflection::GetTypeObject((const Il2CppType*)type); +#endif } void il2cpp_mono_network_init() @@ -1134,7 +1508,12 @@ gboolean il2cpp_mono_class_has_parent (MonoClass *klass, MonoClass *parent) MonoGenericParam* il2cpp_mono_generic_container_get_param (MonoGenericContainer *gc, int i) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoGenericParam*)il2cpp::vm::GenericContainer::GetGenericParameter((Il2CppGenericContainer*)gc, i); +#endif } gboolean il2cpp_mono_find_seq_point (MonoDomain *domain, MonoMethod *method, gint32 il_offset, MonoSeqPointInfo **info, SeqPoint *seq_point) @@ -1203,7 +1582,12 @@ void* il2cpp_mono_gc_alloc_fixed (size_t size, void* descr, MonoGCRootSource sou typedef void* (*Il2CppMonoGCLockedCallbackFunc) (void *data); void* il2cpp_mono_gc_invoke_with_gc_lock (Il2CppMonoGCLockedCallbackFunc func, void *data) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return il2cpp::gc::GarbageCollector::CallWithAllocLockHeld (func, data); +#endif } // These functions expose the IL2CPP VM C++ API to C @@ -1223,6 +1607,11 @@ MonoAssembly* il2cpp_domain_get_assemblies_iter(MonoAppDomain *domain, void* *it if (!iter) return NULL; +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else + il2cpp::vm::AssemblyVector* assemblies = il2cpp::vm::Assembly::GetAllAssemblies(); if (!*iter) @@ -1246,6 +1635,7 @@ MonoAssembly* il2cpp_domain_get_assemblies_iter(MonoAppDomain *domain, void* *it } return NULL; +#endif } void il2cpp_start_debugger_thread() @@ -1308,85 +1698,150 @@ gboolean il2cpp_mono_methods_match(MonoMethod* left, MonoMethod* right) MonoClass* il2cpp_class_get_nested_types_accepts_generic(MonoClass *monoClass, void* *iter) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else Il2CppClass *klass = (Il2CppClass*)monoClass; if (klass->generic_class) return NULL; return (MonoClass*)il2cpp::vm::Class::GetNestedTypes(klass, iter); +#endif } MonoClass* il2cpp_defaults_object_class() { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoClass*)il2cpp_defaults.object_class; +#endif } guint8 il2cpp_array_rank(MonoArray *monoArr) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else Il2CppArray *arr = (Il2CppArray*)monoArr; return arr->klass->rank; +#endif } const char* il2cpp_image_name(MonoImage *monoImage) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else Il2CppImage *image = (Il2CppImage*)monoImage; return image->name; +#endif } guint8* il2cpp_field_get_address(MonoObject *obj, MonoClassField *monoField) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else FieldInfo *field = (FieldInfo*)monoField; return (guint8*)obj + field->offset; +#endif } MonoType* il2cpp_mono_object_get_type(MonoObject* object) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoType*)&(((Il2CppObject*)object)->klass->byval_arg); +#endif } MonoClass* il2cpp_defaults_exception_class() { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoClass*)il2cpp_defaults.exception_class; +#endif } MonoImage* il2cpp_defaults_corlib_image() { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoImage*)il2cpp_defaults.corlib; +#endif } bool il2cpp_method_is_string_ctor(const MonoMethod * method) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else MethodInfo* methodInfo = (MethodInfo*)method; return methodInfo->klass == il2cpp_defaults.string_class && !strcmp (methodInfo->name, ".ctor"); +#endif } MonoClass* il2cpp_defaults_void_class() { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoClass*)il2cpp_defaults.void_class; +#endif } void il2cpp_set_var(guint8* newValue, void *value, MonoType *localVariableTypeMono) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); +#else il2cpp::metadata::SizeAndAlignment sa = il2cpp::metadata::FieldLayout::GetTypeSizeAndAlignment((const Il2CppType*)localVariableTypeMono); if (((Il2CppType*)localVariableTypeMono)->byref) memcpy(*(void**)value, newValue, sa.size); else memcpy(value, newValue, sa.size); +#endif } MonoMethod* il2cpp_get_interface_method(MonoClass* klass, MonoClass* itf, int slot) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else const VirtualInvokeData* data = il2cpp::vm::Class::GetInterfaceInvokeDataFromVTable((Il2CppClass*)klass, (Il2CppClass*)itf, slot); if (!data) return NULL; return (MonoMethod*)data->method; +#endif } gboolean il2cpp_field_is_deleted(MonoClassField *field) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return 0; +#else return il2cpp::vm::Field::IsDeleted((FieldInfo*)field); +#endif } +#if !UNITY_TINY struct TypeIterState { il2cpp::vm::AssemblyVector* assemblies; @@ -1395,12 +1850,17 @@ struct TypeIterState il2cpp::vm::TypeVector types; il2cpp::vm::TypeVector::iterator type; }; +#endif MonoClass* il2cpp_iterate_loaded_classes(void* *iter) { if (!iter) return NULL; +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else if (!*iter) { TypeIterState *state = new TypeIterState(); @@ -1409,12 +1869,12 @@ MonoClass* il2cpp_iterate_loaded_classes(void* *iter) state->image = il2cpp::vm::Assembly::GetImage(*state->assembly); il2cpp::vm::Image::GetTypes(state->image, true, &state->types); state->type = state->types.begin(); - *iter = state; + *iter = state; return (MonoClass*)*state->type; } TypeIterState *state = (TypeIterState*)*iter; - + state->type++; if (state->type == state->types.end()) { @@ -1432,6 +1892,7 @@ MonoClass* il2cpp_iterate_loaded_classes(void* *iter) } return (MonoClass*)*state->type; +#endif } const char** il2cpp_get_source_files_for_type(MonoClass *klass, int *count) @@ -1445,34 +1906,54 @@ const char** il2cpp_get_source_files_for_type(MonoClass *klass, int *count) MonoMethod* il2cpp_method_get_generic_definition(MonoMethodInflated *imethod) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else MethodInfo *method = (MethodInfo*)imethod; if (!method->is_inflated || method->is_generic) return NULL; return (MonoMethod*)((MethodInfo*)imethod)->genericMethod->methodDefinition; +#endif } MonoGenericInst* il2cpp_method_get_generic_class_inst(MonoMethodInflated *imethod) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else MethodInfo *method = (MethodInfo*)imethod; if (!method->is_inflated || method->is_generic) return NULL; return (MonoGenericInst*)method->genericMethod->context.class_inst; +#endif } MonoClass* il2cpp_generic_class_get_container_class(MonoGenericClass *gclass) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoClass*)il2cpp::vm::GenericClass::GetTypeDefinition((Il2CppGenericClass*)gclass); +#endif } MonoClass* il2cpp_mono_get_string_class (void) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return (MonoClass*)il2cpp_defaults.string_class; +#endif } Il2CppSequencePoint* il2cpp_get_sequence_point(int id) @@ -1483,11 +1964,16 @@ Il2CppSequencePoint* il2cpp_get_sequence_point(int id) return NULL; #endif } - + char* il2cpp_assembly_get_full_name(MonoAssembly *assembly) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else std::string s = il2cpp::vm::AssemblyName::AssemblyNameToString(assembly->aname); return g_strdup(s.c_str()); +#endif } const MonoMethod* il2cpp_get_seq_point_method(Il2CppSequencePoint *seqPoint) @@ -1501,20 +1987,35 @@ const MonoMethod* il2cpp_get_seq_point_method(Il2CppSequencePoint *seqPoint) const MonoClass* il2cpp_get_class_from_index(int index) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else if (index < 0) return NULL; return il2cpp::vm::MetadataCache::GetTypeInfoFromTypeIndex(index); +#endif } const MonoType* il2cpp_get_type_from_index(int index) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return il2cpp::vm::MetadataCache::GetIl2CppTypeFromIndex(index); +#endif } const MonoType* il2cpp_type_inflate(MonoType* type, const MonoGenericContext* context) { +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else return il2cpp::metadata::GenericMetadata::InflateIfNeeded(type, context, true); +#endif } void il2cpp_debugger_get_method_execution_context_and_header_Info(const MonoMethod* method, uint32_t* executionContextInfoCount, const Il2CppMethodExecutionContextInfo **executionContextInfo, const Il2CppMethodHeaderInfo **headerInfo, const Il2CppMethodScope **scopes) @@ -1524,5 +2025,69 @@ void il2cpp_debugger_get_method_execution_context_and_header_Info(const MonoMeth #endif } +Il2CppThreadUnwindState* il2cpp_debugger_get_thread_context () +{ +#if IL2CPP_MONO_DEBUGGER + return il2cpp::utils::Debugger::GetThreadStatePointer(); +#else + return NULL; +#endif +} + +MonoGenericClass* il2cpp_m_type_get_generic_class(MonoType* type) +{ +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else + return (MonoGenericClass*)((Il2CppType*)type)->data.generic_class; +#endif +} + +mono_bool il2cpp_mono_image_is_dynamic(MonoImage *image) +{ + return false; +} + +const MonoAssembly* il2cpp_m_domain_get_corlib (MonoDomain *domain) +{ +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else + return il2cpp::vm::Image::GetAssembly(il2cpp_defaults_corlib_image()); +#endif +} + +MonoGenericContext* il2cpp_mono_generic_class_get_context (MonoGenericClass *gclass) +{ +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else + return il2cpp::vm::GenericClass::GetContext((Il2CppGenericClass*)gclass); +#endif +} + +mono_bool il2cpp_m_class_is_initialized (MonoClass* klass) +{ +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return false; +#else + return ((Il2CppClass*)klass)->initialized; +#endif +} + +MonoType* il2cpp_mono_class_get_byref_type (MonoClass *klass) +{ +#if UNITY_TINY + IL2CPP_ASSERT(0 && "Not implemented yet for tiny"); + return NULL; +#else + return (MonoType*)il2cpp::vm::Class::GetByrefType((Il2CppClass*)klass); +#endif +} + } #endif // RUNTIME_IL2CPP From 1c4da8014c7bc04e44dc5d6d71edd0b4b3ebefb1 Mon Sep 17 00:00:00 2001 From: alexandru Date: Fri, 12 Oct 2018 11:54:28 +0200 Subject: [PATCH 326/582] removed call to GC_wait_for_gc_completion(int) this call would result in a invalid declaration, furthermore incremental GC is not enabled currently on trunk --- mono/metadata/unity-memory-info.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mono/metadata/unity-memory-info.c b/mono/metadata/unity-memory-info.c index dc125a56c389..6957c15da4c2 100644 --- a/mono/metadata/unity-memory-info.c +++ b/mono/metadata/unity-memory-info.c @@ -615,8 +615,6 @@ static void CollectMonoImageFromAssembly(MonoAssembly *assembly, void *user_data MonoManagedMemorySnapshot* mono_unity_capture_memory_snapshot() { GC_disable(); - GC_wait_for_gc_completion(TRUE); - GC_stop_world_external(); MonoManagedMemorySnapshot* snapshot; From 0c3c3e09189db4811a824cb23fcf294516879114 Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Fri, 12 Oct 2018 11:24:16 -0400 Subject: [PATCH 327/582] Add a clang-format style file to Mono This is a minimal clang-format file for Mono code. The code is not consistent in its formatting, so this file is most often useful with git-clang-format [1], which formats only changed lines. Usage: * Make some changes to Mono C code or headers * Run `git clang-format` (maybe add -f if there are line ending issues from git) * Your changed code should meet the formatting guidelines for Mono Installation: * Install LLVM tools (including clang-format) for your OS [2] * Install Pythong on your OS Code style: Our goal is to match the Mono code style, not define a new one. The style options [3] are many. Here we try to capture only a few. If you find something is missing, feel free to add configuration options. [1] https://github.com/llvm-mirror/clang/blob/master/tools/clang-format/git-clang-format [2] http://releases.llvm.org/ [3] https://clang.llvm.org/docs/ClangFormatStyleOptions.html --- .clang-format | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000000..a4148517c7be --- /dev/null +++ b/.clang-format @@ -0,0 +1,49 @@ +# This is a minimal clang-format file for Mono code. The code is not consistent +# in its formatting, so this file is most often useful with git-clang-format [1], +# which formats only changed lines. +# +# Usage: +# * Make some changes to Mono C code or headers +# * Run `git clang-format` (maybe add -f if there are line ending issues from git) +# * Your changed code should meet the formatting guidelines for Mono +# +# Installation: +# * Install LLVM tools (including clang-format) for your OS [2] +# * Install Pythong on your OS +# +# Code style: +# Our goal is to match the Mono code style, not define a new one. The style +# options [3] are many. Here we try to capture only a few. If you find something +# is missing, feel free to add configuration options. +# +# [1] https://github.com/llvm-mirror/clang/blob/master/tools/clang-format/git-clang-format +# [2] http://releases.llvm.org/ +# [3] https://clang.llvm.org/docs/ClangFormatStyleOptions.html + +# All function declarations and calls should have a space after the name +SpaceBeforeParens: Always + +# Use four space tabs +UseTab: Always +TabWidth: 4 +IndentWidth: 4 + +# Handle curly braces, basically: functions get a line break, nothing else does +BreakBeforeBraces: Custom +BraceWrapping: + AfterControlStatement: false + AfterStruct: false + AfterFunction: true + AfterEnum: false + AfterStruct: false + AfterUnion: false + BeforeElse: false + +# Keep function return types on a different line from the function name +# Note that often static function forward declarations don't follow this +# approach, and have the return type on the same line. I'm not sure +# clang-format can handle these two cases differently. +AlwaysBreakAfterReturnType: TopLevel + +# Don't warp any long lines +ColumnLimit: 0 \ No newline at end of file From 0170c006e8744d1efb6f12420bb873ad11bc4ef8 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 16 Oct 2018 08:44:46 -0400 Subject: [PATCH 328/582] Update README.md for 2018.3 branches --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index c4dcd664be53..1cd081794e31 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ Branches for released Unity versions are of the form unity-\\[-mbe\][- * [unity-trunk (PR to this branch for Mono)](https://github.com/Unity-Technologies/mono/tree/unity-trunk) * [unity-master (PR to this branch for MonoBleedingEdge)](https://github.com/Unity-Technologies/mono/tree/unity-master) +#### 2018.3 +* [unity-2018.3](https://github.com/Unity-Technologies/mono/tree/unity-2018.3) +* [unity-2018.3-mbe](https://github.com/Unity-Technologies/mono/tree/unity-2018.3-mbe) + #### 2018.2 * [unity-2018.2](https://github.com/Unity-Technologies/mono/tree/unity-2018.2) * [unity-2018.2-mbe](https://github.com/Unity-Technologies/mono/tree/unity-2018.2-mbe) From e8f878c20db7ed1e082033f7f5cac49b29ce2914 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Tue, 16 Oct 2018 08:51:19 -0400 Subject: [PATCH 329/582] Take fast path only for delegate types not Delegate/MulticastDelegate (case 1085270) See upstream PR: https://github.com/mono/mono/pull/11182 --- mono/metadata/icall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c index baf16bd07fbf..befabf51c486 100644 --- a/mono/metadata/icall.c +++ b/mono/metadata/icall.c @@ -3950,7 +3950,7 @@ mono_class_get_methods_by_name (MonoClass *klass, const char *name, guint32 bfla compare_func = (ignore_case) ? mono_utf8_strcasecmp : strcmp; /* An optimization for calls made from Delegate:CreateDelegate () */ - if (klass->delegate && name && !strcmp (name, "Invoke") && (bflags == (BFLAGS_Public | BFLAGS_Static | BFLAGS_Instance))) { + if (klass->delegate && klass != mono_defaults.delegate_class && klass != mono_defaults.multicastdelegate_class&& name && !strcmp (name, "Invoke") && (bflags == (BFLAGS_Public | BFLAGS_Static | BFLAGS_Instance))) { method = mono_get_delegate_invoke (klass); g_assert (method); From 7fb767cdeed0aca76c07357bcefda99378458baf Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Mon, 22 Oct 2018 13:32:38 -0400 Subject: [PATCH 330/582] Build the System.Data.DataSetExtensions assembly The unityjit and unityaot profiles should have this assembly. It exists in the 2.0 profile for the old scripting runtime, and we don't see any need to remove it for the new scripting runtime. This corrects case 1071607 in Unity. --- mcs/class/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mcs/class/Makefile b/mcs/class/Makefile index 64beb024a76b..03fc35fe3beb 100644 --- a/mcs/class/Makefile +++ b/mcs/class/Makefile @@ -345,6 +345,7 @@ net_4_x_parallel_dirs := \ unityjit_dirs := \ $(net_4_x_dirs) \ System.ComponentModel.Composition.4.5 \ + System.Data.DataSetExtensions \ I18N \ $(pcl_facade_dirs) @@ -361,6 +362,7 @@ unityaot_dirs := \ System.Xml.Serialization \ System.Runtime.CompilerServices.Unsafe, $(mobile_common_dirs)) \ System.Drawing \ + System.Data.DataSetExtensions \ $(pcl_facade_dirs) xbuild_2_0_dirs := \ From 2be806ac40418a3949488e2d442e7d2f6ac2a435 Mon Sep 17 00:00:00 2001 From: Jonas Echterhoff Date: Mon, 29 Oct 2018 10:42:58 +0100 Subject: [PATCH 331/582] Use bdwgc nanosecond time limits --- external/bdwgc | 2 +- mono/metadata/boehm-gc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/external/bdwgc b/external/bdwgc index 33b5da352750..f0f567835dc3 160000 --- a/external/bdwgc +++ b/external/bdwgc @@ -1 +1 @@ -Subproject commit 33b5da352750ce094ea11cf8c0634b51ba2539b6 +Subproject commit f0f567835dc33e2df0ef16d97c49f9a30e3e18e0 diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index 12a74eea93d3..9a72862bf772 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -430,7 +430,7 @@ int64_t mono_gc_get_max_time_slice_ns() { #if HAVE_BDWGC_GC - return GC_get_time_limit() * 1000000; + return GC_get_time_limit_ns(); #else return 0; #endif @@ -440,7 +440,7 @@ void mono_gc_set_max_time_slice_ns(int64_t maxTimeSlice) { #if HAVE_BDWGC_GC - GC_set_time_limit(maxTimeSlice / 1000000); + GC_set_time_limit_ns(maxTimeSlice); #endif } From 229c400459c8fc91fff6fe987fd20905932824b6 Mon Sep 17 00:00:00 2001 From: Michael Voorhees Date: Tue, 30 Oct 2018 10:40:00 -0400 Subject: [PATCH 332/582] Additional constructor preservations Upcoming changes to monolinker will make additional optimizations when no instance ctors are marked. To be safe, add preservations for the ctor's of types that are created in the runtime. The change to preserve the .ctor() of`System.Runtime.Remoting.Messaging.AsyncResult` was made for more than out of caution. We have a simple delegate test that hung without this. --- .../corlib/LinkerDescriptor/mscorlib.xml | 71 +++++++++++++++---- 1 file changed, 58 insertions(+), 13 deletions(-) diff --git a/mcs/class/corlib/LinkerDescriptor/mscorlib.xml b/mcs/class/corlib/LinkerDescriptor/mscorlib.xml index 3cb8488c7bef..304d4b03c7f3 100644 --- a/mcs/class/corlib/LinkerDescriptor/mscorlib.xml +++ b/mcs/class/corlib/LinkerDescriptor/mscorlib.xml @@ -19,7 +19,10 @@ - + + + + @@ -122,7 +125,10 @@ - + + + + @@ -254,7 +260,10 @@ - + + + + @@ -303,6 +312,8 @@ + + @@ -524,16 +535,25 @@ - + + + + - + + + + - + + + + @@ -544,26 +564,42 @@ - + + + + - - - + + + + + + + + - + + + + + + - + + + + @@ -708,7 +744,10 @@ - + + + + @@ -719,16 +758,22 @@ + + + + + + From 3898ae1d20e1f560d3f2db789d378a715ccde545 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Thu, 1 Nov 2018 16:58:41 -0400 Subject: [PATCH 333/582] Use mono_mb_emit_op for CEE_LDOBJ to ensure wrapper data is added for indirect load of a ref return value. (case 1096820) --- mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs | 5 +++++ mcs/class/Mono.Debugger.Soft/Test/dtest.cs | 7 +++++++ mono/metadata/marshal.c | 10 +++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs index 76cf1d6624a8..341c247d342c 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs @@ -1755,6 +1755,11 @@ public static ref int get_ref_int() { public static ref string get_ref_string() { return ref ref_return_string; } + + static BlittableStruct ref_return_struct = new BlittableStruct () { i = 1, d = 2.0 }; + public static ref BlittableStruct get_ref_struct () { + return ref ref_return_struct; + } } public class SentinelClass : MarshalByRefObject { diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs index 4539e17dbf67..0bb6328eccbc 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs @@ -4423,6 +4423,13 @@ public void InvokeRefReturnMethod () { m = t.GetMethod ("get_ref_string"); v = t.InvokeMethod (e.Thread, m, null); AssertValue ("byref", v); + + m = t.GetMethod ("get_ref_struct"); + v = t.InvokeMethod (e.Thread, m, null); + Assert.IsTrue(v is StructMirror); + var mirror = (StructMirror)v; + AssertValue (1, mirror["i"]); + AssertValue (2.0, mirror["d"]); } } // class DebuggerTests } // namespace diff --git a/mono/metadata/marshal.c b/mono/metadata/marshal.c index 5bc1a06240e0..395c2b5a8474 100644 --- a/mono/metadata/marshal.c +++ b/mono/metadata/marshal.c @@ -4148,10 +4148,18 @@ emit_invoke_call (MonoMethodBuilder *mb, MonoMethod *method, } if (sig->ret->byref) { + int ldind_op; /* perform indirect load and return by value */ MonoType* ret_byval = &mono_class_from_mono_type (sig->ret)->byval_arg; g_assert (!ret_byval->byref); - mono_mb_emit_byte (mb, mono_type_to_ldind (ret_byval)); + ldind_op = mono_type_to_ldind (ret_byval); + /* taken from similar code in mini-generic-sharing.c + * we need to use mono_mb_emit_op to add method data when loading + * a structure since method-to-ir needs this data for wrapper methods */ + if (ldind_op == CEE_LDOBJ) + mono_mb_emit_op (mb, CEE_LDOBJ, mono_class_from_mono_type (ret_byval)); + else + mono_mb_emit_byte (mb, ldind_op); } switch (sig->ret->type) { From 3b8a070f84fd95d4c620226803191616e951fbd4 Mon Sep 17 00:00:00 2001 From: alexandru Date: Tue, 6 Nov 2018 13:37:02 +0100 Subject: [PATCH 334/582] fix for case 984330, static field bytes being reported without any static fields being reported as present. * changed class crawling to be recursive and now store non inited classes * metadata type reporting will now also report invalid uninitialized types * metadata type reporting will now account for array types being fields inside a class --- mono/metadata/unity-memory-info.c | 175 ++++++++++++++++-------------- 1 file changed, 96 insertions(+), 79 deletions(-) diff --git a/mono/metadata/unity-memory-info.c b/mono/metadata/unity-memory-info.c index 6957c15da4c2..6455c94dcb03 100644 --- a/mono/metadata/unity-memory-info.c +++ b/mono/metadata/unity-memory-info.c @@ -24,67 +24,82 @@ typedef struct CollectMetadataContext MonoMetadataSnapshot* metadata; } CollectMetadataContext; -static void ContextInsertClass(CollectMetadataContext* context, MonoClass* klass) +static void +ContextRecurseClassData (CollectMetadataContext *context, MonoClass *klass) { gpointer orig_key, value; + gpointer iter = NULL; + MonoClassField *field = NULL; + int fieldCount; + /* use g_hash_table_lookup_extended as it returns boolean to indicate if value was found. * If we use g_hash_table_lookup it returns the value which we were comparing to NULL. The problem is * that 0 is a valid class index and was confusing our logic. */ - if (klass->inited && !g_hash_table_lookup_extended(context->allTypes, klass, &orig_key, &value)) - g_hash_table_insert(context->allTypes, klass, GINT_TO_POINTER(context->currentIndex++)); + if (!g_hash_table_lookup_extended (context->allTypes, klass, &orig_key, &value)) + g_hash_table_insert (context->allTypes, klass, GINT_TO_POINTER (context->currentIndex++)); + + fieldCount = mono_class_num_fields (klass); + if (fieldCount > 0) { + while ((field = mono_class_get_fields (klass, &iter))) { + MonoClass *fieldKlass = mono_class_from_mono_type (field->type); + + if (!g_hash_table_lookup_extended (context->allTypes, fieldKlass, &orig_key, &value)) + ContextRecurseClassData (context, fieldKlass); + } + } } -static void CollectHashMapClass(gpointer key, gpointer value, gpointer user_data) +static void +CollectHashMapClass (gpointer key, gpointer value, gpointer user_data) { - CollectMetadataContext* context = (CollectMetadataContext*)user_data; - MonoClass* klass = (MonoClass*)value; - ContextInsertClass(context, klass); + CollectMetadataContext *context = (CollectMetadataContext *)user_data; + MonoClass *klass = (MonoClass *)value; + ContextRecurseClassData (context, klass); } -static void CollectHashMapListClasses(gpointer key, gpointer value, gpointer user_data) +static void +CollectHashMapListClasses (gpointer key, gpointer value, gpointer user_data) { - CollectMetadataContext* context = (CollectMetadataContext*)user_data; - GSList* list = (GSList*)value; + CollectMetadataContext *context = (CollectMetadataContext *)user_data; + GSList *list = (GSList *)value; - while (list != NULL) - { - MonoClass* klass = (MonoClass*)list->data; - ContextInsertClass(context, klass); + while (list != NULL) { + MonoClass *klass = (MonoClass *)list->data; + ContextRecurseClassData (context, klass); - list = g_slist_next(list); + list = g_slist_next (list); } } -static void CollectGenericClass(MonoGenericClass* genericClass, gpointer user_data) +static void +CollectGenericClass (MonoGenericClass *genericClass, gpointer user_data) { - CollectMetadataContext* context = (CollectMetadataContext*)user_data; + CollectMetadataContext *context = (CollectMetadataContext *)user_data; if (genericClass->cached_class != NULL) - ContextInsertClass(context, genericClass->cached_class); + ContextRecurseClassData (context, genericClass->cached_class); } -static void CollectImageMetaData(MonoImage* image, gpointer value, CollectMetadataContext* context) +static void +CollectImageMetaData (MonoImage *image, gpointer value, CollectMetadataContext *context) { int i; MonoTableInfo *tdef = &image->tables[MONO_TABLE_TYPEDEF]; GSList *list; - if (image->dynamic) - { + if (image->dynamic) { GHashTableIter iter; gpointer key; - MonoDynamicImage* dynamicImage = (MonoDynamicImage*)image; + MonoDynamicImage *dynamicImage = (MonoDynamicImage *)image; + g_hash_table_iter_init (&iter, dynamicImage->typeref); - g_hash_table_iter_init(&iter, dynamicImage->typeref); - - while (g_hash_table_iter_next(&iter, &key, NULL)) - { - MonoType* monoType = (MonoType*)key; - MonoClass* klass = mono_type_get_class(monoType); + while (g_hash_table_iter_next (&iter, &key, NULL)) { + MonoType *monoType = (MonoType *)key; + MonoClass *klass = mono_type_get_class (monoType); if (klass) - ContextInsertClass(context, klass); + ContextRecurseClassData (context, klass); } } @@ -93,119 +108,121 @@ static void CollectImageMetaData(MonoImage* image, gpointer value, CollectMetada */ list = image->reflection_info_unregister_classes; - while (list) - { + while (list) { MonoClass *klass = (MonoClass *)list->data; if (klass) - ContextInsertClass(context, klass); + ContextRecurseClassData (context, klass); list = list->next; } - for (i = 1; i < tdef->rows; ++i) - { + for (i = 1; i < tdef->rows; ++i) { MonoClass *klass; MonoError error; guint32 token = (i + 1) | MONO_TOKEN_TYPE_DEF; - klass = mono_class_get_checked(image, token, &error); + klass = mono_class_get_checked (image, token, &error); if (klass) - ContextInsertClass(context, klass); + ContextRecurseClassData (context, klass); } if (image->array_cache) - g_hash_table_foreach(image->array_cache, CollectHashMapListClasses, context); + g_hash_table_foreach (image->array_cache, CollectHashMapListClasses, context); if (image->szarray_cache) - g_hash_table_foreach(image->szarray_cache, CollectHashMapClass, context); + g_hash_table_foreach (image->szarray_cache, CollectHashMapClass, context); if (image->ptr_cache) - g_hash_table_foreach(image->ptr_cache, CollectHashMapClass, context); + g_hash_table_foreach (image->ptr_cache, CollectHashMapClass, context); } -static int FindClassIndex(GHashTable* hashTable, MonoClass* klass) +static int +FindClassIndex (GHashTable *hashTable, MonoClass *klass) { gpointer orig_key, value; - if (!g_hash_table_lookup_extended(hashTable, klass, &orig_key, &value)) + if (!g_hash_table_lookup_extended (hashTable, klass, &orig_key, &value)) return -1; - return GPOINTER_TO_INT(value); + return GPOINTER_TO_INT (value); } -static void AddMetadataType(gpointer key, gpointer value, gpointer user_data) +static void +AddMetadataType (gpointer key, gpointer value, gpointer user_data) { - MonoClass* klass = (MonoClass*)key; - int index = GPOINTER_TO_INT(value); - CollectMetadataContext* context = (CollectMetadataContext*)user_data; - MonoMetadataSnapshot* metadata = context->metadata; - MonoMetadataType* type = &metadata->types[index]; + MonoClass *klass = (MonoClass *)key; - if (klass->rank > 0) - { - type->flags = (MonoMetadataTypeFlags)(kArray | (kArrayRankMask & (klass->rank << 16))); - type->baseOrElementTypeIndex = FindClassIndex(context->allTypes, mono_class_get_element_class(klass)); - } - else - { + int index = GPOINTER_TO_INT (value); + CollectMetadataContext *context = (CollectMetadataContext *)user_data; + MonoMetadataSnapshot *metadata = context->metadata; + MonoMetadataType *type = &metadata->types[index]; + + if (klass->rank > 0) { + type->flags = (MonoMetadataTypeFlags) (kArray | (kArrayRankMask & (klass->rank << 16))); + type->baseOrElementTypeIndex = FindClassIndex (context->allTypes, mono_class_get_element_class (klass)); + } else { gpointer iter = NULL; int fieldCount = 0; - MonoClassField* field; - MonoClass* baseClass; - MonoVTable* vtable; - void* statics_data; + MonoClassField *field; + MonoClass *baseClass; + MonoVTable *vtable; + void *statics_data; type->flags = (klass->valuetype || klass->byval_arg.type == MONO_TYPE_PTR) ? kValueType : kNone; type->fieldCount = 0; + fieldCount = mono_class_num_fields (klass); + if (fieldCount > 0) { + type->fields = g_new (MonoMetadataField, fieldCount); - if (mono_class_num_fields(klass) > 0) - { - type->fields = g_new(MonoMetadataField, mono_class_num_fields(klass)); + while ((field = mono_class_get_fields (klass, &iter))) { + MonoMetadataField *metaField = &type->fields[type->fieldCount]; + MonoClass *typeKlass = mono_class_from_mono_type (field->type); - while ((field = mono_class_get_fields(klass, &iter))) - { - MonoMetadataField* metaField = &type->fields[type->fieldCount]; - metaField->typeIndex = FindClassIndex(context->allTypes, mono_class_from_mono_type(field->type)); + if (typeKlass->rank > 0) + metaField->typeIndex = FindClassIndex (context->allTypes, mono_class_get_element_class (typeKlass)); + else + metaField->typeIndex = FindClassIndex (context->allTypes, typeKlass); // This will happen if fields type is not initialized // It's OK to skip it, because it means the field is guaranteed to be null on any object - if (metaField->typeIndex == -1) + if (metaField->typeIndex == -1) { continue; + } // literals have no actual storage, and are not relevant in this context. if ((field->type->attrs & FIELD_ATTRIBUTE_LITERAL) != 0) continue; metaField->isStatic = (field->type->attrs & FIELD_ATTRIBUTE_STATIC) != 0; + metaField->offset = field->offset; metaField->name = field->name; type->fieldCount++; } } - vtable = mono_class_try_get_vtable(mono_domain_get(), klass); - statics_data = vtable ? mono_vtable_get_static_field_data(vtable) : NULL; + vtable = mono_class_try_get_vtable (mono_domain_get (), klass); + statics_data = vtable ? mono_vtable_get_static_field_data (vtable) : NULL; - type->staticsSize = statics_data ? mono_class_data_size(klass) : 0; + type->staticsSize = statics_data ? mono_class_data_size (klass) : 0; type->statics = NULL; - if (type->staticsSize > 0) - { - type->statics = g_new0(uint8_t, type->staticsSize); - memcpy(type->statics, statics_data, type->staticsSize); + if (type->staticsSize > 0) { + type->statics = g_new0 (uint8_t, type->staticsSize); + memcpy (type->statics, statics_data, type->staticsSize); } - baseClass = mono_class_get_parent(klass); - type->baseOrElementTypeIndex = baseClass ? FindClassIndex(context->allTypes, baseClass) : -1; + baseClass = mono_class_get_parent (klass); + type->baseOrElementTypeIndex = baseClass ? FindClassIndex (context->allTypes, baseClass) : -1; } - type->assemblyName = mono_class_get_image(klass)->assembly->aname.name; - type->name = mono_type_get_name_full(&klass->byval_arg, MONO_TYPE_NAME_FORMAT_IL); + type->assemblyName = mono_class_get_image (klass)->assembly->aname.name; + type->name = mono_type_get_name_full (&klass->byval_arg, MONO_TYPE_NAME_FORMAT_IL); type->typeInfoAddress = (uint64_t)klass; - type->size = (klass->valuetype) != 0 ? (mono_class_instance_size(klass) - sizeof(MonoObject)) : mono_class_instance_size(klass); + type->size = (klass->valuetype) != 0 ? (mono_class_instance_size (klass) - sizeof (MonoObject)) : mono_class_instance_size (klass); } static void CollectMetadata(MonoMetadataSnapshot* metadata, GHashTable* monoImages) From 4302a8a6ad5020b3cfcc3e1052147042e312029c Mon Sep 17 00:00:00 2001 From: ashwini Date: Mon, 5 Nov 2018 15:19:54 -0500 Subject: [PATCH 335/582] Add bee script to pull down required mono-build-deps from stevedore --- .gitignore | 7 + external/buildscripts/Build.bee.cs | 192 ++++++++++++++++++++ external/buildscripts/bee | 2 + external/buildscripts/bee.exe | Bin 0 -> 2473472 bytes external/buildscripts/buildDependencies.txt | 60 ++++++ 5 files changed, 261 insertions(+) create mode 100644 external/buildscripts/Build.bee.cs create mode 100644 external/buildscripts/bee create mode 100644 external/buildscripts/bee.exe create mode 100644 external/buildscripts/buildDependencies.txt diff --git a/.gitignore b/.gitignore index c6ef19a849b6..14166d5d9ec3 100644 --- a/.gitignore +++ b/.gitignore @@ -117,6 +117,13 @@ GTAGS docs/doxygen* docs/perlmod* +# Bee +artifacts +.vs +external/buildscripts/build.gen* + +# Allow +!external/buildscripts/bee.exe ############################################################################## # Mono-specific patterns diff --git a/external/buildscripts/Build.bee.cs b/external/buildscripts/Build.bee.cs new file mode 100644 index 000000000000..fad1d93dc953 --- /dev/null +++ b/external/buildscripts/Build.bee.cs @@ -0,0 +1,192 @@ +using System; +using System.IO; +using Bee.Core; +using Bee.Stevedore; +using NiceIO; +using Unity.BuildTools; +using System.Collections.Generic; +using System.Text; + +namespace BuildProgram +{ + public class BuildProgram + { + internal static void Main() + { + if (IsRunningOnBuildMachine()) + Console.WriteLine("\n>>> Running on build machine"); + + var monoRoot = GetMonoRootDir(); + Console.WriteLine(">>> Mono root directory: " + monoRoot); + + var buildScriptsRoot = monoRoot.Combine("external").Combine("buildscripts"); + Console.WriteLine(">>> Build scripts directory: " + buildScriptsRoot); + + var monoBuildDeps = monoRoot.Parent.Parent.Combine("mono-build-deps").Combine("build"); + Console.WriteLine(">>> Mono build dependecies directory: " + monoBuildDeps); + + var buildDependenciesConfigFile = buildScriptsRoot.Combine("buildDependencies.txt"); + Console.WriteLine(">>> Mono build dependecies stevedore version config file: " + buildDependenciesConfigFile); + + var stevedoreArtifactsDir = buildScriptsRoot.Combine("artifacts").Combine("Stevedore"); + Console.WriteLine(">>> Stevedore artifacts directory: " + stevedoreArtifactsDir + "\n"); + + if (buildDependenciesConfigFile.Exists()) + { + if (!monoBuildDeps.DirectoryExists()) + { + Console.WriteLine(">>> " + monoBuildDeps + " does not exist. Creating it ..."); + monoBuildDeps.CreateDirectory(); + } + + var artifactNameIdFilesDictionary = ParseBuildDependenciesConfigFile(buildDependenciesConfigFile.ToString()); + + foreach (var item in artifactNameIdFilesDictionary) + { + var artifactName = item.Key.Key; + var artifactId = item.Key.Value; + var artifactFiles = item.Value; + DownloadAndCopyArtifact(artifactId, artifactName, artifactFiles, monoBuildDeps, stevedoreArtifactsDir); + } + } + else + { + throw new Exception($"{buildDependenciesConfigFile} does not exist"); + } + } + + private static void DownloadAndCopyArtifact(string artifactId, string artifactName, IEnumerable artifacts, NPath monoBuildDeps, NPath stevedoreArtifactsDir) + { + var artifact = StevedoreArtifact.Testing(artifactId); + Backend.Current.Register(artifact); + + var inputs = new List(); + var targetFiles = new List(); + foreach (var item in artifacts) + { + inputs.Add(stevedoreArtifactsDir.Combine(artifactName).Combine(item)); + targetFiles.Add(monoBuildDeps.Combine(artifactName).Combine(item)); + } + + var targetDir = monoBuildDeps; + if (HostPlatform.IsWindows) + { + targetDir = monoBuildDeps.Combine(artifactName); + } + + Backend.Current.AddAction( + actionName: "CopyArtifact", + targetFiles: targetFiles.ToArray(), + inputs: inputs.ToArray(), + executableStringFor: ExecutableStringForDirectoryCopy(stevedoreArtifactsDir.Combine(artifactName), targetDir), + commandLineArguments: new string[] { }, + allowUnwrittenOutputFiles: true + ); + } + + private static void ExecuteBuildScript(NPath[] inputFiles, NPath buildScript, NPath buildRoot) + { + Backend.Current.AddAction( + actionName: "ExecuteBuildScript", + targetFiles: new[] { buildRoot}, + inputs: inputFiles, + executableStringFor: $"perl {buildScript}", + commandLineArguments: new string[] { }, + allowUnwrittenOutputFiles: true + ); + } + private static NPath GetMonoRootDir() + { + var exePath = new NPath(System.Reflection.Assembly.GetEntryAssembly().Location); + var monoRoot = exePath; + + //Assume "external" directory exists under monoRoot. + while (monoRoot.ToString().Contains("external")) + monoRoot = monoRoot.Parent; + + return monoRoot; + } + + private static string ExecutableStringForDirectoryCopy(NPath from, NPath target) + { + return HostPlatform.IsWindows + ? $"xcopy {from.InQuotes(SlashMode.Native)} {target.InQuotes(SlashMode.Native)} /s /e /d /Y" + : $"cp -r -v {from.InQuotes(SlashMode.Native)} {target.InQuotes(SlashMode.Native)}"; + } + + private static bool IsRunningOnBuildMachine() + { + var buildMachine = Environment.GetEnvironmentVariable("UNITY_THISISABUILDMACHINE"); + return buildMachine != null && buildMachine == "1"; + } + + //Sample config file format: + /* + # Dependencoes to pull down from Stevedore. Please follow the following format: + # name : + # id : + # files : + + name: 7z + id: 7z/9df1e3b3b120_12ed325f6a47f0e5cebc247dbe9282a5da280d392cce4e6c9ed227d57ff1e2ff.7z + files : 7z + + name: libgdiplus + id : libgdiplus/9df1e3b3b120_4cf7c08770db93922f54f38d2461b9122cddc898db58585864446e70c5ad3057.7z + files : libgdiplus,lib2 + */ + private static Dictionary, List> ParseBuildDependenciesConfigFile(string buildDependenciesConfigFile) + { + var artifactNameIdFilesDictionary = new Dictionary, List>(); + + var fileStream = new FileStream(buildDependenciesConfigFile, FileMode.Open, FileAccess.Read); + using (var streamReader = new StreamReader(fileStream, Encoding.UTF8)) + { + string line; + while ((line = streamReader.ReadLine()) != null) + { + //Check if line contains a comment + if (!string.IsNullOrEmpty(line) && !line.Contains("#")) + { + if (line.Contains("name :") || line.Contains("name:")) + { + var name = ""; + var id = ""; + var files = ""; + + //read name + name = line.Split(':')[1].Trim(); + + //read id + if ((line = streamReader.ReadLine()) != null) + id = line.Split(':')[1].Trim(); + else + throw new Exception($">>> Invalid {buildDependenciesConfigFile}"); + + //read comma separated folder/files list + if ((line = streamReader.ReadLine()) != null) + files = line.Split(':')[1].Trim(); + else + throw new Exception($">>> Invalid {buildDependenciesConfigFile}"); + + var filesList = new List(); + if (!string.IsNullOrEmpty(files)) + { + if (files.Contains(",")) + files.Split(',').ForEach(f => { filesList.Add(new NPath(f.Trim())); }); + else + filesList.Add(new NPath(files.Trim())); + } + else + { + throw new Exception($">>> Invalid {buildDependenciesConfigFile}"); + } + artifactNameIdFilesDictionary.Add(new KeyValuePair(name, id), filesList); + } + } + } + } + return artifactNameIdFilesDictionary; + } + } +} diff --git a/external/buildscripts/bee b/external/buildscripts/bee new file mode 100644 index 000000000000..78715cd133ae --- /dev/null +++ b/external/buildscripts/bee @@ -0,0 +1,2 @@ +#!/bin/sh +mono bee.exe "$@" \ No newline at end of file diff --git a/external/buildscripts/bee.exe b/external/buildscripts/bee.exe new file mode 100644 index 0000000000000000000000000000000000000000..1e6347c24a5a4e9b7971aab8f78eaadbcc0d4977 GIT binary patch literal 2473472 zcmce<378~Bwf7yJRh?Cx-91pa>mUcD;r8}7?>!CjGY7t!m&b-CBOIKIFCiOgEMXSlxa_dH)eU73+5 zPMkP#;>3v)OGZB7NjJHIbFRqm?|*mhL)`VZ&aRJsnJ0S5%8x8@_YQq^_YV!6{MFsh zy5!Qv)TT7KIDP8nQ%`&96;~uzOc|M`@SguI+c{mrl_v; z;c6~@aUkt5uCo0hdoL=-(VcPqp&8LlROYB3`Jz|D{s50(451Th*CC4;)4Qc;6S z593$qauJsfr4{f!MLMv_J&1>itVUaR0yOMO@llZrYtdGo$ZG)AQVEyr;Dve{6qnj9ZaYQIcUQ=}8u-m#X)J9x-G^LJ9@K{dJpeUvqqV%Z( zDpXUN$axk@F(hYNQ{)vkbxq$bJd_}sTMD%d`0*S#TLb7ywHOv>B&eAf`G@tZySSg} z;8G;#L@TVH-HD%5dz`3Oxwauv47Y`k1*3t0B8hlrbjUIp>dhqiPgJ5VX|>6-SV|CW zWWY>@LvDN*x9?XF_{&`SJ#lb1f?j2rO{bd%0E{UE31Bt)Q*c!Z4l9+$aonRYXzdPR z&uu&oR@fBa#!IV5okzAEUXSnNb+|OUR8Oos(r)h zI>L7`qK%R}sI>acmi!hmDBcX)XEs_LFV;^YdZ<#ob;Om8`uJcu`FBXoLLZQV=|@Oh z8H|x=G(MPq+Mdb_xNwzXZT)z$QXIPR(zWmS```a=8Kn<`Y!Wr%y&^(JgYMnP2tBH} z_^n7Yh!3OiZE`NAFAdzLWFwCg$@M0`i6r4Zt11eUySc>o>_+j>R@Znnp_rI3Oy8(< zPbWBB%2KQX!^PA-lIx^v%&v6dNV%3A%DtSN3;~yZn6xqa7mXSZKIdwJ>V@$n;PlrZ z1UFuKJ=HfbLbOg0p30)7}-{=g7;&KLnOuT7V)EkwwgQBQEbm?4lHAcjLX4 z5mFA*E3@dZc0C#!#Ass}KLW*gImET*%pV*(w0OgFdW)kCB90!wy~Jid&k}_ z#<}euz@f6wdY?cn%w(atK3Q#<9N@_Nfva11wdz6cxE~wprf()#xuAI6(q1vM;yz$ayN1$^q{V!+)F+Ew- zm{Qe;lefnAkXfe&om&B|U1`U3Zj_a#5vETHz1oM9UVY70Nom!LLSNA@1E<<}uE`>P z3sv975ES>VOl%9+fYiV^M)Lw0JU$ML#?4&lk|<(c+C9J;DJOe!n}|`Z$RwKH4DkjH zKiZtfVTorF>L{9aTPd|G%>r?ygu00y3_aW5CY9Na8zeuDAg^gRIhrLEf^e zmj2f6lj)!BzAXK#-Iu4^bWh%)G(mC$H`T5B@KNdWiS#8~%0&1l*$t8q*9<=>vcB&KOdm`(-%H}%F7KwAv z8JdMW?GysOe^1}v39TE-VgE{q?od4RSc$GbkX{sJsMc!-wd9p(f@}O6(pC==PmwbD zD^G;g`jS6cIQe%~2i74Jt(nST@;3lsg62e(!4xrUN=k!D)uwF4B(QKb8MM2+g=#!W zxN$a@q{d~s@y!A9ELBRS~!%CQZPgv#n%@~AAnd+Ys0s5UV zc@3bz{CU8Cgq`GW%926K_OP0ES8z+Idu-hQRl7^xLaV##S49`JDX?!Q`@vd+OEfQ# z!DY*5d~VNH-SS`FR;gb)5nZGHkr@gbCKqx^UqdZdljjojeGR%h z(?$SZI{O1}93bfkWNNi_ z-NmG{Kl)M1sCF;swWr;0N!}?H?2*|sM9E}kQ88Ur7;Fpw3ADyz5SB)YGt(V{meN!4 zV~az{(CWcTQB7V*`ZoIJWsVfW#(|Q#Kn9mU`eZ(!^bY%9Y10uFlY>FeOQk-&=q{su z;EYn&G4v+lCRcNE?K$3uM-Ri>bM>`g8!Yp>X|Vn|d8ZIfT`Y768O>S}4K~x~O4zG~ z0zXj{Q?h8d6efpppW6fx`e+!;M#FCeu|1NP6G>&|6v*Hj1p zlm^fEFN;PdxTl###5al%7x^vV$(MAK{Cq2Orzpug$RBq?UiEZe;Z-~vD{otFp4uFZ z-ld;`jr0d9ujtg023ITfM0_>Wr;&mmum8avx@uqp7~&p3*LZvqrrWYVDG|`$=}RK@&Y~Q9{B(N`3=Y}TKxqYV$Q@rpa7j3lYLcdQ2hqp zQRs`4U8Tg8!22jSNgQh_<(!O229!f@z?p$so>+8|sZX1}PW5w-1b0PG=6T*m-&>D7 zx%Ca5^frZHJ-hipInsfF(TuM~{#2!nM{dQmFgl_x*QqXjckl^ut?qzHmG6Tn({eP? zqxCxp4<*MCW*Wpg3nM89B{OFzIV|H*91D{5thuqT6t^U|lQmB0gq3Udbm8)t-cN?! z?u>`k@lt(_z_>KGj?;zUEG?!rnA0jTnSv8k!9`sAC1z8^-($&o?ra`x05fDR@=)gZ zCdUyuUaoH;3uDhZhU7LeX1z;tybz)~&Bs-uPLhu*&k zTxDS9h}<_Xs4uoYF0f3!9P>Jt|8_m`OkQBoZKl=FQO=W9(c9jrXPz?bnWy}tv~UP6 zd*>$c4yhDe#)~m-&&jWbA_^RSEGw&-_|Y3)PJ6$6|3`9 z1y>p)SH#4XCcss!ROcxgSBxlE20UCDnsUxSDzEv7+SDp;K_QGNV(l$=SeWk*l{_8k6X2 zq;(j&3E!2VxfeV|!BU%^3y;&FT29RV{MPfkj^91}zQyl<_|>;@ac$`?6RB{Yj*q!b ztvz@SntO8Hw-nTjR{gs|lw32!Ws49eJ>owJQ9{oU)#vt8T;>s9AVk$#hPZMO#pNFH z$;R0#qHSu$e64EZ3hLxYMWSH z-KQT{b?S6)@k186hsWW!ZnsW<4qUGIA^hr6h`xHgUBX=@R-4mYtzJd1z7v>>YM~Et z(lV|;B#H|apbv4GNBp=D7b-v>;&PApY9X3^JZe9JL3+1pP5_&k_tn>zaD`7Og=nko zW}5S!MTOhNBYK6{N_3Cr^ikZ^BW4OAiAW*xI!89txf1M1ANu2@4-#)ySv$~&a~A4@ zW!tY0r-HNEy~W!LSFrV|#+g#CV4{UdDh5HJ8Y76%o`5_r!!6Ef_>&HfGj^S_1ce;M z^pc^0*_}3{m!4u-+!%2M%4~C%HuCK)chQvt=dcqMS4gcFl-ct$wR()|zd>My)0aS<$2VbHEm++>ugzJ~1Y#(i|eyN{B&97Ve}!7c4Kjs6MOohGnYcN!Xg1a(YS+ zrrOES%5&FY23$}`TZlKkj*Cqk=Hz}um%g0mf;C64QH5M9^6}4<*NJ|i zr0?sK5ktI>0$84GP(ftH!pY=G$|OubWf5p|A+geQmMJuTjY&yeNCy|> z_l5raq!TnE@%UU4?7qD;I}c<9U%CIbfv77aHIht7ikTUx4u^BJ3|FELW}3J>OG{wl zwq*BZqYacQLTSebhsMMD1H`!k)0dM^kFt4F?_bR&5eGYl7Wi?+aR0bJa3~s2D z)?4An%awBaRZ8Y3j4!dY#RS!iOvzn&7T4LO-vXt#jw;1UIiaaUuC5x_+&UT+^^j7t z>tNMYA>eET2Mbo0LF`0ULWVJe0CZ>C)|X`6GO2cT$k;R;rNOPx5CK8W#1}xxR-DF% ztR^Z$ew|PnMek4v5R6)8u<~39xM!?ca7P1|9m>_xE2@?A@e}>!44SfrmVLpNwilQ! z>{<~&Fr$|*`}kB^_fZ>WhNZA&)v_$SytpNP8q6;sB;9*2bTCTrH4#5s?bA%{-LTZS zkQAE>#*A-DQRul=`%H~%i|lDe;mZ9E#}&Y5R1thCKq{sOStF>eLvu5LFQ%shUC-ih z-E5LUGdWyDT&=Ml4)d8&`7wb@ptPs>4{S1{@pSMaS3sfb5>a{RR<@ob7n5$TBkWQy z$41}Jps)-NBFZvUTR%EfW`O%~^ubTIn&{Y-08O;W&vpKuFr_8$xGm9H2Jb<1K~Dy~ z<=zn0?-7A;?m(`6LfU_wnv^kPS=nZZZl^U|e|{%LrxBvR&bF6$N?~S=v7loeBH9MoQVD5p$!?_rJ&o%yD5B;#8ut7KM2RR7gzDxNNRe zHdQino2m7W4BW<=7QID&0stysowvtcE0xGo%943~md0k#+Io*4UrKB*@#{p(=HEtP za)GKP zvzPrbL}cwGaP)$1Z}D4=s>Aie6y?>RWDJg!eKn|B!`VpJm2=w$s@6%38q?*7jaTc3 zOFo&gxb8!6TN||oX?D2a-cM3$zatm3AHF)i$gX??$Dro+v9LULegUb37=&+m3d_-Nz~Jb z)coklPT-bFP5n#3)WD;elarzCz5vY(nss8vS+}sV-7f^0_Rz7PqEU_Nn?yq;4{e$c z$a#tw4q~b%v<2qUb?wKgT6^6l)Efh zf1>7ReYv&Cu7>1j;#Hrf({}ay1wIF;2;ht{a=p91TYOAkoX-5qXTzrYpjBr4& zdO0G`*S{eWb-TF#HySY2Pov9ZDSK&J3fZyWW!%`k(O!(~QFsJ;zb zOl9z%Ou0wuYP<|$tjqW`a5niP9-3e(88vnc@@L!fUP+gu4kkt z&iir}SEwCsO>a&fQM>_ab5^}3o2ZWG*xP2zxwpYphnknmW5C3z9OAAPUtIkvVL)0VJ2r1bV9=*-bc2a%JXNvC~JiMmbP7y2?R zB>fpmHmd*qOqaZcrJL?#qWYkYeY_{NG^+0+>Q;M&t5hlrYMHSwoot_#1Kyqu$MgU_ zycZn&YTmEX_>5$L#rqc3sI7rBW+-aI_0z#9+<2+ghqs{Cg3a~}*AF5#G(aH1*#3}6 zn<%5!Avg^M_TzpQaN`;v+R8JND;eq3@6vw!I4v+D*|<-gWKg&Eq{#ulC#{F?z#*Tk zTqZAX6Hyeu&)8R&DTf~rWv28f(e(nB2eWJ)U491Wv=m9q3)IUFc-W`b@nSL_UeeD)(e}G~9tv&jhnMa9!SY*C1TuL1^4^rb z-p=mlKO5pK0UE>?f?i0}lQZd(EwN(1XlCB_BpZn;#y1#MOM)KxC$MCZl}8|3najvr z8W{kJE>eYTb8Y-8@B_=MQ!S>ep8<*f1AovDzRV82rYn;P^H64KT9nepPm$U8iKzZE z(NB77pP8ep$)~0U95E$^3)*R-$BP1`d_4%$j%s>70S&V;ls3#R6-q&(fu3<$OjOY6 z&Pe(Jd;%z1#s3)gdMkcP6^}GlAd6Qj8~p{Dj&}9spvnGZUSF~TR+Pk>wRj$S=CkMK z1t+r;TZ^wF+HF2Bg8w=+Hpdter~DbJ2~ z12W@g)meydL>^s*R$1?W<__A%fy*AHtX9Xr1jFxO%}e=M$XPMx$tnJx#E(R9va<)b zRSpStSCfSNwosew%Zm?pqoObotCG8V=F5Gu+x>F4!k63cNx_D)j{#%HjEh^5ZJ?E2 zL_O0`fu^CJuv}A8%fke#6xmY97BQC1_OJo;axyfbl@c}I5gU5C`kUpU+kX8AVQdGo zIvwJ@>STJ6HHS%+r?;iXH(SwOA#z!hHJsiio8dge%OWAc>>h---&kTyp4!Th9{UPm zOU}7AW^F2du}8B8@W=v=r--8gNS~0eFK2s(2D{4a>~xGw7EIm=S6(9Kn*CR@4vi0} zWI?uRj6y{{Q#NL2W;?WBN-Q(~>bTMqSKvg|x)~Vof(1Yjb9?3Y=cz8NsEgbp@)w&U?qR&Q!o6jA(!-i(E&Jktxy zEkkNFy&^=sxnou===1Nq-|BTNYsFSs--X9s^}=k@P35ga^{@u|c{lfvpPTmr=?S`?zUp%?()Zb#zCKbl({+x75BWa)tV^N^ zlIh*#Q|LPOD9%oT7vj5!=z2JLdmixm;8~>$r9qpouI{5VSc1Smz~?I#@+o_P*racZ z>EE=Fz8`O4Gb)X5z^Z(9Y+Mo1A0=^yO+Do;sc2ow;Ho**({%d)qU?p4x8+iv7s%k| zbyES~R20z2c3m%U!%bH()mrDMG`^MPzZM$gzm6MaFf(FJ^t1&{&3b^aDfAsMh|9E) zL4n%3pCkvsuw?pXF8t#8pbrj>DHX$)jfFqvelNrPxw>w4zG-B zK31=F@Urn*{L0=cH64)kqXkf>nVulDZf>5RCE%c=m7wu42{O;ZcqTSf{pdQRN{bqj3ya0_)_0jrc{C1vg9J<_Qc2>+|T#D+^ zqU64>Y(GL!XdS5R`|@rI z)XjSi1^pl;iz$OPP=BPG_BE8MeG8X4DNuu^7|rX^U_tUaf_`1`7^3aZVr(5b!+E_@ zSBMKVdW(`baB1AeWwRk9SkTDk@F$G&YVAD@+}R|c(NbrY`yh{Xa~gf3J4iHKp8z^G z5WkTJUIZ4eL2@ToV0Uqw`w1@DR!MwpU|W^ezQS+9B#Z1FvR&Nj*wdx+_GnyL*)DS z5kmeg21KpIhJPXK7=;YbnuSWx#Jc*8Q_9>rCRcwQ6`ZkSJIT5>#M)6)DZ6@}w}D;N z{uab(?~roHsO@0y(AQwCm!97bf$gpY*NUwL+sd;3-^)aT=|8tX>PuZz3PBU|RJ4Ib zPQ6=SMXg<$%>YmR7&pXK?2ccPm-VsLQ+Iu7)y0r@U4L3^a8HrY{erbUuqurQ6-Qrs z97*Uzb?X_q--k*!rl`WrJ}U3N=r6aD@X`BAwQrhJrSYRI560}uL${thPF>l}Ls30> z{PnPiwkq0-J9i z@cBp@NkgK^dU5cM*Xsr1S+b@?mG-G%7 zXk7fCDqvnd(~TxAt|$LJa0~=df0E--VaP$5_wwmwbb`f+gT-;4KBei26MaE?>3h5l zi|_fA58r{P+*hu@_BBQ4s%$hn@jHbJK!YbP)e#QKTRi8QSY5U6X>`1NRd0 zdV=Nkb{cuqxQ8n_>a93Nj(Y7cs-u}0rsSUp>wuB}g5Y?uIzCw67dYF*25%kJ%c<`o z-uI>|8~`OQ4H+r6d}tFH8$VdJSo=k+9UC_HLMC%}6AsxIqC6_nnS#whpCX=u_}!4W z3IVe6>!n%H+bT2h6qiIw)<1ty)L7P?YH17YbEy*>Sw%>=@z0Q&7s%jxRos(_S*Pli z|Noc#1ML%ci+L|3YFYif?ig3i?jOZf)9lABxSiqQG-RNqn6RgClI_y2d>ZdTB7F$N z>0K92ig6gNN`npM*8iS|)WTxxd~S4+x&@qF@LrPJn{_3tp^^FvNat&bE@)ITf1h&L zJD2om{4C6G*c7=;r!Rs1WFwdCc{2#peJW0B*O$(ey(gVLXX$#he^EMX2R-TR*{9n+ zOYs0j7>85kkTp2EQ#3xu?`I_mGW;Gc`tkc&ND79}VLPVD{xz;*qP9NN#s+xZ9hMyL zmF@~;aJ{-aliXsmw8~(w)ce7x6uXUEZ5y3)wB3rE=vlvJ`s)GUxcFD9{z`-yw|zk% zGcyHaApQW6Y#aGEm?8f5kvhWAH<>gu6q8&uLLB)WR&T7#<0yv)*p;(e3Te;8C( zk2`KqS(bv?7rhrd!{Y2nX?7Q)%5zn&>2K)~J(qsd;D=yxb7>a4?#ewYxhng5V9T~s zcKor0W#1oAL6f4`R$b!{bIG^Uj2XTucwC|?azm}Qv={n*rt-){m+6R_U#89}lx(D4 zjl!uLK!1`Ksf|y4FzMnvwTmR#PQ)is#Tlvq+eeka`*Idw`>3jgK2!m=kE*KaLlt2A zsH(M$O9lIp^4Z3`kH-sP?qNxfB)k2;_0P!{DReI7-mzvu?}D0L!-q5zVwNcRQXl?N z9cQMsk@m8{2N9@CTXm?)m#y?RhLsI=`iEWTG<%kr=x3U_`GTF{FrmN3?^W=RP}}kW zE+dY&;0Vq%J}QM`E@vkBn8oT{@JVpgM+FNA8rYGtnzyias zB~yahl*x4ZyQ%K6dR;%<``37KmG;y6vZsG3Xbo0pAyyizAf)-}3&C;ma-Qfornxmf zF0rjaY%xAYX8=PwwQc-%-|ni+x2ym?vrzkiI#(ugpn3|rk4RLJ5 z>Mr+)pQR+R@_O4>OjeSrBN6BB@TX(M$Yq9l-9rq1QVdd%nfO31^D1RW*RVajV~us_ zA(G1`zpES*k0mXJpp=T=8 zR_Jnto~zIm3SFmAqR{gc+N4lJp(_=dS19G8wsK04uGpP%&Q&}I@!pirb>wJeZYri* z87j*V=@i$U0Y;9EHKd(aE;^f0gjVkn#9%`Ze5D)B(xt1&u}hM)k5O7lX2)svUzp}# zrI8GGoMv`m8eYr`=OyhOr#W_EnmMI;_M@hG!ooD{9uMbLmpjhqi3`)LQySI!j?-MU zFwL<_BmLNMn#RI3$19CAX~$_=3)4JaX{2*IPP3?fPF5Oe=Z@1XlJ%)dBRy6cuZ#j}rdh8vYEQI}L5(r&FIaX1>dkRA)|arCK$}U6 zywcKEtJ~6g0oP#ihTRM&{so3mr;Yql_tpy)7cYY@Ji5}UIpvY>AKxq{3GR2okQ z;?GOO{B{>!du{tY5W~YoCPLBNw(j9^A!Q!q2Oakwez;$bR^S@^>Q{5&h1t%jf~}X3 z#-CBMPBBe;zK5 z*M7bP*$!XJJ;j5JqMg9Fl3>u-xJWK5Jf^yvtX}*if8IvCeeV40NxJ?JUlEe>x*Apc6tm}C>9k72>qC4+<) z*Twf4Y@KQeFNi+_`PM540(Kt(Jq3lXkpbPSU@;qXK`9EFLi0NuH-W@XvelZz_^fB} znm{{Zqt+`$wy{pZn=OYceV%!}oNIgwt1HJmj%;XaO4c7oeQDl}IHgNI5Aoy+T&_Qm zWxFnFr+zW0_{W>cxErZ6G`G-x&Lb|DO7>FMo2gBTr+f=G8OMs?(#ImZv4KMCH9*G( zs;yhN^ZJku^gRnQ{y^WcfmKaK)Ye;k`zFHW9pia1m@%*rc9@CqGZg=uGx81 zjcX)AaJ~#qEukSs9(@q>`fs_64fMx;1(epS#6>4&(x+2QR z>ARFc*-BL@UoVMS2I=R!8JD_XdpBXi=bh(PO1?&B%-S#k$y<9m*?7ygzyBR&)S8Op zEumFEcY9t5)I66@=i3i3((9N(v1?_n8 z+30oh>!aD@51;TTaVPi3osl2Y-@jmOQIxt&OMX{C_k3%6ZwI|~D+m~x+jX-8+0l=i zh)CY0%d@#;7I4fZ-;mD9>}WCFB-na`(($00Yu(1h*`d1{d0SKlq%g|+;{V&c3t6r< zdzCTv&+t@eTp{+p2}3((Wi|4PcT~vqRz%v%BOJdT{*j+Qt81flrEHi(*BYf3&PtYkZsMVXbt2hd_K71J{wl zSYg{zwUMzx(0HEAih8NBLi#guD%;|Gwk_bhq-nfZ7>s?3LyebHj`8BwaFH<_6c?7dVdc?V=y&Fux%>GTnmHojQ`Lp3_x zr=N0EU%5G-)B-*4SJXCxrj#a^ayRa27AN)Ujq~+ndLFBl#6_AzJf^-*Ix~#z0O3pE7Uv^g&G~U1y zc25Tn=kj%AYxDj-7}YN)uJJw9vdv+~canK>7Z=`E-HSr8fc44_Kk?3j*sBcYR*nWk z@q5JD`?zp==51guSh{a1$2>FglEsnk!M@rgx@TF^zp4pj@8Y#HGmck{($$exUlC7zyH6 zlVlbz2(c%4H|!hcGE#~M;iBvtz3;)22S`%LknSWFUGWvtB&~g|p%jO}J-8>)U^df? zqSLJ75;%iB(av7*r!rqf&ZrL_Xir5)q)FH9oew@QAv8Lf31yJMZgI=JgA>24S)T3Oj3{BK(%oZoFqkx6tU~(&W>syMB0%d!-ZTHFCD9;7$eDVmKbSUY3!c(Agnc7ABjmm_BVDPaY zR3Quyj0MS7p6txFpm94)j{1n9dQvBt% z{u$&IH1F&yP#&kU22IJa!=m*Aff4X z;Jixe=@qmNY=1$u#TbTR*R#NFy+y(H+qqi(yBd{hk5|E&JLy~dK8i7C!URbe z%!``&LUI)7pXe9mO05fd4C)A|XZvtRZkQkBrebzjU_YfF-qPJFqT`=lVYrgRc5xNa z!DS{Kx)R8CaTU?QrG0=aIc*nL5vv(n#~Nk_O=aVYtom9KY}VZOV&7l(t4q$xtF|LO zNq?rPc{c(F>k#c`O*U1Uv_ntm}<(mlNb;!>p_;S5t5uPBuc)kwaxd=}X;XNHi z{3pVJoiEaQmxAW_6ZsGmP5RtI{1pi&o!zGsd`~y{y>4*V)fob5rE7;le?Q8jgB4^* zgQm!*SAv!udZU%2psD=V{g{0#9-)xnYedtUSM+;Fju4F?y*ei!tg7K)R7HO+Se*Eh3@%0Nd&`W88eKJPQ_{sRB%Iq4jRbtl0Wz zZmZp`AS;y7-{6I7pr9$tM8aI{Hs|RZzvQ{~9?@tF$i%6=nYKk_qW z8&(JLcSsS$KUBIukuLrdHjlUZ;s-_U7YJmyeh8_s>A&QmlhLP$wv7kA+cYx0OxX7c zNc0ei=01rgbar{eQ?|=HuvGbu48MPKl{;yZTOzilE9<#mB|hU{LC3#0l{_py8o%Zm z#=qf;bGmZp7$#@ZU1yjJ;aG#;0v-#tRnMZj{pkSo;!(Og(KZ2+AM_%fK7~Bg_SoSd z>3OE?$bWMfW~UTyQ3mXdzX)fbd$f{un!WYr_luHqrSUr`YoG2Xs05aCKdD=x^?BX& zv7j#y$Oj$r+dnYq91CacZ~L+(O#a0C|swTeYWto6=+*bw8t1+Vs_{nK{e{=OU*sgh=~dqOE(}N|ufP;4&|e!5c#~ z9j&}arS|)CydMeg5n%HI89XMxnRr%t3{{5OAIMREEYuT(Dv-hLkmm8IGE|BDyZ3XQ zq{FTvqekPEFg*yQN+pR9WOg%iX>|wMe<;7NcJdqBR>dr5`T3KvceXt~m7V>Z zL6}|)!SwD<*5lX~)5YL zSYBDqX$>~!`?&b7n)Z7CdN6DJuPG#4gYKOu$D9pXLBl_L9Rgdb3 zUb3;O`95>7-fAxEts05hTHOtu_@%wAF8gB8xUakMyzXdty=t=unzRv+Z^*v7_wY&f z$dlaMpM*{)tL{~{;dN}4ukO9v*k1AHCH?8jw0AG=p`G+Jmc5W$nEo^5z_fl!CaN-R z&8MrA4vJPXol)jXzN)Wec^i%E>r@l5Z=-v=%H9d1g0OZZX47r$=2qF;av=IbF{H-Y zn_KLg+`XOL;@&2g$#G9Fls&yrGT=@gxKk!6>te?D!4jc5`_RcAeZ+tZc-V#CtNGzS z_)d+x;P|FCU-aMHt+UJE`w@90;b(B~h401llYr|p5j%0$A3=8`9oKs94{`6s|2B~a zLOU$>!`}|P1$=q|oUaMGHvrf9SH1L~%<~xZFJAzE9nY5l*8*&BzLPwk1Ne#s@EgI$ zyt(HA@1Cia-HF2?f3x@GO{1e6aB1{NT9YZJ`v4wX4qph^Y(M04M00y3%u0+ zNS^)|iU^dcKn9Q3Dbu5MIflzfx!32IpnT7!d_jCHakWN)q`BuHKT$G5ER~&{HLN_! z#wC(Bbwb)<40|Wa;*@TgPxnPw>O|%=$yYSh1pmP}e?HZ7NT=8Ao`Bkoxt#`#Li{<% z*pnK6Hu4Pe$R7ZUzrbbT{0Pm%_0tP7NX%dGo`;al3vtP)vD|+^lK`6u29BVNXNVFLL3UohK`Cn<&;xDO)IgLXz8u71< zgw@F;d|WFYjScHBudie6b8b}*;q3M(IQhD>zE^}R=vr20d5zi+p*zzq$DuK{BO>9h zU;R!{gT`OrrS(NguIaCzAl&*A7n)ZW-V`L8-fM)Cwnqt?@>V_Ow(#E})+iAhKNihR z%EG&k_?3T)IIqoKI6RH4sT5cL4HtGlC^{Ju;-?5@d0K8kQ;;MgZW=^Av_8uvXnu~X z?YmIfYQtN<4=K?y{QKa+^J7%3MSD&@4YoL$+;H3g2@tchbGk^WD9^=b2m#QoKetJf zB)MIt%zO$;8O`b7Ry*#bv}WKzAK~A%_Bb&(50cmPkE z8ItJ=xZc2B{lg0G`V;(>{3d|Cxd)!>zuI)rl-P2O>W(LO-AG&Is+7}vi<6`dmYDT)w_ERROhy}#$^W*$>Q$YUg2qPe*NiaH+Z~#8kKUcafe>u z!`uH(z@Mr2-ZBC%GK@y{ zo)?Gx8Ib~iSyIX-Q}TBETuY}IbHlHvv)O*zZte)DXzvxyL#I)aNoQpEFObtwWxAUa z$+lk(m-mCDI3%?C(7*`Vj$GL<=HUuO8#Tp)iqCC^#<&MjzU!c`g#nR_kE8KM{&;2& z$xdfI9(ZWoQ9c~ihI|YQ^CHET{BLFwzQV1$M+}ujZi4mK%_{PIp2{?0WeQqf1BJ2g zH+0jW_nQPdx%BR15A0iDUO$B-8>f5sedbf3U6-T5A5B@5&Be1kvS)dObJF1YzFn-= z*Fg=M_j5J#BC^?=%5ulEjQYNLLE$N%()E_l&)NC*)gPxlOroFB+QA;CaS28CNnMTg zR~QBNeC2hmm|C!%DU)GS!t;V$eV&V#pp)rmajX5_ri7jOk>E?Iuk_Cg;A;1Db?yb^ z;o3iiP!lyT&W(wQbQ{=l6{grSOq@Q6-o=UcCc^J>mq6pkp(Xi3&x|CU*8?lXj|X9PcY>@z?a!dUld}!U@;omWF5d|~>M4f#!yRC{l7FvG^!$5u>Ba-x zrlI5@K8M;R*!M2ox2ag~TBv-k)D?TSzhy6X;5jO=;|#8X`yQlUC>aIqpCKfhpV)(h zjh&J1yg&wzPo!Klp%Uo0ICpbPp9w45E1wH&%hDC#WZxifJ`x~$)6O%1mhD;Fl_n1# zqzu?lnAH$OWf)d(c$>~qF7ef*Wr@NWwB?zE%#Hp(XViY)>8$P4!&qa;81$JAju*|ms*haQbUcOqi z6_<)HosBDJz87#@kw+=RjoJMY?)8^)@fm{WzgjYsz(q8-2Qe-^>0l|o0DeytHRR>T zYJ**fncI(Ggy!pb=fVyKddlt;l+Fa z!rG62H}}QTt;V&q8rDjoGNVsj{)L%k+Y@GIjR5F;1IkWtB%^vy#6S`Ob_ruinG@3Dcdy=NhV3kZpbN!Gj+R+Cq9!*q*{_fvMnwS=}aQ%AzN3zv+p{k1A*UT7|p!5oNo3y+g(ObDH)ueNmS2(@5WGC@Y9p4@Z+`E#q88v2p4_@O&R|7I6&f zoAfu1I&hFeym%U7<-JXxnWjg5| zd#)>EmRE2b2aEHg+Tb_#|u66Y+^O zX`5=zQ694ZC12cu7xk^DbAP$$ADGd9*yumt=^v!TD@Fh0Mf5Y2gBPIm(I0ewgZ}ka z2S0~!V4HxW(C_J$Ax=L>C3|NnedsXucubMo=Fs;4ro3UlDcK!Bf-}o2{_!-K=^MLN zN>zV42}<_858TsE%IEc^9Gw_1W+Y$NiTD!ev!_CXHv475X*Wu_)o#FN}Dakmu4O`Wm1+U`;b$fySEL?$;;!te}{P6r~7@wmnnI4 zxZb z&dDcU?#Lm--QRGnu1BcrKAJ`Q4#UmJmMtHTKrS1p>!oBq2E2yrFi!NgrRUS~$AZxO zjF$Qs*2t^3w!ZH}ncwvYuMV|-V4&r#2khSd1Gi*f=(K)lfLcp^R=M>@u4?nr5zUQVG_}B;7*-=5CU^#6y_wpGTO@ z9p-b>cmUZ4i0owZ=?NWpeUvg{m^=>&|8Xd9q)Rounj86ut-FI`R(NFPvR*T6Ct~lm z_M@2LGVcO;fBXcu>T)+OyL$>2A77qhYL1eO*HSdw^R*}B28{ovs`7d%NPMJFYD+0Z zd<2LYy6qQX!dL59mB#5r$Tt5Esa%6EmQy+}3f@4QCOh_*iOTE0s@nrw|;;UaM*WX`Bf_9*8C@TKH6QGX}SXXQ|?> zA3G6>^7vYXX`Iff223~PuQ8gMbxk_oW^$0F_rQ{P5b0jfyIuzco8ke_KF|7G6qjDIZEi(&C zGs&s2LH*&qsRc|fbK_JL_4hS*z&5u;P}!^BamPMY8fSyf>loHqwzg5a^clk%LOu~% zsPZ|I$Wdf23oxT^w#;lkj`@5Th>mT3NvkMze}pHDK3-8Dl)g{IF|0U5TQ*mO_WWc9u6=*4m8H|tOA6=wXz#w zay+0G8d>y!N$VfH4GrRBK=fY>7wu1=dVdDfk9c+k;?q=p8f&XIg7nE(-yTT7gByR`@+<$?>%9#_5pNro1z_+twAr zXA-u#o29u+dqHmWLd_KR>l8NB0G&PLa8b;0&3dfxHe-hp0NqYzd@p|HUe}mzP zXcsT{r8M7sEM>S29I9SMyJvH_2dvsRoHkF`tKfod;6YQ}OwEkB@7n^@evdU=_{;N= zth&CHraJ;}hivAf-)ZWmDe4?pcRRc_o=D}YPh-kaoANLVc;mVTO|^KM`Fd4<$AND= zfyZ33JK_Tg^0tkrBqzuQpQU=Li*L=F<$Op+Zw7XUWF({AZSyCRDmj}}!}UXnDkbNL zLWUAQ78X3VwQ(=LpefVhoAeXGo+cGql2$U|jd1kph4)$1=>K9h!>0;T2C`#c(|^fpC1f(MleCv8?FFPA<>692$OC1fW?Oifo}Q+s zL7v!p6*ex^Q&<>EE+W7bOY-#WezDyLlS}L#CYS2I^7P~~?tB+8b6jPgruj&BX)6}i z&-c+aBPHjiFqV9H%{tEb8KfGI#-jL{1neWB<3nLn#pO+?_;P^W!*XReivbr!h8N01I0lKl8^b$p~UJT{Vh z#o{UViWPQSF|2HWT~n$I=Wemj9`Ad+WQML%T7C3|qUqds_(=(V&QHQo8{=p1Dl>!a zUc^r-r$52p%<~@HzrbA?=}&O=iP%KdHE2NXcawsrE=o)?38hK zy~0GO(&MK9;Y+=10F_O3=627bWeq3SN$eT!=vJ)@I$Q5?<$VXOXD%mKAT4rocEVXs z_B_b;w!oK2VC6XtKzLo!AGI=jfpYQ#{ST`KG|&%hQ?y^_*hnHqwSf&7X=P|jSZxoY zU*@!3L>~U5S^^n7d5fK&>GZ(3)0aL3cWIs;sj-JfN5ym22xh-`K^=LQRs`HuIUoya-91Q)Ii5_7 z=lEJebJzWiFF5<$o&XKc{FrR5Q5#x)^vNRR938Q3z@o7^RTrwI+H!y9`ULJr0}xwO zjM;*vgmFUMh5U>co;TazWluuD?XA?4KzBfp`@pZmyb7Dit7I3n9zNcpUVk;_gXaxE7kpS>{hm5Tg=k9^L; z$nnP$xi1$|ZeAGqhYFE@<3eO}K_pH)vx2Wdlr0u|={omCBSu_$wBAKkX!WJb3*s|g(J77Zmz?tq*hTX*Mz-a9by`GI}ELQ~s=JxCEryzbe|WPB*b zSI>&mLb4ARTG|ApFfV=8T3YSp!NOVyCd{5zBhb=Tj^1YmM19XR^uA}dL+IIPjrW8n zd|2bjr9S9!R7UX8`Ni*NUWiz_!zUX%tK-6yRMKZYO5CRYIK7`ag~Z9mr9t{mVzYM$ zC*ltQXOmm}kt|-euAcnI9GXf zMg?;y{#?)k@3TJ_;}jKE?#F4L$volVaOvSP)O?)Xm+oNEu+jyEYG|KjZ|w=S_7s=E zPQXa6BjKz}cbl%i4`>5gLrTx-Aw+Jaa6@f_C%2c#?QSVwMrn;)_9+@Yr!VSBS+b8q zw^k|1ZkFWbpx9?ovLt#=xAY`w?ExNz?~`j&z<#;PH}&oTU!=yv46n1lApIg`@rQlA7#cV{Vw48eBhk*-mAT9%c!8W%Q8YhUL?&-w5XQ1{ zdgdwqe1@m!J}>E+!p^JG(u)9kT~WoRcXu9DF{~F1I(gCf^z0w)EL87*`?BPD(xC9h zOD7Na3iBzY^a>MJZ|xpi6NI%}yGPVmeH8rO1Zx9(lZ~C*v2y?GQKf;P84JQ2iD7&Z zD%_P_yE}Ka4=6!X*W^ASzJZIaZKyBTSfD2|3w{<9e-h&lV6?9Bft?PKY{aZ~GSS|W z(=!^{QX3Qp<6B9&6Yn-Mp7yIVHfBiw2ATNjB(`b#bf;4}POh-vJe-O677}-;OBYKv z_aq*3`mbL|KO==x)s^@{fUFa^&7zo z2K~y+C2-8Eo3Df3hz%<6!5g>pL}5*$ywc3ml45yD81rgSI5e0Kh}J>IcC#%RO#C4$ zxa}_>w*q&0isRu}7{8D}gE3vydL2BJlNS>lswS@>-)Z+C+(5iIf23P;sT;is z26gJt>@~Js89DiLB5iD?Gwvj$tcXScE3Wh8HbIL~f#$1UWf-rwY-Eh|oIZwHDa0>< zh3=r^bXPphAD>dw`3}tOtbxkajGPCCOZ$e^x;mFq@-m{PPIIOCZ3EjX)7jDsuT^N~ z+}hm$Ut(Cg(Up$@UG3xr+Cov-){CAz)eyn6w&2&^tu18YGmW)Z!@CM8Ie(B8Z#5Za$G{+THW(tg ziH7>cC`_Z%Sc6sHi1Xt=|6@1@1McA5+r{wXZ`AxEE zlk2(6&!CJhzJZ`01AP#h{_L0b8lr5>`3XwcxKY>w89aUkkE=U#wwwpR$uv6^d#u3{ z9(&rTnv8fFbhp!~ybZZF?lvJV8EowjRVJC4Uo3`8!q#KByTP8bkQhn1^!PK}CckSo zJMSp;D130nX0>jDq1JvR9SobgCBKFIaM%>pQhXn!W){X9f!hFONUtPS`f5nWw==S} zF4HGTrdcbQT+0L|(?7X=krds%d+RX$#nZ~OGWlsQPbxmF^vhRXy`Y|p#qYlh& z%x3|%C3#P}Nt-Gfi{29JG>UqSoHN_si={fY0vpl6ez;hRX?xCK~zCn3xbcBJS&NnO3&+CU+BEs-YFs4yHPzZ5=} zEE;Jb4JHj)#f!H9Ofa#0Q=-;*19$daCP+J~n&1Yf*EY*&LVsRKXnWG6P)P|M?dSR-99)Tm!pc^dwSrq1;+xv z$Mnn0m`&01vc-OYgGHJ=%>Epm#}k!m{@%EUhmO&fk9Q&o-(mE8bCT;0J++UZ)_4c# z!=;r+){=J;VilUN6A_5-qGmYlYbbsSi++`2<6XUEJ2p=H2cHZ7?}UEi%_PzK*uiSV ze5_KpVvFf>hM?QRw-DQSH&nu=K=FCdWw*CIB*=g*tMBE?H-BaNM(ylF&H0(3sb1E2 zACWEETXD*Y0r?1;$gR4Cuhnf8E6e9=rTF7Std`9jbl5xhE@<$rMlkfAmhRm*QSpr(5V!RjE_zc- zw42f(zHF(WEOIRaOMP?}M3mg8tmlMvt*-H>c(!i=Gee;a0%OQW2JuFi+R97<^ga4# zl>89kHFZrstK=JCAjJWpvMguyn_2wlh&MBoJ%65OI|JHRCR1&%wsc0UgRCtd-UTUb z_9eL18o(DwO-T*;i-eOe>GEYRt;3CXUE_b@*%xWDuSkXxKUGCKMk2e`u)hNKh|SY( zmDe?z3EInHDE=zZw!NnhUXH&8eD%>XRQxUB_f({m@Dq_?TH2wWLLvUTFg4c`-%lvM zheoXdn)Kva@ZYUE_OAgJ(sv;Ybm0Pcv{{aTbH?x-T1Qf@Li#nu4)|D`0x0>|qlm3* zuDX!^RwzLafpQn6U|*1DbYkQW0N-)^rO`h^(u>~-YnhX(?kfo5cL1@>UHw}|U!R+2 zLzhwblu_X2oE{QNkcMYxdkWS6X5WBUW5;*w$)YSkWzfh6@jrF*mY+sMTFuF{R6tih zZ4rs8Fg=&)UL9-+tB+tW+QA((BijAmhxzhN38K>#P)EJzhl%cv;zX=Bu3+aj|1))q zOPhRyinp)0!&o8tCQom^j8=Y~E-X-qKNj4#E!A_$pxqaN=Dcz+$F-I`yzh(I(z*PV z#;bR;0mLyBDu~~Q2;1vGGH?4{p6n}}^8y)M4&O}U54+-By_bZ3Xq}H3RaVV{(swi8 ze>YkezZVjnLTN1!{@nXiCTj8?W$kR?o;NBQ9{_iAn2M9+Ekuo!=V%2kJq1AHgNiJ- zkIs2}zj)h^Ha;(q!S$ZXj2*GqcsH^6i4HU*b^3T6OLpSZD|Bvooh%ifP06IgVyC`n zR+NE3UAJ4eIF--p+2U-Xp_6znNNAhQ82b+6+ekfo1`m2Nf5|5Qs_}P0 zkH4oh>~E`H#tA>dDV8mTug$-bMPmx7Y%USeO>8Iqh#)!FucN#7JAm0yn4WVE>t?0K z_o2JF@mq9H9e61@1|6vkjh9V@$A>G!raE}Y(#*>6c$6LKT#2l%lDjC-wB+jbVcNau zoo;8@S?VU6U{>2;;gpJbKdiVxa|3B!lR&(n25aZr@U)b^39gLk!O0x-`y52K_5--J z_ex(#j%?L@#XaP7r7m_H*aJlSy>|54+P5Kqrf0TQ-vN$s%(1z4_M7$;o`b|@XF$cO z9rHx9&_5)_GXG}E{R}$TBMTte%EeAm8y_q&I$=XY|Jm_ZBHG|;x{LwaMiN}5VDckU z?aZ9YkGb2Y%F`3bL~nMvG$mAue?rW7DSb8%0ed^~-J{0G)hIQuH|V|r<_F*|X#5CZ z6i)4o|CKyMIBcB^bJ_O}o}gg0b*e#r0FBmZ3f5Yu8^otgzfUH~!F9MH zct$^^gU@i1pAlP1br5(S`J#o9IsrV7d~iWz>n!Dwy+$82#bWYvNVZNP`G2$ElZPgsKt^&;t40slSyeIIsixp4z zad2^AMNFs3{}OsOM&KmBPeUR8HJ4%A(~z#)AlpgT9cA+>nuAoIaTRnv;pwPy{0As> z;{Mg@VjdEUEaDa8uR+TXOc(6nIurs|ABLW5tSiGd$PA31Gn4_nn)vNR5rc~!V{kd` zW2e=A7^$xg9B`T|A4#NzpW({5nr1gBko%C`i8D;x(aammZ1PRL4sD?{^m5RQU zUYng9N>NO2qx{*M7QdoQ^$*ZeOWXhW#TynzeFdqFc;uchUW}G!i&(C5`dvu-Wp|C8 z%jqMX=fs|;pOnYn!gKxWT!zv)0cGl~*BMIJ<MRClbiu zB-+}aC`|k)qKN^qy+@Qsko5D=N;U#5RO7D#@LHZ7?~c2PDO2%1cHB+w!HbgnHIOHh z?o(#JybJUTGHIZi?Cu#1lHVZ}ykJ~S27Lvrf$FD_{vM>FpSSa$JW6B~sv|a4u>=l& z&tt9ghOPH$IPYtBw-3EG?{p5@TIHveZ$W2kvKAQM$Ia#y`C=LiXG{R-Bel8J);#?Y zWUhXQRm?R{&WwVcqQP)t58{Hf-Ur4xGAH2}pni{$U+0tUM}0)cjx;u#ph>VGs!!>* zaxVD;C0M%7l3&wFPCU^z@hjV}5!;!fqxNs^#h-^?%Z5@TPKs!YX6SVfZJnFS6*YR5}wK5yC%#YKYV41K=^Q1#veqcfxc_L!*U%+ zT#!B>`Iy;UVb8zmJX=Zsr^7_2r0Q2sdK9`UA_v=|j?=-){Zk`&7By-60x|(!ac(aE z4q4i8pl>f6>R?7{HM%w4QyQ{|Cp{lBtJn6?ArV(w@!o}OnyZCyf;D*i3CT4mQAW_ zrIJ2uYXAiUd$&EXb*~Q5Un#Bm04rQYxf;+z?C*@{@OW3_s1%K9?Wf zvik!+c@pRItD{D45G&l~$@g&IqWr#x6UgB7JHHdudbo?t6=7)a>PPA#*T^Vr%qevH zNP*hAK;icbD9HL)I%W$O_N@Z7bs^m!7Nq+k>|44E7N--atqbWMS&;6gJl)gsbl(=n zpQxL8f!ex|?%xDGky?!}v68OO(_NUS`>rs|2N0;O3+ev2AipWnEs;}ioRFGOdoK?WWa1tQOJN9%Hqeyq(GY7M-Agj}u$_h%@tJ zwy8IqnH_^`bSoONUuqc&cjxen?yV60oai>y7Bv5^dw86BE@{~z{9eG1@tk{@pY-CH z{OVV5!4#_%1Wh%lSPQB;Dl%$aEU`5&;c7>u{U6TW1kA3Y=>I=Ccbz*6xtYnG$;N~w z;gCQOWSN;j5_V*hAS$2;;!02so(l-Mxx=6!0s%x8CCXv|Q510n6;K3O1X0{jk@$j$ zySV(^_09YLe5=oPX9m>&JkQ*7PIq;6b#-<1R$VQOBddUq0aeoYRpmELKf0@-Q-jGt zO@nU82pstX;3FsS0}X0fFPvzOOT?rQa5cVM_S57s*MVQ`(5r#Q@TQRP?ZiHrbvLgvDk!g_5b4WFE@FO+!II)!0G~n|cxLSK$DIGrL9DeoIsM;2ucJ+<3XUb?imXMsSXe zrvvJ@K;@)Q`Hh?oEv*xErTpxwduxe1Z~q)H*ua2Syv>m*VUF_8w-L8Q%NLr~P(=o_PNo}*98 zB_ltv+}9~8_?Lh}-o*BGdI|oQpj<7T+KHhl44PfT5JkBXzD*eXb$YlGYB23b2U#r{ z*3Dpz0j$CX;A$?xG!-^4;f1ne`Tmsu3;9>qp?Qb?6#fyuPv+UrM?M^LMfoD|hG}~F z@Pi1ilI94)MS}i>XM*ozc>XXKo{XWLzLbdOb(>pDbox?po%&L?wBG<9la5q>4Ys9N z;^H|ab`>DWzq(B3a_OLKt|gpYe$U1u)bfxq1=-Ra(^_pj??2A1cq>pQ+? zeTV7&PXD^``m8B;w@91z9jdopN=`M`qZ4U;8CshcrE%|ifw;R~Aa3*Yajzr4@v}O_ z#QO;|Tj*FC>5eBiT9MdwxErida<|HG)CtL)Q)4aJ!EAv%J`CRG9I=P_$2#zP&AEJW zXJ<=ahQFucE_7=XP-*G68a)6um*v)A8(&MHEmmdMxhcrPHCo5FoG<=M(k>O@EeBA9NQyM;Q%Y96U5+kQNtK=p)pH^*`(ix71$P4*b3(#0> zKG7^}dW=H6^Z6fn2S4Uka;;;R9c&5uDEp>siHZYtJ*LGtRu67)&!G)=YpdOrxe3kg zbvgJ(a~l%0$HlppeuG8&zFgm%%kz1+6U1>`H{Y9fCbdI~CHtN%BY9EzwTV^h+9YPq zN(pU}xx4k}BEW(kaP*fGu(>&~IU5|YUQ+KMMeU;vH(WYCr;h-hTB91X5Be$~|+li_9R!(B~(=c1S z?R1!FbG^8h?nkV_~DT zuPB+b5$dlx`@gPoa_wGqv&cjr!y)2r67_AVQCan@Pn)!a=kwb;UR3-aN7t!6j%*y_}?!vJ2Ft|PsYv@{QK z?ycgS;NWUQl4K2R5Mntw-{Y#`bwoRtXJ+aZ-PesePLAZ905Q5VsApr)WD9I@y=P7m z^~N}=>Ly8)Em}iR#agKY53f`jZ)Byiz*N^kR)Qie!`sBr)9dd=2uYRaR5g~sxsX}! zjSX$54d;fB=uq6P}%)Z)79?E z{wOJ1mC@FLM#Ljq@e}_?e8|;kGV;3bLK^2hG^r=Ji z;a0Sl>T*?RycM@^C&T#%%}($0jN zRK@*W#EuJbSNI+3)hw5C*f#;Abw0PR_39b(&z!MHeNS?Jj@m+QOL2cv%x;&C`;%gJ zOvm~Y*C!NM0S&I8Vrp!lby4aiY6oY~dcG-qrQj0cFdGV`K5VS?4uNNvH~Ppu(TcA;%G=oR~; z_cG24eumRW(<%n*Iy9I4D?rd?>>3EpkgkcwQ-T6I=328wsK%e1>{5#j$N8o^y9Kbg z7AGtuHj;{=&b6>c_%3_S4$k7~lv(seQX1;$SIXSo)#Y+Gi2jl*eOBhEdREK_SNiUH zsS?~p`OEA*&Ze0Cw2&H#0|AvKc z$@|SbACr8VW~h0L^blPZMRmtiZOi4m5FdXG_b%U-FHR872zrQIKbtmVW0sopy8|&b zZ{%RXBm}jhUV#8tz?X3PNQ=Pn<++FQb*D4luE1ODF7wnrJb2k~{f)y4M1oXOYo>RWdj6mEw!|SS;aWf|4}MiAVCz`al}q zM{E+lMecoO`W~G@cINw|f`2FGa<#?I%~LsKeuU$YQR(_<0;rsXRT*ezwxinP+5xDA zDhtX(3Zf`2BKhSoXLP$*Bk?uGn|dCTUb%yG-&VT#FkMiGG!E-YJvf8Dt$`@p@n83i z9C^_f!RSOPk=*Zqz9&J#mRYSATaND$XonuUr*?l9(&0cT+O?Gp&kE}!Bo6+=`yt&S zT6TPwzTkKVL@-rkjA3&5GH=!!l0NhRZ|AqWck!h@!}B1m-drGF#6u}s8MvJ~84S*W z$dTU=g1=5?lq^o$5g7I;I+pZJzZpQeC9qi2nuw{6JacHh5Ggx* zLTe--N%oQ^Kh?etClCGktqFi_LBqEhwcpaZge`mwZpeMaQ}SHM95=&tQxNNRa(T-3 z;$HAGMq~_A2v|R?g{!H}?)dcWp}b>JGQlGr==}mdnBa8`^hi69r0pGfIVihArN!H< z-%_=>*^4QC&3Flw1o-R3+v#f{IG^+^sS1Kisr3M!KE zHJ^3w+@UlZ5;3!HpQo&g?Q?ldwk1$lGOLwdc6J6|gg<^u$+EZ=i7{!TeSr{ZuVyK2 zRt(02Sf-fg*TnOf5>q?}NYg$HYp<@Tk5w!#gqTn4EW&BlW5_YmQ2V(2TT zN9U1^1+n?6wTJldr1RV3acjV=EoRJhV?VcUiRP=1zY820%c+lo^_hcV$eMn__ylJ*eC3bKKJW13oK!(v+Zm z5n#x(Wa?a?ejwWN5`<>=nmfTpWI)$?;OA0eW5yiKd3?7w@>y=_*LS_w(PU#+ct;md z70vkog$vS@4iv2khjRyWI~NvWKNodxP0Qof9yd;BJ5GM4Qu@S~=woD28#z*P?iT;9 zfDkj`@Af9mT5PKG84|_UGEF;UDY?S4_M&;qp4MfYMVhJ~Zb=!m>SBiOb>^%LqTHPw z=Ja<^rxxoN+}|TDZ*gi+gEkB2!Uj5Z{Q6aA;Xo`8qw!lKhN)C--oh|)zl98;Zsy=Y z$1G@H>bDYoO6_P^#B|N-l82jGaLI5C?hY^1>b2+&prWtvHYD;J zJ|``|U?Za7M#QEuJkwN4uW8Z_TWWWg1YNR^*RYibIQ=PE{38|mBg<2IW%T8IdX&_g zSg57JU~4GAuBUW1G;G5=+F#c!NCi}*{S~?`p-!u*3QhD`Dp7@WjAN#DFy%3p!4a(E zz|vd<7F%_Ht8i)WELOlT z4cgt9dwAPbsA5-V7+k4oEb&k?s~1>-KclR=WZ9{JklZ9G@C^A&c!%4 z;=+q0BOkr%^_TSMoBw7B_&QQ#ah z!4bbE->Ez&V;|Wvt_0>uV46FVRC_%)k(x8lH|SAp-^fE}o_8U(xg$j@w-gk-g+}6D z?Zk8DD?<8x5ja_Epbr-oza^BW8ymi*wj-}8H7rTU*NG7#|PwBWl1 z-~npQZ(`NZQI2Jhv}8OP0ATvW;s3Jk@~H*4Qsg#$f_PD|J(>RjrBRr4P-Ho0Rnx$8%Zor7C80-NE{=|E#awh(B)DZOU&S+7Y*lH^E zcC5#Jz^%PGd%$BK9+pbuo`Uy!LoOA>N(;U8_{T_S-ThvodS?PB6lCGSCq(~8^mz+E z<^Yi-A5W63NRueY!h_qC;fh{1RXx3IB&D~K3qeL{~?a<49(RjqxSvPj2wOoosRL1#jc zj2TQ`TS754?kP(rT=_WP&euFmT(BP``yo=DZk1S`YA8P;e*BXiNtp{wC?vOs>)YMp zqQM&|1aE`%#7>*4Wb}{)VWYhhK?S?ezz;S68hjxKPbUNXY477VcnM@B6sw$wvhJBt zAFgyE!;6$)wMl7kqoD&kJBcZj#>&2(XE!*1OhqgtC+imS;oD&m7lf^`;u-wpDRDS7 zwRAWNc7+Qg(u7pj@R~cr%l0n((Dd}Wt6oifk@cj`o}nxp|0XI;D*L^*LI5*b8*x6I zyeBl=ou7PGv?L#n?_nv_R+a<*Q^%tb0#kRC#qfH#<*>**{MiiKW?=;~3eYUC&>rJi z4woAqhm)H=KIE+X0aDIZf(wmIGls8j`M<{$XKNAYF z@Zc069Fs_RqyS#VPe8Y}G&q%?+}xvJ=LvqLe2)S~`M#Vd8`*kH zClqAit_t3iK)hKHmVtuC^)o4hT{uEa@7!ERYg|h{(gj=a+|uX`P9jB0O%nH8;&9il zrurYo`DVN${X{x7?SY(nO7ol!Z+?tJdgG(tQX?vaYxoUNy6I&WqC3`V(yLPJ;=A8c z11f|k^E-;BpdQqe3gKJ$HGe=sGmj;YL;A(&o?O2IH9P#HMJ%CBL~Ip-x_c?(W? zb8WRjDXWB83H}rPOq9VXewtR4j>^HDqVSNP$uQCtCjk2#`7}>e28{dO#uJf_c*y6$ z71FCS%IoxPIkcM=6NjiA#uA$2X}mX2=f@fJwAuQpRg#74gq}p_iYLCq>Ug1iTW{y5 z5T41eu_Y-mG>RwN^3>kc_xXhI=LcF~~PV)X}X^X*Gq?@Vn^qHhI3JSH6uLIy`c)KeFj%b_>uF->p z1z!RNty#DS_%%Fm3oBH9)gGPkZQ`RvFtkwR?oJdybD^|ArBDnfKx!F94-?;;3>ym@ z`-{nYabtf8`dVOT3)M!C{gq@C89hm|jr~|+~M4@L5Gj{4Z_rfYyi9jYyp zC8L@0_=CuhsrhrjBfF>Cgn}$QI1Pm}2~BXilo0L~-l-Z@C6)^=tQ?%7sPgzj3Cec} z<+(zsAPW!P4oo6WHpUr*segWfvPl}i%GE??@nV+@xvPb~mSi)bYz}6?I-#I({TPI$ z>~5Y10X+k~$Zz;AUfCWIJ7<-G^Yx_*qI$W4LSAH@N0#sc-V}c!&oR5rx6cx6ZXm0P zEwQ_Jy3D2PRHNI-WfAGC5>3%cFO{Q}fR+L-0%JfYwv+(mdTDdL0 z6-?-@YNA)KCVMz*yxp(&L;2R(_|r0l}88>kT$DfnaWLs|GO<=|SP-%>Vq@v7PGv>)YDw&{aYY|~qc zGNYb0Imrq6>0Gm^K6*s9*J2Ef=c2+`+O zCfeT=;zs*19wT3K)LT$XAsgD?;#Vco)0HSL%LQ<={p~nbPggLkMXX>$QwydjSFrE$ z22MRX3pQlDrC_fTB`r%aUBMI)7tCPNf{AE0o%Han1b$1UVU=ZD`nsg<%r@WcIUVI4 zbE`A4_q`ow9P_Rj;$A9S8Y}oM@jey1G;YB(acXNcjo5D9$;)6{wH9aXghopMS~b$t zY-BHfVmogqLFw1oQ)4haq_(cUWfgS% zQ)OCb^4)2#9=9D6Y}bICFt}FaM8Y*C8}sZ7F8%q<%W0SGABX|*QdLVI&1c9yyn;C2 zeUDB0-aYx&8T}dF-r)Kdv`HwGUdDt>m`!!hkY8s8p0*B!)x`Vw8nX$ri{9MWm}+*4 zYI@B_-EO;!)48loyq_fPCq!iPYQ6p_rPp{f!|w9^U*$jkL!!pC1mQJrg~s5+`q8?d zJ9lmI8DF>d{0XH{zKOotY;vRAGPrTdrI13nf&88Sd;heXDQ`$@1?itQikQEG3}qp#ThAA6SCPw7b=sKCX>2F7w9RQ@|k zk8ukUp=JAZ_7B5^Mz_!<0_wsYOm5^>Z3$)BeuH<=WsMy`BBrzo4s=bfgRs}=>~|V2 z+eb0$nT6K_9NfvE1UJHEtX>##{8!c82$^T>_5qC7VV;8i_%$M35+X~8&9Z>`K_OTs}nA%D{(tnxJ>5R zE{*6Z1m{uCBxPs3$nK0!%tAR~Y{dscb&*plW3!wKAa~3lH7}-LlN4k)Ijf)>8pTTef9g~4r`#B64{bi`10}s0jzvH2^?cWiFyU-E> zM!H;P-vWm@af~*h4x$I%#m|%cm`-t8A+N_BZNiyloX{=W{FXB6jMKVSO!v3QJ&jbE z28na^A3R1}cn##_d8Bs1Sja1>&3#X)=^Y;7X-*Zp*{*n)k3x7N>Ds?1>k7^9ae`bK z$=bPJoVuRk){0`;Q%cJ_ArAW+ib`gM;0Ivi@dOX2qwa>DomCG7<`5b=ML&aK@n*ya z#9CTiJgFbx_=;}yeKlZQ;LGGAc15a@(8xagB)&H6%Voi_gaj z&jshIC%e{HF1QkOM%VXAFg;!QI(7B-hmLyF{)0jsoNxDTm8k;+>oy8^(;7`mIGBSZ z26U2<(Tdjm_m-l$u4KS^(c%6>n}BKvGY>+1^NA={lHkJDY(4GnV&TA0vGsGYd|t zoip>n@5q6AZ~sZfPh{K4y@FCuYuoCI7&kB%`vb|`+D8H**?k@H`tzF~C&%{RK;SoT z)$8B&8VeZ(`WeY{8?S#>EWytz7-6fq&B?z^3I2ox|E~l~Hk~a}72c2kgP?>E^8YY4 zZyK9I$ zgv4hwbX_O|S-PleRR?6s;N{&MGKqtoAk)Ry))GX6a9g$IINlniOLfomsmRDCOLiDu zji|%aPc&*yul=I&^Ap>Ug8Vm4qIo+dwV4{NKBks->_ul?KqGRdH~b{L?Xi6^4w!t354@uXVm_ar=5y>>Wo+Yo92(rJ zRuNAHts=wE0MlP|2#UdH`Qm7()igeiKi7!>b4Da6L9l6C$b<|@U%c}ziHlz)W%i1N zxbs1{y|?IaH=oc9aM7j7`#kU6H`ubXx6FinLegmC`IX>j4Gup1oGSOtn55SHCGX|n zSNvi@K0Gtn4Svk>E5UCFnT77X9iqcKR1llIVeunhVytg?HSu)(pP=_yHvT*y$+Gc} zRgwkC0jXbS$y?3))Utz_xQh{-G(R6QNzw=Q9%}NYbVyz)m$0N;TI@k zw)72uzevD@7-0O}9s+Ev5uHo^;Tj6y9P~!(lkX{ORmpfPd1^eR{zf{_$ty$q@Cvp5 zRHJ0DGiX^98d&ZU;LVNo88_YuVePy4aawK(dc|+u&3AAQ^=8w_=n9C61Fg?AJ)kx# z-FXyGR+!Z1d`W0pU*>mI)6nSri<%f7_evO~tVSdCH`Sp1u_nw3^RxJi!cM;+p<8iN7I3FcUIKRO& z&wsb#;z&`Y#N1WAyVr6{No=#PdqfrMN(NQmB)s_;Kf%S65|`MfiVB-&PoPP<%)L>y zCAMeXxwThTg}pwj&rA%ShYTs>!Hb0tTN_WOmq2GmjQUCO+}epDH~Wvc=2YpO`-)q7&BGC&waHlEx9ab$fSJH2?IC$~ z!m2{2!fN~r4Q~9~lDM+$$?tS~cqN77fjtDfyVCIM#Xh6i}bvLH=S_nqo|MV+;Q??I-ujQABr zN$BGWeH*W6W9yXd;P0Z^ImfHwurF~C-2nLE_W>SZ=;Re<&L~8;La$x+w5Oyz68X_* z^pi%cXU$?p!G7JC;RhgC%SK*BI1*CDQ}If5i{AJlF!|{OkvYpbN&Fl6bqp?Vw~%!Frl{S7hQiteeFS3XFmT$ye6+LayF zRiX@^?|M|yo+}&M>O9Ue6z42>>bJyjt+VTyUuV~f$V>SjDF8|%R7IHvwRI6p+D?{g zn?gU&7a0$r>E6v`>qx`Vyta=TffE(>9Z(4+p*Q)nW75I2YnypHzwrfNKFDN_P z;;&OkumweKcPp;Z?%^SvdipI3bX3&^)T>ZOrr**BC$_}QcAtUkH~0~R*f}-;9Y~VQ zQX4j_nC0qV{gx#X*InP$-a@Es?W{f1uqt3wQy$Tk#~A$?Au=Gvh<6FyE+>`2-7M+1 zgvwUU+I7MCEj>CpJ7m?vQvI1(R>qH*#(cqqnpJt@l4EGhtVtZDe2$Z%&Pu)V+RYe8 zZc;n3EsbCo3tg1S40HjI8k|aSNu2(>ner=|P>! z<6v7d6=&_%@#}!-zr??J3D_h7$04kURO@x)ZCjUDj5qyS{2ajZbQL_Ut@W!dtg|-I zxfUPmDXT)Ktej9gjkV-8j>GXjf~40*s!P`R<|Ds7Tct>*^z8;;OSs3tZz-I?&65bE z&Gj^&bGpN#!c9aZREl?s7w_Vv;g56ivO_a`AtO_IYuUEyTV65Mc}w@q?!;e^v&=LD z;&L=StyI&d`AKJ*gsx>dx>y!Y(JH={FDOY>W$$>?}4ro;EHCqMh+mS%~^a`JS&_TN!fZjQ-n zXBrp21ORi38trxo0KWqh7YJqX2N6HC>QHc!%t;(IzH&JMG1%TfgzNZ;_69@vdoaW? zdl6`3)ZBOTZ3M2h^1c`x(j!_3+m+Cc46whzF=CHp;{^W?AWpfFmdjADyCy^{)!JJNflF`Q%{?IDYNR7nm)j_g zjgZB9wv?4E#`-NqxMS2MNOxti(z&RytwB;6T%qAY^d%rljt+*6wGLoq9*w<+f$62p z2^uT+Rpu>)UUJf)`3R2@&do>IadnK=A#repR7jTUmbDM?Qxq^;ljUC*Qc?_J-H8fQ3kgNIP+%U;CHyC^k1@oZVTL!sQAjCU zKb&anCAu8`i|ED%n@5y;XO-M#Q*~X~!iL!eqtoQbRit6_?p z2qg_<<-yvF7^{M}fq~jxMufz2aIdAjyK8+$7xEfCOh&E&=Ne+BlU&r`3R_B#uLIgj z=u*c>FMqFF+&f0kws>kM`W@`xD#mN_ZlS)(X+G<*1{|QhS3-3m7Qp%0y;iAX8#199 z%=sSBn&T71%v1f$t`(U4joiq$=U0r0J=NjXa*1VixV>D3966Ss^6cfdWOW?Gxxtk(+n*i(;iAAZAy{J6aa$+6Q@!2ty37lI1>@NO#KdTZ4w)QY`1D1_|Y|r>R|?~B+OwA*})d& zvYH-Q)fCPqEur`=k>?P(T;=vHtZz+*n$g|r6jBDMZ&qIiOYvRwHR94J zc<1gmv~f})xCgFVHyaOumoW6Op)_VGtC>b?Dqk$bmrb1j0joLGNSJMapmUIHBab^K z;yV`^81F_I#KQypLdo69m<67qHThXu1rKLvPmPKiT2 zC3DeXg~Us)^2hfgOIsPg85)~aLMIet;X#Wq@$fmn*`>_(AjXfj2aDaCqH}?)o79NX z=ze#7adj<^X1BmccuU8#!|E5gESIp95eeOlzZEC=T%7O8P|nH}&r&|5oa0%_;m~Gt zjzXx{OHOL6P}RAw#)kOLm)n#Am5h}-<&cc4&Dh*-3Qo!(@2gmXOT#Ya_UlbNRbkHV zdzRO?(ChjhBpqNp?E{vR9PcD|a7#Y+2Yf3li`=C$Dx4{Fpsn*9bca<~3&ZUfJ58dx zvLVDtS8cKDgN%nNo&?8BM%BaY++-viXa$usmI4 zWkVsv!z9~22?_szKaPSV`O1f(z}uwqEQSN&zkuj9ndU0p|K$TWa4JRBkx$@e0>}P` zRBr2;!G_j}Y?YKDI}x3zv9wG-OzYY&G(Qfn zg7f%UoNh8IjTRa$4J^h7axIM{Tc z{PI1G)$?-y=TxGcDlLQyNS8@=qB9qZ$9{8+vZR^Hmr5OE+etRQs+dGW6s|}#rypKH zM0aI&xQgdskF9|B`fe!$KVvmp9ErcB4sE70&|fSxZzn;2sqEIw50=Q`#OCt~tc=`1 zF>v~OC~Ba;>{S+pD~0`N%Y^F&2g%>rJ7~`5aVuQJqiVh(HMPX8P4GTaEZ(G95jSD; zeHGu%x1#z1zm9R+)yfQqiDshQkYmjTykGdrEfI=GU{i7;aX)FQ z)zVa&qSPy95<)l%sP<&V)?3Zm+`U%9BSC`#<=%l>f8WSyO4AoE)K{-p?+uS3daSIx zHyy3G-tZ7YXma=Su!|xChFeSfx2SJ1rro;9ym9c24gE9yXaQWR&y11UKBg-&ZHhdN z@QIZ0K1X=p3liSdUpLKCud6>vbnq9pb3RRc?-esHe9FD6UwH#Cf#izLSlzfh6tPdQ zq?{ta{|Q}6SvOD}uR@myHf>+1hIbG!*tI*JR@hY*D1#?x3@M?Rpu-F2nWzF-OI=4;{Cfm~gRgAeNr zjzeFWhQfl{DD8vQjfZ)Sj_-`wg&6!bPDy5Y^d*^Oi7ed9?o;f4QB}6*TmVaX9Z#$! z+Yn-ds;4&cQ?l?2vu4clXBDvaQUfu!7O)NKJkFz<0ysmY@S)b{Ccq%h%OTch&zxJz7D;9 zfIyRN0>u?SJ;17yt9DiN#(?#nS~2)w4ph5|9raKD4?mV#{g0kXY|NJMrAoDoZ}#@I zy!O6gX)gu@6!4FgiLJ3CiVR>ti`sw_c_NIa{?X+8SlNd!zoV zWaG#koV*+b*x*X~R}8^zsUY5%A6~j#^*bqW$5m@YMzN8?YTa;Ax09d4iKEusV0u!@ zrM7%laGgp|sbEr7Dw|N1tZ_SeDVMB44>|*hoYGLgyBGDkqt&bJ;JcGAas4x1mxAxXwoP{YP<#4NCwvFGL#Mu?*X&hJSaxJc!!I*Zpyh_qQ9#NTW`VxIhE%*0K z;OaVS&DMo;@;%^qtMqC)Jyq94@Ho9c0~MPwv!!8!PV;A5;%4CB8tT`ayP;m_F6sSh z{nb*{@uSPQCFKM0w&Ym%6wYJD%Z9QZZs3M3(g zOWhWkHf4Id+@27JYQh7FH(L zsyYd+p3Y86hsQyhDLG9E_muaOduM1aZT8!5bjpSwxKqtC_59@0+g4;8qZM>=t z0=dh^Wb`c+aTUjuJ z!rBO{d01(xtu?oYs_xl3#`H%e^t)^qL0gQ&tz)d`GhIT|9{dwJw){$7MsDJ#tGY_H z>{W(aZXaNFkL{9jtu_4-@mNoeT*V9D2MCY=m#wq??$g*s=0;zgCKSa4v! z$oyB0$tI<**a);F2E?`YU2;Y%+&sVvscnTp$m492-_ zP;R>@h3CE3e0J94zAm+2lp8J>rv5nG)q&xA-Mn*k1WPtG%-Rh;Hor(gv{$(wX*<^D zI{c1lsV9|~WZzQb@yEe~(q!NAKoDr(QqS`KEJfL{_w_tSKE)55_gl)usLZ{FyFn_N z5GMz<_Pzl4E&bY9!Mt;l&H@glTx}2oZ~(uywWrKR&_%8dQ&xl2dQL8f+-s5w@4BtbJS0@ zrhCHd-L$l(8^^PqWMCtz)&z&@aey@1m-20~tJ7@saew?!P}m;N*U6+gO6my(S$O*p z-u&P}#XQ9!p5Rg5B0TG>OG&ghW5gc^ep!Md=*(vlO#^xbf?8afv;z!}xOc4$__M7l2b?Swhiy zFmd)*ir(^mhICqsbeol>=)xqR6kVUaelmG2oX$#$ZyTGX=o?9BTt6y5Q_FfG`spxe z8LDR#Cw;&{Mw6({)AW2iEr_4iH$($hr~bOk1T;%-d`jvh&)Y;Mlc#79jjkU;bGciS zQcOu5sV?&8!{*_)1Buiajyp_xlhgM%mTbNzBO?*lPWea8czu|p^t9>{N zEc3ZIcrh_{Uf9m}_SZ(X5>(Aj%l3Dbqo<&y-ZdCDsho_@0PF`EkWD++8&(gqu^SFH^tbwU$knM)n8H^XDeY`gUm2Z2BR44n>dKb58V}p6w&Sz(7x>^jrD}O5*>A z_-P--r$&!@+UQn}hw~2OZcui#DK(sa9D$CE<_yGLZE=#NAu&ij^WovsA3J~Ut=U@ zNM{t7^0RG7p>)pa6cO7n8H|Rovima5V)y0N#?JBXKVUkaY|1mMtEB&@BcUEU<75Ye z;KyTjSATJtsj+E%Jy}sUF_tEPcGJrSQ>%IzoQ}+7i?DZsj-A@2(^g8}#7Hrxl zTPO=7wf0-|I@o@z9?@wCRr?ed5*o|_f;mI4vUFg=m(;0io5vHA@lrln6r#FF;Anf) z{Rvax6q1MAQ~YnK>>0iUhs*24jyUC|kUS3dWWXV&O~tXo;>5+NaVsrOY@HhCaEi}U z<5pQZG5-1DR1?n^r>dD6x3}R`T}_QU(0HlJ%i_cbh2;6LkKs_wW^f5FC7*sv)t$u& zheGl=T)jyaI^h(OhjaKOES+!)nF@F66gY+C;at9Nn*yhhsc_L0IECcl_BCEKr@$#B z59i8p+7vj2BygIS?FYW`w|9V9d)EB-rSO*RsR4$-;UGT=N2Ftq;1*;2hOoXQ~4+T3p}3;t736@Q*CT!KA>5WG8ZN9-`DYlDgLq z{x<_TRKarqFdrcOXol8uKTm?SzpIOF;JOklFw1gmH7T`p5-vt6q0=vzdS`gotoLKd)EHSxiG_g>TSnKikd< zW2AeczL^`?yf>;`$HI;FV@5SVVCL??sxEfhmlMl2M=d^3z`EPyt~;Y9+<8OUsD`W*uFH-8MN^2!H*q4@CW(GIT&#DcmX^tw zK*G3c(Ytp+TNE)71-4;$uH zsOw@gP9t!y8bB=T0d5X~CX_DQl8A#u|E{8+Il(*0$tD9A@{&yk1iLe^Fb};q-X_vo z`ce_J3-vRhAPdhq5=w_=rdRJ275Z~+Egk}E)!4Nxx9GkAd1%HOOzJhBbV)cInDdhJ zR=}pwc~WTMvG7B8BrhFPT}NLAH0rt@LDI5Jf?LhfRxidD8frDq@Ks9rSyI}#IhsSF z1b#m7;#tu{;dw7{`v0#+;F-wK=z9r;!jypV@q|Y^q&!lPg_}dfT6vLqCR&_J6?~4& ztp%VtRQ%kXa2kllS1LG8IDhmC?(r+t=o>0x+E#+Uk=pi8lJNrl8v8eDqDgP&WOx;X zA53{N#Xb-W1LX&|L(KTuNjY{@IbJR4RFH)ScL0%KlZ@;Du0teGdnp_Gy!C)0Ru}70 zXkVd+rkYpsl1P{K1$QUip~lnJ=|qho0OF=~l^nt~J`Xg$xhSC|2bSX6<4tZ>z^37BQb{eF5mEiN#*q9vHvDfqk-m}A{Za(;0 zZ}|u9c(`{!BN$SZznq^5jguHWNtTr35#n>g489W?qf^5_;qMU1EV481FbPJg7?L;} zvxU!4@~Lsl4CfP*;xgM#Kj(i;obogOW2OLn*OmN?=3!^cCp#rmeJ>@Q(U2|#|4m-n z!gZ8nOa+d;u;pCAre&5)`C(_fO4c^ChLVgY@n>MYedl=c-^WYu8edx)G8Mu%N;3Xx z$^eCi>)3pFC+pL_AJHLAt1=cs@sfLn!Iq!QCNyh3=KBoZ-Fl4r0ju$=2639Q+)fJ;%1?DKgeK#xwchKya1b(ykvDQs+Vw;HC{=9XxLDqf;7 ztQ55N#LcfG}Bj;Ra4r2<=5ab>cX{2^`2^zdgjmbhG5hG z$W4Iy&HW*}eUpYr{(6i6yiEY0QJ#+FF$_ka(=B{t86r&O`sAk zgICWOz8M-EQHIKfDvq4@kmPyVtfCw#m+=NZJvy@-GIo;X8s*rs6w|d?MZ{udFxIw6 zV5PMLGddf&BH{!FlQc%FJ)OUe+u}khO>OZkp82*Y9WsZoTXNw^TeN<-CDuJ(TkMQe zTU-l1*A|@|4YtMfSe)Fs+#>-=+u>n+s2xf#Y!yf3+u*beiSN^xw(Mye+}kT1khH-a zyxmWHp*FbRlr{+4yd$j*8Yes3pc{YsEsZ$iL8ytd8;R!DdNaS^zR42{z6e;}kzdj; z$`0^VYNLjxuhhPgNX;=g@`IeK>5;wbsg}YEt3qV=(4?Hjah; z^i@hZwOzS5VVWA}`bJgq)Hs(;bv-o>Uo+$Q68!jXBYT#qg_!`@yYgu zTa2f~X@2wy#RXdX!d>U)#?Pr)TT9L6g{~~G1aAD64ixwzeii8^6uRU>Kf0BYwm-&) zAAOG3Xzh*sEWZh1KMpWv!3nLd4g{Ie`Z${=pH$ibXRhSiJj7;KX5dL1zE#o1_HBBU z+MnQo4(r4zkPK&MoDw`=oN(sj+@0F4j$Q-tesF^Q9?!29Fw*HZ`4??ieKh=`|M@tG z##X>r=FP7a@OoCY-2QYqyqkSkji;|t!Pf@+?&ssSXJFn01mB}Q%2W>=QS;F1DQgjhTHERl!HRr!q`UTsNt5t^TW$Q9a5B_(^<}7d9qu#f{NQ(xs;IpW}ng{n!{~qunl<*g~Xc`x;jx z#hSm=$3I7L7n!TD#my%5uxLUdDFasc!3`2G+Vky%n|-Zh+v#itrJyMvB|pxxA|F@u z-bMpGmOPv5RNt&@-9d7%G_ab3;H%3meT~13{n=Gpkbze+tEScXPhfAF6aN-{D$!M3k1W}YU)T=rMX-N5 zmG3b7mWg2=e*-LHt0QE=p&b3B4?+KsEct##p-rD=a*~Z3Gn-o0fK>UxTIfn3wf@BU zd+$}qlOO#_h~5gV?JokD4I@9VuVVWPJQyKmwsJEIowjo`>7i^-3p1o{@$X&A%9>!Y z9KHIZ2$9_DJG-S|Li`DAIJA{saf-mBd5U;-w^DzJpYglM)KvJDiadhI2?bfW?ZAas zsekFfbCp0t;rX)g+@qhb@Y7v!TbI-o^*Mfbg8F@ew@o?)S-5S|_2ek6T0X9SaAS`n z#Iu%olW;TZmtDIS!}4(@lbu(Sj)s*MJh&IqobUdnR?k=2`(lMTo_YP=SklU3AN^_ z)C2bc*+m%5xA9@?(vfP1VOOmZHhB$ChbVY;vFxz=v1UKI+LG)Ci{A|0O?-ZJX7$j zl@L6{LWIY;mFNmSbjxuq`UG!H_Wo+J|N49y{CFB1oKMNwT?<@*);;dckbeqUR%t`^>UXJeGGhPF?i;$!Fq;}`_ z%IvcyXy^LTwjF3Si%KHr`O&K9jhydC$L1mzdQ_VoXiHKr@S`(w0E6rAp(97wdot5UL!$857(iM6@sOx=&CF?dx!dMcj`H;8d*tzwD(V?H{= znndq&YsTj2R6ZO<7M-XO+fc+mM0r#LS8%>7pGZALj<`^O)?ef>#ql#C-t5J}@!1>> zT;HxIDl-iBO?}&Lp>47cg>=j@vy3$MoFx4*UMcwAu7I(?Qgenec=0dj;1)H^%4H)5 z3j0fq{<2-KEsrT1umP!XaI+9xKtfzH9Id0v^%DD5n^@qAn^Yp1)=piM`T;agX*;f7 zdQ`NFR3*_apGX;^&}bFkX8IbegJhhgvfA-adsORi8i3WiOs5kb5dI`*=)-p?nV7@Qztf*}oq=+DV2g@-omjMy z+q@U`djDk9a{_v*c@1>RLxZNQ%yHz6Nfk1EHS|=YBPde1k{n01&HlpBv2y8&8+tLg z5X`1BUJsU(%ae4&J92Rq*QO=gu1#lRym1k#;)7FRi^nCfpCmGAWwif$@~{-Oqn)Ax zzMYG&Ch2JXzsQBhQYWhx98tjO=&miP;y*C)Oj4i@s<-7zw~&t{4sEb3A9qkLPI}~f(DVyxhn!*_zduQ+~BlEDULa4vxp3bOFvel$YxfPQY_rypA=qfe#`*fs;3 zvkR-nkunH!ktH*~as+l^2UV|(eg#?e?<_0@Y(lDDFLP-5;(#+!vdK9k{d^5XrF9X(~~`MO%AhxcVeh1rxlnlZYy zQqA%s|C3oGiQ`-|ak-W;vNBcHaY*B0%imeI_YaKhCR_t%s*W)h@-sJwG+M@oY43Xf zWYtX~)23fewdsJHUr z=}F3Qs((%$6{}%oqN?k0@@&B7s0J*`-W3r1@Ip!dypauJ#Jun#ea(G-M$8RmwDIqGFuzV0(7}Vb;i06=Qw>B% z@#ltzOoGrk8Yj*3T)B=-%QerHE4f0j-qpWlqknkhU=?G_`tXMS1-NWm5Uqp1NxSS{ zSYOBnYmVd5=lRH!RIV?KGaRP*4%dh4The?#My>_yYD5Zi9>#ROcX#oSYRSe0+=5j) z`}*Ylq0-YI=HbPuFWMseMc&7l+w`YD9YN}K%n)tQOT8; zL+Xwf4Mz8YXJddCaXurv$+!}HU3nCXN61WbBSbdOq7(rGzoo&Wit<=*teVZ(8yt_` zL>6`#T)a=m!cv**$);~+xNJ=nOQxa9IR(_+k?Se-Jj$gUXE+Eoa~H|FGZT79O)l*KXMJ9S#TnxFQ! zzZG}Q@X9vL%hp%eO@GeRK9vluXEVBv*YBJ}^htE@f%CRF8t13L_}U0JW3uVOdo7go z&aTtl(|Q`31 zZ;3!T+9~~BXy1#{Z|zFha_IQiAfemV*2f>VS2G}(r^2`%<99f+TU$Zb6}>BpB;yZT zyN`;c?}75>W&BL2Aj5|xr#KHJwN~-k_8f}7V9z$sNQHB_tF==$-Qh5UFlwCMqhR>_2}>J zWmYu$1xwW*o$Ou)qKn+i?C1{n(ujWKUIwG>zi7Zi(d*pHoalY-Wo~r0dzlwK<6h=R z!*?3+g6JgovSoCQdl`@StR?*(>W$Wl<_p(j&QTMWK^ey+YDEggySsV@C zZK<}4Uglnc=mPh$ee@movLsshC4*TSz1_X+5dF}->=@1avPCV6_H{2iMHjf27e$Y{ zmz|^fJqEK&wA#JAIJ&^S>>7Q+z3dkK*1hZ=E%=H7?-9M+y^KU3a4)0Lx7^EE)PJwR zERPO!FMCE!_p(=XhkIEOJ?mapMzilT;8oF!-OJw51@2{^=uY>tZ}hZ#*)JOYssZmG zy}`X45MAS54vg-0F9$`>x|f$k!}lBT!O>ps<&fxQ?&Z*^sh0^!|L`t}++J*vgVCq# zITSfLo)gRQ+~`LZJ}=th0im5Lx3Rc(CE{93#I-vS*PcXNdlM<`OQdv*L`r8SQd&=> zbXFpq{fTf6B*Hm65za;;oP&u>4kZ#eCy~Ipi3H9|ByfHrZwnF;+Ar-HW}-6Xx5oZ9&&+J5{IVr{GI7OAZFN?R$&!h^>&n)?<%X&;mHPp%KT zNuA3S9e!l8@9YP+0?_`t2q16uBj@sbi)e5@aaQx`MTa0THXM_U!zrj{>yx8q65Kok zG~G7si7rS2lU-r+HeHQDwiCYKr!2WS6n{vd>yD!zfx-@d&We!HVM_71@{roTjrS$(yXiQ6Vpu$}` z+jiw-(~A`}Wk=gx%i6i2Y&-I7AKONN7rp<%n78tI5_5NFA>*@i8~Rg}bn-T|$_K8v ztkK^v@~46ceJvNS#o=%||KEgmP(qOK-x-fZH=t#ocIB2Y0k3A_IQKqS;@%6!epv1fen8^6=#v+uiDKS zYB!IQQ~17)cB6PT__vD}PMLS}*?iitEacU79v1kF1={P6bGf{RHnoZG=KIyAu2!2; zPSy`4y?!Ur&^1n~}ynH5}(SSEgB`-kM1r$cSa zZz(j(Bax{Valr?{l0`wkTPIjYT(etQvM%xj$?fFqCSKCvM#p%Ag_`(WhhTI*NYBiJ zlE%Ac*{1U}!e{ixuNCrX7WirZh#0^1B)@hJM>x!bZH%wehh^K!rX*Pb5}u(ODR*a_ zd{_!~j4btGnWSNL5?wk=h0cv}+&cQW@>(Z)8l7i7VjfwU9HY34J-h%7?1vZG@5TIL z3^f2=+1>iySKx*HZBb~c8(6esd9k^S_QMa+i7X~qIzJ6Aq`~T5ELelUE&QC@D+huD z+7dA%s*PYaoq}(Uq@7#e#)`QF`_b)dV>_HN4NeTq9MK1T3|9)y$GI(LxdesD2?S;d zoSYTBt3h)%{PCJCimEF(Z9Qz9k4j0-)ye>r%)eM{JZRqF!U+NN8HDBneI=LfTnjD+ zXYpjTUkr5YxEx-_r!6bb8EjsM(DsaIj9U)HURz9V*d_!^`wEFcfbgoKQ+LAL$8$n* zJx5i{JmP8C$&UPwdDygTkZ`vnuOJI=KP4C(`;#Nfb8`jpA>M<>>68eVr+|$L_&x#S z|C68^QuqyoPbkR3gC779-bh%_h!(=D;Z3~LTUJ7D*{pe+sst|PBq7%t=^pjPq8f(rwZYqq~m7b2ZA%Ghv0{~&Kp?Ce=;{IgdYXY+Dgcn zo`ZF&5IZKFW|oY*P5%z>v|NJX55IczjHNSDwJx3YRl?sP84PX_t(-4^f{blW7R{rK zh4nOt8MaIqeVFg&LNZ(%pZTbmxSRWLIsbkYxV(yU{vFJxBJH-LuEA9rM8)B_{@#kO zasp<#ZJ~tKLVORXdA_K|0CAYScz3z%R$fijR!!t>{WWurLH}5w?JhZ%>rFpKY5ZVI zh>+>{$N9=^_kU|TPGKp#CiOo`osTPcFM+~$!Y7sk6sNN<6SR(SlpJha8$BS2u-NWd zTz8bko+ITWcDLn)8F(h_yn`oiiAG zl8?6FU8=^K#+r~D8fXie7B7yG?O4)v)A2|6DS;1Is)c_-!~@KiNdQ0sGI}|jbr{XU zbRjL+8*F}>gh-@YH8(X^bXR9PH;5KeE}ELMcUqzvUK!R%&oEN0J-I~or`&Ao?R2QO z^RTtM>%CpR?b@BrHy%PPm6!0rspC-s9X;V^Ai^!L!~wbDVAvI2LROuc!1-I$X_UTw zTwB*YCMXB*Jn_4)C=F}+vuGwh=={%;iQP!eT_VBf_&|1wr7{Zkc0Rf{Y2b`byF)Qg zR$^a#i@p9)JECD@0P+7_!e3~tSjamUKdOZWv-m}70@jUc$20<#W!$Z5v$J7=_bZ^8 z_t!?PFVYCVklt9_s~d}J?$&z@zCRBM%`rF|{D|hdSh8K@M6~Bgwms{SqGKOP1TquX z9VM(4Suz_6c^hYMc99$HDGh&R0CxhrN zpo1?!m)(gGFPboHb6$W3LVCM&HYUI2jrQ-+TB)skunf|;OOra{E}CE$9{KT@=23p@ z*QChWrTnHTBo8Ou?YDk21x_J(IITzct=~?8Q;36e`+J5j5ZnAFE%-k@?^s?rY zl3n9nbPs&6mhPC8k!!HXzQK+^M@I3vmta?LE}BqC3Vpk05b;JZI@pVzp1|PxIdPeZ zXRS#Of+Dt55G-9T#cFh1rP^Eebs!l+No#Rt0qA6Kr8MSh|B z`xQUIoxn^=ze|#zQbnH~k+|hJwOpa6ii%VUG6bS`H_|JAZYZ<@e!Bz)n`c`Io!8rS zAaH?BWHS_2X7$$#g@eh2RZV$#r{Uv6T19R6)$vQs8RHBeA1r_*Q=)0BQ$H!4@NVRx z`Id&pH-q6WJb4`J9{aclZhy)snpN(xOpoR&;X6XF2}0o;NXq30djSv(&dx+ey6!;Y zFCahZ5(8KOz-e=tkJRGxLF-j$SIzqpx3=89Nl1IV=-xD@+NAH+ww>9(ijyzenRQ`a z=m*c4OY_m#jn2orP-WW}N@{GL{sk!`<3hQmx8OVgyEp9*)M78Vi#iVP=7#~=e!w@s zB*AzR4Kw~{fNiX|kHQZ|OHC-q!UH;yrQOz(Kn(UUl+uKf$?Xz&$#f1r@*hQzX}wOJrD-&KeU1Ov1Y-d^C)d6QqW$1NQl~VkOnyrd zX)m8{p@|7dCr_Ub7tnunKK=vr!lFqTcfe3YP8|@D^5$}pL2AM@lR94ZJlWeNp>E?xBGN4xrj?5 zA%68v#}(98SVz#KA-)AKzxfxQHhLh;c=SMSjUL4P8kaT&SXJ8Omrt9<4@5j-Vin^D zx8`V)PK!D}Xdpq)r&E0nmrlvEqR=}{r;5|=K;lhGZ^P4X-p!~$ z8~wA)U`NOXPV#9NiB+XtepAz~=puTnNc$aaG~L+ACnQIwiO06$j_R`U>?(9}HimTm z_i0o=X)>q^tElzPo;f2cRliZx2Z?XoiGS;FJQ(`XvvpVE9%>v;J!q`}kU2F*O}~D= z4PErIvqQSVjYDYs0)VuJ4OLWwQ-QSZ&Qtg@p?}Vgte4Ml$mkx?%k7w0S-uB%gGH6y zA*=7&{O*Al@=u;77s@XVm3bfR z*)UL`=E!Wl&x0 zPH;claI`|bCqGJ#b6Zl(27s8)$%3WLJo%Wrwykq_)^m@v@$Ak8|CH4Mli$25h}tNV zyOuRnPUKu`wdgQc)X@<>R_f}AF8YuYE-S65pwiMaj8xaZ!FPqqnZw<5vAoy%rj5Xm zRl8rX%JFGJ>gpQZcd4#;frd?%+NdP}YpdfKqv=>@OfZTf0^C zh490}OeTL2XVLES2p=ch*b#i=_g?(G;t90F)50f!_gL{%!aZbZaV=(Q^?VG>=(s`c z2Q#a(a^hS9F6g!Xde!yU3*m91X(l*V*o*h9$UMiRui7;fG7R3`)os_1W=LU1E5-5P zx9lSIOJo<31}iDqHc?Il|AtyjL;Sl8ioi-1#z1Uuh*mwKRj_V&eQjByq_}(Rts)ve z4~el|&G{dk;S2C+SDF+;`+kY$}sCFb~$EvYn- zTf}b6_)QhDag!w9TkZ$zLtrv*^ItxLaG@46LxIP{du4-?=FT90~nJ4 zu@gk@bR$-DlSyzcm_6~C90l0qm~e$2vdyJzUZW0wif?0<`;Eg-@-bMh=r-+IX{c7t zTv_7m*x5vPo$}cg$H5dwxE_x5slhMqp#NQF2AWR@ubDz`uA}!IkyAI+um52R&YBKK`okMNO-N}%XTNqr z@1H_&Ek_XL5J&p#6r8mk4&!DZnf>I>vx&t`r-7m~tqnfNd;5>v(Svb)BMXsF$wXG} z-JCeOc8Z_ujU%Av>^~>h!!1cu6rU6BbwH7T>%FR9_K3lb@|E)aCa<*X>dp?lM3pmc zQqd*O9{i%}^l4V-^7f#s%dT)-O?DN`RqjRHQ(C?e@m)`;Dg-A2nhMRevXdDsRdDdpYdra{sWCjcNT)n_&{fFAjZ(7 z3msz2*OyI)Eto=2kSzadm;I&!XZd$!?)(%%>c_p4!KK7(yr4{ff!opZz1`vSVx>7a z04t8MeLql}WW)V-1zrL+>1)u!3MFr@nSWq@n#7PeHLsYN08Yvr9Jo- z&&D@-r0jVw`g7tX+mDvD6nnV-PkYaZVi7ywowZro>3pb9p` z2M@|_<9-V6m?#Zmgl$a?;HHqSTK7<`$E0=8by{k@t_+LbM~VBZIZRAK)PfPi&0ahSPrwYGWlFObTT1;Gba7L;8cf2+|!qth7#S5{LPnJf`6> zDUiW~e}NJ_qQ|2=;#wyeD%;%$UlU({6kklrtWSMd<6O)TdP+sA7R$OH$ICYDvB{H9 zRb#u>lC7S6N@0aRlBZlq3p zLwprO={w?)YNU6o=$Jwl19T}&7e0qO_^B)}jpo-U`#66u^{LnvvKSX7SEfEGTrqrw zXJ0OYa3!F@Vq-DXbfSxkHhd$WNN6d}VLHF`EUE^NqEf*|`L8ZSjc$)IX9ceCQU5{; zL7wVhghfgv!F&V?2C>|+^CHK`3_Gio=Ao2yX|@yV8wlgB7!kBev%#B^?$ zQE3)KwJ)}L)`?M6T2T%pWgMSPmiBq9shHB|iFK{oiR@jqYHKv}@lDBv-$cWp(Vjr^ zQkCniJrwIz*PdJouJ1}hbuGaZElu@Vn|&h6z3psH`DfM73j#ue$>D_+{o*-E~ zXBQkW1y7JH-nT7Y6-Pc^L9%$48=lH5k0(eL?>mO40?p$IlEwS3;i<&)c!Ff{t}r}_ zL>^C&EZ&udCz;9P2@>PU&NDkMu=Y+$AVF3+NJXm5>|oHuCoLlckTN=SN*sd3aj1+O z-eFVl1j*vLvV7YVJVCN}PIgrZQl=#1g2Z^Q#k-S-Bc{+0B&H$Wud;kp6-(oaWz_nX zy89|KXs7!B3gNCMob3s@36-Ya!p#!+!=tXlpY?HQ^q~q7ye;~;GmG|DeH;||+?)9b z)kY;@9?bXzYUh$p%l%oOzh^(5)`vKNwYza^J>#bEUF|v_k@erFM-K@YnAZGSkpU9d z>EY|^`Vvo`tx>FU3dwI7XJM(At_DvRCqheo*!S}O9(mDtl}I$X{&unwQ}HNX9_EwY zZa`8h+AYl;4xUCQVlgp&Qf`!GF+Jk|)7k-k4v?CG#9i{%gW@$R2d!$us(VQ+aQ8A{ zFjK<{gp&}fZtGm1QuV-Vs|a!X@P1koB`f?Rlzo?^D#XJTM2IjY{x_ulUGo1^oB!|H z{Qu_sm5)1sDn z%+XXWDK`acqdDs}XkIUxLlMp498Fcja#OH2nzLVn<_|@4PDFE!98Fcza#OH2nsZk} zlR--FN20lAL~||CRLQR0F;pxoKUSD|QJDD(lgJ9=3h*IV8z1X*r0D9g`1pxvt{c%@ zPc+5H`W-{XeEd{l7DQndDon!1y~c-NZG3Fdk)q>6GW#>pWcthM!G<}SQf1|)U~M!P zt%l}Xp!svr9EoUdl%uJxO1UXma56@UO&g{aY~#*^m44Cvh3IY)(cLshSDL!q6s!|n z#*aEx+&EuoS^J)b&dY>NMdk(A_^K41W_cfHVlP>T80+GF zr%&^n<4}!Oq(>??nbWv@`n2isYIP|%zqvKYZj1&yWh4rA3tq_@lWZ8XUYpw}3}&yJ z?ux?Pnhj%oY@70NhdfD7j?e8<|47y6{kKp3ALjYD)yjJ}zws76S`*j@e()4aBGPqpzd^SBrhHP{QhOwR2f5!$?h7aG4Y>syX`QU* zvFfL3Sjev2tiOuW9m+Ew1N2nJ_;qDpPh)pt>&2*h12wD=?!i~MCl3s>#Zagf!@c})s zE4pX8GXeZuayJ_zJa|Kjtxu!TxZ}L__NXWC4{UwyS?<`66JN zFWGw@;yM)fQEmXgu`ki4=tfI@fZxk+zs`Ptkl$N7`~6XV`*-$ZOsv*8ptB$5eywp} zXTO`}x1_V*pX9f+v)`ZPcTi`)TjY0eXTQJ5?~u-Zx61F(cE5t%)uKLOeBQ`&D7lGA zio!;3cSR5yhY@O0AcF`07RKo@#%{uRn=k}2clFQai-L(Hdb^sw!zE*c%l%#J&U{vDjMx`l+YvhJ0dq7 z#lYNJ`|w$4+yQSi2O*0X=qw%!q!MnA8{0Q{CxL92t*oJP_+=EMi>^H2hwsAEws|z( zjjJ#6=n9YKtE;ysUU}vhU$VRHke{DrGBWmb>J@ z?St@{4VyeW-d9%88W!(Pcy7EG0_rCoCqj*oXAfhwmKn$M(KmWDm;;62eSGwK1Ab7) zfkoEf)i{Ai@S-aAiMXulzhCf^cuWdp@PM@vBf-mhFyz6!L#=q;(L>v*3RfU_GI*rq z6kdwxRNmuu4z9*k1_~>O_9gvMvyoXPL_18&tJCW~@MTY^lxM*^j`!b`t|nwO*L0f5 zx&##lrdf86Ef%&G+qLk_Bw~V3OT-5Rw?qgup+}mCUfVqwtRyMP@;r-sZ>ZiSIf$e4 zTy&c%y7I(iO#SqPxg-cGASu3DD-D|4k6M_D}^-J5v^e)fo)0z^o zF^#iFZoetH2tUXpx7{GIKV^S!2)=Z2$MDMk4&kY{XW-L1lSk)zdlo)PGHq;Hkg4@n z6v7W>k)yi$VWGFVRc{Thdix3ZzFXy$)Z2FeN$c%LATXugDmvBMvw6FE`%zrfTl44& zKgJjJws8(`NqV7mE-tPfXq{*8@O)lzjs5s4YHTdqUEZl@xH>D@J`C>eaq^|exDk-2 z-F~1$Wv;;rrJJ)gNRAojKk*5WOsGGJqwy&olL8q$V9C%(Q;hXiV`+2sNUN;wC9cM& z@l-v!fOkxodSuDh#O07%L8{vH8Bi>O0JE;GZX5*aeWLf-h~DQi^fC#V<`Por9aTwZ z6G8+RCJ`ij_jRRpP-XgkLfx-;mRUT7*5?&ZqSq2(3BLfmZ}jb;qjN6e17q0Auxi{8 z+ZO@4Gp^(DTXl7Vh*qH~T4QSdoYQZrgs0Th z|1zvf^Zz!iN@z-0$@@ky_ji@$N3c)SMqPqgfGB=TFTeF&y|gUxY85>$vgh$x6vhI@QJj2g#_C4e0V>f3q5~gIUJiTeOPAjSMi?|$lyT%Sqi@f ztanr+8`bdZxO>X=6QNo$&W6JV4N8V&bhyKxVs(-`+`;Ya%&a4DGPaL5_R(0kI6KH} zuQaQYM8-0pKId^I&wI#ZO}Vaho_c5RQYR0*AxP;rx;^MrV{QXg^1jEzlKpWd`x{EO zKn4$rak5)q0hU?tsor6HUAeq0KU!bK1zo*bSIXVIil;5}6h|!c{1utc^`Cr%W*)U& zS1ylenWy2qK%m_P;(N=n$J zz*=7i7TxL0A`@@_=r?*lJpo9`JG@MY-@v75;cwd8Z|ZyES{@e3Cl$#`t&I`L;I=j< z{FcIA3M>-|#uL-n)cWT3pmr-&fbHT=f^ZzT zDC>*+6(VKvcqxvKsJ2P1em+X3zQ-DD)u;XKwg}VDlq-@g^&6$@NTvGii~4M(jM-JH*?tCl;(7v_41HQpgezbWxveCaD}cy#6CB-p@9qH5W+s${C=D=+6( zkjo=dErw&Ng~+XfTY&z20C_|K49DrBNVnRe<{fs2dr}~SWhuWO^3zbC{sg}mS$sb= zoWZ>ud>i1sMbCS42ChDXj1a9;@tYFxMAawu1f!Ny{InkWql9zop`HF8Zb|J%%|Ll4 zVlp$8*w{Glexu?yxZoMw!y5~~)@G-13rW4i@vNmzZEMrCAr3yD6r?%eoqib~4A_?GrWW!LOb|N3`C^is4>_+F{jZajl8LdtD;zbKO? z<)wz-6?WnmkZml>_^QuSvU4|5+V@El_T9{513kug$l@9akB|!e2(E^>PTBJ&>IVw5 z|4%%A#>3F<=ITksxabDIe!`zwmrWkAtSer|eKH^|PCMb6GZ}jrDh1c2DH{nR_Sl%{L80Vvlq)gxs2?q0P?c0_RY0nc|Wybm}OBL=45oZCE17~ zc7nPiC=yn^<91B$_-7l?qGqY1q+~bzC^M(zE6UNOZ?RX}DQ>Hd@JjDoU0e0-oWfBb zc`-~qVr`YxvwU0S>bI**u3Ebya24JatgH35E>vxT)>G2|H8b%$nb;K9_wawz`TvJG zb?)XkA4u6YpxAW(xOy~Y>nFQ!j26DNF~xnq(Z1`+_qct(Kl$Fwz8?-^d?e7bfgsK) zAHzMn$IM|~BYe&2u@3SYJ$4oW=ay?)qq zSP@72Jw3+U zuY)`IF_=UkIZ->Yw`(WD>j1|!Q*kp3=&>N9*7%t`Xmsv_E=>?!VCKBbO?^gm8&^nS z3cx9UI8QiMYYodyp|Y!m@HV0o9*&Il1}9;7R3q@IxcfLLQOV*0$RF`yJn!ec8dpIm zU=YluAQaaO#tOq-7>izHxxZZ)t4VC?Hk%@9#S8HK+uO%=fBKp!5%T^^+I?wMR?4dKNR$FbN)!qCsKqb z&G}Y3%$vb^gbk#={Hd{F#EiXwC!4_14SgJV4G@ z%=vR6ylPHMh0lW9D0diqiJe6`10+ckk-sNDIVABFUJX=jclZlv_m5{Au%3IZpL+ z;Z(3w{hqOKD(O}EspzNrJ!|143#;;za7^`cyhvK6`aNefB|cOATzrzJseb>qa1yYo ze$ShqByOsoqbU)b>PO>DUP~sY`n_O&64F)qNouG1y=dVi##8-VIY_Rj`Z+!&=u`ci zetSOWr}=q7vii-@Pz{+%!{xiG%v8UZjAzxMyx*4S5&6-YzJzCVpNpJ9A8nf*EK~2l zB|dA`VWlLzPfE&#?tC(V&P)Pj`G48?Pz6qj#Ipa2`KdCrCDKC$rKGdHQN!oS&4%s{EuqvVH~cZG=;~k#{9L7mV))V4+hj;cw6d6BWQ_ zJNRe-x7SS|g9n%fm<=+lvS9*L|44Wg?RXLyvm}LoaM}7DkId%{d{$7A+@D+=l~u|CAeS7&P+G57 zsD{7C*RCQO@R|x}M-SjuC|$i%4bNt&2c`j6t}^A@#a@RW((q?jwy6ypAOWw!Ph&bc zqki{H(uWB&OD|3b;f0d^6Kd3!sTadPKp(?phBESxxOIN*NHCoThoT3ZT@xeTD9;)4 ztnuir>R8>8i7EuGBnl#6R-8Zv4+g>D?jg-B)>k67T{fNMPETdhDR>;}N{l;k7<0}W zVijPm*qjcD@FpTOn`psCMeVz^{l#1``#doTtz-w>MA(*HxMwKj&4lzumytcy!HNd{ zxK`TAt6+C;GLTpE7_d-;<>4hgqg&zd%NC(uu~%@7j0y=vqe^tW)pAQbRVyt;Q0*Jt z5U&bhIXM1L#I{&HduU%Q}#qc!PF4$Vit>;6eUb>Yo z%hfzwxca|v25XSY2HxGLnvv;3gTq_ldU8R9)@EkyHS+{T7bXpGn4G2TwHx}1lh-irKB9* z3RYrvs-N%+@O+g=W@?3;(Fo%cnFeLaLg0GSAz_7_kaIqe=6C>FLTgrzwlMf8?)f&SQ4|BwWZYrHET6c=p zTxiAWP2QoYw>1^>T6(O_BReih?}bVM%{dXxxuVFqMS9t}ML6OB;A$S5Jq%t&Vb-xQ z{iW7=!Y;NJ=%w>U^!8gD^5S?pc}{fkFnwAStAB&lNr4O=%oArxvU^;MSZ<13co(RZ z;6)X(3a7WkDZ}Qm6@a< zVupitNXTGipwj$12*J9_!}SEJ0(wwvbvc%5)wP2&pjqom4|5oF4S&tngt;{hFMHdJ zPLpYayjMK-zUYAaT4Mv^>sFy|1P7Gy#(Md!O?Y|z6>BVm^@+BJj|IGY`^(jd9(=8| z%i{JSn3)vF;JPDVB;D9Cqs;MXgGCxhJ1$9Qhb`;tqADxCuHZ=+43b;U@~g5B_Xm@Npm6m7cu$4U5VSaZFJMxJq?I6S!}n0Z8Kj$JGjb2 z>bf$!QKh4HA)am*k2<>rtG|Bmx5VwTSejUoJ*CJv057k6doe_y<8?XxuVb{#Znnel zU8@`29B~BNE3sh}|3=_)Dq5|vh%8WBu_<|jywWUcsO$}TNv&;#BUWp&k!3R>^0JZD z2RDn=IlJwsUw3Tx&Bw(HlkCKCvj8&(dUxCU)A~lVsm}T+FH*lk1ToXRuaWr=kl-;U zfjKOF`gP-N{!_S0|Rw$q73_X)Tp__KD--S@=#E- z`SrH24pr-7>$TfszWhcn$O|S#CL!xxxkfy%W~;TBS9>-(9!aCjoZ3>?==1VPYJSvD z%AOlx7nCN%l&9+wsr9vN>}y=Q#SPcF10!;0LdJc%>q)O4-k(jbrDu9ft8LFh9B#nE zRT0&M1;V+tS-r@EZ{w7vt`dZJ{Ot$vAWxw+K++~^JnTNE#v`hZ`ZSmyKFaqZ?`h9I zUH;404J9Nd2K%P6F}Ug6aUa(6*TI~RNWrn+IFHZoClXATw%%{ze) zFP3z(2ya5-`4#5z77P~qSUldv35*Kx1T@g;#c@iHkz*SQcBi1(fIVZ#Unfwb0$mQ4 z#CBISQCJz&I*O@Q4mOlptU7I{3#Q_7l|EP>%90JoX=r-LH#5;vVCpGOxn$O|T=)^v z%8Vqo)0M17bWM-?O__dnOHMg%=3GoS=0|hK+fb0x zCFjj`;la+3bem40qim^)-Y&-*Rtu>UD9Bs$T+DX4D%g@@$#ZHn0z^DmLjM58 z@Oj0!wt~?>pqk|j{{s+_6HArw1wJA;)u(&>uc{K7ByhlJ>d?Z`=j^@=?keTsy zL1yYwIi^F|U7fkz+q`RH-OpZd9Z(!8I}rdOgP(yKV1eSSs)M9-Z? zSW{f58Ati~NN1nB0&~{6%dM6f?3ub+v31-7&}l4C6f}M#Fhk?Fh!^QMV|`_LA)bvF z$-ZEOyy&S|pLS+%bRMNl-Aecp-U}Q1o%TahU;TZ?)cB|6<1zxfmoinjz5EsHXQexC+)k|#uXf2H_;euQ7^D^w&rcKA2 zou_6cUWiXQ%C#|ZeGxs{rHG!=Q?M4NZFzD|k1(PT%_+(9_02lvOe0d1l?itSPe$L! zzVyvL%W0ZaN2xzG$Xujb_aUo9byx4~+4@@$yMCiAt+MJRt0ta8yq`GC%u&6Qo#R$Z zY=$dZ>H&T0M86^um@w#oEy(cJC@6l@o~^A@cT+*#N{Vq@h>TFQ;~Q+nY#B8culGzm zTdy~aEqPjfS1MR*@dhGX@gJf#8#(;Ejlw9<%JS89X?fs9a`j4lG*Os~l8Y5ig6DmrLvxxX41i@=2L( z1wvAe6%S1dVcMo`-HSXTjbk`Y;}F6!)Ixl4Wp1^jJfaYWV{h9-mLT{Q5b`HzV?V zzmqfg%-@|4nevh98^@1q;pmz(J3pc5Zp8{t7Hu^&4(i6vGF!$L(orHy?NZzKCw5#g zN}^dc$mMdn+-w_OrYl|f&a^gbn_SteFCqwNN!y0(AS2sO!4o8lXLfvZyD4~r#CU_y zWvYO4MXmFAMAjIOZE?gj_CLDaUs+&$2O8T+^HKKaj`%5T{lnCH-w=Y=OS!tZM9U9! zo~A8itRG$Qj<tHX<7AOqh!6 ztmRL*LtFY?Ur>JZpmLsS%c#p97g?!qZ)-g!=%mv14J9DSz%V$g!S^rz%sdL2T&=daO{u56xnObaux?P=~i%t-zu8|A6j`tD@U6U)a9Vo-bd7k0I5Wp>9s_H1U=W zaVPH-@hs0>!uXgfuREuAu>qM0bIQjZsFnd52?=?46(?>)B$Mw9qI4TA1^>}C5$>b6 zQcaM`$?%umm3#>742##9-LrZyR$jsE?HgSeXjixrH@h#HXniYmHR)K{PLoqisPH2rb2Kw@ukE>$<=LlPz_V54;RhwdQ`xK8{HErX{X(M*G?r`j8*BCU zMs!Ewy~i8NE&YEYVP=yDjj94L4&BAuD~)M7ycCe)5i_GoHd;Q4rsUc}zp0qn8#L=e zO<>ddb=&vN$6zbbjexZt12B->i=)xUqt$PqN^3grYB+b3UAUch^fc&Gu?*x~?h zSQ*r-)SAhQCR}ksa2Bt|5RYIJ(hzK_J{GIx*keN3&4&{ET4(do%ZBKt;w(2sC!E8> zDB`~c?(x4QgFI~KXZc*To!_BnMqlGGpB=n6oaDxQl-G6fEFI28=1RTYvKzVmaIPYd zxG-zH8!tSRBZYG&NpZMl##iI2_$pIk5^@(q>w`rk^h&gc=N;q+Yk{NH2y64^IFWh0 zG^Xp@T}Eq=mvm@>EwBT17f#H_ZPxrcI2!Bnm=wt1v6M)E6ul1+)m)Xudibj>*5^%E zcL6U7LGiKNQ9!$e#YJQH@K!jAnSsF(x}x%qquv0wMa@8X6tzGTdKhudCvF(~L1QzC zCTFfXSy%hr1y9QBOcuavXLxEG`gVSo!qJO`ez1r~!HUKfO>**o0?0I+#FeF?Hsmp* zF(Pa$z^^jdKR4Wn?{nn(>Liai7t^psZ$4pN{1RwJ1MMksE(9C%jKhpO+Y@W_1Lzu+ zqZ?nfu)!p-U~@7hMo-c%yCr|Nv9nPH_id&;36jt>yEM?iVR#jf1YuSADY)#%HBF}W zoMNX6qI#^oDtqxhPjLrYOc2UW9X|I3T9gGt5lDJ_`OIL%XM$#LLYiQF4CKZP7H>}q zWblA#gM50WW3d-Hp64n*<<-PqIrb>WNkPzaCA&xFOHMa(x(pLqXAx^ZXK1V0&;gs* z@J@0=>2dc@uSL4C|13d=s}<7u_GnW==q!5#>Rznn_()FFv9h+nHwZt#na+juYi$!e z89gi1EmWw{=~x?Jj6~5S*D1Mc#S8tV;8q=vHE%{^76UtdUG)n=4r!{pyXu$Wvr?n0RQ}Yfq~63uAyEod0| zG1wP}TL@JQHlbDxt@NqRc3_BCtq*@Xinm$}H^nzPqy8nu<4QHj?m6dno2*9J!2Ty( zN*2fL<5KFE$2UI}@O9a~eBxdhs)h{7cMr|X+|5);jR07dZq{7O?dr!Bg4gHkv%5ob zp7buVYI=7wF{@(+H^<>lLEVx-sXV!PAWX)%e{$k6Qbu}AIbjgF8;a|K1TfZ1Pm(6g zq>S9h`s+5GMYsh~CnpX{uun97msfw$34%^_ke-?=*KzE*ldLbe z(*l@*Othf#XqwF{xH-uOsBLZtC-?+WkIKICgOB5k*;RYB8BlC-owI1dTOWkHP2sxx zw#xMl0Ms8`0rb-hTO}2ea2>A`giA@uR~790b(2*A%VQ zb#wXZ%BMZ=*UsT&^8QQzOWyB4CGQ1sd0#SH$=b($*2$-$5fF8tH4-yy2PoIbO=%|! zHpjoNvbi{MKwMZ~OA1RMgS$;ST5CZwxg3Af+J$n%ClXtaiTf9{rg7=Twui}1_%tC> z!BV-cLmsb3ywg3#skefzsmV-HrRW|fdksfEm#BD-iLN6!2=0=hzt&RA5y_15#p+3T z8R!c(t}L8s8pz$!7flgNFmBzZzh28$&F_27*lW!Li92OjbwdzWK3TjaQ}6`I;<>R$ zr6r{o=cRO&-&CqoKgA`8qtWmEinOn<@>I8xBL5*d;IxVZgg+60r4K9(Pc%N(PNHAm?sWalmLn=U{X)LwKnIl)9LS)~=?(YIK`Ommhvx zK3vptt=`-&a=G5z9P@p>`?Mu0y;5Z6aIJUd%vzt_CQ=>jcOCHlIA5gqu2b4G!kxV% zQTZb~Qu$*SRixQtx@lAV7Dz|@oVe95I+zTjk9r6%Yo>nzyg>`s9iWd=B_TUG$ z`Pp9zuM?3%c%PY$2dC+vos3v-?r_l3tNM~f%yAn#NVNgzr*w@wce%|i_MPI z+i$&FFD=(O7Drs&ES(!eClH+*jZUc*Mj?-PAy0@yo|Fyg^sL77-1tLNn+I6yq`Gbe zVfrw(Ep(>5vM)MwURh|%f5R(@lLCwJG>4~K7+WT@VpVf^dS}n}(dz$|{8mt1M>Tij zH~s*f)_cJ7oA%T}g0Z`)9BI9m2bg|SIl(;;iGNc*epC4s{s=N|d-vgdu3~$)yxjKg zBNWn(*(@a3nzS+;+CNRK+i{T*`zyOHpsC`2drpII@dUw1}d;MukTb=f4tEf^TjrAmB|LDoQpXTw7gLlS4@pJMxtP?Ob zkEc&}*2s>aC>K=i<<9QQ?pVaxec2r|nL6Rp)A>A+&UbYGo+8Pn%bkzAA$8k7&9W&! zcjxqmD^8~$T(xMKBJo|dF>T^%hf^s|Hl13@td($g4qb2gq`GI-j9RbC75+HOShlY3 zMfGrXUCKpuU2oNOYPDtQmC8;QZ<_o_Gx<&FrHPYyn2mUwYR5GUuuckOa5Fn5PKhyY z7sl4;+ev{89*m=>Y^h}HeZXuw-3|mAmp1g9(s^bEMEeEYG8my|{4~Nn!VV$7DGxV0 zUdOcxwIMGzJKhi-zo}R2M7f*q=V=rDN{#8D$cB&I9tQXf8I~>zZ1MT`FCYB+!D7@QMrOz2NcPFR;)YnsJ7Xy4Pq>O z~k~%NjJBlTP}>9rhB(`oQwa z7Sd(&%Ju0P&Z=?5^VZqcF7EGd9NkSsms9SH?&65<4xQ=7_0Re+JAxDSVZKX_t9)Yr z?3wgZ_I~q?Ag3M9DA@NDEDoc*lRZouUP~r6`DXl@?6mRgmW0O+#KroI^IBatzj<0m zxpXqCVA*s#nbr6pXVT~VWZMd&v~cFYHCS9`+aH7}8!z2vJPBsuG?$qPCo`^og>@|z*aqTq6dE1Uwi#vCo`!x1b*?wlY>bF; zBF3qoAr4#e>j#R?c1qcL?` z`jCa-W&Cpk04m4j_-_F{rqne+z&5RdIf6GK;tQh9Y`vp2O<<@S+Bd*edUCX39Bdd$ zkVYm8mb5k$iA0oURcDvxLTD)`U%N-8j9khKR$$?&sDnl3J;PmrvO{M9C~T|TOh=sX|vzv43&^C%PQsx}Ev-@(wDTy~u}PM_j=hc_hff-JW>21h=s_ zIBGlg;Z0w3UtS9Trd)X1l>P8%yp>0=6JAN>5G~2$8$^ryER5Cx5s{tSi5%FGh-mBy zjjcpuNkn5QZ}>S#uTtw^z36)$!dvX^(oXqMJUXyPzPK{Ad`WUZy7&JLJZ-1kSdw&v zhP@9Hqs_PRj9RsgGXrp>H4W$XfXCquPeW{y4Uyuzakd!$2#e=Pd%oSCN2L@t%~J5Z z+oJKRbC4Y0?sC%^-m&vMbE+L{oiAr0;BdES%(rM~p`!z9@dSq-t_g9*ru|UEx=e5Q zp~e`~(_UQrwl-;X?Sk;rF)%kllop6|Xo@S6|1GX!T^+8|XV<}djC0Z^J^}m@Lf2!=!#G@;r1D!`1ufiHpIJK z2#2B&M=3-hAEJ;AakLBJP!wWwg>X}T;%dJ8%y4y#3*k@*(IL+Y-n$95A7#b(W%f{~gS<8J&oKZ`+X2tA2~Q({3bu~TZIKJ!su@sK2ETB^*IAMkY(@+uK8?SiJ!^Kh zW>k80l0E-iD)&J->9d8mE&;-@nU$df+Jouytd~zOq3ZK@d$`)cv zaV@xq?sv>6FwO04!TT}Q$@&YjX2Vkn6#kW|^stG`>{{D^-#CrWp|Hg>p`dy&KMo&G z;I-hKNxEFNs)rK_K9E6v4cuTdhwIjM7+=BZ_yoI=E17r;-XX-RH2F=XKKvk$i8FZE z2*;T?8fWpC6v*JgTc9xUp%~-C!qAedNr4O=?5^zJBNLI@?KB=`r;Fz!xGbKtakzK{ zn$W|=^U)aNW5Td_1e(yJb3BJf>9I2MgL8y!@`BGMyM{DyJh!6X)vH8lM40b?&pgspiT^0)9>bB@qDwXd{uBs=Zn0G8mK#JE6!F zk0d!U38^=k_Q51RzcDnny-a=+sde^3(yshZ;hZhkPA|2Y++CC$rcQm3?wDA{!-V4V zO4S#5ObTT1U~dUJYePmjCF~;kTgIq@sGZ5zvvD%O(UtOX^8ZC#M*K^0;7Nfd^f39) zlQBKBTS7Ff=Q zQ>ralsWBVuU^fgvcOGohFfPer%!x5Ft%S3y)%h1)-E=ysAtsq3Y1AekvpeBrTC}w6 z+&rr2d41y_*(1b_NHfXGkj#@*fQoPz8q7HwBJ-MG23QL zea|F!WOwDFvo!sGr4jS9GU@k4<3aWPQ6&vbo$gax7h?#r^hLQJ`yQJ5E|;08`bGWs zwx!%BzML~9;nS@XGMhZm^1AR2S~EKf-w$j}^!NA<7+6ReGSQQ1z#U-JA2E<-V(fQ` z)+99*ecn&~Tet7zV8tb|N)Xh(Y8?EpgdIMYHJe)G7ixuE+KUi<(J(m;jK)TJ8X5oa zP{naFo$gE=j(6@XgTG61{K>8sM0!s7vLWxqhW8bq3v3nsLf;RMgle!KHGe^OOFqfs z0t=Up86?J1L~mo>%IEq?6p-&SJ24%i%)VNgjXWor9nn|0 z51Bb5;StoaBwsI$&iwwC$PLG56TAfS^47O4idCKUtq=(rOOIrWF$Bs-A+vt&%!nN* zlg3FZb=s}VL1A3rJ9_!8tM$?(^tCwR7D#0&E7baKt2xvAAqvOM6)CjliuBf8k=BW6 z`avtJf57i(Fh9cYa(<)V<$;~-Hx)V8LD*CL1n-yl?L%Rc?FNbY#x z)%u>?O=g|ktc@69)`npY=8i0cje@mJ_R1rgwK1H4sBN-W+++^tzLL+(-0quUfAozm z4f1kxNLS(V>y?KP)u!B;C7gNgW?MGF-8V&|X%vjRZ)=QhEl}W>PHbJBMvKaS{(tW2{9mvmxxw_{B-c>o5 z_pUO!5_L6_wx`ScDaz!HqSbhGEf!H+ugq}HADZ*iYXkjJ3jJ~F{7LHkY3lr0;^Y#l zK_oP|cpf#a0G)Dut+wwC^53nWTi~zIkhgwe&acY(OLH!v*W3D4ituZ5ew#xNTQ{W6 z->0~LkTdv-2F6gL-`7{Eb)ESuRXvsZW~xBJ2c-$V4y01w)&L($0S6o4!ztht1Du@# zzG;AS1fWgocBysLZpEwq6c2YMP1b9Jf8w<(kEvcCme*w+y>6A)s~x>Idl)aBpGVX3 zF_^J-DjVZcA$*v}st~?}pC5cAP1#QXm?%(?w)-iVh037ph3hs# z!C7%yyXq?paApd4%{0}YiQ{p(;3|bnhdnE;A0VDZTO02Or$f5l^9bh(rsasD`i&&m z559zN@J${DNah=48*on$I9Z+HbYj)~6vb3O?#v*Zs{g9|qz|V0Ihs-sQ~exGX^d6* zNrkM+Pda5)eo`{4@{L(kF%Lb+)yA`nD%nd0O8Ee?OR1t`o+M z4y34@tHG$so=47)~!{K$})t6J8vsfpiZQYp;ovPIP5!9ysp+reMXwf zP}P_Bhl5WLSF{tp+ieIb1}DRW&99~hWcS#nv7Lkof+n zH}PBYY>2}OJ`KtjeKJ7~g9aDia&kxhM&sT8MIL85NZOnE1;XxZ`C`c}SaN9q`W}mt z6&y|4xCwI87;wTv76vi?4#Tk3NU>;Uz}0ZwRk??UVRMoa{b&mkgG!&ecdb6 z^Wx-5YaArz3T!6owaGMc(M=;4-86Ev$9Bxy?;JNrEWWpf$~5hbfsvgd+cT;`fQp&R z9FWHWt7K1fNA-guETLY-9o6e^Y+dqXPomC+`VHv2SiZPC4KJlo7zme4lr59$mykFP zkhlKi?S(ABPGJxEbgc1w5}q1i9A3-Ezb@GX56D{OB1Hmk#rRl;n*5RdbUvlp2dUe*e zx2w|7UyYahFfA}LqiU6$4(9jxa-I18^4Mug2K()vB-$QraK4FwjRC6QAxvx3?}In) z248~voI4S(RPp!uU6p#@*N^j@)@OmM7vi}Quc6B%6=8xD*1jk zC>jUGmMXrC)G-ODUn}-kOT|KPG12t*=>`@J#`X6x+W9?Y702Fp2m4E3Q*k-yw%E9e zeCN#0VyR5nuKu3>?*3|jrN6gU3cf&y!HQQL?9xe`X#C_P&LLLYn_Snb13gaX?Swb| zHWP48atIX= z?de8Yx^*N!o3_al)8vnQ7d_4@^LCSLm_%a#OC1$brQ~d|`cFwv!JbZ!J7fMvgX)=u z-epidv(QHks%I9e3S3C_W)z$EgrIt6ao07do>}Og2GuhQJ=LIkW}%lGRL=~wyHLM7 zhM1LEw(ktoxXP?Q(wh9=_@4I`%Qy8AyBWOU!fiDajo%;;eO;C6veuo5ET^+atyWi4 z-vdP_N|I!xG1XO(7VKJC{;h zwsl5cb$Cf{wSulY7>vfRCAHOB)e5?lnqELu)NFW3^bsJHFqJN=JZ!1(#EqoLbksHC z*>sdZ1~(lQVCZBN6|_t`CT@xYUYi6I$lz_tjWCj$Ojikrwn+#JXF{Uk<#3_dkR$rBnVOH;zcImB6zB&nZaYz?<9v>h{z$77vb;~4$^9=pi9 zR;jBa+250D?Edbt9SGFVg}Y?Xm`2{gdQkMbC;k+(dR@Y*Kn8DPwZAJ4D;e(Zn)q`Z z_6G|4eWYblAcF@7B2Os~oHX2JV<W;siZI`d<*xT|Kbo}ia_5YOho?Bo0N!}?j=^D;m_x7M18oyI9 zcr@6{aZKD27xndgHBLeIPYPu4fVD`jeeKaUd{oJr^Z9ZNX5LeCaQ-1PexGijXbrEnlNnTpm28*kuwEry0PfOTQ`ObBE2u z@_VLtcHcDla;8ez`#bMFO@3d1Lbt_Vn7A!w`Ns*%0vX&`#=6O~thuBfZ{l}g**zpp zMPDl}!-lC=!t1DG;SZdWCbQI9??HeQb|Gzp%#N@U^bdT`K6jQScHaDp77Wi@_o9%! zTHSUUfI?W>ey+4>LaA0hajuXDE6&KTI3u5400(_X7nw9cMuocyT#fAiqrEp@;l@o> zFG5IJy(rXYJw?{TZ?_F-*Vp3H86{DlG3wnF2VCzi?RvV~D#TBei*;J*KWDlPt0o@LA89@TsXiuzQM3kSLQooS3@th zU}t%t`dD>Ye?y%0Rg;`*q-n}^jq<1D8N*l)`V2!T0=jyZoo$4z&c`Dae-dFcMB7Fx zP;6@=BHjXT@jG0(`rcXI*pK6Ji<0+kV%lew>E0}6Y~rsJl3AZWRWbiiwvIps50;|C zC+>(bekP0`2}2-*2M0;ZU#yl*Q=YvxQ&qK@%}fSP%`vmE)yCv{FQxK& zxDX|;ZW@3# zcMuLHH5e9rnbfk#{O3yaPw)*6R#Fe)F{wt($-5i>mi^*etw=i~MDMMHt$&JK@NKkZ?FKtVlY+DK_uD#koV3z9+CV2kF&I*1V5FO& zk>38k;8I(Hp*u~3Z#bv9zZtn%=cDD)mQN2P4tRdbCdDzUf9Z2F1hXm}=HRX_Te&`13q z0+b8=WsMif7~uFTjc`SsH!}lltR|ckI_D95NN-zm&(zl|gf4|YqY`w5ACyN=f5{G{ ztc0iYS>O5@#_=>E7&0i9(_F z%}#5aLAgx|&mrFia-5TDs~FF(kyZZwfn1|Pf40ym|OwUoOor>O@P&Xd&1tc z>%-6TJ*k8w7n^iMp@+ATbu7d?$$(78$W*3{2{^JIZ>^||C@cKyQSBh7x& zFirPpxH-p-{vDyG2s_rV0_X~bDW<6XDkkf`>T{l__U)?2v3i`vL)ve|*}j+N^TVwz zl#aGqn?_@Ns9~30ns}0ka()Fn7xDnpLw`fOtirPEatA_aEzthdw0WB?mTuuzbiNYc z>kP<-%*6ofm%v>)FbbMnb6u<8A5b)f;tdCP1NFa zzZQndD9M|r+w&&l_snYip6%?XbWA)q)o(k}sC{q2-<3HUWb;QC@^qP{?}FQTV#lQE zyJ+VVHA*PUQ`5pz9XSG$lF)7U99skB);W0w%tA6^StIu3M} z%T6k7&aYcR#TG>*AEhkQI%y40+B!`tZB|zcSiPQiAZcp+M#aQ>z~Ay_A>i-y(n7!+ za3m$|^s>S%QJCLb7{B!gAs1SIjKkd69>$%6`-0?yHheN;DX0&%4)h{FtVFuUBW~y6 zVX_jl$lyuV)R$VS_;0fK3$2@Z+kroS!jXoJ*;bg133HIb{8?e>IX7;>(fSJy?QprZ zV?c|~H(j7Qh|T;qSjw6OrthdWPWF8_r1TW!5SO;fT5Bh*ZeS?in=yanmkB$ck+&cp zwxGHn)vKFkVMNvS%q=E19^Jam>y5{We^a{F=sW`-jYrjP3uN%%a1s#nrnPoQ68>QF zh51CbINwG#^p0)>tQy{qyN4^83g;X{w>&!B;ASMxja~GupaW;qi{M(X`F9<=ZnM(! zon3#V$J=4|xIg0L?+}#>3wcfcSUoNIyHhX8-`~WBjVe_TSu20Z-=PX~mxb|LD}-EV z-5rOyr#;Lx%SR_;!4VQG?wA-cSDYCUZRxSYMEl-|_I)wY`*TF4f98W5(Ue?RzWC9- zXs=2Og3x_xd6DvYcW~dPeD;G6Nc=GhAAn%5O@T9k`FBw-RKmw8Ep66HGEJPEnC;Bl-R`?(xGj;oLrR5=D%G7`ICZ8VGOL_Y*9GScopBi&G zLVOk*XQ8$BDY;i98$EXDPsL<|f#0&b@mPAexOdquHy)*P>6N07csxaO&Z`_x8TPh6 zAe9H@(~*jw`R&bd`{hd{ekOzCEEv_{=H<7O+i5iqIKqj&IjTu+w)?!J7ypVF{WxiH zJyRX_jZ*vmne6@=MVI%F_Yo+6?jn|!=rkWurn1&c@9h0GY7w^PH+lsR2KSneg3x-5 zhu?ghr=23BK%<|G5T4*8WHUf_>q%Uhg~by4`05sUg{-=#ox}xMz4Byd8!yS>G#0{Y zX4^7nc|;3|4F`SNeOH_k7WO*1I@DWwja%0n_pcwbbSoukrIDZPJ&J}rk>5F!WMG1z zJlhq2hFFq38*V8dq6pnRD{2DtQx7V;M7JZW(gTjijl9xkt6P`*bQ`bkZj!enU;b%U zZuxb&&j_7eDpq28;8x+Z^ho=cc{zAifk=$rSvg?D-20A_V{#xtcn%C#&i}@>iskI` za^?IyE<)+m`j6br7kHZZC@#u*Ddhd8h3Hhy@`%dWa9lb2%@={^Db6|4#ZMY%x0^mav;Ce$$`tW;g%8{VbbJ#bs5>54Ch=xb{zs|?w& z!J4L7^H1L3DL`A9DXvwOnf&r)raV*?cXh+%;c!cwMv*&_VjkGpg}pddXgtezEVk7J z`FNer-Q1*&FIN|iwsN;r=F5Fkp;PWEv6ddVmF+D(%8L$jg%fEJD<`DAn|@x=I}9F< zfv(rs7LfYXuOm#a-S=J%H^bdi9++0&{y%i%Z=-N6%bno?VbbY5qnmq|PkDf&i$9ePmZQQKB6VV914RAMZ=J2+T@p>KJ{!{Rd@#;qa zWYg)k;4)}~D7%#}ZvFZ=>7?n1=RlbJ@#-z3at`Wnnk|#HbJOa<0`ZVSv+_~!t|H*E z$}cWWQTcM4n;&vuN;iWh&N2Ql8R8E&wp88?^;W_+;27GDEJI$0!maq?STt%wckokq z9A94^_4DDyLA!JlN4F)zrl7RKt$Ucb=0%DByx0z_N}sJwzzXiR%&Js_?MZyuu0E%4 z=~$=?8PwKyl)QOl!h6I&hbeZO0aiAadMY8y@Va4Fob^>Xijw!3wWHN=8{F=UCAD+m zw)zB}#@5D6wWg+i8En}S3f&rAzdrdYM=L4OET1AomrM0~aaJs)V;a(_mBtU|<#pL8 zweF4%-bGT}vULq9#DI6uX&$W9?}5Bys~Ucu^w->;5l7MGT_OOUt^KT5UdRV=TQih- zaX;KjYWsh23#eqqjmgrbtxYT_wT)$G{1)c@WTU(ee&4G+uCGI!Zgx1hf#guV3Pa)P z#Mfgr#tq6wC)rh^e(ZoZeH~Xv^0c;^N^AIkp;h)iMtL7+eC;P%F-zfF$pgC}-Inq6 ztiWXU{E78QSokU(c!tuqA=`mj;q>{zyD)53=JPh?4mL8VIPVY}{H5eeb|8P3yBXH5 zccN&ej{$`w+;$NS$M;+;?{SyU9?B3?&kEX6&#wkMkyCD^dNp`6?w%EYaUMHoJa#dU z>*W#biaXei#~`wH-qG2lECYe1;qQjw`sst{FzOLU0|H`8_eg#JPa?D1EBPn^AsRG6 zWIS7od~N7F+VwNo#kVScggmMW;VMD*eAfMO*-kJ z-VWrAEZ07MA^Cn9Ke_d%abU{E`fF_Ow{n`jbg{Z)e*IXAFno^Uv0*%xa%}`SLRuq6 zYP2J%%}I_8&{+0fF@3-O0g%@SIf%BqFuZi}W_Tb4>mvn)xl6+Bsq(WHtKZ`!BZY}1 z(Mu3g(zY(@b3j7LTbeO!o0+pDJcu0c@rQ^eJP>Da2ZGUC=bESE-4u-K3Mwe1r&k^u z6X9xQIAk1>GyaD-JyLAw~1yE*F@p;Ti)O+rvBu~7TYxM9jIbwqn;mIv+$9| zTeciE3~zKR{3^4T2u}j00W{=HYO;~UAX?z_6ZmpjTGGY=(?TKZfUz$PQ==al* zR_8R-%PNK;u69K1A~~KyBc<$(YEU7HTMB0km6re(Q@Q$}#(pZR5UU}S&6g_pjsYB* zGV`pj0(&mcJQZAp9NYd>nl@Kx*`*b>)_1;C7v_zOo)xJtbf@Ucb{le@e#bMj=BuzWIgt_|u z;<(Pv=o;Tag2&vVRLoE~$&=Z${Xt6?X6qV3HvzSu;9rNSNr4QmB#s1gtieN@qS{Nv zU`LWcm$SzD;UV?_>`e^pR_a>DMkwr*eV{UkMH1|RV@y(7ZYmMA?(lRB#W4&Mw3lNE z*x~qR)B^jb&IH-HW5cDXkyYkF%vyO$7*H>u;WW_*VwY8zLq%V9E0gy70ECxF%G%JHNN(l|MbT#&j&_<5X zRd64>D|`Ea56&1Gtd0Is;2E{rvcc(`IOQ^bAjA{{V z9RoB0kgW9t9~_ghQnhVpTsH+1dcqGC1;7rdgZn>=d(X==*frx-~OQAoykoj$cB=Zt{*h zj##lBZF}?blCX%mQ2V=;C)Xu;oMo!@nI6@Iezxa*p33(w-acwWc6*Uv79%8f1=?ByW!tG;LV$H z&dU&6IizR!7JzmM>VRifN4p;;T|CW(edXI3`gwXCgXO|V`M+O0(1%ik1Itb|s(wIz zCa-vAZ~J@5*S537cfcQ`fHu-?r|+de#^(d{>wk=G)NwV&ex_v;Z7es7BJGlzjkpnB zCt04DxfbrOjA3_<)@S%I;_NL8nweuP+FUv)UScaOlC7})MUyi9=eYeAHy?{TxC`Af zDN}HEyq?Q#!x^qWt8F)v>L4Xv|FoSrv6uQs==pf83=x>JUN)XTPMQajkI(HXVIi&fPPr+FP;Z+|)_SoM^YfL(&v#5Zbo7M{}HA-g+B38}*AiumLU-2IX;{O`|0hk8azFVAL$)f6p)ZzpC`q2a|~EHqhmb7H8vnhjIbucc)T563&9qrTOC z1V2r2WJvBPl0#G{&eqtIh;LffCU9~T z<==R3&$T8xhN08ge%1}^93VJA zvA7s%SLYB2!w5^&Ig~DzA>bTmLh)F~NqtDUJFr5alu&?{cNx-wVTBz5lWfzn%9d~k zBbHm`+!>VK6%g2@I!Fv{HDZ4u%qknFw6xAs-C$cy)`BffzdI%4&?E8qgXrI^89lDE zUy7vh0PAdjuxP!zyEGeP7tPcYJAqqk6*_8TYs?O&ADyxu1oOu;ZXE;9_DyqpK&cKXYBfEpmQMwr?**Yy_mSa{)CL`qjIj==%1W_bSw6h=G2!643xb zmrRxMrBud2Ke9DRxT$NnwJ9Lnlq4MRsN?KWcaCF592Yo2>Ot2RW^Jo;7bfkYbH0I` z>6|~vbfnNB+8Lkj<6yYUeS%{5Bz|^G$341Z9+nPyr|ccmq7iqrQad;pwaUxBe{Vy? zrrRdGpD^Mn@L2-+qMf%PB19jOHV?P4rYeAGr|Srany&gINZ_*SPnI5bI7h)dp`TK6 zhmq2f<{9$^NhH?CIf(B>DO2ujK=;?>HileEwkPD$vI!xV&+0}4Q;`vdVOjN05?OSP zW$ZYQoqHAn(EvSC9^a2i6!S5;>6#VdRtG1wK#0D?s+) zY|l2%$;gOAqq`RMzw+;G;xb}xVnqqbT1EOF#~=7z{wXeQ@rCbtGVkWUZL zm{Y4jTdHK!?%s&}P-h?fy5}e?UP}uZJj3NzZf}znVwb@4UR}htZoSq1CWAT+29@- z!aCjWhVG!C;Xj5Y8xS#J#@2w1i^0l_?5G&A6A9QC*^mP(Dnhj30VH?MpQ(-ZgLnKJ z7ofu0l^sKa!$b}~Tr@5D)*@rhAgC|Z7-yuz5=`UPu2z#^xT(&Y}wXSUI#^vY5ev0lG_VJ*XbNR zT6*ZZHmpZ>Jft+(UzHUtgiY@wfHj(t(?s9MUkl_Sg~xscA><>8w{{gCA#uFBpl{^@ z_EGf6cN`Dm0lamq=n)dfI~{4VeI_@_A0dht?W>TZk!**>jupiC72_caH-w8kH$*s- zamln{TxL`pgv5DKo}np6;SmzYn=5IXSA|DN91nA2NZSTgc!b39*f+I(avr6HWkg6E z?{&eOUxi1A;$^KxC{u06oHLO_gFEBfyB{rQ@0qC1IM@N3907NkiP$?8d@(b5-HwEj z{sPW>z&>_>aZD$ErJtZjKa^l~;mEs))!4p3T|>3 zB9>@SF*?T}LZ&C-|1DH8+owhh{b`r5^^*Kc^}49OVW(@f-<~!6q#O~B(^G~=6VCV@ zfM_GXw4UFF^r0K*Tn0Xes5HGbR>DfrgZb2!#b}dQUn%+3adbllbuMMGvrTy;ol8SH zM^w>K0y5eXhBtj{kig$F7)Xg(`Q9C%;kY2_dQeRxnfO70VGE+kdM`5>XrgIgLWuLdd-nuB!!EF`UZ?Y7W zozb;>Ucj8vyq(_Bp;Kp}p~5&x%DNc%XOkDq!)^(pvT^1{6YmH?0(TAr2ks*9l9z)z zOTPgQ3_bT?fXcfAEd?X&0Ta+Uoai^>Gw0J&oX)PuEt%|Ape7(VY~=ZQTbf`9uAI!02*DukfYWae_wR$B3CdiGdw)W@hw}-r=l889WQA8q+&u zcBpJ+()?4heh3mXLXf~6m^TBJtqsP{h;bM(2okt+1TduAZIup(&l1wax|*K=HM2u{ zhrYZx1vZOUEY?jOnC>qwC&Kl{#d_lUvPXuaqd8zGJ_b#X4=(rATzd4>Y*3+q)U8C zQ^z*7z1+SEkB~T?ZYSPqJA)Y{l{ zMeay8Dt{xBlSF=#eq0yJ=mTnX*2VrByvFIN&3zu@I+i?lCf7#>I$n~lias%J%0WNM zv({Eylyy{br6-nhe}O1j<5JoW<5B%{gg!Gj{Ts?KJB6uCMKs zH&vWd>6{}@ij+4fPFVexx0yKMq6NRU_n{mqr$=i7b{^f7Ooy!XqcQNF)MVwjp2)HYIz_Zcy z;6!J9{GUlC)mUBxXwy=DMO||059-bz2v7S0qf|mL=ScjR%Er2OB5*Du&Xm(2ucf2l zJ;D_9tzG&q-Hfrq;9LWbj`}O81@c|`J-BUY6qd^01VW=QTHc>d=V*j=kHJs*ThaIT z_};0z)#YC?=j%0g{n2m#EKuv;*Fxg$ZFGS_R zQoG9DKstB>G%uJBVu43USgCa)LRm!_A8Sh$(p3~KDR%cHpbgR5tFUmSm@u}9JbwzA zsq2HO1eZxZNP(S<5JvnkpHX44NO?FfBS<7mYAQrBeYJp}Ybi-u5t|mx3O~&z5Xz`^=(4_K@(0?0INJUi8W+T;_5e+_dZg z7acUwj7Lbp@fa75;d2neXZ7YWoUftWapt7$ynwVW#Y}Dk5954?Q0HV+0mH`nupU^a zou?%m!*sB|-i~x!#(bHAe^zOA^jk5JHfaDefp36Bf7U^@!eM=X1675f6Lc_$Nhj!a z_?1p$77-+H2fgY6_xpgg$aHq2dpg|B*_`tVkc0gT;dFL#>810U#5JbD#Fcek70A?x z9~tj8qj=EQ(8o4b?5=jS>HB1@myo8*nWmIaZGl5ZIzcfj<2EUu3d8vm$Vz3sf&}DEd1*8#uR=N~lI}t#aP^>$ zv1Us2C^^uN7ae?AwCXFzhz2>X2Ovs~TevT@24oTURCrI?CZAY0($*8;a-Otb-VG_V zD+P>iV3mdLAvpsH(qv;qCa;8T?`7gGt?AXCZdj~mRm=t*=bH#s9ex)eIcFlg6ic=L zsq{ae5pq#Swg27pKMUcdaKvf|SQA-bx-!HZ}z;WA%#hxcJz4HgPglVJx%-GmYU^Y$|F2d zM0DZ?@JBO^^X#w!CSN`ja*xsJ!}yY6eayqLFlmd+nW0(dEmXVkB+$Q@c-Vek3E8kq zZ@}NA&caSKJEbd^WI=%QHhih$neH;)@@M;u7tJzQ7-Z|@O+wbjZ($1ta|JKuUVy|a z-ci6y#g-=+JSIT)HDH1i@|M-}KDsnv8XKlV5gmEinuD8|_!;1lcFv!L!}c}DSg*tH zDx|6O0h0tp^&=c&=Umx<25mWh%10xT6s9}>0l(6PEPG7y40!j0CpjCYSyxlA+3}tL zFw6Uh)9z^qt1Rb4^)(~X`%s_c!gB8;AdbQEVl=<`W{EKfb|oVx2X;$ZZa-+v#0YY5 zNzY)$#TV@v+0D`(-K5ZzMPt;SYsAsR+&qBeYCEw%qoc#UI5?NDea)P80~k$FZ&eNl zpSFwYl660&(!o&rz!1mlyp2FeyqyoZn1nh^N0QBQCqSSQ?*N*!J3OV-$2E9Q01zIC zcF@6WLAz|t1+=B!pWq!Y$K@#pvv0WJn7Z|_B*Yo*a6 zsHpF}IgJgAaRMT2Z!KZn9Jt#kXg=jjH9G`B(8RL}OJco4fav^{3GiGv!(u0##jccD z?7ZM3zPf0+7I=(UP6QiEmq5yh+e^F)|&%aPnL`6Qc^db!^u zfnJsV?lbeKPkPRI({kr~;4dpGD&8qX{?qQ*3-2F6MnXo<))>8uY^-^0uMDUz$p7j##k?fesxv5N8i=Jkz@tK-JkBF}A~B%{bpUq|x7XFPE~3{oL6 z*CAZ#bHs)Jw(}8wD@%YV`s-i#DqW7;7$HdD4%TuERD6T+2{Eo920;RMu!C-(a;(Al zlo(eMgCK!B*o-t#DI1J`6XPmk5F~I1W6T52arh}82UynUZ>3^Fd=`cvNZ`&0LvWi2 z4q|62&?NqcXv;y^!M2Y9=LGz;l)eCvvqrY_F^D*TB>g{_MYW;_N4r=!Yd zy<&UA;vn*Ngu~5Ev1}^N6r694#>om!hVzV{_)is>K?Saq%} zHM!CRY%KtSD*TD%N|X1s@ePaH^Rd?XLI4VR=^M#rFGd^%Mase6Q(6)F`0eOExICH*#p|Cu3wk`L% zCxO#8HAb*2OKceP7Q@tRT$k0a%h7}A;-weTfv}YNt|U=#FCnMM7g=TY3VOU+Q*fi$ zF=&&6Rc6RlDT2#G|JHaBWV~ZROf#ijlhdxteWTonMcOWrvM;yM0Wg>F{yEBKYrN4u zSZojYNBB4JxX`V?!4rpng73M&#crMi{6)aApuyTK24~-u{SSb#eq$LJO}W%j!HkKV zC@XUC2E2+0sN2w_giJd^TM4}jrIGU91LmmnM0Gx0;z)VFnjG|6q&gTP2v1(t59w6S zF%_egRY0mTK>~M9MP-oEOT$yVZ-r@C~TPe`f;jlP|b_(eIYzJ z|35*Cwrk)={a?@T=SjbmH6;k=WRD=wwB8$!l*V40aPw$Jw5mgXEM-^-l@ z)CVREaoHe}FK=DYS5%QV;FHfp9L#U358^9rVBJD28UTi>_E}#5()F}K`{{+lMwf$? zY`T0kIg-&ItPQ#bADBTQtnx$rh^5g-=@Pqqzy)MDejmCpdGTxzIKA)Pg8#}FiN>B~8Tz%O3_n9VDuFbI+@-O8kW zAJJ7VGr^~Z!3h$$24{3i<3gcPx!eSqCY*!R2tfiz1gjJJ3r27{A}IfWfyBHkU!>u$ zFyU7V!xL2D55mtfPzNh42g(;~pes$F>Bf76pbCEwXuv=<&?Oq^Didgi@g54T^&ums}euYH#rQ2w^hJgw))ysGxQQNl4xs{NocL6dn@?RS^> zF)Ql%F~!w>Kb82Hu()5!+ANTDE9L$fLX>tJAy_kpkb0cYvk&S^%6&Tq=Y(xPF5wl> zLi7$2l?R@zZ?q1lfKSkTGz^QgA0G}s%+(L7O{oW?u^OBGP2CTbavzZ(xFijo>|pYe zS`??Uu+2XZuA;OQ)VaD%Oa``cvfgSuFvoLWU@Gl?0z%Tqijto!Uw3q0Cpz0-g;rt< zLsL&sw@O(>+{FA7y7CUl*8fw#NH?ZsU-Dx}cdEly4Z?2W44G{2w?z}VyTm(oM(1&C zK|?_2-3gA}PZ2O=TgrAykf*j!#g@Q!CZiS^?4*va#+~rLz{NpqRdltERMVXl!(DEd z?m{ZcKO(24U($JP_^dK+&6VEbgYasz&( zq4*j|mF@=TBLoTDITI?%ISW5Rr+TMa*87;0oVf@qDA)qK2I=gCpO(@eP}^D?F$Mk& zd^Sl>J6awQ%tLNxZ5Xb>w5`ztcVVzj)}_l?$qiiI z%Vgx-UxD**t0VF_ZQYB&KPN5QX94hzxO;$PwliJ@Z#&rEyB7GvQgA`by7vMr>y1Ht zUMGHnJayodLJq#SyMPyseTN!?owxuxL@uc@QZAS}cZ{)==iwe@b>k{iC)9VUhl! zF5M9P-UfbcpP?%^;YVa^0r)QchO$MFz@4+98#rJ70Ki9fqg!r-12lev(UA=iMz>M7 zAz{gj^+-LHEx;D zPBx+h8e3M|c*a=mr)?_vuJ%*8B=d2q<>@ zgY(rh4=9CAkd4k(_`w)EOC;Cfe1vAJKN1mfueX4R7SQ7>Db$seX2tfjO&ZPyxDT?+? zQ;_UMNT#;~DCszuki&@bs0J4RD)e}mgTgRu9e|K*k^ztw_E<7Wj3#N&#qbe>9lK@O zw0q|OAu@+>8dhl`a=N|IyD{m35>B-@ceb|__eQ=InhPz<+VgN^+($vCeN1r*z!({P zj9;xhTPyFf$Bg5maHCt^P2-3DkHbHe4 z8m!QygK*yCN!G>{8l_7vedPAB8f2UX85ackOEO4XVQl3NQ&jIkVoF%ilOG{S;M~}x zeeU*x(rZ(CZ2`Se*@i9&Mi4(_&W)Gzh1$kDAMvZBsnDTDgG-~KAMlR>ACkiZIgp2= zraH0c%8V~+WbGPRdobvzz~sfqUdw8Uf*;MFtwnZx1`!upCP2Lg>!QQG?x2c7x zT0bs;j|eva4>LR7i2*j=#ftX>fbt*s#(D;Tv`rrknFWYmYADres<)Vclkj6Ax`2Qi zL%@{6RIxjoyk`JI$|63e6{abl?}gaYM)TP#l|+V>DtA^3BtZgKf#gU~`)Zmq)2+g4 zTGsu=Cs=^}TGlgA)-&97nTIoxsn4?x&TyYVwUgC1?M}hrit&NLr3j=`fbFXnR`)t* zAdT~p$^AGXr+uKaeRdIFR$-tpds+J|Aj}6sVV3)CXe>FcxG+om-=LE%a*P@PG%CSK z(}mfn%Cifz3j?UiT-F5&JBLveW_o*(-0IRoOV(P2>4lk+l}rk3^Zd~2oURh#>{mJL zS2;w!vUCg6wM?dYqe^W`VVV%qjGEKr9nQGoMKiZBSBvH(vLr=4*Sj2U@6H(DGXgsL zBaDe~dvjxetqEAfJ1_$p`vK4?2W}b2F+@2f3^S)NH;|X5fF+n(qp*fD_2UqG4ewE6 z^(nD6ynpd)iu)u=(}2dz1ZYkIG##M0psyjV2jU9*W)KXH3I&xes;=#87S>er0Cn3c zOv3jX-h9TeW+HG@$#Irl)?Eb4z}ppQdYJTDg|&3}{Q!W9GLf(ZuJ*MJ{N@n;AHvr` zB5;8eZUxkSfzlnv3g$WS9 z-9G1ujDgM|VJWP%cRk$ReK7ztyUE#xS~Ng;lqes@Q1Yt-Fc&`tV?F_q2&BD30SG6Z zPQk}=gSr$SXm(p zn#~IT2wxxHT)4`4CDtVV5&kT`(P&w3je@7)i6LxjUA*J?`{H{p;GC6>)8852+X0UC zh6#L}=wV%g2R3Q~{x-fzA15v+;4c8aGvKpE!Jma3z79An=L9~c6|IHvgL(_$>_cn| z+$oS;%jTuG=n-QWh?1U?)+is?zUWFR0>@NrX_|}|A>KR4_1zoC;xUUN>x@iXI>^QH|@ZrFpH(V115$$47? z7)e*oJB8nO;wP#J;Xn_^$gmvL`X%`k-G?1$Y>AtZ#xG!hwaPB&CU+&=E!-BfHCu^v zV{RcDEnKm;5$duM-xcattMF5ZORF%)%-S>FTL3h=n*bF@oYE@C;mzqnHr1GRwj;S5 zj$+Y@*`!*0DYZDqbP{Je+m&CM=57ZBD^0^$MQe_G6{Ie}TKSED_WR9A&+GcEZ4JE;NtIeE^vK*{H4olFWMmYGi()85S|w zEVKmss5`C71*Tt^u{_A>-7JreJdP{fgqXNz`5j1PMkKO1H#mvFoF0wVC|#a>qYR}% zN@ebnAvhqPab-XrS>p90L3S!5#UQiXB2?&<$Ut2vka9MVob0Wzar|fBXj@-NvVL4pw5Ck9G0UYd*Hd#{~1i#%H4WI0!zIf{zjM zD2x`eZH?~UU~BLkCcJSobZIO$PUsNwZaHgpJnP}v2oH7IFdj^GSjGMDAcl`o2g^H0>CBAbOrZP6fX6af3ZXOw^=nBC8a1+V z<}HiQo(q*Cb{jqp3P0%e1AL*9#*DJG_nXl$>_*e2=Bt4V1bPDq!8{KwyVx?%FqUa+ zh{QZC62snI9)=f&9)g~P6jAY0~J*pod<37SzC zwk>RLA@#r!8<>rVSirW7Zp(=m!P0OOD%$h)Gn}ql`Ym)+`5v%i`~3B8S_?%t6GN34 zRpqQfx3dd=XI+nB;1NH zICM6g7|)aVo(SWU?-}k>UrMsM+!IQav^-bz> zD1EE(CVI2>Rt3OF(s4s0I-~&4|aM>J@o*fO1B)BnO8C++hesFm3=wT8z1L z*Fp@x0RKofitQOCh7ku2D+@CA_%D>UT+{bE6HU5%9_#}8qP~X&aKnyd!zAtolWeb% z4TY?XeY(#ePq5S{hthW&43(d>gn=Gtb>+009C^W;iMH^Pg!?xu>f-+Gn<6kx^Xc6^|DxL*0o_>;M8zDras-N%t96yD~0a&-prbLs4NYFeff=s4>qyIOyn3k zbt(UXvGQX#>386^{2L&! zE}F5`dm#I^PiR!{jGxq3pOmZp=CUsPj4txqDV!j1E=0WLhepM9uf#=Y6oz)!L9j)C z4ZqSMkWG%G{}Cuk3yV=+#0Sm`^aWG0|XhWAn*30j&HE$TAXn5K&$L$_POMca{OK^1Q+L zHZlG{41xsi{E*}>H8gqsHIgF?egUTx;m{xo0eib5Ft6uM+cG503%fD<`y$G={1ly? zXXb%ieh%*9JXl3Ru>as&PEx`Ev5;>-!gPXxO=soz@RwwKhfK=KFoFbLdBJ!t3OxxD zxUBj#azi#+WMs3|`-C$0Gypm0QT)mYiI2fC_&JjUHS{<>Vk73wXq;!RoeaZ6_azK; zCX^w*7|6Q>Xzo;03pte2K!1{ey7$Acaa(KT*X*`pM|R`^AsCrrJ;SB+Uw1`PxMA@El^92JRYm%WT6pqY4yFQ31*&sIWpV4&PxR=QBR zL)$MVfQs6=44S$05`|Xm-5f*$GGJTd@z!#d8p8G^wahRCzlbMYZ>hLsMyu550Hle$ zleDJ%FNIHX>zoXuK1P@AJi9&o3!Bj3Jag|nWR14+xcA5Y5j&Eb_w8QKUw$9}zzisP=nQ{75VEV|&f>Rv&|(o`~c9k+l#eBk!hYlH+D< z#{(>fJv9)^B5*)se^x^zgpRoWvj{ z7elDN>#@eqwZyKJu`bw$kFyNZl|P|?#Y#9DVM?!o&~NMJ9}UdRw=$;H+bI*@dy&Qb2adWXdI^`Ga+I7aU3Jv&TbNXp2*JAm-%w;!Vj+L;F#V~7z?&% z%uaJqXK+uDvOMVBV6}kePNO-SX?Ns~@DlbS-b9xzn61gV-$x?Qww{ic_viCLW6G5v z=RAa7r&T-;rZZw|4Pt{mFt{UQOKBW=6UU{=IP&qTh^gVr8Ap?Q1>^V|%Q7CvT#Wznlt8e0plHGLRtdHwJZkfx|59-Fr*JPXb4a>S(?BCMKitpNe! zEeh=#O5l%Jx>BdMM{qH`yc3eKU@u9OZy7^^szEA;EFQAF=NX9dXB9`7QEg)k)41Lz zUJRIAkI3Pg$H_oWb?T9)!To1?LI*}@@-lvr@;XR@-|b^@;Syu93u6r@OiV`VC4>kz zJdXE<7#5$w00c^~G05Fi$}t%}^82x6(iIQJZc(@I5x0Gv+%wB5kqNx-wbV~H45 zEZhzyC~94{=|p6kT9+8+(4uO`$&XT0)INoRuHK8PWqUmFR-sMnaNj2Dbz z>hfx)h@wo5SEj}*Qyqq>P9v?tRL5whI+IM{HYw!CP{h=DH8RJWS*%!24NXNx#krL0 zhP($yFNV^JMgO^B2U7W}$qqYFAElkc#VWE2{ksNPv^4lu1CRpC91P7W=uB44*6x|P9aH|zf&bd=1y5NG( za7IbP1+a6h1FYVPwnyBFbl_z=?r&QsG>ko0&%3j&cN)h2)3|rG$9_x4MQohTw(eub z-IN;JosxFVw!Tbtj!y^f*Hb&Mmu8!dxGqR{UT@&vP4E1;fj^SzT#*rc+Cw`57cB_p zsk8~8MG>wSq(T<~>&_PkNK}-rKzi~r+GHO^6)BKjy|`*ZWH-?kEFc){!Ge|#9uLRuO^Wphu3XMfh4xB)!Z#Sc7B9PRlmJ^!ShCynxq3~rt+^fKan zlG$RrpCWB3_dRhArlZC2# zAV>!z`eNfyU3M#5jZL=yCOESFxA0rq3xu2z{OB0-RZ#K2Wje(m^X>*=+m-Q}&l$$u z8fCY^8$w!TG{ag*x6;E}@eY9MM@reEb9!}2L)`CY_5LXg0n>&fza zfVIl_dz1S<+%1jD4ht!mOO^3=){n$os^MXO@__O4fx&}?hu2~}(9it@Qi*x1e)wVp z3Zv>U7QHbGko>gXw~&r@|B2!Qmb6fE=>ioItO%+Uz#VY)ipK0s1_?>5?e0q+$gyGS z003h0d=NFFVf>UngVysSskonxOF&?7M#_0eitU_>Uy-p0 zO~ynxexZ28Q0&oo^P{x9ALp6nW%~q0MEh~<)`g(NxexLmwpTYoJR&r!F5YuVJW~d- zGX5JPL>d2`tVkRz1C=?|QqV z%<&<-KGGKlVDZHvS;+mr_zHG*(N>V|hUA|hj2fq zv0rcv7(tvL!b6j=El9#Rbw2_GbJLt=ZfkO2*kE!|IW9CV)6@X|Plk(@1~;wj91JJp ztRj~~;*dM$Pq5bHRcmgG+Lp9Mjt6mc#b}FAYvM?xGqKhltBFd#L{gSJKSMHbt5%t% zhO_ZFy^@oxZCoblX`Bb0j>S)qPQBDH;ky(~bAuSjr72L4OY|%~2_Kl^x#(C;$ZSUT zLvn16)7i++TbQ38q0MoySPgSa91Z&!V4)yz3~_C6@GQcV?xhb6s?`x$xsgR8abXnn z*Cg~WWR-IhQxpz>nz_d382&zn#{g>+LUQVjZ&_pG{1`sXx$!bXjI~o-`4N)7KSA1T zW&s9i&%yh5r2U(Kc3x;3wjM}?jo3n1+qwZ^pO?IFenh-a!M=`yHCw4x9RIEDej$B9 z3l2H;;ENk2aE^B&-GtnI3ngFN1tidhkHD`zlS2#4@iLV%7`7%6xU*gaxINd2>1z%L zLo^#NXwRZaRk|p+_C_qA;uzg)APky3IJa}dEAWwvEudhUUq%)DJ=6S9kmhEjIh!fB z@@1FDFb8;W(!)#?3NK%7p^r~A-58vc)e=K9z)8+_t^uAa)*);@BnLqsNd%3`;!(n7 zuv_LLZ$??SWPL^~%LW<|^f97P65M~|ryrN6B&SieB8&iQBu ztj13Fb9{)*w-!0;7nc9y)p6o1b&Zq^7dYqoL^4*?ZjF{J5z;ckgW3AD#v6Ec&PVM* z=tRt{uVKtj)`%GgB}#H7<_u!~?WmYDwPMZ$F{@_~b0!fpO}O!4ZDl!gNfg##qOOX3 zrYfI6Nr;7gE93kR@@s@3fxBNYFZ0En5D1kU`(>D&RGZEXz;4F<#VvBnrIkxHMtSY7 z1e%zSfPM+L?yE^jA{IO&q6nRhI?w!Eup9u`4jBux(AFO)gHM4t=T62UCfr<_qlqjd z$*oN(9X)Px8vt!Y|03sL$?E_sP};QtQ~iA%7}l}p48}O+&~=oG7D6GbHAm6&z~qsW zN*BWcs5PiUii(=^5V%7fOo8;!CcyPBS%^L(*Dc{N>rYMQ-NwwrYZW2R@-;kaSFz zqMTB4H`X6ThTNs-q6P;1k5J1i|27$N{bUfygUAR$0(Wj_y6(Ua`s_DuglXbyf#fZI z5`DhinK@Wmhc#+kjMkiUu0^y7y_~V01q&}qyn@Orgn%pe$D^+e{O01#K*`F%pw4|D zIoQH)56deSyBIY(fX;Ic$cF3;4d;M3u|B&YobTh7gwF&AlRQp?n2 zi7u&N`$Cn6K7RqGDMthnZ7S_B`Z>+W_mqUT<=1TiAVd{AlMM!{8~P|KJK5k%^BbW^ zTSiqz9B<8y&7#r}V6xb7cp0}KHn7yE_{Jv1KunIRrJL6gBfql;q~v}bAmqm}2m7-s|LNa*PX zl@yWQVB9I1=d@C|`2dPA4KmKoFj&IWCFf6>uPhfcFG?dt4NqyQeUIKi!*`x7Uuh%i@ zjNwWC**@EUY15qpS-~XZXT@_Y!B;SUOba2&J?$$ynp2lnFD31>b0_pd?9`D)!diMD(|hN`;+x4Q*6%$HP0X;;WfV`&WN#M=6_^>PS+b8w2 z77cC1l0kUl`|KL~qPt?>RB1l-*D_zU*2?UQWSf>jWDf|lXe_&dC)xTEaSF(!5rPEn zw&Ani&Q^L1(#u4`+SL3AK>~N~X8M1HpK<{(+xY`|n7tn&h1psndH)=M;yKythj>rZ_Pn7I39onTZ zNt2Ij*-M>ZX$izA$ndwqgx*Kyevi+{@Zp&*Uqe){A-z^g>(-Ia;V`BHKye99fMt9s zU0@<&>Rv~3N8l%Hm{@jf!(L~ey-gq3)_qL*jJ}oSemG1iQ$J@cY$dYZV0_S5WBge$1k=aVP4 zVX^%Vigd{q0lJL&7NI2(cSeeX9Rin&Rh;`-LchTewm)goFi;&^^-#JDSZ+77VRjYs z=!_52?lK`83+d9824C0HsF&pKf?wn4$>>CaQULDM7bGFApvP6c8+&ZEH{nx4Q)Tdj6KkAQ;s7AucuwfZK<_ znGtYF2!z}l%qtCWprK1HYwI#nZfp-3iJnyLsv_`7opX_B{s-0Y4O4YnXyc< zi=`@rUg5ZU!k&<|9Jc7f(e^~tu1DuWn(9Rr7g^&;8?h4!75goyid1D^6_@I#7B0`S zcmb_jnPu&>p7IVxzHuj3c=6cQi1{HrV;~Z1k9vw1AvkI=EBol?H!MyyIPB6H$k_69 zVA}o+{K_SRjI6jbh!nTOPi;bBX%A9Z*gi^h+_|ky_)JnObgaz2&!R&qO9dc?y{6`y!w1 z9o`K60o-JVy8w}!&*S0U2E|S?Vf#dLH)epTa1p}yk?+A-o(2~He0fh9>SF7ZSEHBD z-@zwAQJvm>obHqwwJ8}BfA0lTPliS!;D;fwISSskm8pZe5FD7)!-L(xi<47M3wV0+%u#%|c~$6XNe- z2!aHzQgL<_e-jLU_amt*PQXu?U>;}{OB=@$N*7lVm}m%$kibU&jli-h0+S2@j;gO< zc$Aw61&S~~^wJlYuHM=+|E5MPtR8xm%bwQtRG!dRa_zv=VOE_*uHDh@G z8NK!v^|a5L8R<3S$NuhUKi(^_H^PH-s5iRGtkXf%sywCwCH`da9e;`lZ>{LUPo0E- z{b0T3LMyYGMNF%=v_0}+Nyt0w4)j0XLq5iN*E>P6M;v#8iatx;2^!caqDRzFk-0^V zM<9EGb}!kpXMTkKQs@46{?Pl?YgYDy%tvfXn!-82@2tY_(4-&dy^aU(@6e`7p&!9k z(ei!?EHOQT^&;@;l5uOxd&+nPYc}F5Lh{+tGsw>7lq@f4v2Y35^Z0JHRI8z{(Ip$0?!O!7iZ!JRfI`!E&|=5m+%cUY6E0a zc@02q9}T&-rzBSVl-{<_98fDXiPbGp7M~L;w$B`r#T4b)aIuN%8QzRh&c{<6R9f_s zH5TPLaDg~qwTSl!acKAw1Nst9G#8INzd1t}^pFh)xS_ zDp1VBLZmyc+iE7&)Ds&gzOj8ZOZ^~MT2>vR%O=Ksj+f@ElTvY5eE44ys zacivz??I*=cmmpn{~=AEqD{Hvn{o+_C~BK5>;kOfZuk)aV{Nc~Rv6o7eX)I37u#oL zaXv@MsaUO#Pl{ESiWTX|svSrXy;Q8e#*ntpS9wFa{rUJ68q}yNkdvA+m7DeFN&PpH+w{sVu~gm>w-C ziPG)ZTRuXNz#SZ$GT=@?f2@qLvvhGa=8R9LI}yN^AcDgYL1T<|fFkMmEz_Z`Aj1V| z5E7CG^1*!7%p8hhp;I!iHHhUT#L|?AMNme^LSPV!_y;*9Ik5~RH2DF|YeoUwNk~>d zSd!dg^(@Z=JvoNY_UY7s(shjPDnJ1GC5yIOWULs}Uy(Phzu?HW_OOO;)%t5&^BXqw z8>IcWt!o-Kd|ln9UQ3(pQ)=S%M9=rudY$xRz1|81rS)3ny{k-l3&dW9p7pp^eXc2K zQGK3mW!73%eQvI*&$}a{ccnf{9wh6twoA4MvbH~(_u5ct#naYG#YCGd6(0-3?Xa|#q zHgsd4qqW?OFSeFj!V$KXv^%xkeV<__24S`$a=N@VUzzeYe4*XlmT$ZKb-qYxCpbb% z>~nLziZ%gQT91^BqBL!?`bnF-e%wE5lT+5lNMu>kNk*yr_@?elgE~c^9}kp*RRAU~ z=7Ec~lIgR3Ce~>KZ5M4tzPt%O>u5WAx!V$HQ--vCzRH`^?Qel!(RPd)+Kv;Awl5)S zX*+rZby#qu4of9;ufXzQIlWgIbUw{us%kn`W4p(I$w8SW@a|-pCt~iFL>HNVLBJ0X zFhKuX6?%`N2X$BSE7taIYYqRXR@=)M!y+2h_9p#UN4EnnT1T~9y2{L@pm?-!rUJ#( zQM%*pZp}Q3>gk$RX1!I_(+P2L5t+quQ0s3}PbIy{daAOoS*Mb(qM?-`(blpft@1{3 zro8bTmp7KeJ9s7lv$!dKMBZ2nY@Zdy_E}GCpVh?nSxFq+&l5=CcKEC#f%H-d+@2wA zpRe)`bo)EvS0s?kKmwm;q`rixC4uw^Bv5dIR)jn{??G}poMX^M*3}Xxkd!xO8^~ND zu5L+q@xUl~5>)ps)BF!C%tW9b4Ya1P#|#LLo#6Lq$tNSKC!a~bqV9K8P_c>56#%jdC5OxIPwjg>@s*d>r2XI&&W)ciP)&Q6t1!~}7f z!9dKkSJKA$`&Y$Dh>0_73wYagRlN5ix=Yn|K11d@dtz3s4Vf_mnc?gae9Vb|%;d*@fzRsEhg|9!%RjcAtU}}) z1pf%?y|R)KopSc`ZEkPKx_e>$jeBdx%JwacMvzUL|1r{1!V(y1^S_4#pru~I7hCEw z9Etd}&HpFEY$9PYS?~Ir`go7+1U-xd3-}f zUy0{y=o%e@=L$UCFiUZKymb?vu`nbK#d9ql9H3`SL*Om&T#e^ZJXjZQwL#8ZJlErS z84uRfShMkLhvzUnr{dYF(Xu|rb1vH5JMk2M$p)CV2=m?f5Jgr#2rksnZ{sD~R^TZh zpO9tc@6g-!`6~N#`^Vx}6hBi}JQx(=PvoxMg^GSC6)af05&e}gMr_*-TAf7*z*eWb zx|c^UZFLTY3&ia3f}i<_2ZD zXC7u5b zESW=?`p)v9c?8fF^9K#Z-@Wb_!9 zFejKy$P{1tq3MTAeTd0NAV@A#x0O*5fWu!oB3PYW^HvAF;#R`Q*lkA_;AD;XCy2B- zAUHT&Fj2^jc3+bsokXOFyCCYQfInja)Bd!*{Xrz~e+Q-5(uRHd>vB^%n8|zF_2O)p zg<~-90qva^qa&W}h%v7*vU zjZ-A-@k~fUkjgiZ%JLDyDt|*(*+zdIk8pW`aM`n6m6R2f_GHr5q)e?wYEz_tqkRaH zvU)XAyCOYLBu&a%)kqzR#Fi#5)In0-Vp2Rw3V(wNMQ7JM=6sQ9GBu`}xVC!5okkJY z%DM(sjL^%Fcl4H^eI2N)=j-MyT#{oq+-k2O;hh&csByd^StQ;Q=m~cF~nq&GY$H%}0 zj`biq;r$Zt_tO({U+wx!B*~oBbV%0iSj7JdEcZJY2m}#MzekLq%h6&Gy-$3oj~U zx6b9Dtk&BT@X2~xV;YEFT5V5+3)J{3f1hsubo@&1guI~Ea!SO7!GtJB<;=_#y_DsX;R4HiC1dE37{Ic}Eb=8p zEtcsKuq-&rvhAM&c$k@|;zKu)1iB@WJH48iK($DzLAB_4s(V|*x0`vCaSg+ZRL2+{ zf!u`tAhA$%!m$+9A4xyz52i=;hssG;nS~UHiweueK%v0!&AQEZyf)S>rg&|vnJF+- zG)>W*scr3IW%gLrIPTU}^^W6YpGm!woJ!U^9h*>r)-ebbYaOhxeM+^CSZE39sD1E3Nj#Q#=7btXNBd9&{0C zta%e4$zrbS>8NMI8(19rkU^aCSp@j}m0J56!muDXcKt0p9IYsRi67e=5QBsSL@AWd zk&x%&SLz%2EUqN_2ZFxds?fV7Sw)T+7w;GJO;&~8qv%%>ogAT;wJP*pML$9?PXuO? z*9q#q6RDwsf!fcja3(6wT;fc@kGDc14D)U2LFm%ynDMbtD;zUs26VE8PSzD>Q@y&9 z^qY_IQf6mBYgX-cVW%qjWLbSK@+mAN`5*{v-=AMsl^Zh;iKwDi1OcAK=c^p`e0ea^#Y;i~6LGT1` z07=l!WZ~${|aJnVQ#cPRkvEb|i9NQ;j+F4JK>{0ZiiM~kC4_Os@ucB{B z^dUh%epTob6rIhooLu8w1niO#Hzr2JZIrx`!FuwR^rO5nZ-RoZBX4_D$r~CR>pvoI z!b4Ktg7H!*XdN^a*V}yK-WnKYAP9q@*F2Lmr)Ch8 zQA*Awuo-4<5N3@a%$lnXlVX^)f-q|bVb-Y~#*9brG`0cr`@mV*Il^1s`caDPwENI3apy_- zN{Vo=+l~n&VAGIHb-jTN z2R{Z&`n4i{hVx!Vos7JsF47N5wNP1}2!^~LAw=S(>4l127`>)(Y5=$0?;^#r?bkUH zE^X3rLguKr3>}=chLBo@l(l*IAb)72jwT_}^+sB;zMIrKWp9e@{1W*fJ5=&=o~i;u zN}TiIa5(u?GO-PjfYW~*-f76EWp_9aV3fcFHh!7F@4=YgLAG~DBee6?$P7%&{S%9V zoTFpwJvrY--f?$%A_I4|z0Z-`@up67On|!6PO$@tf z5Ed4o^1S(13Y%xxErPIHny_1arLfHmyLAwD8xwZhRfbLI6-+^ydV3+ts7mi_ANgN0 z%759|hOrHS&cb$h7%N`~vV%r{Ab|c*LYVmC_?HU)4x{idtBZfR;O{sJ|B3{@=+T`b zelHSV3+Mkj4?$SUKcg(F^QOpoGo2k}s2K=&+PM*dAgIPJl=|e~0MAHHInPZ9^D2pV zV-+4D)p$Rx!XqS(2Wts+iX127C8QdU$w}f7QjN#7Ch-V~<7vHQW<+=K3%4LRCVOw?D^tFWFS~pXU!3#3500?na*rbQmZTT!tDT!kBhrsX zc6gTaY)F=lVUPrEUcNboLCr>6b8S4I;o&IQ_IOUigA*~VSMX$Qt}M_w+-vc^56^+L zr_+}81fJq=@q>m67n*>o?K2U!&otORli*wp&UCor7x=6*+(9oLJGh-8ZJ)35y>$D( z#;@46WE*1#`yfKwmk^uQ81A4)Fm@m~FtPI37eelwpMsY`1VVUzyI1m?eGA)L9pw{) zI`3c}O4^Mi7u}M1#g~u+L6W_#5Yo97l#-Y|ig|Mk^T67ey^48C4D(dshIuL1l}T^3 zMjR6~qVct<2bCP0WmOo74Z);;tR!p3A7UZY198H|;3$wj<5hk7? zGSSEqEM5-$qKph{pX?SZ8eskTo)6~{Z_G6g+=cx;~#=_gf{2cm2dZXu*NKLD8`bVNw6 zOOE~1BM?%-5g`qkq?T7E?*g7M*;>sc{gg@AI3bf836q4>WwO;U*&$2{omx!NBVbZ+ zl1#E`Q6}#Oo-jG4no0U8lfQz?$oSkr zP5F$ER@Rh__-JL#atZQvKPz*fnIkyf%A8`{%dO0H#{Gbmd304{m^Yv(Ui?Yb?Xv z6NG!lVE!(KNgFF`Ed=g3;yxs}ney{M;h}+9pRO_KF&XDBr0>Yhu^Jj@Kd#I^48+nm zU=6wt!}yE#i>Jk2fxKukvr{_MgJ9m?q>FS|7)E zAa)5Mx@y!+3_Su}B{-^3i>#%vKx7&U`Cr-Ye9Rw%1ABmvEA{QM=dZ5u{CU!p1_%;#SC* zD=T+qa*>a4_c%h3y9vtOmgH^|Mq>N)QtqCB%l6Ke_JVF@QAg(!xiG=-IVgMz1>y6j z$(ENM0iS}S?L{DOGWpy9kZm1j4gb;T{#_dOz0J%+f7GyOFI#lK(do!q)O9iwihJ0< zQGK8EqrSfgOsc+DdG9Jylmf9=q5l?8DENHy>BmD!iL2?F0u@)&HA^L~rfX&g)`UwQ z6s^pLMjsDbnSG3ViIq8SRl50CR5oE}ggR>>7%zx!mU^Ak&8q*jj;h+z`l$-h_9@V+ z6=U;AY3nl3)I6l#qt4(v+MUPD^6<#=DTprBr27#q)b#;Hg}X?kir_ByUx16sDnE;F z+kXzfQnN`@R(}-dFp!c_{3L3(L~pikF_;crhq9n@Lh|vviSNlu`f==M5P7M|PiyoASUL}kXaEglcg6?h)TQ+yOZ5X-9}mYt==(39mqAQNo=kN6c? zWS$hS0haCEUk9mMGOl=>AiZ1%sYj9a5Tp~Iw`xY$t4Qk!QfjB#JWWufae~xS2Wg@r zy^FNl-e4W1Ns9EaAPv_+nyg4y5y_`0b}w|0XCS+%W(etYO0FHwjJJKtZP!BD5eW0W zdSUV!4aVkybzMEIX2rs}UBFsV535D7{sw`tz1%lyWh1z3RV=7$U=7y88lzYkVF%W? z>S2vlEG%GxOf5uZ0P^|ukjE+V*M;QuP963NinThif_#5R^YF2HgxfR-PSi&9f3Jtt zu2|0qR$=El(RV1;^@25{9+v8i;z@#4H+MRf);@x@pdPI*#gbJ8;C~o+-Bnc*-c(DL4|uzu&%0y71X%P1?!%ASV5ILMzDTg4=bp1I}uBYwQFI& zh|Bx+LIf3XiiFV0bPrS~lC}CSb+V{Wv+{kQL1^n?O;M~z1k107HC3^$6095QVNFvk zU$7plhqanw?IKwJu7@>UvDOf*ukTtXjWZMrvl&R^A@#8O6$@v80qgvFSThw1H!l+l z6{n`)If`|WVBJxV*6NCNgkZg14{MfUu`^|R<9DkQS3*?SU(Z0tLkB`uUIDv*3F{o(4AQ~IoQMT`R+M_P^$8JZ|I+jc zjKMng?=w~QFURvc#r_pWlJ;+4$BMR7V^)me4z%%~^5yM?%n(b+x?=B|YcmDF$* zsUF4shLEBjNs{VSZ)OA3I%y5*TA-7wC{0k*pxnsdsB(jdquiK~uvo(WjFwx{k7dRL z2boo;%>GzaW|TwhiNM&MFp(^?pdTSgDNAQ!7SCHS2Q%!04P4*`ffn#xmnDIR30F-y3BSMjM63#qG!nI$7-HbR7Rr)xo^4lPW?h(v9?HBz6j#2%h zd7#z9Fz*IoJ|uFw{1IQ7^2dB(%jZA&w#%RL#U9q@aDuDsm zEM-eZDcgK=yp1b6V9m&I!$){`A^G$09FB*R8lU2si8kPPJnU6HfoB-hipSyy0%!Zo z1KVeYIIkn6I!EvhKI;sy(Mt!|{>+fJ&sX{Hbo(FRS1J$L!ypv$4>BzwQ1z;oI@2Q< z+z}jz73ThwCFd_(ZHFI_4O{Z6Jwj>Tvtk_8vT3f$X6=Z@28IK^EBzFb!H&_WP3Gnts zpqO7UTGqzFz(gu0Dyhd&m;w5$AT_v#Fnel5gisw8Nd%vy!OsYTJ1D5c$ruUr$%?)g z(KR}sHMRU#DGdIa!l1i*9>-^JBNp5}^S%yu(G|X~7?mT^yQ5$fZBQ<5El3YlBjq*v z6{JL^ZF}4AnJf-aYF4B>iG;_BmRos1=5nhm<=yQ)BkvxsaWBBj|AY8rX&O9S0^2^} z<#*}XS$>Z^ZcL)KFCd?gW##wjjVrM5iWd*KX;E&do`67X>=NZmKa>o1iQa(0O;dR} zc&TSOEVhOpt96zG3nfx;Mn9?^Px^6;@(4t(?Vsw1t}<(55SuEBsX(E!;QOmS@zKYc z^_7X%bnI+phF3Mt_&<=&czSgINUyXbqR*1;i0W!BEY;Mirc`-{Z9mWc;=L%UAE|z+ zANh{&`=F4#jAuMB*~u<0!jF^|H8-vXkzeX|+ox)`eJXb64X~^l5ko}vG$OrJBYwh= zw$E4j-*o$*;a4;w8G=Uqn34JtqLxOaN1zb}M>V2P9-Wt2#Ku6k>TC&b~;<6DRXHEK1);YVRvaaRbRc1a1kws_Pjh6MeEZ5BGNS34h z8MW8Ee^@2UyMw0*BFmEEq%5lqVM{@(t)L=T7Nf%UnQdxWsQ9UQp+cx8M!05qB5e}v zXP0$@yWuTsmUoAv{+i`U3^N>r*~5g{vt}4G&MWK8_5w<<%Iy`TnE7M;w@xh`L5gjE zZ{Ub2$Ms~o{&F(nr|5OGfoex)iiT=8Cd+ddfx zs!9T@Td2#5eWH;;cXPJu76Q|uF_0WO5%s}}JdAr5V#lV=i6w8^MRK6(V& zL~vA_1PPDYpHr-T->y|BnV@=gGU>-UNi$6Aq~>o|nHd&jb99!_RG{%;hR5q;O|>>zll4*MM~hE|NXtkiX;#Jdu1CS^sxqkDd>J=T$-+rp;cMDr zh!px;^o#PztR=?1QCv&>86>sNT4G{E;pXezIK0;s_g9U+E0mxJmvb<*X3=RxJ@ak> zukLL%>J*Z8a`@&yvQbWfx!xQFQ(pbzd0 zV0~`3-y3$daFKEgh*(wzY81R6A&5kx7-F9>j26vU&RX1#`xqGgl>fkQ0Xn3Xw;U96 zP44#rZF0}RuhR=QaF?K5Fj)u!WX7bO4z#;X?zuo29D|TOT_v1nhuh0maN)Mn9m>Ml z$qh?Zw?Yg~9w07;KMTLsD+OMBWzN6uhR=ZrQpO`__~zaN+I;|-J8U36ICm#)qifoV zw|6fXHwBYHndk~d6p8IHXHXb{Ly949J1i(~y+wgUW!{g)Z+k2_)B8P6L{z1H z(C#epjy%}JirdauXrl1EhXGcMv{yVNNKCW02b?Ll6NL2elLd$2s=6)k6CHlig5#nk z&A241i-`Lo9^6WKGSZ2IqxZuXp(+Xc<4Z0`kn1{D><=8NBD@d7+m3WuJ>cFK?k1P$ zBJ??}3Ywql7J(8OEyyh%rK>Yy@{GPy9!<| zu(^)2e%RYUL~BTO3}j>s@;O@ny&CnTPgs=qT(i6f!mwN_m^DieO~+T~Gce;CM8iC@ zx6w7ux0tR2@H0Y0!S)Ztr?_mV0~zLdH)E;MK>)hn#!q!T`(O=L1$WVyc;2WN4<=~y zBSaKze-Y#1XAsY=%yo(9;8F3UC-EQVMzPDEyVTM+=}66>%JTw9;QA|r zQL4;iz05iA>y(EGfJIg;Jbx@mVtqTz?OuvOOny-OWgIOz6ixz;>m7^KM0+@)A81nv zi0LRJ=g`Ct^0tKziz6K&Q1@8QHPAZZybn$R1Fs91t~UoV=>OvoktJgNo(P&5)W!8E zCTtP532TRV7G5IrLaDr5K$eOAUSk_L}}cc-@iRU=#lf%v=)?&_jR=WjVGkmC+g4g;eZ z@^8Zj4E@`23s(gsF$u9R@GE=chFA#l(c>&H*a|f@Tn&F2%%}e#f`jJ~xjzL~$bT4r z!)XAd;BTbis}o)$R`52nq!mQ{9IL}%UCi{86j5ta{}w=K3UD%(`AE^q^1n0nzcQIz zs;@y$LTu;GFDH^)eKY#c%vk45cJDxL>j72g_4BWB@XaR++|FIWr_g>4u4P($zSm@&%nWk z%h}e+_j(kv5I+B?sU7)nDyZOnwg?UXs0V6wMAqlp{>#xoI!TIL*9YP++9qvJW{G}L zB&*di3_ccgFAd{(4(C&6C-kyAWMWLzs+?;AMe>O{y?iQeMs+j+Eh2v@BfcG%_ng8k z85A1kn>`z*Yy#^c>n_%wV9Y`4NP5h{)J>@&T0vneT;~wbAY0InUkEeqYWHP1%DG&T zDdUBJnoyR0S=I}?3qOuN8j2F{HUMcG zeL1HbcFxV@0oO_+E83mv$+S{kEpmpd zq(rkJ{t)$OoQ8I5R9ofb2*W#_p(~-~ZL0(b?LO^Z!64Hv^UnUG^7HnC!_lT2_LS)v zBxeVzO;4m!ecA-Y&{kPR=pqGcQ$2nh$<=mS^|(1|YsE&09!16F>>Fr}sx_k9>MJB6aACK1-QI4qcZp2l`aq9s+Va8|^Ju6RgJv$FtF~ zPc+{$-m*60R(m1J?sl)wR-httFiq8{(od7uB0ze4t&H7Uzgy^oZGhr>8!>NK*xrOLkxN_)bFi%L>bHG0wy-;6$IomHi?52cQ9Xb z-V4a4NTS#u$vGI)HRJfq9Qq@C(jQ?nL{;A#7w7pl$Hl{d&c)RN_hemM-@mJLd#l3ou6X<%P(r8jDB95~~>L)+2#QYyjIKCv~!L zZ3HGf7rLzW*foN5vTzP5@hKEM!Y}f@R>56bW2OkLF%RQ*YeFGyaozqT0!-s2IB0!j z`Glkg6WYZE$6~xMrXS&N{|my@#1++6RLpRlMB)TsYHYYJ z0X%OeZ{|#Ynu&6}M){b;NPL6&at3pPVq*LOvXQ3@L*f%PB-%uT3%ZZ2Pw_;hI)YTe zCUsz04Z(7*e3kSz&G#a+Wy6atF$N?O?rmFF8sLL3H<3>>xtQ7z&9`3S?D9#Yxg9E8 zRJ|fUOnt31jB`5&fi*N9ei&ooepjlhiA*cr6riy3@wuWaIq%a@iD4einu6_|!dFLH zQ?L`VBbg3eQ}6}0?TaaE-M&(_v#R21Wwq|A;YE8gT8<=V|4f(o1U|~G8{^7!pz}la zEjQ%)w;}4_RDk{Y7(>uO++NcZ05ov9EAam3|2CA8(J^)2R-LdfGSuBSEhBK9boIJb57Yd8N zKhLPTm?&4FNDb3(DN~ChaSp|C9#j{nz%Pm6hZ^|K=1`W+SaWjS_6U}!?v0ZAwK3}# z+Y3nu*F7?XX|jDK@mp$hGk6S1;>j38ZIcWhLy~yPZ_^AOLy~yXF4ri1T0Vv-o}Tg4 z&+=S|L{on^2M}u}x8S1?ZpjBGrnchK4Y%QgUe5M-i3Ta?U!8{Z4uB8*3v35-r_OZY zWy42tqK}|ofO=Q--?rNThgvH1HFFEG&XMTon{R;sk!N-X(3|`_N@$?>wF7?i)X2t! z!^Wv|30|W?%VTn`gA-x}qyJC8aebyQH0j%cNx;`=_$Y*5;lmBT&Ii*q4=?JIlkZu{iMEF5JB; z(xdAWzJ$NSxGn_wTfxZ)acUD?3O>SZ`Ci)&cX3@P2way1jI<^cja(N3jO!ve>bi)G z-ocQ?EG(KDi!Q(TQ&^>ptq%=LYp!H1)S?iS+wN^lU(+gs2 zE!1Mys;Gsp)iJT2uHZZY$5Zu-Dop+2lls*RDcH=xo-qHSrcu{7+Fd9dYI?Fqf(yj3k?#%bvH*gn?qiE2$ zRS+S*0fs+1JzD216JRt>a75!+FDReK#zCd|8varm^A#A3F`9+LZjB(7W+%KE(m;=y zVTg{%-vFDD7O_Wi4JCNl4I$#O;C1R-(e6F_F!FMvSG}GFf)D5PHCFeL}f*lwHi$OfC|k~w_Wa6zu3iD zT8ACj=uBzqS+Wi$*CeK4v=zr98nqQ#XSzdbsEJrB&ZanaMoWjO_}9^)n&%@N4S3{d_ZUCBH|b}?*UtLc z8)04IPvD-xwYn6KXbkBRnXh3`G9NI8W8@7kMwH%R&@w$Jn15x%Y48*QSHXRV2<R*vYeKpvxLp4l`R!Lcu#3 zDE`mzY7E*m@5@hg&isGGYBtD+`&|)hXbzZsz1H9$R z!+6K);-e`4T6oWyRcJp(z~HrDC1bWf$4eD0QF#f2B;3Pb*o>9jTyQ32k*Hfro&KR9 z8%Xj$1U!SAfD$~3n^}z`*^b$E%tEy`$pRnms)^|1H6IODm*Gvud&lCiR>U@~xzpPp zgUm7rXT_G`!(4N|E1OkFb571C)x7FVWeD|UeTXE!xIai~Iace+X>vg?E6bXgCNi!rgg>Y{o=fZuJbU#aaV1m^4wMbt@n$@n7Ieig6Yc@A(R@$lg|bB)8wMXW`H>jWKX=}+m5)47eS`hmE^nZth4?hT2738 zkRr}A3sc`Q4dcE#ayG&av#;*rjLlsKQf?wPS42qLT+MS$q~^G$M++h0zvUcEIT-(q zxyn4_GwHw0MNE6)T88U3T+iV8JFb&J`7>M4k$CkHx+6b?$1=#4!~V< zkN-G|dTVp+G6zxRCGTx1pugte<|H2!!*GY|h8b&mn4yR%CY4%2n zwC<@Mb%!izqfYA6OaV%xi++v`Pr57(b0O{*#Xd{peHT||>dah3w5ik?$%AyAQJbS` z9Ez#Y(pMv-nX8s)I@U(Mh2aEP!hhhQYa^Mtw8`=8PdpB@8RM*8m6B%wM)zTi>v`88 z7?V8L!wwwA923@D+IOFsF#*4dd78o)?yl z_ZLVTvx&-0Wb^w{K>7?lCJr+g{Wu+k`6vO)q5;mIKL<{R&)-oi=1KnN!zxmWj9-(0X?_`;U;XDb{v(3RT3xoHHa$)qt z!6?pfFp8IkHLCCXyZW7)qkxU-y&nV_#-}1i%x{q!yu*g*=mg!!E5O;Gaxzixk^K=LKbZP2tLZ?Uyq4KQS2s*lm}7~ z6C}3-QYaO3c^?}hi!v47?fN*%vDk@Kt)^=xtgy<{e+uC~4)`jT+QbMn!ys}@bT;Hh zK)W5wHPiDvop8Yo8141%8O?1B-N7^@Vkk~DbsyG6elWwQGAp~nrTREsA7|*}d-^z& z4-aF!Gs3g@x^nn^KH|@UNBQ50&k*3lUVz5&ajc#pNjt9gmQkni7?Q+O+jCk5k0D9C zFG)RN8q)k2lEm9u@R-On9z&9NDj#zpjmMBI9_ky_;(3F^pd>l}bt*R7I8oeKX{c}ApdmjyDB*f< zf^QN>=Q*}P9#{X)DAAcY8v^5*7NZ z=TV5hb$V|RTPmCQJ5A1!;DbI0);Gx>;Hd*H0;c84c08VaE!TSzWHOCnUJpV>2JbC( zFd@U&?xn~+u3?{bfe*pT-OD^IPSJ6I;FU?-1p+KAI<>r_q(Huc!$H#RnU*5zbs3p@ z7m|R6zgXi7cUWP6ZE?XVsQPjOZV71B>(L|ka6ZwD(fN{(6HSU!Jq**=KhT_rE`?VJTk`2`A@}(Y(^q6`_&`@c+XM3 zod0wTe-3aD&eDvwW)E30Lou5@tj3+uQi5j(LO5#Eqd8RW!5WJ)2@&kpsKV?|^2z=r z6@;!n$trK+hC+2~)OdU(OYW=_ZjDvKt+7J*f2I1!$p5+cn;7|DKpuxH2ZD609n;Er z$9oy(zJG1PY7FT1G2K@Vj_H6lVWhd-FUy}!M4l*I7Bp2S1F{I>kRm)EH@Eg9+@+_= z1fb700G8k>(MhLmNqS740Mls`9PPB3^e6gTJ3BvktI;|O#u`)CiNS* zCO`w{;o>(tF?{cAiYvf1gzHgU*tP1+$8`d(U*Q_aJI=1S7U5cki{HNZ1lO0rkXvIf z!gVjM7jcb+DcTIzIk<4dh0}$4u|BSE;X(`N{2bS#xJIE;?T+ghT$kZ`2v;jy#tm`p zf$Ml&m-2rZvf;WMR{>RRDz5Et9fIo`TrcCoH{zXRaFyY*9f#`)T<_wVG#WcjaqWfc zhq$i8Rat}U;#jZP0(dwwpcrC(1l^e*<00#70hFK`LzaaX5iF}6^5IQ80$x&gk3rnJ)$F(4yGbF<-a2BRnn)C*KTlbOe)D4Io3WU zy#S<6WwsPaGAn9PR$L}*>(XfRjSKT+VV$m*o5UOqW(=aIkSeHg8rfQuGnt8JNxUY% z=pS_X3lVXHOd78o{thj}31^4^U#}Voe}dxQE%=%1K|ck%6Jja`y2rbm!$7NbIxbX8S#?(V4Y>!~*X56_dJ~3Yz_4-&kqpWfZG_KMmBbv82^!_FqUg#EFuZ4i2u$K7<=_M zG*h;6;2f_ar#(^Sc$dZ5`r5s|a2*dQGFC(vLMaKA{oQ<9-3^!l#9Fj zmFd^A_>;7#?gzeMx?2`$vLc~jMS1R*g-=oV5`kZIE(UKB<{T+qMd9;fp{QUoISYn| zW*M%k1Z#pIDn2X^F49?Fo@RY%7F@rxb@3zty zFUb$iE{jBHh3TM<(K%_Np1I7;?g}05u3 zryN>Da3k~M)W4rH*So^2@u+OaRJkCS$EFk@_-mBA>P*YfmyNig{|uAeuMu-P+$8U9wj-Me$A1e) zj?BpiePv9`GQ^UFtV0fl1IloBG7JjGWYl?mg>L}3cNe4D2T=jFEsMH=qP7dGm9y{- z75-15Uo#8eNa2rZ1lt0^tuZkxO2WoUcb?FhTzLbztphq3hLZuENptlhLH$6JudzS{ z2-6WA__XYt@=@1F&K2$$mLZ`b*&LnZfjiTqGUR1OWrVE_;(z+51p zI`6{jcstPWokZMaREBX>mVkpBoR9(chzN4_fsLTC2PJ(}m7oscK)6^FHl8H$Ka+`| zS0muuAu48+g78)mlJ_l`bY5$ii{l?V;;P(&n;U$X;n}A=uO`lgywPU3LHDusi65tk z#}NmnIFmx{CC_XCNqUbPpp)$cv%p<92fM*XnV80FOudXr(0};l2wjW0;d$yTs-!+9 z*8!(tT=&HyHA*wgx~~E!HpE@F>l|ReoUe#}QxEF&+sx@mvFOB3q_5lHc#^w7;eU}6 zT92dNaNSDISsnbo$~hF6GucN5lT~(cE)l9vgJVJ?njJ}l;uadHfzTj{Bhh?~G)T12 zKzyNrP$SXoM4Gz|%{_+Z-jQkW<&XC2eTL>2hUS+e)9g%|Ul|(o??kp=k4*Co(mY^j zeq(5UJ2K5Y(mZHr9x^l!k4%G8*xReWGc=DFn%_63vFjmaZyAQ7?S8jEN{Pq&-30zv z41c~3eof+A=A13Xhtq)U^(dG z*+%d`#_;DF!JmrZFE)Zd9m8KSaMlAFsa=`R&j8MO+Gp{U{gi*g%gFmFr+{`<%=3?N zIzKHwkJ+($^tcL3{b5|YF|OxKT+3}-&;NIEz3}k)T6g!_?Ha)6tpR*e(X`9mgU{*hj4a7R2Z&Ik&oTR z=QyJM#=Ig7M54Xox)g>mz19zg4ge2^q7IKCNjww+@L(hA@EDTCqm*%_V7v@T;$emk z{Fsb19z&9N=+6QVMxzdoAxS)(@&G*MMa<8pQP;}Aa3o-qi6NE;2Va@S^!m<5YmTBX zqOM@gQG5njS1c0pz39wBTzez^Sju3|Gm|g*UW_S#aX=(&qGwn4Imls|&CNhF`s_S5`!z3Y%e(bA8D&^`CRO76i1NQHLQtC)r6R&Q^RM1tsJC8MijqlTB_10@2AeSHB5nT-aLj55QY{zDc$N`3K1#9I=9@FwF(? z!ByA4psqTd{p=&|$I>=P74q&u zsYbQT+SzfaFGrQ_ngXg9`*3`6O#wY^c4Jtx7NH34!1XLH_WF7-!o(w2cE-i;5A})UMZW4wYH^#LWuJdr+kLxX5bHMmaTo2&lQEVI)zaJM?KRTP0Fwc(* z&NWs{qlV#Hi0e{ZNQSc?OwkFrZoyT#4L9U2K6V4Cwb<%D#tc6uxpL-9K-cWY7o-64 zw_+Os9|r?%&hZ@E;d_rC4@{xiMfVeJt9Cz`Js5V`6cHN^n}fqZ-N%^8+6=o$EFN&4 zGg7kY?wh-uf;;#iiaipk53zIk)LQcF3BDxH-e6C8_60}Eb6jwiJjVw=m*<4wad}P* z-k0a3=Ah{WGMZEl#_LN zQr{!WQP~ou0AiA1e31|Rqx>+wI3xp|K>%K1ib1b3D3C#LYzEw?V7N*EUy%WiQ!siQ z0NL=~N@d(B%b-;moDT+Wa99@Jrtq3Xa77~t z#cCM|Ps=hGtqf$$zj8n$24d6S5m$ggRdLBl7+V`{1}11pM{TA_}+xq$+GZ22Jz0QTL=eoe5~szV13nZIB}Dq~DOL^B~`(cRIl zX6R<=*tq%f2gm9voZ5r%gsII&ABO>9uVL+N@|&{vFnoDaG#dW*s_n&Xxf4mKj~$S?D1@5#=QL& z6sFuZhbEZ08@hsS@SKPsO(9{!$8Kz42wr9aQ%Obozk`c7Uc=KHW4R$^3Cbr^3x#wQ zyb5U}HJPMp(j-YXN!S!(hUg+g6?r$SEcn{JJ{=D;={^U1lPw99ZnAQ_9k$U-y3flZ zO;MzCh$I=S6?!19LW3f_WEn%{lLL)}Uqv}>8=K;}Kp&Va`F?gb=2aD+!``;edF=7} zF#P2ZEu3ojYC8L~8L%oF3F>0PJQ$jCh>?P*Mdo`WxmJ^Spyk(*T8TfUmS0aTXYWT& zqZPoXU5H|w9z5%9%RJZ=aH@7z{;4YeZUX;B7Cuek)H^VEL~@ZTFucyJt`v0Gte468 zCsa4rdC@s&Yu$tCI^Qqu{cdrb@O2h8@Aqso6A|^tk)PyW!D>LuB z+mV1ivq97K4hB7X+#0uh=ZONzcb+)LCqfQ+FLNjhbD+_YFOHPqFTpBNhFUfsXY!IE z**yOwgU66$o_{Nq=a*`p`;e+(o)eJFBl$0R#Nn@09tp_g`4PkMBOu97{tG{jpr!Z; zD4XYNrSjbFcXd5RFL_S72ARus1+-{~NcuaySCISGl33WG2KJW(4ClGLO)up?$Vcow zKAK`SKF@_1mSgrjm(hq@%kt9{9_u4RY#DKG2rWZmukGg@_tvvv4nrEMCqhcjwK+{P zLW^B9IzpSrOEf~u`mZ!TX-*fKLWnUGjukgqnwEN+qSFr<4=2qJ3{5L=Sdoi0zR8zD zII@n}Zfu|_R?(Q1{a2BxskmKdRq#22c@7h>8o7*3q&XAt1ge zO7H>7r5x`OCDBkzL8?@1(D&U@hquWbEks-Dmzi!hO*|#fYn!#GLGk&lavi2k=cvijZzcRqr*C zp=iBZV|uhAB>cR*oKCKO9u=H<#wYzej5dg$Hx*9~4!nY^@+xlVkI1U>W+1w?GVYQs zq?0`|bOl*^)Z4=lvv_;v6vK_kg%t-#1gW=I!W#nk&<;+RV%{S{!RI@Ogi0qqU){Mj zWN3Uo;jKQO={>O~Cwot+7)LGb(A}^UGVR?sbF`Tn@XLLU2V*_Pui3sI8(K0Q&54OgK?dQ>r0@hY=fJ%E!`k+YdyG&Z6SSSCg5(c zn5CNn_Xzt6K37MhLRpOsNn!OW)@z7^XiS7;jz0~JnpD6&6J!VHC-#?&8{Kmd(y*&JgVbp~n+e|wLR%;aPunroVJ&b~UDXj)YRy*FZ0$RqhV`=I zQg?%rZM`K6Zl|7nv54) zk&v!rUE&Cf)+HjbF7e5_#H{5t8Q1S|{T&xi zbsmp5Hz>V^^K@!_Pi}mkNLXzW?ouf!2-NvXMphFJjntU{qt1e3)men2I-5PZDds(r zO7YcPIZic9fqNBfj-_KZHe%AJSf)-$wk7MtHqJpeG-}fsQ(Sx1f`TVwvK zBDyu^plaiEeCM(!?_DIFZ}ta~HuHU=GpIqo>`2!0Vu`KAsu;dNS9muzZ|C`mUT0JKOP%MiLT)5bdbt*@d? zqWXE#&q@aKNCbaP1p5a;T=@!Ed8`wE1Pt$A!;z`Ffy!2M#s!_i9Bv#JKXfKCc7a(W z71Qd<$Fii~Y~&&?7OFT#o``g|B#%qVrv=BOsgy-LDPH<*xO!e36L9@r6mM`hJ&rL6 z5!kmvwbg!mBK`yo#|HjenqOt($x9m((pEl$q2h8ecmzncESN~9Oy%^seAd4YSzZjD zuEUaC?2h0z(?QF;q`t}8okUuMVzgu)os?;E_*PxMoeY5Fo8*%onlKe%N%<0af^XPs zp6F^2C6Y<|5s11XA~{E9E&SEw%H)(TOR{1yEfcLwiL@{Q_{@Ex1bI4%JvYy-ejAz{ zt|C=*s;n=V=KTm2K3o++v^&=3>6vy!v@yo8zsh_LZ4KO| zEo9_q3%3A!d^;0=8lL=5fN2W_$F_wcOmvJ~I1OlshmY!ySXQaXdL*TlXPFM~2xL%? zrluO;J&oF{sMiuzQ!Hy^kRz_Ha4?}PE&qI|fZ=pYCel9Tv|k;k|Bw@he^uJ#E|`tk zD>A9@e+`C)_fIpt$0={qPD?Q++vy#gT`o_z(@=Y~Bg~XoH>}=hJDrB5eOJ|&?vQ0? z)F$>_X$Gd$UCFk(VF|`<^@@DgCz1H1%xYJ^BW<-LJl$5Cx*|oV6$WQm<{d6BcryF6ZH9ldcfX!b9gu*q+k94bDJNEM{a6 zpxnrJMi&E_?`!~RPoV|m838Hl#vodP^f?k|Ij7$RoeT7@iDMp%K{hUCC zXnre18(b5qk>lN;N0wHh(B&lzl5l+58~wyQ&M>psYgz0UB5Vc?@)l!*?b;UcMIv5K zwhWSR9v3zvxN{;tuFEf3M~0DYF#F}l(1yMQI<9A42UO@stjh;J)yN0C6a9Fxglr>h z+a2UjWn;=**F51u<1TL@?kP9n;9xEgy#sOjyx<9N36+9+;>O>N4!9s!25u8&o`m1k z5Kes&UD5-6B3f(TxkmjZD5Cn+ObzWjpT#YxqpYN-;JOXh>$tuSWe1V;=WYrGOQONTLk} zvtQNv9iUmf@QXrT!ChJiieG7i5a7c|gWn^MWzDnbeHtBKK_vR~NPtCuas+gI1(E2o zL0%GAW2H7TStw*OVY(%_*9m`;OmKujK`j#jiiJ% z$$^jY*8fQ&2Lh>J^D_+aeMK@Dl}McAg(%bB8FYLbk?4=3U{iT93_3oLNOYWq48fvA z|IhP+(F~gx_^u)&TMv;rmDMFm$qQNANgb!i)S7?`(^Y8_nJH^sg~Pjw8Y_n2?_HM} zz{eLB8RM@K_@WuZ;kPLM*~HIe$2{c{<ok^`@gkg$f$<{dW!>C~+E&dgHK}R? z)YxiD)Z$Km-wn1p4Gr-6lmYtyK6lHz0SLq|);=uLJ%}!8BH2;8p+m?M#*j=ys?8<0 z2*@_~1P~p^Hdos;*-H~lE^%Dy5P+m5ZZR$Kx-6=aY40`!Cu#5AiCQoQ4f2*~!7BHI z#x&33i&*-NEd9SCdIk;h7SoqZ!~b>Uom2^F^PP%MuJ+i{6yJ?4-*+Rv3>xHZ#e7Hb z2dv<8Z3OQ{5in?ww?qVkn^?T}i6<>LgCxAJ<&H{(eWrpl6&b&d_(-wWqb+BmAc|21 zT!_3e=D0gyj`8u%MCEI#JSGJpmX`$?)1Q!}k4;!T{h4t=jzAyR`Fi@V3cd7cN1*>O zGNJYK?Vu0Nfvo79!VS{>@@B7@`a8$d-}yIkoAVHxBd_81Y{7>cZpjDzovrcG(BJtT zIDamGXX?_dzrzYy@9#ABXSf$gY?n6Y^HC5{>Hoj+mvHzJ1WbH+}L6wKim2&%DM)B~!40XZ-{ z&W%ve+!`6x`#oC;hcDqSZW5)g^g|9X5%fC0CxzZ4iL8_Z^NSFIOi81(Uq zPL~1$9=MrYk!qR}g%wksl1#1$Xzxs}Oid& z+Pc{yjD)0wV{o#J#CsBbF+&G@r%PeS0@R;iRz}q^YFE{tNWjGmI;AE{Q?JGh-@|08#G*~V5cApBAY-R?6^1+<0VZ?j+ftyMS3+k6 zo%QYT59!OvY!7w;qF;@*oaH6kAlwcC-~c-v3uv*&cD5G1ry#XA7EIbo-W&G4Bj401 zfgJ_!i-2_$@hLHANU@(o8u+S8(d$QW^^YLvD7BaT0{+Qv%|S+3Lh7V)R8A43cmUqnR@XzhW`QMHmc{aKW&pPW|Fy?UN%J zu%a_DIg!>s7NDh!$4|dYeW|fHlQ7p|4suSz3`ekO(N~`%`}+O3kOK-?O!!bdHs8#r4>%hiEmLLC0rjbtvV1*L zzTZHxI-ZMvSf+^My^B>WsV#eNphno7XP=^k#^-cNFVDXpC?W37a^+um9Y`4RQ2QkB=JMTK-BKkN8 zrQA}QRn)1VQn2G0P?XgWxBycxqgtE1dx6!@AulI55U>$=c@VSQ>L|&;WKcB8-g|Ff zRMU0BwbS40J2O#?1W*1f!+!-h|HK0r_Ug83hjhyoE5*(hxd9&zYkR zZ`XZVIu&LCTbxx7XfIgx727ul>&0>oF z|I@mzNo8 zr|~#-=Zb9$R!59Fw~O5eoSNtKya|-;BD^B&B=1+l6LwbH zYge+uZvm26FmteIEQhW^BED8#3n8y0jH!)b@z}ABshowf8r%_i9HTfpI63(=Q)lp9 zCW+EcpIsdfNtO^ZTGPn#-WxJ&e~RrM`%`?zYl#N{uWW!D{b06{+FxQLEi)RT^x;kb z;M2soOXr3x>>5+PHyr;WO)Rucv-+!P82wf9Ho^_#udWV}lKgbe>HEkZcd-bO_E$~2 zFKN=oKanpkeG~Cda`d%xT;bS{L9EBR`Lav;TsR4Wm z=o;}#azoxsgs#wp|r($eb80(T-W5h|AuH|PPay?On**`ZuEZ18L@rqVN z1k9gRA#MWyWh&-;RMFw^sdD%xnw?KG(Qpn;$XYPC7Dd!rY?7fhoYJxxvZ-jlW=5T2 z>&titcTXij>KI{6``{k+u)K31U|53>8-Zml*TGua=7d8*x&mh9xl|H0PgvWJYKnz6 zIZ=_R0yr2!StKPkn9;-++u5HWvwy%i2ls?PGJ!5{<;rP*c|=!D3-ZD5Tjrb(@P#a9qISVD9`3-e0-IO|A0 z0AMLNj)06WC#`Y0@)JS1GKC_kpE@uaplOrJU6cO~b0RCn+M4AH*&X@d0T497XQ1;a z-d!iZoL=mQL3M)H8UqKW0O$mt0m>7UNE*!f;i$tWeaFL2%_1CMI=ILYdUkQP*ow`1 zeIyXF{_;Ku)jaqc*x5XQ<7z?=I5!S8$)@vP3YHTvT+YzssVr6k+OUFi1H#Xha$x7a ztWIFiavn|^Mbn1aaOqPLNHMOV<+Gt%PeLXLNi@x$}=F&}}przKzR(L4KfSdxN zOO1&7Gem4|tx%tWn*eRrmCW{==TbrhS^t>~% z*>N@?A9Au5khacy6xpCl0TGuI+|3wXMR!KN(UrB$vw(Cw)|xog8a<_=w;||7ulzv- zVBUWTA35)6JR)zCd7qO7D=moA30^@gaGaRByoX}}POrR`@vlm*cFw+tJ%>sZg=KJLHu;TJKhQ6>X}Mkp-~~ zaaT7N^>D-a$V=(#ABdM2nf<@*fqOpX45mSnl{Fzne<@PlzdB&SdI;A4(pl3!NYOtP z2wor3VO5S@lbE&S73KI5<=D>1agdec@RS^}k5_aS!T>{8&<0ah`e%H`{@F~xD__A4 zt7PtgXl{*(TiM$fQG|Qr6<=S*T@wICPEh!f#Zr)34ADn}E4?ZorPRL#2*CK{h~$6B z7)%npqt6x2)Xx=$`%uoV@SAv44rYw_rniXBkY(Y%xHF7T>2G;+nY#T1h4)S!keIBb z3<>ua-~qUcN6JjA%mAEx$Q1`p@u7b-Iy4=}q3JMLT<5c59sy-Qu5qPH`>bggeOAV9 zxDDg8Zc9a|P%OKCkRAF9pd;>Lid;8mYxGx&Sd}>8vlg8rB3+?AQCIkkPcpa@ys_`n zsn8X`XgSqSn)&_${#WKms0R1gFG{vuFtvM9*_6}4AV4{N3y;bhWZ~8%sK$_G;UTy) zj87@2@KC(DHQs{NGXZcrNBweJ{sh*{|(fiu4)-=XLy)U`nXH^F(DOn z>72?pNv$lOwk!u$jsxGZf&Kj>#?#Xvo*v1tNKcq5=m{ULBvF$KJ;|w_P^vmTxsYX7 zqx8vgP3|{I!>A`rr75go^yF&|_2kE*Cn7|;Z)5C>6mTd;2L6ifhem%DK5eJ>HU|cb z=FyJNL}pzqu)!lBjyO&`Bi8CFaAKD*NW#5;rs!O;|8RrRhs7{n(cc@b%tGu?ayviG zS@zC@ZuKJ==P+P8M;D^i^Hu)OhYR>9gbM{~7t^zD(X6BMiZh!*T|K@o4-)XlRsjE1 zBY4i)&G2_zU4n;p%<<+)H0-Xq3uPurLU)l+W|FHDfD*c^gvtVD_X1eeU_0Cs_Eg5t za?UCsW4j#eLnQgAxOXT>1ykIPD67y;V3gA0UmfAQ-r*z=Dz-8yDwf}>mgZg3czXaF zt7aQVLS5)F_^!7*kb=zj$J01_5~uY-)ZqCrRaRPS|Clz{ACIE95baxXJcPQT?lA|M zt)QPVY2}K`$4V)Aiq4l22;IegsxtHi z`_Pv#Hh(n`*Ov*Gq+Jm~<5h@5uD6g9p_rm-inOX7A#c}P0C*g+h2cCK*dNxkEKJ)l z*19ZA@}|bBn1$*10PANGmZM*yV|Bkl3W7iL_9<>mMIM(d_f&Y<7!3kfOf@@tw z&N;#OALILS7#}e^AvEU&GMf-F@VedL6X5gs*NZk)PTr?WzxmiQ61>#(JTI zjiamfBZ+n{(Zs6g#J75u9!*FR&Apgt3{9a`>(KTQG=?V7rn6pV>ixq&P1Rm&7qz~S zN3hZmV?7M7(q;3GOf+ZUS#)+s;)x&i7W;%E5YuS1jhP3tZoGu=YFPD7R%?WMnU9NwUVeto$MsKKV-fotT$Ocj zgNw=3#Ge^gt8^zI=ntKUG7f8iyS2r*i-$^4E7%PW@J}+}9!W{%IRP(RSWn%n;JXC; zV1~L+!Ei0X{H+XloPx2t0^pS{sb@Z3!Seymrb;}VxtgloGo%xgl&3Mf!J-U!qJoPJ zIg3ReQqI4qBb5~`l3@>`5ZvI2EWE6|uM+rMS$K=W@lATrf0Bi_D*Rx9cl{)tDTu#K z;oATX2J?WRC0?VV>ohElT(XowHCm}Uh3oNIu45F=#rgQuaTdOk!k-ZMomqIh!fzD# z8(H{Rg`X|(@}-$nbtrs+z-MRSoeJNHa8+=ANY;K5bDu1MR>8`uAOMNdxHZ;yuSO$^ z(eQG36#jBk*`%)QH^>OnZ;&00H*nyiE?2umDr_rb^>S-MvN;&ne}jww8L~Dw@RNBM zwp3I}#}|ZN{;v%q)3g36B6e_EHeubG6Wb`l&$9@o%F-uwg9ce?>MZT1HB{WqrF;8t z$?Y~aKaRYuUxo~XUq+h|nZ5|7b6#l}_i|kd`td@i_OLsowK1`&QJeyl|BZ{rHpw@+ zH>_bXux-$^pX?NtjaI5rxoF^_dX`xCS$?qad`>AtMCFOU=C2Gxxs0G%lZjnXkc`%0J|m&OSPfe z-`xr0w85i{=J(M4q#OzO2aVu)=T$^>IpxGsmZKn^uHGnD9z}RAn0~o&pX`9QowK+O zVDGy~MoCvZ{00%XHu=BBqkl4B!49Bo@*l+iZvP?N{fBY$FurTnhmx&vcS zaNNCcGH1uWk28a&35oWbz12w%b=3HRPjIGoltp#4PudEZ3OTK(HGkcmDS22)0L#m5kE-g#&A zC1nnZ6Es&s?&?`gka%AwBC<$xtbf(9R;hf+MNlApqlfHHW?&3^Qt_t-ITh1|d^M8S7kEFG-hw$XA!T$xGy~@)x0hCz> z18uo(B>Q)nv~)eCO;VemhH)&ASzrogn6bd~SkRIEJlI_<5vPqNl|k3^b7b@?=!Y$- z>iH>hX8`LLQ43)+PeRPG&D1_W!{WHu=YrhMPr*;d$z1P8;O4Ik6|Y{D=9|Lh=-KDR z<(S$CxQC$wF%QZQXC&uy{HFSC+`^M7yv_F;WDJBsN!iuj%U=I#nCyZ??Xbdb0Kehr zu1mqDySZ-f`|KcTzRg75pw?h)<_3<1${uuau*(1hUqrpouK&khj)xy;d+4@Y%{qJ~ z*`q)8U5JkTAE)q92v6n14bR|%y{ohE64h^xn{i}K`&O`SL#d=iYgG7+mMb7!DE