Skip to content

Commit 35bff66

Browse files
committed
Add unknown map to DebugImage
1 parent bb7feb6 commit 35bff66

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

dart/lib/src/protocol/debug_image.dart

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import 'package:meta/meta.dart';
22

3+
import 'unknown.dart';
4+
35
/// The list of debug images contains all dynamic libraries loaded into
46
/// the process and their memory addresses.
57
/// Instruction addresses in the Stack Trace are mapped into the list of debug
@@ -51,6 +53,9 @@ class DebugImage {
5153
/// MachO CPU type identifier.
5254
final int? cpuType;
5355

56+
@internal
57+
final Map<String, dynamic>? unknown;
58+
5459
const DebugImage({
5560
required this.type,
5661
this.name,
@@ -65,6 +70,7 @@ class DebugImage {
6570
this.codeId,
6671
this.cpuType,
6772
this.cpuSubtype,
73+
this.unknown,
6874
});
6975

7076
/// Deserializes a [DebugImage] from JSON [Map].
@@ -83,12 +89,27 @@ class DebugImage {
8389
codeId: json['code_id'],
8490
cpuType: json['cpu_type'],
8591
cpuSubtype: json['cpu_subtype'],
92+
unknown: unknownFrom(json, {
93+
'type',
94+
'name',
95+
'image_addr',
96+
'image_vmaddr',
97+
'debug_id',
98+
'debug_file',
99+
'image_size',
100+
'uuid',
101+
'code_file',
102+
'arch',
103+
'code_id',
104+
'cpu_type',
105+
'cpu_subtype',
106+
}),
86107
);
87108
}
88109

89110
/// Produces a [Map] that can be serialized to JSON.
90111
Map<String, dynamic> toJson() {
91-
return {
112+
final json = {
92113
'type': type,
93114
if (uuid != null) 'uuid': uuid,
94115
if (debugId != null) 'debug_id': debugId,
@@ -103,6 +124,8 @@ class DebugImage {
103124
if (cpuType != null) 'cpu_type': cpuType,
104125
if (cpuSubtype != null) 'cpu_subtype': cpuSubtype,
105126
};
127+
json.addAll(unknown ?? {});
128+
return json;
106129
}
107130

108131
DebugImage copyWith({
@@ -134,5 +157,6 @@ class DebugImage {
134157
codeId: codeId ?? this.codeId,
135158
cpuType: cpuType ?? this.cpuType,
136159
cpuSubtype: cpuSubtype ?? this.cpuSubtype,
160+
unknown: unknown,
137161
);
138162
}

dart/test/protocol/debug_image_test.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import 'package:collection/collection.dart';
22
import 'package:sentry/sentry.dart';
33
import 'package:test/test.dart';
44

5+
import '../mocks.dart';
6+
57
void main() {
68
final debugImage = DebugImage(
79
type: 'type',
@@ -13,6 +15,7 @@ void main() {
1315
codeFile: 'codeFile',
1416
arch: 'arch',
1517
codeId: 'codeId',
18+
unknown: testUnknown,
1619
);
1720

1821
final debugImageJson = <String, dynamic>{
@@ -26,6 +29,7 @@ void main() {
2629
'arch': 'arch',
2730
'code_id': 'codeId',
2831
};
32+
debugImageJson.addAll(testUnknown);
2933

3034
group('json', () {
3135
test('toJson', () {

0 commit comments

Comments
 (0)