Skip to content

Add "flutter symbolize" command - #49465

Merged
fluttergithubbot merged 17 commits into
flutter:masterfrom
jonahwilliams:flutter_symbolicate
Feb 10, 2020
Merged

fluttergithubbot merged 17 commits into
flutter:masterfrom
jonahwilliams:flutter_symbolicate

Conversation

@jonahwilliams

@jonahwilliams jonahwilliams commented Jan 25, 2020 •

Copy link
Copy Markdown
Contributor

Adds flutter symbolize, for turning crashes into human readable stack traces.

Example Workflow:

  • Developer is ready to release an APK for distribution on the Play Store.
  • They create a directory for the specific version of the app to be released. Example: symbols/v1.2.3-final-final
  • They run flutter build apk --release --split-debug-info=symbols/v1.2.3-final-final/
  • They upload the APK as normal. The symbol files are either stored locally, or commited to some internal symbol database.
  • They receive a crash report from version v1.2.3-final-final on an arm64 ABI.
  • They retrieve the corresponding symbols file generated in step two.
  • They run flutter symbolize --symbols=v1.2.3-final-final/app.android-arm64.symbols < stack.txt

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

@fluttergithubbot fluttergithubbot added c: contributor-productivity Team-specific productivity, code health, technical debt. tool Affects the "flutter" command-line tool. See also t: labels. work in progress; do not review labels Jan 25, 2020
output = _stdio.stdout;
}

final Uint8List debugInfo = _fileSystem.file(stringArg('debug-info')).readAsBytesSync();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@jonahwilliams jonahwilliams changed the title [WIP] add stack trace stripping and symbolication support [WIP] add stack trace symbolication support Jan 29, 2020
@jonahwilliams

Copy link
Copy Markdown
Contributor Author

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),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alphabetize.


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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a github issue for getting the things the tool needs made part of the public API of this package?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,125 @@
// Copyright 2014 The Flutter Authors. All rights reserved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

symbolicate -> symbolize

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
if ((argResults.wasParsed('input') && !argResults.wasParsed('output')) ||
(!argResults.wasParsed('input') && argResults.wasParsed('output'))) {
throwToolExit('"--input" and "--output" are only supported when both are provided.');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree, I should wire up something to run - though I can imagine us not applying dwarf-stack-traces in run release too.

@jonahwilliams
jonahwilliams marked this pull request as ready for review February 6, 2020 22:14
@jonahwilliams jonahwilliams changed the title [WIP] add stack trace symbolication support Add "flutter symbolize" command Feb 6, 2020
@jonahwilliams

Copy link
Copy Markdown
Contributor Author

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.';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

symbolicate -> Symbolize

.transform(const Utf8Decoder())
.transform(const LineSplitter())
.transform(DwarfStackTraceDecoder(dwarf, includeInternalFrames: true))
.listen(output.writeln, onDone: onDone.complete, onError: onDone.completeError);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Symbolication -> Symbolization

@jonahwilliams

Copy link
Copy Markdown
Contributor Author

Updated to latest native_stack_traces package

@zanderso zanderso left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm w/ nits

SymbolizeCommand({
@required Stdio stdio,
@required FileSystem fileSystem,
DwarfSymbolizationService dwarfSymbolicationService = const DwarfSymbolizationService(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dwarfSymbolicationService -> dwarfSymbolizationService

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

output.writeln(line);
} on Exception catch(e, s) {
subscription.cancel().whenComplete(() {
if (!onDone.isCompleted) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indentation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@fluttergithubbot
fluttergithubbot merged commit 5681727 into flutter:master Feb 10, 2020
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Land support for "flutter symbolize" command

5 participants