Граф коммитов

63 Коммитов

Автор SHA1 Сообщение Дата
Sebastien Pouliot 0cc8b176e8 Merge branch 'cycle8' into xcode8 2016-09-06 18:46:23 -04:00
Rolf Bjarne Kvinge cfb84f6e17 [runtime] Use printf on watchOS, NSLog doesn't shown up (by default) (#772)
* [runtime] Use printf on watchOS, NSLog doesn't shown up (by default).

* [runtime] Use a wrapper function for logging.

So that we can chose between printf and NSLog at runtime,
depending on where we're running.
2016-09-06 16:55:23 -04:00
Rolf Bjarne Kvinge 3859240031 Add support for debugging over http. Fixes #41554.
The watchOS device has limited networking support; in particular
it does not allow inbound/output network connections using 'bind'
(kernel-level sandbox restrictions).

This means that we can't use BSD sockets to connect to the debugger
in the IDE on the desktop. Instead we create an http tunnel that
knows how to convert socket send/recv data into http requests on
both sides.

https://bugzilla.xamarin.com/show_bug.cgi?id=41554
2016-09-05 10:05:00 +02:00
Rolf Bjarne Kvinge a9294ab9c8 [runtime] Check if debug mode is specified in environment variables. 2016-09-05 10:05:00 +02:00
Rolf Bjarne Kvinge 18a5b4eccb [runtime] Make the debugger mode an enum instead of bool to allow more than two debugger modes. 2016-09-05 10:05:00 +02:00
Rolf Bjarne Kvinge d11b3f2761 [runtime] Only enable debugging on watchOS devices if a native debugger is also attached.
Launching a watchOS extension on device with the managed debugger
attached is slow, which means that the launch watchdog will kick in
and kill the app before it has launched.

So we attach the native debugger as well, which prevents the launch
watchdog from killing the app. Incidentally it also makes watchOS
not background the app.

We're using private API to determine whether a native debugger is
attached, but it's only in debug code, and as such would not be
included in release builds for customer apps. Also the code is
currently limited to watchOS since it's not needed on other
platforms for now.
2016-09-05 10:05:00 +02:00
Alex Soto 209f4f3709 [GameplayKit] Update from Xcode8 Beta 1 to Beta 6 (#689)
Runtime
- Added support for Vector2d, Vector3d and Vector4d SIMD types
- Added support for GKBox, GKQuad and GKTriangle SIMD types

GameplayKit
- Apple introduced GKQuadTreeNode and GKQuadTree in Xcode 7.1 and
  removed those types in a later Xcode (7.2?) but we kept them around.
  Now apple introduced again both types but renamed them to GKQuadtreeNode
  and GKQuadtree (lowercase t), this is a breaking change and since we do
  care about binary compat we are just changing the registration name and
  keeping the same managed name deprecating old methods and introducing
  the new ones.
- Added tests for new SIMD types
2016-08-30 15:32:46 -04:00
Rolf Bjarne Kvinge 36ea73ca65 Share the same block descriptors between copies of a block. Fixes #43592. (#683)
In bug #43592 the following occurs:

* App calls an API that takes a block.
* We create a stack-based ObjC block based on the delegate the app provided.
  This block has a pointer to a block description, describing the block
  in question (including the signature of the block, as an ObjC-type
  encoded string). We allocate a new block description for every block.
* Apple's API stores the pointer to the signature string somewhere.
* Apple calls _Block_copy to get a heap-based block.
* We create a heap-based block, and copy the entire description into the
  new heap-based block (including a copy of the signature).
* Apple returns from the API, and then we free the stack-based block
  (and the descriptor, and thus the signature string in the descriptor).
* Apple uses the pointer to the signature stored previously to investigate
  the signature of the block, and crashes because this signature has been
  freed.

The assumption in Apple's code is that the description will never be freed,
which is true for any Xcode project (clang will always be able to create the
block description at compile-time and emit it in the binary, which means the
memory will never be freed). We could potentially do the same thing in the
static registrar, but we'd still need a solution when using the dynamic
registrar.

To fix this instead of copying the entire description structure when creating
a heap-based block from the stack-based block, we make the description ref-
counted, and just use the same description in the heap-based block.

The signature will now stay in memory until both the heap-based and stack-
based blocks have been freed, and we hope Apple doesn't have any API that
needs the signature after all the blocks for that signature have been freed.

https://bugzilla.xamarin.com/show_bug.cgi?id=43592
2016-08-26 19:22:38 +02:00
Vincent Dondain 5999d9cc4e [modelio] Update for iOS 10 beta 1 (#606) 2016-08-19 13:55:59 -04:00
Vincent Dondain ddd1988f64 [spritekit] Update for iOS 10 beta 1 (#498)
* [spritekit] Update for iOS 10 beta 1

* [spritekit] Add missing MarshalDirective

* [runtime] Add missing simd function signatures

- Add matrix_float2x2 and matrix_float3x3 natives types.

* [introspection] Fix ApiSignatureTest

- We now avoid checking {?=[X]} encoded signatures.
- We now calculate the right size for matrix_float2x2, matrix_float3x3 and matrix_float4x4.
- Fix SKWarpGeometryGrid wrong bindings revealed by tests (IntPtr instead of Vector2).

* [monotouch-test] Add SKUniform and SKWarpGeometryGrid tests
2016-08-03 19:12:07 +02:00
Rolf Bjarne Kvinge 1c8a8db412 [runtime] Make sure to call mono_gc_init_finalizer_thread for watchOS. Fixes #42780. (#504)
https://bugzilla.xamarin.com/show_bug.cgi?id=42780
2016-07-28 09:56:55 +02:00
Rolf Bjarne Kvinge 22921dd8b7 [runtime] Fix a crash that occurs when Objective-C holds weak references. Fixes #39236. (#501)
Fix xamarin_switch_gchandle to not crash if the gchandle happens
to point to null (a collected object).

https://bugzilla.xamarin.com/show_bug.cgi?id=39236
2016-07-27 17:43:28 +02:00
Rolf Bjarne Kvinge 774fdf80b6 [runtime] Set base directory and config file name for extensions. Fixes #42784. (#493)
The base directory and config file name is normally set automatically
when we ask Mono to execute the Main function, but in the case of extensions,
there is no Main function, so these values are not set, causing some
features (reflection-only assembly load) to not work correctly.

https://bugzilla.xamarin.com/show_bug.cgi?id=42784
2016-07-26 11:39:33 -04:00
Rolf Bjarne Kvinge e6fc5a15d0 [runtime] Parse unions in objc encodings correctly. Fixes #42452. (#394)
Unions are defined as follows:

    (name=type...)

and we were not correctly parsing the 'name=' part.

https://bugzilla.xamarin.com/show_bug.cgi?id=42452
2016-07-14 18:03:02 +02:00
Rolf Bjarne Kvinge 905a6bc03c [runtime] Fix watchOS debugging. (#318)
Don't call any COOP macros when configuring the debugger/profiler.

This occurs before the root domain has been created, which means
that the current thread can't be attached.

Since the COOP macros assert that the thread is attached,
we end up aborting:

    Jun 29 13:35:56 Rolfs-Mac-Pro monotouchtest[97569]: Cannot enter GC safe region if the thread is not attached

    Thread 2 Crashed:
    0   libsystem_kernel.dylib        	0x08753572 __pthread_kill + 10
    1   libsystem_pthread.dylib       	0x0871b654 pthread_kill + 101
    2   libsystem_c.dylib             	0x084a962d abort + 156
    3   com.xamarin.monotouch-test.watchkitapp.watchkitextension	0x0033901f monoeg_log_default_handler + 159
    4   com.xamarin.monotouch-test.watchkitapp.watchkitextension	0x00339087 monoeg_g_log + 103 (goutput.c:114)
    5   com.xamarin.monotouch-test.watchkitapp.watchkitextension	0x00329e00 check_info + 96 (mono-threads-coop.c:93)
    6   com.xamarin.monotouch-test.watchkitapp.watchkitextension	0x00329b3d mono_threads_enter_gc_safe_region_unbalanced_with_info + 45 (mono-threads-coop.c:230)
    7   com.xamarin.monotouch-test.watchkitapp.watchkitextension	0x00329a7a mono_threads_enter_gc_safe_region_with_info + 26 (mono-threads-coop.c:204)
    8   com.xamarin.monotouch-test.watchkitapp.watchkitextension	0x00329a4b mono_threads_enter_gc_safe_region + 27 (mono-threads-coop.c:193)
    9   com.xamarin.monotouch-test.watchkitapp.watchkitextension	0x0035e2d2 recv_uninterrupted(int, void*, int) + 50 (monotouch-debug.m:402)
    10  com.xamarin.monotouch-test.watchkitapp.watchkitextension	0x0035e531 monotouch_process_connection(int) + 193 (monotouch-debug.m:828)
    11  com.xamarin.monotouch-test.watchkitapp.watchkitextension	0x0035e0cf monotouch_connect_wifi(NSMutableArray*) + 2815 (monotouch-debug.m:604)
    12  com.xamarin.monotouch-test.watchkitapp.watchkitextension	0x0035cb42 monotouch_configure_debugging + 3858 (monotouch-debug.m:344)
    13  com.xamarin.monotouch-test.watchkitapp.watchkitextension	0x00351d37 -[CocoaThreadInitializer entryPoint:] + 119 (shared.m:131)
    14  com.apple.Foundation          	0x01d30259 -[NSThread main] + 76
    15  com.apple.Foundation          	0x01de5484 __NSThread__start__ + 1346
    16  libsystem_pthread.dylib       	0x08718780 _pthread_body + 138
    17  libsystem_pthread.dylib       	0x087186f6 _pthread_start + 155
    18  libsystem_pthread.dylib       	0x08715f7a thread_start + 34
2016-06-29 08:45:43 -07:00
Rolf Bjarne Kvinge 386c15c503 Merge pull request #153 from rolfbjarne/more-exceptions
Handle any exceptions when returning from managed code back to our native runtime.
2016-06-09 18:13:23 +02:00
Chris Hamons b7a797b068 [XM] Dynamically look up NSExtensionMain to unbreak pre-10.10 XM apps (#154)
* [XM] Dynamically look up NSExtensionMain to unbreak pre-10.10 XM apps

- So having a simple reference to NSExtensionMain is enough for /usr/lib/libextension.dylib to get added as a reference to libxammac.dylib
- If you have a reference to /usr/lib/libextension.dylib then any XM app (including our tests) bomb out on startup. This is suboptimal.
- So dlopen/dysm our way to victory.

* Fix spacing
2016-06-09 00:19:16 +02:00
Rolf Bjarne Kvinge b9629ac8ba [runtime] Improve documentation about exceptions a little bit. 2016-06-08 20:11:07 +02:00
Rolf Bjarne Kvinge 2d28e24837 [runtime] Handle any exceptions whenever we return from managed code. 2016-06-08 20:05:54 +02:00
Rolf Bjarne Kvinge 5e302f9719 [runtime] Catch and process managed exceptions that are thrown in reverse P/Invoke (delegate) callbacks. 2016-06-08 20:05:54 +02:00
Rolf Bjarne Kvinge 71f4d78b18 [runtime] Generated binding wrappers that catch ObjC exceptions are supposed to always convert to managed exceptions. (#133) 2016-06-06 14:33:37 +02:00
Rolf Bjarne Kvinge db68e69a1d [runtime] Support binding NSObjects as IntPtr. Fixes #41132. (#103)
Support binding NSObjects as IntPtr. This is usually not
a problem, because when we fetch the ObjC signature for a
method, we usually get the signature as exported by us,
(in which case a parameter bound as 'IntPtr' would be treated
as 'void *' in the dynamic registrar) *except* when the
selector corresponds with a protocol the type implements,
in which case we get the signature as defined in the protocol.

https://bugzilla.xamarin.com/show_bug.cgi?id=41132
2016-05-31 11:58:27 +02:00
Rolf Bjarne Kvinge c9bcf1f56d [runtime] Mark all the new Mono API we're using for coop as optional. (#100)
This fixes Xamarin.Mac apps using older system monos.
2016-05-30 15:27:02 +02:00
Rolf Bjarne Kvinge 0b24bc0b8d [runtime] Fix boolean logic for thread attach/detach implementation. 2016-05-27 10:35:05 +02:00
Rolf Bjarne Kvinge e1464027f2 [runtime] Make new functions optional so that they don't hang XM apps using system mono at launch. 2016-05-26 17:47:44 +02:00
Rolf Bjarne Kvinge 5054c1ee45 [runtime] Update thread attach/detach according to mono changes.
* Restore the mono_jit_thread_attach signature to how it's in
  the latest stable.

* Don't use the new attach/detach methods when using the dynamic
  mono runtime, since the methods aren't available in any released
  version of mono. Also XM doesn't support coop yet, so it's not
  needed.

* And finally don't use the new attach/detach methods for anything
  that isn't building using mono/master (iow only watchOS). This
  should be changed once the rest of the products starts using
  mono/master again.
2016-05-26 17:47:44 +02:00
Zoltan Varga 5270b63cee [runtime] Use the same coop gc macro names as mono master does. 2016-05-26 17:47:10 +02:00
Zoltan Varga 8b59d42144 Make the sdb send/receive functions run in gc safe mode. 2016-05-26 17:47:10 +02:00
Rolf Bjarne Kvinge 13b7c6dd11 [runtime] Make sure to switch to GC SAFE before calling xamarin_switch_gchandle. 2016-05-26 17:47:10 +02:00
Rolf Bjarne Kvinge ac8d493581 [runtime] Attach the current thread in xamarin_invoke_trampoline.
It's entirely possible to call xamarin_invoke_trampoline on a
thread we've never heard about before.
2016-05-26 17:47:10 +02:00
Rolf Bjarne Kvinge 4a5ce42b48 [runtime] Add a MONO_ASSERT_GC_SAFE_OR_DETACHED.
Since MONO_ASSERT_GC_SAFE asserts when executed on a detached thread,
and yet it's clearly safe for the GC to run when a thread is detached.
2016-05-26 17:47:10 +02:00
Rolf Bjarne Kvinge d7bdc5d126 [runtime] mono_set_pending_exception expects to be in GC Unsafe mode. 2016-05-26 17:47:10 +02:00
Rolf Bjarne Kvinge af0d01c93a Initial review pass for COOP for watchOS. 2016-05-26 17:47:10 +02:00
Rolf Bjarne Kvinge ac5ff5e321 [runtime] Replace xamarin_try_get_nsobject with xamarin_has_nsobject.
Removes one usage of ObjectWrapper, since we don't actually need
the return value, we just need to know if an object exists.
2016-05-26 17:47:10 +02:00
Rolf Bjarne Kvinge fc0f656a53 [runtime] Make xamarin_[create|release]_managed_ref icalls.
This way we can pass pointers to managed objects to the native objects
without the coop GC interfering (since icalls won't automatically
switch to "gc safe" mode).
2016-05-26 17:47:10 +02:00
Rolf Bjarne Kvinge 297b6a24f3 [runtime] Ignore SIGPIPE for watchOS.
Usually mono does this for other apps, but not for watchOS (where mono doesn't
use signals at all).

watchOS can still raise signals though, so we need to ignore at least SIGPIPE.
2016-05-26 17:47:10 +02:00
Rolf Bjarne Kvinge 5feea25f3c [runtime] Use xamarin_process_nsexception instead of xamarin_throw_ns_exception in our generated bindings. (#84)
This makes the generated bindings play nice with exception marshaling.
2016-05-26 13:36:56 +02:00
Rolf Bjarne Kvinge a5c7575387 [runtime] Remove debug printf I haven't figured out how to fix. (#85)
As far as I can tell there are no memory warnings on watchOS,
but I can't find any documentation saying that either.
2016-05-26 13:11:28 +02:00
Chris Hamons ca028ea150 [Mac] Add support for os x extensions (#83) 2016-05-25 17:20:33 -04:00
Rolf Bjarne Kvinge d48d7c2e11 [configure] Add option to disable device-related parts of the build. (#67)
And use it when building on jenkins.
2016-05-19 14:33:35 +02:00
Sebastien Pouliot 323c7f42fc [runtime] Add dummy _stret symbols for iOS/ARM64 (#66)
The `_stret` API are not included in the ARM64 version of iOS (not
needed) but the removal of `dlsym` cause build failures*

So we're providing dummy symbols, just like what we did for tvOS,
to please the native linker (so nothing is undefined) and keep the
benefits of not using dlsym.

* Xamarin.iOS.dll (or other bindings) when the linker is disabled.
Normally the linker would remove the 32bits parts of the bindings
on a 64bits slice (and that would not be noticed). However we can
not assume this will be done for all binding projects, hence this
workaround.
2016-05-18 16:51:45 -04:00
Rolf Bjarne Kvinge cffc2e9181 Rewrite user-visible messages to use 'cooperative mode' instead of 'coop'.
This seems to be how we describe it publicly: http://tirania.org/blog/archive/2015/Dec-22.html
2016-05-17 11:30:38 +02:00
Rolf Bjarne Kvinge f7a5b7fb70 [runtime] Add docs about exception marshaling. 2016-05-17 11:24:04 +02:00
Rolf Bjarne Kvinge 7c1b81eb9d [runtime] Make sure the stack is correctly aligned to 16 bytes. 2016-05-17 11:24:03 +02:00
Rolf Bjarne Kvinge 53582429ec [runtime] Use the right condition when to reference libxammac.dylib vs __Internal. 2016-05-17 11:24:03 +02:00
Rolf Bjarne Kvinge f478657298 [runtime] Only insert dllmap for exception marshalling when the ObjC runtime supports zero-cost exceptions. 2016-05-17 11:24:03 +02:00
Rolf Bjarne Kvinge feb12f61b5 [runtime] mono_set_pending_exception is a private function in mono, so make it optional.
Otherwise Xamarin.Mac apps using the system mono will fail.
2016-05-17 11:24:03 +02:00
Rolf Bjarne Kvinge e51c48cda5 [runtime] Don't store xmm registers where we store other registers.
We store $ebx at $ebp-12:

	pushl	%ebx		# %ebp-12

so then storing xmm0 at $ebp-24:

	movaps	%xmm0, -24(%ebp)

would write 16 bytes between $ebp-24 and $ebp-8, thus overwriting
the place where we stored $ebx.

So allocate a bit more stack space and store the xmm registers
further 16 bytes down.
2016-05-17 11:24:02 +02:00
Rolf Bjarne Kvinge e8e8d6ea43 [runtime] Fix lookup of the inner exception when printing exception messages. 2016-05-17 11:24:02 +02:00
Rolf Bjarne Kvinge 79c68238ce [runtime] Don't use NSMethodSignature to compute frame size, it can't handle all method signature encodings.
In particular NSMethodSignature chokes on encodings like this:

	[NSDecimalNumber initWithDecimal:] = "@36@0:8{?=b8b4b1b1b18[8S]}16"

with an exception:

	NSInvalidArgumentException Reason: +[NSMethodSignature signatureWithObjCTypes:]: unsupported type encoding spec '{?}'

so implement our own code to calculate the frame size.
2016-05-17 11:24:02 +02:00