decode method
The decoded stack for stack, exactly as the VM printed it, using
symbolFiles (the bytes of the matching .symbols files). Null when
the stack cannot be decoded with them.
Implementation
@override
Future<String?> decode(
String stack, {
required List<List<int>> symbolFiles,
}) async {
for (final List<int> file in symbolFiles) {
final Dwarf? dwarf;
try {
dwarf = Dwarf.fromBytes(Uint8List.fromList(file));
} on Object {
continue;
}
if (dwarf == null) continue;
try {
final List<String> lines = await Stream<String>.fromIterable(
stack.split('\n'),
).transform(DwarfStackTraceDecoder(dwarf)).toList();
final String decoded = lines.join('\n');
// A decoder given the wrong file passes every frame through
// unchanged; that is not a decoding.
if (decoded.split('\n').any((String line) =>
line.trimLeft().startsWith('#') && !line.contains(' abs '))) {
return decoded;
}
} on Object {
continue;
}
}
return null;
}