-
Notifications
You must be signed in to change notification settings - Fork 564
[One .NET] fix debugging #4864
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
Merged
Merged
[One .NET] fix debugging #4864
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b543c26 to
0212fe0
Compare
Member
Author
|
One failure seems unrelated: Really weird, I guess this temp file |
dellis1972
approved these changes
Jun 25, 2020
jonpryor
reviewed
Jun 25, 2020
If you tried to debug an app with:
dotnet build HelloAndroid/HelloAndroid.csproj -t:Install,_Run -p:AndroidAttachDebugger=true
The presence of `$(AndroidAttachDebugger)` causes a crash on startup:
06-24 11:57:42.538 14948 14948 E mono : Unhandled Exception:
06-24 11:57:42.538 14948 14948 E mono : System.ArgumentNullException: Value cannot be null. (Parameter 'meth')
06-24 11:57:42.538 14948 14948 E mono : at System.Reflection.Emit.ILGenerator.Emit(OpCode opcode, MethodInfo meth)
06-24 11:57:42.538 14948 14948 E mono : at Android.Runtime.JNINativeWrapper.CreateDelegate(Delegate dlg)
06-24 11:57:42.538 14948 14948 E mono : at Android.App.Activity.GetOnCreate_Landroid_os_Bundle_Handler()
06-24 11:57:42.538 14948 14948 E mono : at Android.Runtime.AndroidTypeManager.RegisterNativeMembers(JniType nativeClass, Type type, String methods)
06-24 11:57:42.538 14948 14948 E mono : at Android.Runtime.JNIEnv.RegisterJniNatives(IntPtr typeName_ptr, Int32 typeName_len, IntPtr jniClass, IntPtr methods_ptr, Int32 methods_len)
06-24 11:57:42.538 14948 14948 E mono-rt : [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentNullException: Value cannot be null. (Parameter 'meth')
06-24 11:57:42.538 14948 14948 E mono-rt : at System.Reflection.Emit.ILGenerator.Emit(OpCode opcode, MethodInfo meth)
06-24 11:57:42.538 14948 14948 E mono-rt : at Android.Runtime.JNINativeWrapper.CreateDelegate(Delegate dlg)
06-24 11:57:42.538 14948 14948 E mono-rt : at Android.App.Activity.GetOnCreate_Landroid_os_Bundle_Handler()
06-24 11:57:42.538 14948 14948 E mono-rt : at Android.Runtime.AndroidTypeManager.RegisterNativeMembers(JniType nativeClass, Type type, String methods)
06-24 11:57:42.538 14948 14948 E mono-rt : at Android.Runtime.JNIEnv.RegisterJniNatives(IntPtr typeName_ptr, Int32 typeName_len, IntPtr jniClass, IntPtr methods_ptr, Int32 methods_len)
We need to check if `mono_unhandled_exception_method` is `null` and
respond appropriately. In `get_runtime_types()`, we will use a
different null check for `exception_handler_method` to return early.
This surfaced another problem when using the `_Run` target by itself:
Xamarin.Android.Common.Debugging.targets(518,2): error MSB3073: The command ""adb" forward tcp:10000 tcp:10000" exited with code 9009.
The `$(_AndroidPlatformToolsDirectory)` was blank when running `_Run`
by itself, but things work fine if you run `Install,_Run` at the same
time.
This broke in fb637e0. I accidentally replaced the
`AndroidPrepareForBuild` MSBuild target with the version in
`Xamarin.Android.Bindings.Core.targets`:
https://github.com/xamarin/xamarin-android/blob/f99a3fad1b12d9674de2f624e243f296cfc40fc6/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets#L47
To fix this, I can just move the binding project version of
`AndroidPrepareForBuild` target to `Xamarin.Android.Bindings.targets`.
I added a new test verifying that breakpoints work, when running under
.NET 5.
0212fe0 to
90a4612
Compare
Contributor
|
Updated commit message? |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If you tried to debug an app with:
The presence of
$(AndroidAttachDebugger)causes a crash on startup:We need to check if
mono_unhandled_exception_methodisnullandrespond appropriately. In
get_runtime_types(), we will use adifferent null check for
exception_handler_methodto return early.This surfaced another problem when using the
_Runtarget by itself:The
$(_AndroidPlatformToolsDirectory)was blank when running_Runby itself, but things work fine if you run
Install,_Runat the sametime.
This broke in fb637e0. I accidentally replaced the
AndroidPrepareForBuildMSBuild target with the version inXamarin.Android.Bindings.Core.targets:https://github.com/xamarin/xamarin-android/blob/f99a3fad1b12d9674de2f624e243f296cfc40fc6/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets#L47
To fix this, I can just move the binding project version of
AndroidPrepareForBuildtarget toXamarin.Android.Bindings.targets.I added a new test verifying that breakpoints work, when running under
.NET 5.