-
Notifications
You must be signed in to change notification settings - Fork 35
Add XBOX support. #183
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
Add XBOX support. #183
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7545dff
Add XBOX support.
cf0e544
Respond to comments from Konrad
875b789
Respond to comments, should be all ok by now.
ca6d004
Catch possible exceptions throwed by the native client
konraddysput fe89983
Update the changelog.
95ff539
Version 3.8.0: Version update
konraddysput 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,132 @@ | ||
| #if UNITY_GAMECORE_XBOXSERIES | ||
| using Backtrace.Unity.Interfaces; | ||
| using Backtrace.Unity.Model; | ||
| using Backtrace.Unity.Model.Breadcrumbs; | ||
| using Backtrace.Unity.Runtime.Native.Base; | ||
| using Backtrace.Unity.Types; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using System.Runtime.InteropServices; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
| using UnityEngine; | ||
|
|
||
| [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Backtrace.Unity.Tests.Runtime")] | ||
| namespace Backtrace.Unity.Runtime.Native.XBOX | ||
| { | ||
|
|
||
| internal class NativeClient : NativeClientBase, INativeClient | ||
| { | ||
| [DllImport("backtrace_native_xbox_mt.dll")] | ||
| private static extern bool BacktraceCrash(); | ||
|
|
||
| [DllImport("backtrace_native_xbox_mt.dll")] | ||
| private static extern bool BacktraceAddAttribute( | ||
| [MarshalAs(UnmanagedType.LPWStr)] string name, | ||
| [MarshalAs(UnmanagedType.LPWStr)] string value | ||
| ); | ||
|
|
||
| [DllImport("backtrace_native_xbox_mt.dll")] | ||
| private static extern bool BacktraceAddFile( | ||
| [MarshalAs(UnmanagedType.LPWStr)] string name, | ||
| [MarshalAs(UnmanagedType.LPWStr)] string path | ||
| ); | ||
|
|
||
| [DllImport("backtrace_native_xbox_mt.dll")] | ||
| private static extern bool BacktraceSetUrl( | ||
| [MarshalAs(UnmanagedType.LPWStr)] string url | ||
| ); | ||
|
|
||
| [DllImport("backtrace_native_xbox_mt.dll")] | ||
| private static extern bool BacktraceNativeInitialize(); | ||
|
|
||
| /// <summary> | ||
| /// Determine if the XBOX integration should be enabled | ||
| /// </summary> | ||
| private bool _enabled = | ||
| #if UNITY_GAMECORE_XBOXSERIES && !UNITY_EDITOR | ||
| true; | ||
| #else | ||
| false; | ||
| #endif | ||
|
|
||
| public NativeClient(BacktraceConfiguration configuration, BacktraceBreadcrumbs breadcrumbs, IDictionary<string, string> clientAttributes, IEnumerable<string> attachments) : base(configuration, breadcrumbs) | ||
| { | ||
| if (!_enabled) | ||
| { | ||
| return; | ||
| } | ||
| AddScopedAttributes(clientAttributes); | ||
| HandleNativeCrashes(clientAttributes, attachments); | ||
| } | ||
|
|
||
| public void GetAttributes(IDictionary<string, string> attributes) | ||
| { | ||
| } | ||
|
|
||
| public void HandleAnr() | ||
| { | ||
| } | ||
|
|
||
| public bool OnOOM() | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| public void SetAttribute(string key, string value) | ||
| { | ||
| if (string.IsNullOrEmpty(key)) | ||
| { | ||
| return; | ||
| } | ||
| // avoid null reference in crashpad source code | ||
| if (value == null) | ||
| { | ||
| value = string.Empty; | ||
| } | ||
| BacktraceAddAttribute(key, value); | ||
| } | ||
|
|
||
| private void AddScopedAttributes(IDictionary<string, string> attributes) | ||
| { | ||
| foreach (var attribute in attributes) | ||
| { | ||
| if (string.IsNullOrEmpty(attribute.Key) || attribute.Value == null) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| BacktraceAddAttribute(attribute.Key, attribute.Value); | ||
| } | ||
| } | ||
|
|
||
| private void HandleNativeCrashes(IDictionary<string, string> clientAttributes, IEnumerable<string> attachments) | ||
| { | ||
| var integrationDisabled = !_configuration.CaptureNativeCrashes || !_configuration.Enabled; | ||
| if (integrationDisabled) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| var minidumpUrl = new BacktraceCredentials(_configuration.GetValidServerUrl()).GetMinidumpSubmissionUrl().ToString(); | ||
KrzaQ marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| BacktraceSetUrl(minidumpUrl); | ||
|
|
||
| foreach (var attachment in attachments) | ||
| { | ||
| var name = Path.GetFileName(attachment); | ||
| BacktraceAddFile(name, attachment); | ||
| } | ||
|
|
||
| CaptureNativeCrashes = BacktraceNativeInitialize(); | ||
|
|
||
| if (!CaptureNativeCrashes) | ||
| { | ||
| Debug.LogWarning("Backtrace native integration status: Cannot initialize the Native Crash Reporting client"); | ||
| return; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| #endif | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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.
Does it make sense to start every method in "Backtrace" library with prefix "Backtrace"? I think it is obvious enough if we call it "Crash"
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.
The DLL exposes undecorated symbols, C-style. It's idiomatic to namespace them
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.
yeah but the dll is alerady backtrace dll
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.
That's not the issue. C does not have namespaces. If we have a method
Initialize()in our DLL, and another DLL exposes the same method, they will clash.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.
but you call the dll directly based on the dll name
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.
If that's a hard requirement for you, I can do it. But IMO it's better to offer one generic library that we could reuse in other projects.
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.
it's still can be generic, right? We can share the library with a note it's an abi_mt library. We don't need to show in our code we use breakpad or this is the "simplify" the library. If we switch to other crash reporter for any reason someone will have more manual work to do. Can we just rename it to backtrace-xbox?
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'm of two minds here. We actually offer multiple versions of Breakpad because some customers use mt/md libraries.