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

36 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 34f58bbed4
[runtime] Use calloc instead of malloc. (#20692)
It's safer, since the returned memory is zero-initialized.

Also add tests.
2024-06-07 16:56:54 +02:00
Rolf Bjarne Kvinge efc7551e3f
[runtime] Add support for passing on a connect timeout to sdb. (#18037)
The timeout can be given:

* By setting the __XAMARIN_DEBUG_CONNECT_TIMEOUT__ environment variable for the app when launching it.
* By passing the XamarinDebugConnectTimeout MSBuild property to 'dotnet run' or 'dotnet build /t:Run'.
* By setting the IOSDebugConnectTimeout MSBuild property at build time.

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1778177.
2023-04-13 16:34:52 +02:00
Rolf Bjarne Kvinge a99f6c928a
[runtime] Remove dead code. (#15479)
This has been dead code for over 9 years!
2022-07-13 20:33:40 +02:00
Rolf Bjarne Kvinge 0dee77cd83
[runtime] Deal with the rest of the Mono Embedding API for CoreCLR. (#11642)
* [runtime] Mark numerous Mono Embedding API as used only by the MonoVM bridge.

* [runtime] Exclude more unused code from the CoreCLR build.

* There's no tracing in CoreCLR, so no need to process the MONO_TRACE environment
  variable (and set the trace options).
* There's no sdb debuggger, so that code can be skipped.
* The profiler support is very different, so skip that code too.
* We don't support AOT, nor aot data files, so skip that.

* [runtime] Stop generating dummy implementations of the Mono Embedding API for CoreCLR.

All of the Mono Embedding API now falls in either of these two categories:

* Only used by the MonoVM bridge.
* Has a CoreCLR implementation.

Which means that we don't need the code to generate dummy implementations for
methods that aren't in any of these two categories anymore.
2021-05-21 07:53:41 +02:00
Rolf Bjarne Kvinge ff619c2d21
[runtime] Fix a compiler warning. (#10755)
Fix this compiler warning:

    monotouch-debug.m:524:12: warning: unused variable 'monotouch_debug_enabled' [-Wunused-variable]
             NSString *monotouch_debug_enabled;
2021-03-03 07:41:35 +01:00
Rolf Bjarne Kvinge e0163bfb23
[runtime] Always enable debugging in .NET/macOS and .NET/Mac Catalyst in debug versions of libxamarin. (#10751)
This makes it so that it's possible to attach to the debugger by setting the
__XAMARIN_DEBUG_HOSTS__/__XAMARIN_DEBUG_PORT__ environment variables, without
the need for enabling a setting somewhere else (like in
Settings.bundle/Root.plist on mobile devices).
2021-03-02 15:33:44 +01:00
Rolf Bjarne Kvinge 7ab7e25138
[runtime] Build a .NET-specific libxamarin-dotnet[-debug].[a|dylib]. (#10723)
This also means linking with the runtime packs from .NET instead of the mono archive
(thus we have one less reliance on the mono archive).

We're also using the Xamarin.iOS code for our macOS launch sequence now, since
(at least at first) we're only going to support self-contained .NET macOS apps
(so no need to support a system-installed runtime, which simplifies things a
bit).
2021-02-26 14:42:30 +01:00
Rolf Bjarne Kvinge 9327af6960 [runtime] Put MonoTouchDebugConfiguration.txt in the app resources directory.
This is required for Catalyst apps, since no custom files can be in the root directory
for apps on macOS.
2020-12-03 10:42:25 +01:00
Sebastien Pouliot 37b62cbaae
[runtime] Only include debug over HTTP for watchOS devices (#8828)
We have better options for watchOS simulator and other platforms.

This only affects `lib*-debug.dylib` and `Xamarin-debug.framework`
as the non-debug binaries don't include debugging support.
2020-06-10 16:27:15 -04:00
Manuel de la Pena 3f0985ecac
[Runtime] Move some of the changes back to int. (#7529)
Some of the fixes done for the warnings have breaking changes. Move back
to int and ensure that we do not have any compilation errors (we are
using -Werror).

Fixes: https://github.com/xamarin/xamarin-macios/issues/7509
2019-12-11 22:17:29 -05:00
Manuel de la Pena 8f6a10f3bd
[Runtime] Enable the -Wsign-conversion on monotouch-debug files. (#7459)
Enable the flag that was disabled via pragmas and fix warnings.

Continuation of PR: https://github.com/xamarin/xamarin-macios/pull/7405
2019-11-20 13:42:51 -05:00
Manuel de la Pena 63ab48e679
[Runtime] Enable the -Wsign-conversion warnings flag and fix some of the warnings. (#7405)
The flag adds a lot (A LOT) of warnings. The diff would be huge and
dangerous to review. We enable the flag and fix file by file.
2019-11-12 15:10:16 -05:00
Manuel de la Pena 2e5b64893f
[Runtime] Enable the -Wshorten-64-to-32 flag and fix all warnings. (#7353)
* [Runtime] Enable the -Wshorten-64-to-32 flag and fix all warnings.

We want to enable the -Wconversion but that will raise too many warning
for a single commit. We are enabiling one by one the flags included in
-Wconversion so that we have smaller diffs.

-Wshorten-64-to-32 adds warnings when there is a implicit conversion that
loses integer precision. We are moving all the 32 to 64 conversions to
use 64. Expecially since most of the code changed is related with sizes,
legths and params counts that are never going to be negative.


Co-Authored-By: Rolf Bjarne Kvinge <rolf@xamarin.com>
2019-11-05 11:00:14 -05:00
Manuel de la Pena 8b45260ee4
[Runtime] Ensure that all comparisons between signed and unsigned values are fixed. (#7339)
Enable the -Wsign-compare which will raise issues when a comparison
between signed and unsigned values could produce an incorrect result
and fix all the raised warnings.
2019-10-30 15:58:13 -04:00
Rolf Bjarne Kvinge 0418008046
[runtime] Use newer atomic functions. (#7119)
Fixes these warnings:

    shared.m:252:6: warning: 'OSAtomicDecrement32Barrier' is deprecated: first deprecated in watchOS 3.0 - Use std::atomic_fetch_sub() from <atomic> instead [-Wdeprecated-declarations]
            if (OSAtomicDecrement32Barrier (&bl->descriptor->ref_count) == 0) {
                ^
    /Applications/Xcode11.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS6.0.sdk/usr/include/libkern/OSAtomicDeprecated.h:201:9: note: 'OSAtomicDecrement32Barrier' has been explicitly marked deprecated here
    int32_t OSAtomicDecrement32Barrier( volatile int32_t *__theValue );
            ^
    shared.m:270:2: warning: 'OSAtomicIncrement32' is deprecated: first deprecated in watchOS 3.0 - Use std::atomic_fetch_add_explicit(std::memory_order_relaxed) from <atomic> instead [-Wdeprecated-declarations]
            OSAtomicIncrement32 (&source->descriptor->ref_count);
            ^
    /Applications/Xcode11.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS6.0.sdk/usr/include/libkern/OSAtomicDeprecated.h:171:9: note: 'OSAtomicIncrement32' has been explicitly marked deprecated here
    int32_t OSAtomicIncrement32( volatile int32_t *__theValue );
            ^
    monotouch-debug.m:309:10: warning: 'OSAtomicIncrement32Barrier' is deprecated: first deprecated in watchOS 3.0 - Use std::atomic_fetch_add() from <atomic> instead [-Wdeprecated-declarations]
            int c = OSAtomicIncrement32Barrier (&http_send_counter);
                    ^
    /Applications/Xcode11.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS6.0.sdk/usr/include/libkern/OSAtomicDeprecated.h:182:9: note: 'OSAtomicIncrement32Barrier' has been explicitly marked deprecated here
    int32_t OSAtomicIncrement32Barrier( volatile int32_t *__theValue );
            ^
2019-09-27 07:15:59 +02:00
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