This package provides libraries and a utility for decoding non-symbolic stack traces generated by an AOT-compiled Dart application.
Converting stack traces #
In some modes of AOT compilation, information on mapping execution points to source locations is no longer stored in the Dart image. Instead, this information is translated to separately stored debugging information. This debugging information can then be stripped from the application before shipping.
However, there is a drawback. Stack traces generated by such an application no longer includes file, function, and line number information (i.e., symbolic stack traces). Instead, stack trace frames simply include program counter information. Thus, to find the source information for these frames, we must use the debugging information. This means either keeping the original unstripped application, or saving the debugging information into a separate file.
Given this debugging information, the libraries in this package can turn
non-symbolic stack traces back into symbolic stack traces. In addition, this
package includes a command line tool
decode whose output is the same as its
input except that non-symbolic stack traces are translated.
Take the following Dart code, which we put in
throws.dart. The inlining
pragmas are here just to ensure that
bar is inlined into
foo and that
is not inlined into
bar, to illustrate how inlined code is handled in the
@pragma('vm:prefer-inline') bar() => throw null; @pragma('vm:never-inline') foo() => bar(); main() => foo();
Now we run the following commands:
# Make sure that we have the native_stack_traces package. $ pub get native_stack_traces $ pub global activate native_stack_traces # We compile the example program, removing the source location information # from the snapshot and saving the debugging information into throws.debug. $ dart2native -k aot -S throws.debug -o throws.aotsnapshot throws.dart # Run the program, saving the error output to throws.err. $ dartaotruntime throws.aotsnapshot 2>throws.err # Using the saved debugging information, we can translate the stack trace # contained in throws.err to its symbolic form. $ pub global run native_stack_traces:decode translate -d throws.debug -i throws.err # We can also just pipe the output of running the program directly into # the utility. $ dartaotruntime throws.aotsnapshot |& \ pub global run native_stack_traces:decode translate -d throws.debug
Features and bugs #
Please file feature requests and bugs at the issue tracker.
- Finds instruction sections by the dynamic symbols the Dart VM creates instead of assuming there are two text sections.
- Added static method Dwarf.fromBuffer.
- API and documentation cleanups
- Initial release
Use this package as an executable
1. Install it
You can install the package from the command line:
$ pub global activate native_stack_traces
2. Use it
The package has the following executables:
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies: native_stack_traces: ^0.2.2
2. Install it
You can install packages from the command line:
$ pub get
$ flutter pub get
Alternatively, your editor might support
pub get or
flutter pub get.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
We analyzed this package on Feb 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.7.1
- pana: 0.13.5
Maintain an example. (-10 points)
Create a short demo in the
example/ directory to show how to use this package.
Common filename patterns include
native_stack_traces.dart. Packages with multiple examples should provide
For more information see the pub package layout conventions.
The package description is too short. (-7 points)
Add more detail to the
description field of
pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.