dart-sdk/pkg/native_stack_traces
Tess Strickland 73c639a4ba Reland "[native_stack_traces] Remove initial spaces check in stack trace lines."
This is a reland of commit ae4ee87601

Our Dart tests that check for symbolic stack traces assume the frame
number comes at the very start of the line. Thus, be lenient about
how many spaces we see before non-symbolic stack traces, but only
generate a prefix for the resulting symbolic stack traces if the
original stack trace had any initial non-whitespace content.

Original change's description:
> [native_stack_traces] Remove initial spaces check in stack trace lines.
>
> The strictness of the old "check for four spaces" was causing failures
> in `flutter symbolize`, and there's no reason to check how much initial
> whitespace we got prior to the line contents anyway.
>
> TEST=pkg/native_stack_traces/test/convert/regress_262474517_test
>
> Change-Id: I6a6e31732cb2a5b5d40a088b9a04877052726be2
> Bug: b/262474517
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276905
> Reviewed-by: Daco Harkes <dacoharkes@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>

Bug: b/262474517
Change-Id: I3b0753404e00d535cf438e79078736f5d9a10dbc
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277001
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-12-22 11:52:18 +00:00
..
bin [pkg/native_stack_traces] Add support for MacOS universal binaries. 2022-08-25 13:27:24 +00:00
lib Reland "[native_stack_traces] Remove initial spaces check in stack trace lines." 2022-12-22 11:52:18 +00:00
test/convert Reland "[native_stack_traces] Remove initial spaces check in stack trace lines." 2022-12-22 11:52:18 +00:00
testcases/convert Reland "[native_stack_traces] Remove initial spaces check in stack trace lines." 2022-12-22 11:52:18 +00:00
.gitignore
analysis_options.yaml pkg:native_stack_trace - enable and fix a few more lints 2021-10-14 07:35:43 +00:00
AUTHORS
CHANGELOG.md Reland "[native_stack_traces] Remove initial spaces check in stack trace lines." 2022-12-22 11:52:18 +00:00
LICENSE Update LICENSE 2021-04-07 10:28:38 +00:00
OWNERS [infra] Add OWNERS to the Dart SDK 2022-02-14 14:06:34 +00:00
pubspec.yaml Reland "[native_stack_traces] Remove initial spaces check in stack trace lines." 2022-12-22 11:52:18 +00:00
README.md [pkg] prep to publish package:native_stack_traces 2022-05-31 16:39:16 +00:00

pub package package publisher

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.

Using decode

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 foo is not inlined into bar, to illustrate how inlined code is handled in the translated output.

@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.
$ dart 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.
$ dart compile exe -S throws.debug throws.dart

# Run the program, saving the error output to throws.err.
$ ./throws.exe 2>throws.err

# Using the saved debugging information, we can translate the stack trace
# contained in throws.err to its symbolic form.
$ dart pub global run native_stack_traces:decode translate -d throws.debug -i throws.err

Features and bugs

Please file feature requests and bugs at the issue tracker.