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

21 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 34c1d38917 [runtime] Disable debugging by default for watchOS apps on device. (#5184)
The previous default (Wifi) would never work; only Http mode works on watchOS
devices. This means that unless debugging was explicitly disabled (for
instance when running without debugging from the IDE), we'd try to connect in
WiFi mode (and gracefully fail, but showing error messages that are
unnecessary and potentally scary/confusing).
2018-11-27 16:30:32 -05:00
Rolf Bjarne Kvinge 02fe5339a4
[runtime] Clean up public symbols. Fixes #5124. (#5155)
* [runtime] Clean up public symbols. Fixes #5124.

Clean up public symbols, by:

* Symbols that don't need to be public (most of them), can be private.
* Prefix all public symbols with `xamarin_`.
* Add a test to ensure we don't introduce new public symbols.
* Use C symbols instead of mangled C++ symbols, since those are easier to
  handle in the test.

This minimizes the chance of getting into a symbol clash with another native library.

Fixes https://github.com/xamarin/xamarin-macios/issues/5124.

* Some test fixes.
2018-11-21 11:48:15 -05:00
Rolf Bjarne Kvinge ad67a39104
[runtime] Improve diagnostics/behavior in case of failure to contact the IDE when debugging. (#5029)
When debugging watchOS apps on device, we wait forever [1] for a connection to
be established to the IDE (iOS apps wait for only 2 seconds, but that's
because the app will be killed after a while, which we avoid on watchOS by
attaching the native debugger).

Unfortunately our error handling was not quite optimal, which meant that if
the connection to the IDE failed, we'd wait forever instead of launching the
app without attaching the debugger.

So improve this, by printing "Waiting for connection to the IDE..." messages
while trying to connect, and printing detailed log messages if the
connection attempt fails (as well as terminating the wait and launching the
watch app).

[1] In this case forever technically means "1 hour".
2018-10-24 07:52:58 +02:00
Rolf Bjarne Kvinge ad3a4a12eb [runtime] Store the launch mode in a static variable.
Store the launch mode in a static variable instead of storing if we're an
extension (since the launch mode also contains that information).

Also pass the launch mode around in Xamarin.Mac's initialization data.
2017-05-09 08:12:39 +02:00
Sebastien Pouliot 22a5cb5ab9 [runtime] Remove unicode character causing warnings at build time (#1945)
16:59:44 monotouch-debug.m:568:3: warning: treating Unicode character as whitespace [-Wunicode-whitespace]
16:59:44         } else if ((shmkey = ftok ("/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch", 0)) == -1) {
16:59:44          ^
2017-03-30 18:00:48 +02:00
Rolf Bjarne Kvinge 24dacc6d02 [runtime] Don't look in shared memory for debug data in normal apps (#1841)
* Bump maccore to get fix for launching the simulator for app extensions.

* [runtime] Don't look in shared memory for debug data in normal apps.

Don't look in shared memory for debug data in normal apps, because it
interferes when debugging extensions from the same solution as a container
app:

Example, for a keyboard extension:

1. Run extension in XS.
2. Manually launch the extension's container app (which contains a textbox
   that can be used to launch the keyboard).
3. The container app reads the debug data in shared memory which was intented
   for the extension, and takes over the debugger.
4. Launch keyboard, which will not be able to connect to the IDE because the
   container app already connected to the IDE.
2017-03-08 20:00:58 +01:00
Rolf Bjarne Kvinge 1992b667ec [runtime] Plug a leak in http debugging. (#1720)
Clang's static analyzer tought me something new today: 'copy' properties are
not automatically deallocated 😒:

    monotouch-debug.m:237:1: warning: 'XamarinHttpConnection' lacks a 'dealloc' instance method but must release '_completion_handler' and others
    @implementation XamarinHttpConnection
    ^
2017-02-20 19:35:17 +01:00
Rolf Bjarne Kvinge e5d601c8a5 [runtime] Remove unused return value from the *_connect_* debug functions. (#1719)
At the beginning of dawn, not long after the big bang, we used to vibrate the
phone if there was a problem when connecting to the debugger in the IDE, and
the number of times the phone vibrated indicated a certain error condition.

This innovative debugging technique was at some point replaced with more
intuitive (albeit less innovative) error reporting, however the *_connect_*
family of functions continued returning the number of times the phone should
vibrate, even if the caller was now soundlessly ignoring this information.

After many years someone had the wonderful idea of running a static analyzer
on the code, and now the unused return value is not so silent anymore:

    monotouch-debug.m:663:5: warning: Value stored to 'rv' is never read
                                    rv = monotouch_connect_usb ();
                                    ^    ~~~~~~~~~~~~~~~~~~~~~~~~
    monotouch-debug.m:665:5: warning: Value stored to 'rv' is never read
                                    rv = monotouch_connect_wifi (hosts);
                                    ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    monotouch-debug.m:667:5: warning: Value stored to 'rv' is never read
                                    rv = xamarin_connect_http (hosts);
                                    ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

So fix the warning by removing the return value.
2017-02-20 19:30:09 +01:00
Rolf Bjarne Kvinge 8e229908df [runtime] Blocks must be copied, not just assigned. Fixes #44568. (#1471)
The completion handler block must be copied to the XamarinHttpConnection
instance, otherwise we'll just store a pointer to a stack block, and once we
invoke the block we'll access stack memory (probably from another thread),
which is really not what we want to do.

https://bugzilla.xamarin.com/show_bug.cgi?id=44568
2017-01-11 19:45:38 +01:00
Rolf Bjarne Kvinge 19d237473e [runtime] Fix support for debugging on watch device with multiple IP addresses. Fixes #44568. (#898)
At startup we send a request to all the IP addresses we have,
so we must make sure to not get confused if we get responses
from more than one of them.

This fix also requires an updated mlaunch.

https://bugzilla.xamarin.com/show_bug.cgi?id=44568
2016-09-27 08:07:31 -04:00
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
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
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 af0d01c93a Initial review pass for COOP for watchOS. 2016-05-26 17:47:10 +02:00
Rolf Bjarne Kvinge ac418df815 Build our runtime. 2016-04-24 14:47:24 -04:00