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

refactor: change DebugImage.ImageAddress to long #2725

Merged
merged 2 commits into from
Oct 15, 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 @@ -26,6 +26,7 @@ API Changes:
- Removed unused `StackFrame.InstructionOffset`. ([#2691](https://github.com/getsentry/sentry-dotnet/pull/2691))
- Change `StackFrame`'s `ImageAddress`, `InstructionAddress` and `FunctionId` to `long?`. ([#2691](https://github.com/getsentry/sentry-dotnet/pull/2691))
- Enable `CaptureFailedRequests` by default. ([2688](https://github.com/getsentry/sentry-dotnet/pull/2688))
- Change `DebugImage.ImageAddress` to `long?`. ([#2725](https://github.com/getsentry/sentry-dotnet/pull/2725))
- Additional constructors removed from `TransactionTracer`. ([#2694](https://github.com/getsentry/sentry-dotnet/pull/2694))
- Removed the `Scope.Platform` property as it was never applied. ([#2695](https://github.com/getsentry/sentry-dotnet/pull/2695))
- Reordered parameters for ther TransactionContext and SpanContext constructors. If you're constructing instances of these classes, you will need to adjust the order in which you pass parameters to these. ([#2696](https://github.com/getsentry/sentry-dotnet/pull/2696))
Expand Down
7 changes: 3 additions & 4 deletions src/Sentry/DebugImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ public sealed class DebugImage : IJsonSerializable

/// <summary>
/// Memory address, at which the image is mounted in the virtual address space of the process.
/// Should be a string in hex representation prefixed with "0x".
/// </summary>
public string? ImageAddress { get; set; }
public long? ImageAddress { get; set; }

/// <summary>
/// The size of the image in virtual memory.
Expand Down Expand Up @@ -60,7 +59,7 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
writer.WriteStartObject();

writer.WriteStringIfNotWhiteSpace("type", Type);
writer.WriteStringIfNotWhiteSpace("image_addr", ImageAddress);
writer.WriteStringIfNotWhiteSpace("image_addr", ImageAddress?.NullIfDefault()?.ToHexString());
writer.WriteNumberIfNotNull("image_size", ImageSize);
writer.WriteStringIfNotWhiteSpace("debug_id", DebugId);
writer.WriteStringIfNotWhiteSpace("debug_checksum", DebugChecksum);
Expand All @@ -77,7 +76,7 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
public static DebugImage FromJson(JsonElement json)
{
var type = json.GetPropertyOrNull("type")?.GetString();
var imageAddress = json.GetPropertyOrNull("image_addr")?.GetString();
var imageAddress = json.GetPropertyOrNull("image_addr")?.GetHexAsLong();
var imageSize = json.GetPropertyOrNull("image_size")?.GetInt64();
var debugId = json.GetPropertyOrNull("debug_id")?.GetString();
var debugChecksum = json.GetPropertyOrNull("debug_checksum")?.GetString();
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/SentryStackFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public static SentryStackFrame FromJson(JsonElement json)
var inApp = json.GetPropertyOrNull("in_app")?.GetBoolean();
var package = json.GetPropertyOrNull("package")?.GetString();
var platform = json.GetPropertyOrNull("platform")?.GetString();
var imageAddress = json.GetPropertyOrNull("image_addr")?.GetHexAsLong() ?? 0;
var imageAddress = json.GetPropertyOrNull("image_addr")?.GetHexAsLong();
var symbolAddress = json.GetPropertyOrNull("symbol_addr")?.GetHexAsLong();
var instructionAddress = json.GetPropertyOrNull("instruction_addr")?.GetHexAsLong();
var addressMode = json.GetPropertyOrNull("addr_mode")?.GetString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace Sentry
public string? DebugChecksum { get; set; }
public string? DebugFile { get; set; }
public string? DebugId { get; set; }
public string? ImageAddress { get; set; }
public long? ImageAddress { get; set; }
public long? ImageSize { get; set; }
public string? Type { get; set; }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace Sentry
public string? DebugChecksum { get; set; }
public string? DebugFile { get; set; }
public string? DebugId { get; set; }
public string? ImageAddress { get; set; }
public long? ImageAddress { get; set; }
public long? ImageSize { get; set; }
public string? Type { get; set; }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace Sentry
public string? DebugChecksum { get; set; }
public string? DebugFile { get; set; }
public string? DebugId { get; set; }
public string? ImageAddress { get; set; }
public long? ImageAddress { get; set; }
public long? ImageSize { get; set; }
public string? Type { get; set; }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { }
Expand Down
2 changes: 1 addition & 1 deletion test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace Sentry
public string? DebugChecksum { get; set; }
public string? DebugFile { get; set; }
public string? DebugId { get; set; }
public string? ImageAddress { get; set; }
public long? ImageAddress { get; set; }
public long? ImageSize { get; set; }
public string? Type { get; set; }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? logger) { }
Expand Down
4 changes: 2 additions & 2 deletions test/Sentry.Tests/Protocol/DebugImageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject()
var sut = new DebugImage
{
Type = "elf",
ImageAddress = "0xffffffff",
ImageAddress = 5,
ImageSize = 1234,
DebugId = "900f7d1b868432939de4457478f34720",
DebugFile = "libc.debug",
Expand All @@ -28,7 +28,7 @@ public void SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject()
Assert.Equal("""
{
"type": "elf",
"image_addr": "0xffffffff",
"image_addr": "0x5",
"image_size": 1234,
"debug_id": "900f7d1b868432939de4457478f34720",
"debug_file": "libc.debug",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
debug_meta: {
images: [
{
image_addr: 0xABCDEF
image_addr: 0x5
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion test/Sentry.Tests/Protocol/ProfilerTests.verify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public Task ProfileInfo_Serialization()
sut.StartTimestamp = DateTimeOffset.UtcNow;
sut.DebugMeta.Images = new List<DebugImage> {
new () {
ImageAddress = "0xABCDEF"
ImageAddress = 5
}
};
sut.Profile = CreateSampleProfile();
Expand Down