Skip to content

Commit 15f8793

Browse files
radekdoulikjonpryor
authored andcommitted
[Xamarin.Android.Build.Tasks] Preserve Debugger Async Supports (#875)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=59516 Context: https://bugzilla.xamarin.com/show_bug.cgi?id=59015 The linker requires that the target process contain members such as `System.Threading.Tasks.Task.NotifyDebuggerOfWaitCompletion()`. If these members are missing, the runtime may abort: * Assertion at …xamarin-android/external/mono/mono/mini/debugger-agent.c:4765, condition `array->len == 1' not met [libc] Fatal signal 6 (SIGABRT), code -6 in tid 11492 (…) Update the linker so that `async`-related Debugger support infrastructure is preserved, so that the debugger can rely on them. *Note*: This commit does *not* fix the assert reported in Bug #59015 on Android as that happens when the linker is disabled as well. Fixing the assert from Bug #59015 will require another fix.
1 parent aa8ef23 commit 15f8793

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/MonoDroidMarkStep.cs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,14 @@ protected override TypeDefinition MarkType (TypeReference reference)
140140
if (type == null)
141141
return null;
142142

143-
if (type.Module.Assembly.Name.Name == "System.Core")
143+
switch (type.Module.Assembly.Name.Name) {
144+
case "mscorlib":
145+
ProcessCorlib (type);
146+
break;
147+
case "System.Core":
144148
ProcessSystemCore (type);
149+
break;
150+
}
145151

146152
if (type.HasMethods && type.HasInterfaces && type.Implements (ICustomMarshalerName)) {
147153
foreach (MethodDefinition method in type.Methods) {
@@ -155,6 +161,40 @@ protected override TypeDefinition MarkType (TypeReference reference)
155161
return type;
156162
}
157163

164+
bool DebugBuild {
165+
get { return _context.LinkSymbols; }
166+
}
167+
168+
void ProcessCorlib (TypeDefinition type)
169+
{
170+
switch (type.Namespace) {
171+
case "System.Runtime.CompilerServices":
172+
switch (type.Name) {
173+
case "AsyncTaskMethodBuilder":
174+
if (DebugBuild) {
175+
MarkNamedMethod (type, "SetNotificationForWaitCompletion");
176+
MarkNamedMethod (type, "get_ObjectIdForDebugger");
177+
}
178+
break;
179+
case "AsyncTaskMethodBuilder`1":
180+
if (DebugBuild) {
181+
MarkNamedMethod (type, "SetNotificationForWaitCompletion");
182+
MarkNamedMethod (type, "get_ObjectIdForDebugger");
183+
}
184+
break;
185+
}
186+
break;
187+
case "System.Threading.Tasks":
188+
switch (type.Name) {
189+
case "Task":
190+
if (DebugBuild)
191+
MarkNamedMethod (type, "NotifyDebuggerOfWaitCompletion");
192+
break;
193+
}
194+
break;
195+
}
196+
}
197+
158198
void ProcessSystemCore (TypeDefinition type)
159199
{
160200
switch (type.Namespace) {

0 commit comments

Comments
 (0)