-
Notifications
You must be signed in to change notification settings - Fork 64
[Java.Interop.Tools.Cecil] fix symbol loading in DirectoryAssemblyResolver
#1176
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
Conversation
src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs
Outdated
Show resolved
Hide resolved
| { | ||
| bool haveDebugSymbols = loadDebugSymbols && | ||
| (File.Exists (Path.ChangeExtension (file, ".pdb")) || | ||
| File.Exists (file + ".mdb")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed .mdb support, which should be fine as it was removed for a while now: dotnet/android#7950
43bc5e5 to
1a2d9bf
Compare
|
Testing this here, in case: dotnet/android#8592 |
…ls (#8571) Context: #8421 Reviewing the build log from: dotnet new maui dotnet build -f net8.0-android -bl I noticed: LinkAssembliesNoShrink 3.410s ... Failed to read 'C:\Program Files\dotnet\packs\Microsoft.Android.Runtime.34.android-arm64\34.0.52\runtimes\android-arm64\lib\net8.0\Mono.Android.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'C:\Program Files\dotnet\packs\Microsoft.Android.Runtime.34.android-arm64\34.0.52\runtimes\android-arm64\lib\net8.0\Java.Interop.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\microsoft.maui.controls.compatibility\8.0.3\lib\net8.0-android34.0\Microsoft.Maui.Controls.Compatibility.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\microsoft.maui.controls.core\8.0.3\lib\net8.0-android34.0\Microsoft.Maui.Controls.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\microsoft.maui.core\8.0.3\lib\net8.0-android34.0\Microsoft.Maui.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.appcompat\1.6.1.3\lib\net6.0-android31.0\Xamarin.AndroidX.AppCompat.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.fragment\1.6.0.1\lib\net6.0-android31.0\Xamarin.AndroidX.Fragment.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.drawerlayout\1.2.0.3\lib\net6.0-android31.0\Xamarin.AndroidX.DrawerLayout.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.activity\1.7.2.1\lib\net6.0-android31.0\Xamarin.AndroidX.Activity.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.core\1.10.1.2\lib\net6.0-android31.0\Xamarin.AndroidX.Core.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.recyclerview\1.3.0.3\lib\net6.0-android31.0\Xamarin.AndroidX.RecyclerView.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.viewpager\1.0.0.19\lib\net6.0-android31.0\Xamarin.AndroidX.ViewPager.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.swiperefreshlayout\1.1.0.14\lib\net6.0-android31.0\Xamarin.AndroidX.SwipeRefreshLayout.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.cardview\1.0.0.21\lib\net6.0-android31.0\Xamarin.AndroidX.CardView.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.google.android.material\1.9.0.2\lib\net6.0-android31.0\Xamarin.Google.Android.Material.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.viewpager2\1.0.0.21\lib\net6.0-android31.0\Xamarin.AndroidX.ViewPager2.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.coordinatorlayout\1.2.0.7\lib\net6.0-android31.0\Xamarin.AndroidX.CoordinatorLayout.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\microsoft.maui.graphics\8.0.3\lib\net8.0-android34.0\Microsoft.Maui.Graphics.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.navigation.fragment\2.6.0.1\lib\net6.0-android31.0\Xamarin.AndroidX.Navigation.Fragment.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\microsoft.maui.essentials\8.0.3\lib\net8.0-android34.0\Microsoft.Maui.Essentials.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.collection\1.2.0.9\lib\net6.0-android31.0\Xamarin.AndroidX.Collection.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.vectordrawable.animated\1.1.0.19\lib\net6.0-android31.0\Xamarin.AndroidX.VectorDrawable.Animated.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.lifecycle.common\2.6.1.3\lib\net6.0-android31.0\Xamarin.AndroidX.Lifecycle.Common.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.lifecycle.viewmodel\2.6.1.3\lib\net6.0-android31.0\Xamarin.AndroidX.Lifecycle.ViewModel.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.savedstate\1.2.1.3\lib\net6.0-android31.0\Xamarin.AndroidX.SavedState.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.activity.ktx\1.7.2.1\lib\net6.0-android31.0\Xamarin.AndroidX.Activity.Ktx.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.annotation.experimental\1.3.1.1\lib\net6.0-android31.0\Xamarin.AndroidX.Annotation.Experimental.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.annotation.jvm\1.6.0.2\lib\net6.0-android31.0\Xamarin.AndroidX.Annotation.Jvm.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.appcompat.appcompatresources\1.6.1.3\lib\net6.0-android31.0\Xamarin.AndroidX.AppCompat.AppCompatResources.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.arch.core.common\2.2.0.3\lib\net6.0-android31.0\Xamarin.AndroidX.Arch.Core.Common.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.arch.core.runtime\2.2.0.3\lib\net6.0-android31.0\Xamarin.AndroidX.Arch.Core.Runtime.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.browser\1.5.0.3\lib\net6.0-android31.0\Xamarin.AndroidX.Browser.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.collection.ktx\1.2.0.9\lib\net6.0-android31.0\Xamarin.AndroidX.Collection.Ktx.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.concurrent.futures\1.1.0.14\lib\net6.0-android31.0\Xamarin.AndroidX.Concurrent.Futures.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.constraintlayout\2.1.4.6\lib\net6.0-android31.0\Xamarin.AndroidX.ConstraintLayout.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.constraintlayout.core\1.0.4.6\lib\net6.0-android31.0\Xamarin.AndroidX.ConstraintLayout.Core.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.versionedparcelable\1.1.1.19\lib\net6.0-android31.0\Xamarin.AndroidX.VersionedParcelable.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.core.core.ktx\1.10.1.2\lib\net6.0-android31.0\Xamarin.AndroidX.Core.Core.Ktx.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.cursoradapter\1.0.0.19\lib\net6.0-android31.0\Xamarin.AndroidX.CursorAdapter.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.customview\1.1.0.18\lib\net6.0-android31.0\Xamarin.AndroidX.CustomView.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.customview.poolingcontainer\1.0.0.5\lib\net6.0-android31.0\Xamarin.AndroidX.CustomView.PoolingContainer.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.documentfile\1.0.1.19\lib\net6.0-android31.0\Xamarin.AndroidX.DocumentFile.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.dynamicanimation\1.0.0.19\lib\net6.0-android31.0\Xamarin.AndroidX.DynamicAnimation.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.emoji2\1.3.0.3\lib\net6.0-android31.0\Xamarin.AndroidX.Emoji2.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.startup.startupruntime\1.1.1.7\lib\net6.0-android31.0\Xamarin.AndroidX.Startup.StartupRuntime.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.emoji2.viewshelper\1.3.0.3\lib\net6.0-android31.0\Xamarin.AndroidX.Emoji2.ViewsHelper.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.exifinterface\1.3.6.2\lib\net6.0-android31.0\Xamarin.AndroidX.ExifInterface.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.fragment.ktx\1.6.0.1\lib\net6.0-android31.0\Xamarin.AndroidX.Fragment.Ktx.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.interpolator\1.0.0.19\lib\net6.0-android31.0\Xamarin.AndroidX.Interpolator.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.legacy.support.core.utils\1.0.0.19\lib\net6.0-android31.0\Xamarin.AndroidX.Legacy.Support.Core.Utils.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.lifecycle.livedata\2.6.1.3\lib\net6.0-android31.0\Xamarin.AndroidX.Lifecycle.LiveData.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.lifecycle.livedata.core\2.6.1.3\lib\net6.0-android31.0\Xamarin.AndroidX.Lifecycle.LiveData.Core.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.lifecycle.livedata.core.ktx\2.6.1.3\lib\net6.0-android31.0\Xamarin.AndroidX.Lifecycle.LiveData.Core.Ktx.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.lifecycle.process\2.6.1.3\lib\net6.0-android31.0\Xamarin.AndroidX.Lifecycle.Process.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.lifecycle.runtime\2.6.1.3\lib\net6.0-android31.0\Xamarin.AndroidX.Lifecycle.Runtime.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.lifecycle.runtime.ktx\2.6.1.3\lib\net6.0-android31.0\Xamarin.AndroidX.Lifecycle.Runtime.Ktx.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.lifecycle.viewmodel.ktx\2.6.1.3\lib\net6.0-android31.0\Xamarin.AndroidX.Lifecycle.ViewModel.Ktx.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.lifecycle.viewmodelsavedstate\2.6.1.3\lib\net6.0-android31.0\Xamarin.AndroidX.Lifecycle.ViewModelSavedState.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.loader\1.1.0.19\lib\net6.0-android31.0\Xamarin.AndroidX.Loader.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.localbroadcastmanager\1.1.0.7\lib\net6.0-android31.0\Xamarin.AndroidX.LocalBroadcastManager.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.navigation.common\2.6.0.1\lib\net6.0-android31.0\Xamarin.AndroidX.Navigation.Common.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.navigation.runtime\2.6.0.1\lib\net6.0-android31.0\Xamarin.AndroidX.Navigation.Runtime.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.navigation.ui\2.6.0.1\lib\net6.0-android31.0\Xamarin.AndroidX.Navigation.UI.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.print\1.0.0.19\lib\net6.0-android31.0\Xamarin.AndroidX.Print.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.profileinstaller.profileinstaller\1.3.1.2\lib\net6.0-android31.0\Xamarin.AndroidX.ProfileInstaller.ProfileInstaller.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.resourceinspection.annotation\1.0.1.7\lib\net6.0-android31.0\Xamarin.AndroidX.ResourceInspection.Annotation.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.savedstate.savedstate.ktx\1.2.1.3\lib\net6.0-android31.0\Xamarin.AndroidX.SavedState.SavedState.Ktx.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.security.securitycrypto\1.1.0.1-alpha06\lib\net6.0-android31.0\Xamarin.AndroidX.Security.SecurityCrypto.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.slidingpanelayout\1.2.0.7\lib\net6.0-android31.0\Xamarin.AndroidX.SlidingPaneLayout.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.tracing.tracing\1.1.0.6\lib\net6.0-android31.0\Xamarin.AndroidX.Tracing.Tracing.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.transition\1.4.1.12\lib\net6.0-android31.0\Xamarin.AndroidX.Transition.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.vectordrawable\1.1.0.19\lib\net6.0-android31.0\Xamarin.AndroidX.VectorDrawable.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.window\1.1.0.1\lib\net6.0-android31.0\Xamarin.AndroidX.Window.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. Failed to read 'D:\.nuget\packages\xamarin.androidx.window.extensions.core.core\1.0.0.1\lib\net6.0-android31.0\Xamarin.AndroidX.Window.Extensions.Core.Core.dll' with debugging symbols. Retrying to load it without it. Error details are logged below. In general, it doesn't feel like we need `Mono.Cecil` to load symbols at all for this task. That feels like it would be useful for `Release` mode that is doing *real* trimming, but not in debug mode. Generally, we don't think anyone will be debugging the assemblies changed in this `<LinkAssembliesNoShrink/>` task. They would likely be old, precompiled assemblies from NuGet if they need to be fixed up. Some other issues were discovered here, addressing in: dotnet/java-interop#1176 I disabled symbol loading in this task, but left a private `$(_AndroidLinkAssembliesReadSymbols)` as an escape hatch if this is ever needed. This should avoid 74 exceptions that were try-catch'd in the build log.
…solver` Context: 7d42864d Context: dotnet/android#8571 While debugging dotnet/android#8571, I found the usage of `MemoryMappedFile` (from 7d42864) broke `.pdb` symbol loading. This is OK, because we'll likely disable symbol loading anyway, but we should at least address our bugs here for the future. In order for the following code to load symbols: AssemblyDefinition result = ModuleDefinition.ReadModule (viewStream, options).Assembly; You would need the following `ReaderParameters`: * `ReadSymbols=true` * `SymbolStream` containing a valid `Stream` to the `.pdb` file To make this work, I had to: * Create a `List<IDisposable>` for bookkeeping. * When successful, we transfer ownership of the `MemoryMappedFile` from the `List<IDisposable>` of `MemoryMappedViewStream` to the `viewStreams` collection. * When unsuccessful, we'd just dispose of the `MemoryMappedViewStream`. * If `ReadWrite=true`, we can just use `File.OpenRead()` for symbols, versus `MemoryMappedViewStream`. Other changes: * Added tests to verify we can load a `.dll` and its symbols with appropriate settings. * Stop looking for `.mdb` files. We no longer support these in .NET 6+. * Removed unnecessary `$""` string interpolation.
1a2d9bf to
a872d20
Compare
|
dotnet/android#8592 is green now. |
| } | ||
|
|
||
| MemoryMappedViewStream? viewStream = null; | ||
| // Likely 6 entries when symbols exist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does "6" come from? Why is that likely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like OpenMemoryMappedViewStream() has 3 disposables.Add() calls, so a multiple of 3 makes sense, and there are potentially 2 OpenMemoryMappedViewStream() invocations here.
That said, the feels "distant"; if (when) OpenMemoryMappedViewStream() changes, this value will be "wrong". (Not necessarily a bad thing, but…)
I think I'd prefer:
AssemblyDefinition LoadFromMemoryMappedFile (…)
{
// …
var disposables = new List<IDisposable>(
(1 + (loadDebugSymbols ? 1 : 0)) * OpenMemoryMappedViewStream_disposables_Add_calls);
// …
}
// Number of times OpenMemoryMappedViewStream() calls disposables.Add()
const int OpenMemoryMappedViewStream_disposables_Add_calls = 3;
static MemoryMappedViewStream OpenMemoryMappedViewStream (string file, List<IDisposable> disposables)
{
// …
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made these changes.
Context: 7d42864d
Context: dotnet/android#8571
While debugging dotnet/android#8571, I found the usage of
MemoryMappedFile(from 7d42864) broke.pdbsymbol loading. This is OK, because we'll likely disable symbol loading anyway, but we should at least address our bugs here for the future.In order for the following code to load symbols:
You would need the following
ReaderParameters:ReadSymbols=trueSymbolStreamcontaining a validStreamto the.pdbfileTo make this work, I had to:
Create a
List<IDisposable>for bookkeeping.When successful, we transfer ownership of the
MemoryMappedFilefrom theList<IDisposable>ofMemoryMappedViewStreamto theviewStreamscollection.When unsuccessful, we'd just dispose of the
MemoryMappedViewStream.If
ReadWrite=true, we can just useFile.OpenRead()for symbols, versusMemoryMappedViewStream.Other changes:
Added tests to verify we can load a
.dlland its symbols with appropriate settings.Stop looking for
.mdbfiles. We no longer support these in .NET 6+.Check for
SymbolsNotFoundExceptionas it inheritsFileNotFoundException.Removed unnecessary
$""string interpolation.