Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/7.0.2xx-xcode14.3] [runtime] Add support for passing on a connect timeout to sdb. #18056

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1851,6 +1851,7 @@
<MlaunchEnvironmentVariables Include="__XAMARIN_DEBUG_MODE__=$(XamarinDebugMode)" Condition="'$(XamarinDebugMode)' != ''" />
<MlaunchEnvironmentVariables Include="__XAMARIN_DEBUG_PORT__=$(XamarinDebugPort)" Condition="'$(XamarinDebugPort)' != ''" />
<MlaunchEnvironmentVariables Include="__XAMARIN_DEBUG_HOSTS__=$(XamarinDebugHosts.Replace(';', '%3B'))" Condition="'$(XamarinDebugHosts)' != ''" />
<MlaunchEnvironmentVariables Include="__XAMARIN_DEBUG_CONNECT_TIMEOUT__=$(XamarinDebugConnectTimeout)" Condition="'$(XamarinDebugConnectTimeout)' != ''" />
<!-- It's not possible to set an item group from the command line, so add support for setting a property (with semi-colon separated items) that we'll include into the item group -->
<MlaunchAdditionalArguments Include="$(MlaunchAdditionalArgumentsProperty)" Condition="'$(MlaunchAdditionalArgumentsProperty)' != ''" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public abstract class CreateDebugConfigurationTaskBase : XamarinTask {
[Required]
public bool SdkIsSimulator { get; set; }

public string ConnectTimeout { get; set; }
#endregion

public override bool Execute ()
Expand All @@ -52,6 +53,11 @@ public override bool Execute ()
builder.Append ("Port: ");
builder.AppendLine (DebuggerPort);

if (!string.IsNullOrEmpty (ConnectTimeout)) {
builder.Append ("Connect Timeout: ");
builder.AppendLine (ConnectTimeout);
}

var text = builder.ToString ();

try {
Expand Down
1 change: 1 addition & 0 deletions msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2369,6 +2369,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
AppBundleDir="$(_AppResourcesPath)"
ConnectTimeout="$(IOSDebugConnectTimeout)"
DebugOverWiFi="$(IOSDebugOverWiFi)"
DebugIPAddresses="$(_DebugIPAddresses)"
DebuggerPort="$(IOSDebuggerPort)"
Expand Down
25 changes: 22 additions & 3 deletions runtime/monotouch-debug.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
// permanent connection variables
static long monodevelop_port = -1;
static int sdb_fd = -1;
static long sdb_timeout_time = -1;
static int heapshot_fd = -1; // this is the socket to write 'heapshot' to to requests heapshots from the profiler
static long heapshot_port = -1;
static char *profiler_description = NULL;
Expand Down Expand Up @@ -593,6 +594,15 @@ void monotouch_configure_debugging ()
unsetenv ("__XAMARIN_DEBUG_HOSTS__");
}

evar = getenv ("__XAMARIN_DEBUG_CONNECT_TIMEOUT__");
if (evar && *evar) {
if (sdb_timeout_time == -1) {
sdb_timeout_time = strtol (evar, NULL, 10);
LOG (PRODUCT ": Found connect timeout %i in environment variables\n", sdb_timeout_time);
}
unsetenv ("__XAMARIN_DEBUG_CONNECT_TIMEOUT__");
}

#if MONOTOUCH && (defined(__i386__) || defined (__x86_64__))
// Try to read shared memory as well
key_t shmkey;
Expand Down Expand Up @@ -681,6 +691,8 @@ void monotouch_configure_debugging ()
#endif
} else if (!strncmp ("Port: ", line, 6) && monodevelop_port == -1) {
monodevelop_port = strtol (line + 6, NULL, 10);
} else if (!strncmp ("Connect Timeout: ", line, 17) && sdb_timeout_time == -1) {
sdb_timeout_time = strtol (line + 17, NULL, 10);
}
}
}
Expand All @@ -703,7 +715,7 @@ void monotouch_configure_debugging ()
if (monodevelop_port <= 0) {
LOG (PRODUCT ": Invalid IDE Port: %i\n", monodevelop_port);
} else {
LOG (PRODUCT ": IDE Port: %i Transport: %s\n", monodevelop_port, debugging_mode == DebuggingModeHttp ? "HTTP" : (debugging_mode == DebuggingModeUsb ? "USB" : "WiFi"));
LOG (PRODUCT ": IDE Port: %i Transport: %s Connect Timeout: %i\n", monodevelop_port, debugging_mode == DebuggingModeHttp ? "HTTP" : (debugging_mode == DebuggingModeUsb ? "USB" : "WiFi"), sdb_timeout_time);
if (debugging_mode == DebuggingModeUsb) {
monotouch_connect_usb ();
} else if (debugging_mode == DebuggingModeWifi) {
Expand Down Expand Up @@ -1251,8 +1263,15 @@ static ssize_t sdb_recv (void *buf, size_t len)
transport.recv = sdb_recv;

mono_debugger_agent_register_transport (&transport);

mono_debugger_agent_parse_options ("transport=custom_transport,address=dummy,embedding=1");

char *options;
if (sdb_timeout_time != -1) {
options = xamarin_strdup_printf ("transport=custom_transport,address=dummy,embedding=1,timeout=%d", sdb_timeout_time);
} else {
options = xamarin_strdup_printf ("transport=custom_transport,address=dummy,embedding=1");
}
mono_debugger_agent_parse_options (options);
// Can't free the 'options' variable, because mono_debugger_agent_parse_option stores the pointer instead of creating a copy :/

LOG (PRODUCT ": Debugger loaded with custom transport (fd: %i)\n", sdb_fd);
#else
Expand Down