Add "flutter symbolize" command - #49465
Conversation
| output = _stdio.stdout; | ||
| } | ||
|
|
||
| final Uint8List debugInfo = _fileSystem.file(stringArg('debug-info')).readAsBytesSync(); |
There was a problem hiding this comment.
This needs to be abstracted into a separate class so it can be faked for testing. The elf files are too big to commit only for unit testing
|
Waiting on an update to the native_stack_traces package, and then for a confirmed roll into google3 for this to be safe to land |
| UpdatePackagesCommand(hidden: !verboseHelp), | ||
| UpgradeCommand(), | ||
| VersionCommand(), | ||
| SymbolicateCommand(stdio: globals.stdio, fileSystem: globals.fs), |
|
|
||
| import 'package:meta/meta.dart'; | ||
| import 'package:native_stack_traces/native_stack_traces.dart'; | ||
| import 'package:native_stack_traces/src/elf.dart'; // ignore: implementation_imports |
There was a problem hiding this comment.
Is there a github issue for getting the things the tool needs made part of the public API of this package?
There was a problem hiding this comment.
Yup, this is pending https://dart-review.googlesource.com/c/sdk/+/133720
| @@ -0,0 +1,125 @@ | |||
| // Copyright 2014 The Flutter Authors. All rights reserved. | |||
| } | ||
| if ((argResults.wasParsed('input') && !argResults.wasParsed('output')) || | ||
| (!argResults.wasParsed('input') && argResults.wasParsed('output'))) { | ||
| throwToolExit('"--input" and "--output" are only supported when both are provided.'); |
There was a problem hiding this comment.
The feels a bit too prescriptive to me. I could imagine wanting the input to come from a file and the output to go on stdout, for example.
There was a problem hiding this comment.
Done, now users can provide any combination of input/output and stdin/stdout
| .transform(const Utf8Decoder()) | ||
| .transform(const LineSplitter()) | ||
| .transform(DwarfStackTraceDecoder(dwarf, includeInternalFrames: true)) | ||
| .listen(output.writeln, onDone: onDone.complete, onError: onDone.completeError); |
There was a problem hiding this comment.
I would prefer folks not have to say flutter run | flutter symbolize. flutter run should take a flag to point at debugging info, or look around the project for one that matches the targeted device.
There was a problem hiding this comment.
Yeah I agree, I should wire up something to run - though I can imagine us not applying dwarf-stack-traces in run release too.
…r into flutter_symbolicate
|
This is ready for another round of review, modulo the changes in native_stack_traces landing (CL is approved) |
| final DwarfSymbolicationService _dwarfSymbolicationService; | ||
|
|
||
| @override | ||
| String get description => 'symbolicate a stack trace from an AOT compiled flutter application.'; |
| .transform(const Utf8Decoder()) | ||
| .transform(const LineSplitter()) | ||
| .transform(DwarfStackTraceDecoder(dwarf, includeInternalFrames: true)) | ||
| .listen(output.writeln, onDone: onDone.complete, onError: onDone.completeError); |
There was a problem hiding this comment.
If the writeln throws, it'll be thrown into the Zone. You can handle exceptions from writeln like:
StreamSubscription sub;
sub = input
.transform(const Utf8Decoder())
.transform(const LineSplitter())
.transform(DwarfStackTraceDecoder(dwarf, includeInternalFrames: true))
.listen((thing) async {
try {
output.writeln(thing);
} on Exception catch(e, s) {
sub.cancel().whenComplete(() {
if (!onDone.isCompleted) {
onDone.completeError(e, s);
}
);
}
}, onDone: onDone.complete, onError: onDone.completeError);| } | ||
|
|
||
| /// A service which decodes stack traces from Dart applications. | ||
| class DwarfSymbolicationService { |
|
Updated to latest native_stack_traces package |
| SymbolizeCommand({ | ||
| @required Stdio stdio, | ||
| @required FileSystem fileSystem, | ||
| DwarfSymbolizationService dwarfSymbolicationService = const DwarfSymbolizationService(), |
There was a problem hiding this comment.
dwarfSymbolicationService -> dwarfSymbolizationService
| output.writeln(line); | ||
| } on Exception catch(e, s) { | ||
| subscription.cancel().whenComplete(() { | ||
| if (!onDone.isCompleted) { |
Adds flutter symbolize, for turning crashes into human readable stack traces.
Example Workflow:
What if the symbols file is lost or destroyed? In theory it could be regenerated by being on the exact same version of flutter with the exact same dart code
Fixes #50206