Skip to content

Commit

Permalink
feat: debug images for Portable PDB (#2050)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind authored Dec 20, 2022
1 parent 9840ccb commit f98922d
Show file tree
Hide file tree
Showing 94 changed files with 3,914 additions and 677 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ docs/docfx.zip
*.received.*
mono_crash.*.json
test_output/
test/**/*.apk
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Features

- Add support for Portable PDB format ([#2050](https://github.com/getsentry/sentry-dotnet/pull/2050))

## 3.24.1

### Fixes
Expand Down
18 changes: 15 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Contributing

We love receiving PRs from the community with features and fixed.
We love receiving PRs from the community with features and fixed.
For big feature it's advised to raise an issue to discuss it first.

## TLDR:
## TLDR

* Install the .NET SDKs
* To quickly get up and running, you can just run `dotnet build`
Expand Down Expand Up @@ -68,7 +68,7 @@ Note that the MSBuild version should always be `17.0` but will change paths base
We'd love for users to update the SDK everytime and as soon as we make a new release. But in reality most users rarely update the SDK.
To help users see value in updating the SDK, we maintain a changelog file with entries split between two headings:

1. `### Features`
1. `### Features`
2. `### Fixes`

We add the heading in the first PR that's adding either a feature or fixes in the current release.
Expand All @@ -86,3 +86,15 @@ Below that, you'll add the heading 3 mentioned above. For example, if you're add
```

There's a GitHub action check to verify if an entry was added. If the entry isn't a user-facing change, you can skip the verification with `#skip-changelog` written to the PR description. The bot writes a comment in the PR with a suggestion entry to the changelog based on the PR title.

## Verify tests

Some tests use [Verify](https://github.com/VerifyTests/Verify) to check returned objects against snapshots that are part of the repo.
In case you're making code changes that produce many (intended) changes in those snapshots, you can use [accept-verifier-changes.ps1](./scripts/accept-verifier-changes.ps1) like this:

```shell-script
dotnet test
pwsh ./scripts/accept-verifier-changes.ps1
```

You may need to run this multiple times because `dotnet test` stops after a certain number of failures.
1 change: 1 addition & 0 deletions Sentry-CI-Build-Linux.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"src\\Sentry.NLog\\Sentry.NLog.csproj",
"src\\Sentry.Serilog\\Sentry.Serilog.csproj",
"src\\Sentry\\Sentry.csproj",
"test\\Sentry.Android.Tests\\Sentry.Android.Tests.csproj",
"test\\Sentry.AspNet.Tests\\Sentry.AspNet.Tests.csproj",
"test\\Sentry.AspNetCore.Grpc.Tests\\Sentry.AspNetCore.Grpc.Tests.csproj",
"test\\Sentry.AspNetCore.Tests\\Sentry.AspNetCore.Tests.csproj",
Expand Down
1 change: 1 addition & 0 deletions Sentry-CI-Build-Windows.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"src\\Sentry.NLog\\Sentry.NLog.csproj",
"src\\Sentry.Serilog\\Sentry.Serilog.csproj",
"src\\Sentry\\Sentry.csproj",
"test\\Sentry.Android.Tests\\Sentry.Android.Tests.csproj",
"test\\Sentry.AspNet.Tests\\Sentry.AspNet.Tests.csproj",
"test\\Sentry.AspNetCore.Grpc.Tests\\Sentry.AspNetCore.Grpc.Tests.csproj",
"test\\Sentry.AspNetCore.Tests\\Sentry.AspNetCore.Tests.csproj",
Expand Down
1 change: 1 addition & 0 deletions Sentry-CI-Build-macOS.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"src\\Sentry.NLog\\Sentry.NLog.csproj",
"src\\Sentry.Serilog\\Sentry.Serilog.csproj",
"src\\Sentry\\Sentry.csproj",
"test\\Sentry.Android.Tests\\Sentry.Android.Tests.csproj",
"test\\Sentry.AspNet.Tests\\Sentry.AspNet.Tests.csproj",
"test\\Sentry.AspNetCore.Grpc.Tests\\Sentry.AspNetCore.Grpc.Tests.csproj",
"test\\Sentry.AspNetCore.Tests\\Sentry.AspNetCore.Tests.csproj",
Expand Down
1 change: 1 addition & 0 deletions Sentry-CI-Test.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"solution": {
"path": "Sentry.sln",
"projects": [
"test\\Sentry.Android.Tests\\Sentry.Android.Tests.csproj",
"test\\Sentry.AspNet.Tests\\Sentry.AspNet.Tests.csproj",
"test\\Sentry.AspNetCore.Grpc.Tests\\Sentry.AspNetCore.Grpc.Tests.csproj",
"test\\Sentry.AspNetCore.Tests\\Sentry.AspNetCore.Tests.csproj",
Expand Down
7 changes: 7 additions & 0 deletions Sentry.sln
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Bindings.Android", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Bindings.Cocoa", "src\Sentry.Bindings.Cocoa\Sentry.Bindings.Cocoa.csproj", "{F533FD6D-1E10-4F06-BE3A-3B3C713A75A6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Android.Tests", "test\Sentry.Android.Tests\Sentry.Android.Tests.csproj", "{5E12E053-22AF-4184-8581-3FCFD225617D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.AspNetCore.TestUtils", "test\Sentry.AspNetCore.TestUtils\Sentry.AspNetCore.TestUtils.csproj", "{C96CB65D-3D2D-404E-85C0-69A3FC03B48F}"
EndProject
Global
Expand Down Expand Up @@ -399,6 +401,10 @@ Global
{F533FD6D-1E10-4F06-BE3A-3B3C713A75A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F533FD6D-1E10-4F06-BE3A-3B3C713A75A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F533FD6D-1E10-4F06-BE3A-3B3C713A75A6}.Release|Any CPU.Build.0 = Release|Any CPU
{5E12E053-22AF-4184-8581-3FCFD225617D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5E12E053-22AF-4184-8581-3FCFD225617D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E12E053-22AF-4184-8581-3FCFD225617D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5E12E053-22AF-4184-8581-3FCFD225617D}.Release|Any CPU.Build.0 = Release|Any CPU
{C96CB65D-3D2D-404E-85C0-69A3FC03B48F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C96CB65D-3D2D-404E-85C0-69A3FC03B48F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C96CB65D-3D2D-404E-85C0-69A3FC03B48F}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -466,6 +472,7 @@ Global
{70066C6C-0A18-4322-A02A-9A0DFE59C02B} = {77454495-55EE-4B40-A089-71B9E8F82E89}
{9A23DA57-3F0B-4646-A37A-71A4CE7C94CB} = {AF6AF4C7-8AA2-4D59-8064-2D79560904EB}
{F533FD6D-1E10-4F06-BE3A-3B3C713A75A6} = {AF6AF4C7-8AA2-4D59-8064-2D79560904EB}
{5E12E053-22AF-4184-8581-3FCFD225617D} = {83263231-1A2A-4733-B759-EEFF14E8C5D5}
{C96CB65D-3D2D-404E-85C0-69A3FC03B48F} = {83263231-1A2A-4733-B759-EEFF14E8C5D5}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
1 change: 1 addition & 0 deletions SentryMaui.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"test\\MauiTestUtils\\DeviceTests.Runners.SourceGen\\TestUtils.DeviceTests.Runners.SourceGen.csproj",
"test\\MauiTestUtils\\DeviceTests.Runners\\TestUtils.DeviceTests.Runners.csproj",
"test\\MauiTestUtils\\DeviceTests\\TestUtils.DeviceTests.csproj",
"test\\Sentry.Android.Tests\\Sentry.Android.Tests.csproj",
"test\\Sentry.Extensions.Logging.Tests\\Sentry.Extensions.Logging.Tests.csproj",
"test\\Sentry.Maui.Device.TestApp\\Sentry.Maui.Device.TestApp.csproj",
"test\\Sentry.Maui.Tests\\Sentry.Maui.Tests.csproj",
Expand Down
1 change: 1 addition & 0 deletions SentryNoSamples.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"src\\Sentry.NLog\\Sentry.NLog.csproj",
"src\\Sentry.Serilog\\Sentry.Serilog.csproj",
"src\\Sentry\\Sentry.csproj",
"test\\Sentry.Android.Tests\\Sentry.Android.Tests.csproj",
"test\\Sentry.AspNet.Tests\\Sentry.AspNet.Tests.csproj",
"test\\Sentry.AspNetCore.Grpc.Tests\\Sentry.AspNetCore.Grpc.Tests.csproj",
"test\\Sentry.AspNetCore.Tests\\Sentry.AspNetCore.Tests.csproj",
Expand Down
23 changes: 23 additions & 0 deletions scripts/accept-verifier-changes.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Similar to `dotnet verify accept` but doesn't create new runtime-specific ".verified" files if a common one exists.
param([switch] $DryRun)

Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

$receivedFiles = Get-ChildItem . -Recurse -File -Include "*.received.txt"

$receivedFiles | ForEach-Object {
$nameWithRuntime = ($_.BaseName.Split(".") | Select-Object -SkipLast 1) -join "."
$nameWithoutRuntime = ($_.BaseName.Split(".") | Select-Object -SkipLast 2) -join "."
$ext = ".verified.txt"

$targetFile = (Test-Path "$($_.Directory)/$nameWithoutRuntime$ext") `
? "$($_.Directory)/$nameWithoutRuntime$ext" `
: "$($_.Directory)/$nameWithRuntime$ext"

Write-Host "Updating $($targetFile.Replace((Get-Item .).FullName, ''))"
if (-not ($DryRun))
{
Move-Item $_ $targetFile -Force
}
}
52 changes: 52 additions & 0 deletions scripts/update-test-apks.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
param([switch] $IfNotExist)

Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

$repoRoot = "$PSScriptRoot/.."
$apkDir = "$repoRoot/test/Sentry.Android.Tests/TestAPKs"

New-Item -ItemType Directory -Force -Path $apkDir | Out-Null
$apkDir = Resolve-Path $apkDir

function BuildAndroidSample([bool] $UseAssemblyStore, [bool] $UseAssemblyCompression)
{
$testAppDir = "$repoRoot/test/AndroidTestApp"
$outputApk = "$apkDir/android-Store=$UseAssemblyStore-Compressed=$UseAssemblyCompression.apk"

if ($IfNotExist -and (Test-Path $outputApk))
{
Write-Host "$outputApk already exists, skipping build"
return
}

Push-Location -Verbose $testAppDir
try
{
# Need to do a clean build otherwise some DLLs would end up being compressed even if it's disabled on this run.
dotnet build --configuration Release --no-incremental `
--property:AndroidUseAssemblyStore=$UseAssemblyStore `
--property:AndroidEnableAssemblyCompression=$UseAssemblyCompression `
| Out-Host
if ($LASTEXITCODE -ne 0)
{
exit $LASTEXITCODE
}
}
finally
{
Pop-Location
}

Move-Item "$testAppDir/bin/Release/*/*-signed.apk" $outputApk
}

if (!$IfNotExist)
{
Remove-Item "$apkDir/*.apk"
}

BuildAndroidSample $true $true
BuildAndroidSample $true $false
BuildAndroidSample $false $true
BuildAndroidSample $false $false
10 changes: 10 additions & 0 deletions src/Sentry/DebugImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public sealed class DebugImage : IJsonSerializable
/// </summary>
public string? DebugId { get; set; }

/// <summary>
/// Checksum of the companion debug file.
/// </summary>
public string? DebugChecksum { get; set; }

/// <summary>
/// Path and name of the debug companion file.
/// </summary>
Expand All @@ -47,6 +52,8 @@ public sealed class DebugImage : IJsonSerializable
/// </summary>
public string? CodeFile { get; set; }

internal Guid? ModuleVersionId { get; set; }

/// <inheritdoc />
public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
{
Expand All @@ -56,6 +63,7 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
writer.WriteStringIfNotWhiteSpace("image_addr", ImageAddress);
writer.WriteNumberIfNotNull("image_size", ImageSize);
writer.WriteStringIfNotWhiteSpace("debug_id", DebugId);
writer.WriteStringIfNotWhiteSpace("debug_checksum", DebugChecksum);
writer.WriteStringIfNotWhiteSpace("debug_file", DebugFile);
writer.WriteStringIfNotWhiteSpace("code_id", CodeId);
writer.WriteStringIfNotWhiteSpace("code_file", CodeFile);
Expand All @@ -72,6 +80,7 @@ public static DebugImage FromJson(JsonElement json)
var imageAddress = json.GetPropertyOrNull("image_addr")?.GetString();
var imageSize = json.GetPropertyOrNull("image_size")?.GetInt64();
var debugId = json.GetPropertyOrNull("debug_id")?.GetString();
var debugChecksum = json.GetPropertyOrNull("debug_checksum")?.GetString();
var debugFile = json.GetPropertyOrNull("debug_file")?.GetString();
var codeId = json.GetPropertyOrNull("code_id")?.GetString();
var codeFile = json.GetPropertyOrNull("code_file")?.GetString();
Expand All @@ -82,6 +91,7 @@ public static DebugImage FromJson(JsonElement json)
ImageAddress = imageAddress,
ImageSize = imageSize,
DebugId = debugId,
DebugChecksum = debugChecksum,
DebugFile = debugFile,
CodeId = codeId,
CodeFile = codeFile,
Expand Down
Loading

0 comments on commit f98922d

Please sign in to comment.