Skip to content
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

fix: Uploading all .pdb at Temp/ManagedSymbols for Mono on Windows & Linux #1226

Merged
merged 3 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Fixes

- Fixed missing debug file upload for assembly definitions for Mono builds ([#1226](https://github.com/getsentry/sentry-unity/pull/1226))
- The ANR detection is now unaffected by changes to `Time.timescale` ([#1225](https://github.com/getsentry/sentry-unity/pull/1225))

### Features
Expand Down
95 changes: 59 additions & 36 deletions src/Sentry.Unity.Editor/Native/BuildPostProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,44 +141,67 @@ private static void UploadDebugSymbols(IDiagnosticLogger logger, BuildTarget tar
};

addPath(executableName);
if (!isMono)
{
addPath(Path.GetFileNameWithoutExtension(executableName) + "_BackUpThisFolder_ButDontShipItWithYourGame");
}
if (target is BuildTarget.StandaloneWindows64)
{
addPath("UnityPlayer.dll");
addPath(Path.GetFileNameWithoutExtension(executableName) + "_Data/Plugins/x86_64/sentry.dll");
addPath(Path.GetFullPath($"Packages/{SentryPackageInfo.GetName()}/Plugins/Windows/Sentry/sentry.pdb"));
if (isMono)
{
addPath("MonoBleedingEdge/EmbedRuntime");
addFilesMatching(buildOutputDir, new[] { "*.pdb" });
}
else
{
addPath("GameAssembly.dll");
}
}
else if (target is BuildTarget.StandaloneLinux64)
{
addPath("GameAssembly.so");
addPath("UnityPlayer.so");
addPath(Path.GetFullPath($"Packages/{SentryPackageInfo.GetName()}/Plugins/Linux/Sentry/libsentry.dbg.so"));
if (isMono)
{
addPath(Path.GetFileNameWithoutExtension(executableName) + "_Data/MonoBleedingEdge/x86_64");
addFilesMatching(buildOutputDir, new[] { "*.debug" });
}
}
else if (target is BuildTarget.StandaloneOSX)
{
addPath(Path.GetFullPath($"Packages/{SentryPackageInfo.GetName()}/Plugins/macOS/Sentry/Sentry.dylib.dSYM"));
}

if (isMono)
switch (target)
{
addFilesMatching($"{projectDir}/Temp", new[] { "**/UnityEngine.*.pdb", "**/Assembly-CSharp.pdb" });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure the original files are still matched for all supported versions of Unity?
I remember some of these rules (not saying it relates to this one specifically) being very different for each version I've tested this on.

Maybe instead just add the new rule instead of removing the old one unless you've verified we're not losing useful files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I double checked and at the very least for Windows this works.
Line numbers on OSX and mono don't work right now. And that directory does not exist either. Checking for Linux.

case BuildTarget.StandaloneWindows64:
addPath("UnityPlayer.dll");
addPath(Path.GetFileNameWithoutExtension(executableName) + "_Data/Plugins/x86_64/sentry.dll");
addPath(Path.GetFullPath($"Packages/{SentryPackageInfo.GetName()}/Plugins/Windows/Sentry/sentry.pdb"));

if (isMono)
{
addPath("MonoBleedingEdge/EmbedRuntime");
addFilesMatching(buildOutputDir, new[] { "*.pdb" });

// Unity stores the .pdb files in './Library/ScriptAssemblies/' and starting with 2020 in
// './Temp/ManagedSymbols/'. We want the one in 'Temp/ManagedSymbols/' specifically.
var managedSymbolsDirectory = $"{projectDir}/Temp/ManagedSymbols";
if (Directory.Exists(managedSymbolsDirectory))
{
addFilesMatching(managedSymbolsDirectory, new[] { "*.pdb" });
}
}
else // IL2CPP
{
addPath(Path.GetFileNameWithoutExtension(executableName) + "_BackUpThisFolder_ButDontShipItWithYourGame");
addPath("GameAssembly.dll");
}
break;
case BuildTarget.StandaloneLinux64:
addPath("GameAssembly.so");
addPath("UnityPlayer.so");
addPath(Path.GetFullPath($"Packages/{SentryPackageInfo.GetName()}/Plugins/Linux/Sentry/libsentry.dbg.so"));

if (isMono)
{
addPath(Path.GetFileNameWithoutExtension(executableName) + "_Data/MonoBleedingEdge/x86_64");
addFilesMatching(buildOutputDir, new[] { "*.debug" });

var managedSymbolsDirectory = $"{projectDir}/Temp/ManagedSymbols";
if (Directory.Exists(managedSymbolsDirectory))
{
addFilesMatching(managedSymbolsDirectory, new[] { "*.pdb" });
}
}
else // IL2CPP
{
addPath(Path.GetFileNameWithoutExtension(executableName) + "_BackUpThisFolder_ButDontShipItWithYourGame");
}
break;
case BuildTarget.StandaloneOSX:
addPath(Path.GetFullPath($"Packages/{SentryPackageInfo.GetName()}/Plugins/macOS/Sentry/Sentry.dylib.dSYM"));

if (isMono)
{ }
else // IL2CPP
{
addPath(Path.GetFileNameWithoutExtension(executableName) + "_BackUpThisFolder_ButDontShipItWithYourGame");
}
break;
default:
logger.LogError($"Symbol upload for '{target}' is currently not supported.");
break;
}

var cliArgs = "upload-dif ";
Expand Down