-
-
Notifications
You must be signed in to change notification settings - Fork 220
Enable symbolication and source context for net9.0-android #4033
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
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
7e7e512
Ensure device tests run on net8.0 and net9.0
jamescrosswell d569cf0
Move existing reader to V1 directory
jamescrosswell f660e63
Bumped NSubstitute to versino 5.3.0
jamescrosswell 0b36c8c
Update Sentry.Extensions.Logging.Tests.csproj
jamescrosswell b94434a
Merge branch 'main' into store-v2
jamescrosswell 4e9183b
Update Sentry.Maui.Tests.csproj
jamescrosswell 0c22666
Update device-tests-android.yml
jamescrosswell 9420d86
Update CHANGELOG.md
jamescrosswell 1291467
Minimal work required to add the store v2 files to the repo with attr…
jamescrosswell 339f4ef
make members internal
jamescrosswell d18d462
Tests pass on net8.0 and net9.0
jamescrosswell 1c6494e
Merge branch 'main' into store-v2
jamescrosswell 75e15c7
Format code
getsentry-bot fc3e17a
Removed Xamarin.LibZipSharp dependency
jamescrosswell d618ac2
Removed dependency on System.IO.Hashing
jamescrosswell 509482b
Format code
getsentry-bot 956f1c6
Update AndroidAssemblyReaderTests.cs
jamescrosswell 8b95555
Merge branch 'store-v2' of github.com:getsentry/sentry-dotnet into st…
jamescrosswell 0a9580b
Revert "Merge branch 'store-v2' of github.com:getsentry/sentry-dotnet…
jamescrosswell bc58628
Removed junk comments added by dotnet format
jamescrosswell bbfa502
Format code
getsentry-bot 6f7cbb7
Tweaked ZipFile calls
jamescrosswell 440baf2
Added support for non AssemblyStore APKs
jamescrosswell de304b9
Format code
getsentry-bot 8a1253d
Merge branch 'main' into store-v2
jamescrosswell 3423f09
Format code
getsentry-bot 45769f9
Removed unused code from ArchiveAssemblyHelper
jamescrosswell 7652f11
Remove unused code from StoreReaderV2
jamescrosswell fd470f0
Update AndroidAssemblyReaderTests.cs
jamescrosswell d8ed437
Delete ELFPayloadError.cs
jamescrosswell e866cee
.
jamescrosswell d0b8688
Use System.Private.CoreLib.dll instead of System.Runtime.dll in Assem…
jamescrosswell c024e2e
Merge branch 'main' into store-v2
jamescrosswell 8ede9cd
Test AssemblyReader with APKs published using AOT
jamescrosswell 7ccfa1a
Merge branch 'store-v2' of github.com:getsentry/sentry-dotnet into st…
jamescrosswell 81fac20
Shortened file names for test apks
jamescrosswell dfc59be
.
jamescrosswell 4af3523
Added logging to the Ubuntu build (Temporary)
jamescrosswell 75bb2ec
Removed dependency on ElfSharp NuGet
jamescrosswell b3c0948
Add structured build logs to build
jamescrosswell 92a74d8
Format code
getsentry-bot f22991f
Set RID based on OS Architecture when publishing AndroidTestApp
jamescrosswell 2583dea
Merge branch 'store-v2' of github.com:getsentry/sentry-dotnet into st…
jamescrosswell 9f14f9b
Format code
getsentry-bot 294872c
Update Sentry.Android.AssemblyReader.Tests.csproj
jamescrosswell d7936f2
Merge branch 'store-v2' of github.com:getsentry/sentry-dotnet into st…
jamescrosswell 2a332b1
Update Sentry.Android.AssemblyReader.Tests.csproj
jamescrosswell 74feb9c
.
jamescrosswell 64fadc1
.
jamescrosswell 7077f90
Merge branch 'main' into store-v2
jamescrosswell 78817b7
Update AndroidAssemblyReaderTests.cs
jamescrosswell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
namespace Sentry.Android.AssemblyReader; | ||
|
||
internal static class ArchiveUtils | ||
{ | ||
internal static PEReader CreatePEReader(string assemblyName, MemoryStream inputStream, DebugLogger? logger) | ||
{ | ||
var decompressedStream = TryDecompressLZ4(assemblyName, inputStream, logger); // Returns null if not compressed | ||
return new PEReader(decompressedStream ?? inputStream); | ||
} | ||
|
||
internal static MemoryStream Extract(this ZipArchiveEntry zipEntry) | ||
{ | ||
var memStream = new MemoryStream((int)zipEntry.Length); | ||
using var zipStream = zipEntry.Open(); | ||
zipStream.CopyTo(memStream); | ||
memStream.Position = 0; | ||
return memStream; | ||
} | ||
|
||
/// <summary> | ||
/// The DLL may be LZ4 compressed, see https://github.com/xamarin/xamarin-android/pull/4686 | ||
/// In particular: https://github.com/dotnet/android/blob/44c5c30d3da692c54ca27d4a41571ef20b73670f/src/Xamarin.Android.Build.Tasks/Utilities/AssemblyCompression.cs#L96-L104 | ||
/// The format is: | ||
/// [ 4 byte magic header ] (XALZ) | ||
/// [ 4 byte descriptor header index ] | ||
/// [ 4 byte uncompressed payload length ] | ||
/// [rest: lz4 compressed payload] | ||
/// </summary> | ||
/// <seealso href="https://github.com/xamarin/xamarin-android/blob/c92702619f5fabcff0ed88e09160baf9edd70f41/tools/decompress-assemblies/main.cs#L26" /> | ||
private static Stream? TryDecompressLZ4(string assemblyName, MemoryStream inputStream, DebugLogger? logger) | ||
{ | ||
const uint compressedDataMagic = 0x5A4C4158; // 'XALZ', little-endian | ||
const int payloadOffset = 12; | ||
var reader = new BinaryReader(inputStream); | ||
if (reader.ReadUInt32() != compressedDataMagic) | ||
{ | ||
// Restore the input stream to the beginning if we're not decompressing. | ||
inputStream.Position = 0; | ||
return null; | ||
} | ||
reader.ReadUInt32(); // ignore descriptor index, we don't need it | ||
var decompressedLength = reader.ReadInt32(); | ||
Debug.Assert(inputStream.Position == payloadOffset); | ||
var inputLength = (int)(inputStream.Length - payloadOffset); | ||
|
||
logger?.Invoke("Decompressing assembly ({0} bytes uncompressed) using LZ4", decompressedLength); | ||
|
||
var outputStream = new MemoryStream(decompressedLength); | ||
|
||
// We're writing to the underlying array manually, so we need to set the length. | ||
outputStream.SetLength(decompressedLength); | ||
var outputBuffer = outputStream.GetBuffer(); | ||
|
||
var inputBuffer = inputStream is MemorySlice slice ? slice.FullBuffer : inputStream.GetBuffer(); | ||
var offset = inputStream is MemorySlice memorySlice ? memorySlice.Offset + payloadOffset : payloadOffset; | ||
var decoded = LZ4Codec.Decode(inputBuffer, offset, inputLength, outputBuffer, 0, decompressedLength); | ||
if (decoded != decompressedLength) | ||
{ | ||
throw new Exception($"Failed to decompress LZ4 data of assembly {assemblyName} - decoded {decoded} instead of expected {decompressedLength} bytes"); | ||
} | ||
return outputStream; | ||
} | ||
|
||
// Allows consumer to access the underlying buffer even if the MemoryStream is created as a slice over another. | ||
// Plain MemoryStream would throw "MemoryStream's internal buffer cannot be accessed." | ||
internal class MemorySlice(MemoryStream other, int offset, int size) | ||
: MemoryStream(other.GetBuffer(), offset, size, writable: false) | ||
{ | ||
public readonly int Offset = offset; | ||
public readonly byte[] FullBuffer = other.GetBuffer(); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
once we clear all callsites to pass a tfm, we should delete this and throw an error instead.
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.
This is just a default argument, if you don't specify a target framework. We could try to change the default to
latest
or something like that - would need a little bit of extra scripting to work out what latest was.