-
-
Notifications
You must be signed in to change notification settings - Fork 61
fix: line number support for unity 6.5 and newer #2805
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
Open
bitsandfoxes
wants to merge
18
commits into
main
Choose a base branch
from
feat/fix-symbols-unity-6.5
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c1441b8
write additional unitylinker args
bitsandfoxes 8a213d1
updated changelog
bitsandfoxes ba2dae7
test for stack trace
bitsandfoxes e57d9bf
fix assertion
bitsandfoxes d5cd2e1
Probe Linux linker environment
bitsandfoxes 856bf42
Revert Linux linker environment probe
bitsandfoxes 7844761
exclude linux from line number test
bitsandfoxes 1f346cb
moved argument adding to different interface
bitsandfoxes 1754b9f
Merge branch 'main' into feat/fix-symbols-unity-6.5
bitsandfoxes 461d481
revert skip because we are so back
bitsandfoxes 8b55488
cleanup
bitsandfoxes 90800c4
Merge branch 'main' into feat/fix-symbols-unity-6.5
bitsandfoxes a3d2f7d
simplified argument adding
bitsandfoxes 0644480
moved argument addition into editor
bitsandfoxes f086b66
moved into the il2cpp processor again
bitsandfoxes 93451fe
is it caching?
bitsandfoxes 5c94ddb
find. that. switch.
bitsandfoxes e63d929
make it go away again too
bitsandfoxes 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| using System; | ||
| using System.Reflection; | ||
| using Sentry.Extensibility; | ||
| using UnityEngine; | ||
|
|
||
| namespace Sentry.Unity.Editor; | ||
|
|
||
| /// <summary> | ||
| /// Provides access to Unity's 'VMUnityLinkerAdditionalArgs' diagnostic switch. Unity feeds its value into the | ||
| /// UnityLinker's additional arguments and, unlike the 'UNITYLINKER_ADDITIONAL_ARGS' environment variable, it is part | ||
| /// of the Bee build graph's inputs. That means changing it invalidates the cached graph the same way the additional | ||
| /// IL2CPP arguments do - without it the linker keeps running with whatever arguments the cached graph was built with. | ||
| /// The switch is internal to Unity, so we have to go through reflection to get to it. | ||
| /// </summary> | ||
| internal static class UnityLinkerDiagnosticSwitch | ||
| { | ||
| internal const string SwitchName = "VMUnityLinkerAdditionalArgs"; | ||
|
|
||
| public static string? GetValue(IDiagnosticLogger? logger = null) | ||
| { | ||
| var diagnosticSwitch = GetSwitch(logger); | ||
| if (diagnosticSwitch is null) | ||
| { | ||
| return null; | ||
| } | ||
|
|
||
| try | ||
| { | ||
| return diagnosticSwitch.GetType().GetProperty("value")?.GetValue(diagnosticSwitch) as string; | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| logger?.LogWarning("Failed to read the '{0}' diagnostic switch. Reason: {1}", SwitchName, e.Message); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| public static bool SetValue(string value, IDiagnosticLogger? logger = null) | ||
| { | ||
| var diagnosticSwitch = GetSwitch(logger); | ||
| if (diagnosticSwitch is null) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| try | ||
| { | ||
| var property = diagnosticSwitch.GetType().GetProperty("value"); | ||
| if (property is null) | ||
| { | ||
| logger?.LogWarning("Failed to resolve the value of the '{0}' diagnostic switch.", SwitchName); | ||
| return false; | ||
| } | ||
|
|
||
| property.SetValue(diagnosticSwitch, value); | ||
| return true; | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| logger?.LogWarning("Failed to set the '{0}' diagnostic switch. Reason: {1}", SwitchName, e.Message); | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| private static object? GetSwitch(IDiagnosticLogger? logger) | ||
| { | ||
| try | ||
| { | ||
| var method = typeof(Debug).GetMethod("GetDiagnosticSwitch", BindingFlags.Static | BindingFlags.NonPublic); | ||
| if (method is null) | ||
| { | ||
| logger?.LogWarning("Failed to resolve 'Debug.GetDiagnosticSwitch'."); | ||
| return null; | ||
| } | ||
|
|
||
| var diagnosticSwitch = method.Invoke(null, new object[] { SwitchName }); | ||
| if (diagnosticSwitch is null) | ||
| { | ||
| logger?.LogWarning("The diagnostic switch '{0}' does not exist.", SwitchName); | ||
| } | ||
|
|
||
| return diagnosticSwitch; | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| logger?.LogWarning("Failed to access the '{0}' diagnostic switch. Reason: {1}", SwitchName, e.Message); | ||
| return null; | ||
| } | ||
| } | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.