From 35bff66639dc712b21670eb91ebe5c0904e90d5c Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 9 Jul 2024 13:53:59 +0200 Subject: [PATCH] Add `unknown` map to `DebugImage` --- dart/lib/src/protocol/debug_image.dart | 26 +++++++++++++++++++++++- dart/test/protocol/debug_image_test.dart | 4 ++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/dart/lib/src/protocol/debug_image.dart b/dart/lib/src/protocol/debug_image.dart index df45a12fed..64862ea157 100644 --- a/dart/lib/src/protocol/debug_image.dart +++ b/dart/lib/src/protocol/debug_image.dart @@ -1,5 +1,7 @@ import 'package:meta/meta.dart'; +import 'unknown.dart'; + /// The list of debug images contains all dynamic libraries loaded into /// the process and their memory addresses. /// Instruction addresses in the Stack Trace are mapped into the list of debug @@ -51,6 +53,9 @@ class DebugImage { /// MachO CPU type identifier. final int? cpuType; + @internal + final Map? unknown; + const DebugImage({ required this.type, this.name, @@ -65,6 +70,7 @@ class DebugImage { this.codeId, this.cpuType, this.cpuSubtype, + this.unknown, }); /// Deserializes a [DebugImage] from JSON [Map]. @@ -83,12 +89,27 @@ class DebugImage { codeId: json['code_id'], cpuType: json['cpu_type'], cpuSubtype: json['cpu_subtype'], + unknown: unknownFrom(json, { + 'type', + 'name', + 'image_addr', + 'image_vmaddr', + 'debug_id', + 'debug_file', + 'image_size', + 'uuid', + 'code_file', + 'arch', + 'code_id', + 'cpu_type', + 'cpu_subtype', + }), ); } /// Produces a [Map] that can be serialized to JSON. Map toJson() { - return { + final json = { 'type': type, if (uuid != null) 'uuid': uuid, if (debugId != null) 'debug_id': debugId, @@ -103,6 +124,8 @@ class DebugImage { if (cpuType != null) 'cpu_type': cpuType, if (cpuSubtype != null) 'cpu_subtype': cpuSubtype, }; + json.addAll(unknown ?? {}); + return json; } DebugImage copyWith({ @@ -134,5 +157,6 @@ class DebugImage { codeId: codeId ?? this.codeId, cpuType: cpuType ?? this.cpuType, cpuSubtype: cpuSubtype ?? this.cpuSubtype, + unknown: unknown, ); } diff --git a/dart/test/protocol/debug_image_test.dart b/dart/test/protocol/debug_image_test.dart index d06dad4b5e..5f3de134e1 100644 --- a/dart/test/protocol/debug_image_test.dart +++ b/dart/test/protocol/debug_image_test.dart @@ -2,6 +2,8 @@ import 'package:collection/collection.dart'; import 'package:sentry/sentry.dart'; import 'package:test/test.dart'; +import '../mocks.dart'; + void main() { final debugImage = DebugImage( type: 'type', @@ -13,6 +15,7 @@ void main() { codeFile: 'codeFile', arch: 'arch', codeId: 'codeId', + unknown: testUnknown, ); final debugImageJson = { @@ -26,6 +29,7 @@ void main() { 'arch': 'arch', 'code_id': 'codeId', }; + debugImageJson.addAll(testUnknown); group('json', () { test('toJson', () {