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>
This commit is contained in:
committed by
Commit Queue
parent
1f55c4ce32
commit
73c639a4ba
@@ -1,3 +1,11 @@
|
||||
## 0.5.5
|
||||
|
||||
- Fixed issue introduced by 0.5.4.
|
||||
|
||||
## 0.5.4
|
||||
|
||||
- Relaxed requirement for spaces before non-symbolic stack trace line.
|
||||
|
||||
## 0.5.3
|
||||
|
||||
- Exported more ELF utilities for use in Dart tests.
|
||||
|
||||
@@ -125,9 +125,9 @@ const _symbolOffsetREString = r'(?<symbol>' +
|
||||
constants.isolateSymbolName +
|
||||
r')\+(?<offset>(?:0x)?[\da-f]+)';
|
||||
final _symbolOffsetRE = RegExp(_symbolOffsetREString);
|
||||
final _traceLineRE = RegExp(
|
||||
r' #(\d+) abs (?<absolute>[\da-f]+)(?: virt (?<virtual>[\da-f]+))? '
|
||||
r'(?<rest>.*)$');
|
||||
final _traceLineRE =
|
||||
RegExp(r'\s*#(\d+) abs (?<absolute>[\da-f]+)(?: virt (?<virtual>[\da-f]+))?'
|
||||
r' (?<rest>.*)$');
|
||||
|
||||
/// Parses strings of the format <static symbol>+<integer offset>, where
|
||||
/// <static symbol> is one of the static symbols used for Dart instruction
|
||||
@@ -272,8 +272,15 @@ class DwarfStackTraceDecoder extends StreamTransformerBase<String, String> {
|
||||
// No lines to output (as this corresponds to Dart internals).
|
||||
if (callInfo.isEmpty) continue;
|
||||
// Output the lines for the symbolic frame with the prefix found on the
|
||||
// original non-symbolic frame line.
|
||||
final prefix = line.substring(0, lineMatch!.start);
|
||||
// original non-symbolic frame line, modulo all whitespace between the
|
||||
// prefix and stack trace information converted to a single space.
|
||||
//
|
||||
// If there was no prefix, just swallow any initial whitespace, since
|
||||
// symbolic Dart stacktrace lines have no initial whitespace.
|
||||
String prefix = line.substring(0, lineMatch!.start);
|
||||
if (prefix.isNotEmpty) {
|
||||
prefix += ' ';
|
||||
}
|
||||
for (final call in callInfo) {
|
||||
yield prefix + _stackTracePiece(call, depth++);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: native_stack_traces
|
||||
version: 0.5.3
|
||||
version: 0.5.5
|
||||
description: Utilities for working with non-symbolic stack traces.
|
||||
repository: https://github.com/dart-lang/sdk/tree/main/pkg/native_stack_traces
|
||||
|
||||
@@ -19,3 +19,4 @@ dependencies:
|
||||
# See also https://dart.dev/tools/pub/dependencies.
|
||||
dev_dependencies:
|
||||
lints: any
|
||||
test: any
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:native_stack_traces/src/convert.dart';
|
||||
import 'package:native_stack_traces/src/dwarf.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group('convert tests', defineConvertTests);
|
||||
}
|
||||
|
||||
final String pkgDir = Platform.script.resolve('../..').toFilePath();
|
||||
|
||||
void defineConvertTests() {
|
||||
test('b/262474517 regression', () async {
|
||||
final inputDir = path.join(pkgDir, 'testcases', 'convert');
|
||||
// Test with a prefix without four spaces between prefix and trace.
|
||||
testPath(path.join(inputDir, 'regress_262474517_trace.txt'));
|
||||
// Test for no prefix or whitespace at all.
|
||||
testPath(path.join(inputDir, 'regress_262474517_trace_2.txt'));
|
||||
});
|
||||
}
|
||||
|
||||
void testPath(String inputPath) async {
|
||||
final contents = await File(inputPath).readAsLines();
|
||||
final pcOffsets = collectPCOffsets(contents);
|
||||
expect(pcOffsets.map((o) => o.offset).toList(),
|
||||
[0x14e87f, 0x2a4e27, 0x4ee12b, 0x477fc7]);
|
||||
expect(pcOffsets.map((o) => o.section).toList(), [
|
||||
InstructionsSection.isolate,
|
||||
InstructionsSection.isolate,
|
||||
InstructionsSection.isolate,
|
||||
InstructionsSection.isolate
|
||||
]);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Bad state: No element. Error thrown null.
|
||||
BuildId: c3126a4381294e13185549e5e94a4db9
|
||||
at . #00 abs 0 virt 000000000031ba6f _kDartIsolateSnapshotInstructions+0x14e87f
|
||||
at . #01 abs 0 virt 0000000000472017 _kDartIsolateSnapshotInstructions+0x2a4e27
|
||||
at . #02 abs 0 virt 00000000006bb31b _kDartIsolateSnapshotInstructions+0x4ee12b
|
||||
at . #03 abs 0 virt 00000000006451b7 _kDartIsolateSnapshotInstructions+0x477fc7
|
||||
@@ -0,0 +1,6 @@
|
||||
Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Bad state: No element. Error thrown null.
|
||||
BuildId: c3126a4381294e13185549e5e94a4db9
|
||||
#00 abs 0 virt 000000000031ba6f _kDartIsolateSnapshotInstructions+0x14e87f
|
||||
#01 abs 0 virt 0000000000472017 _kDartIsolateSnapshotInstructions+0x2a4e27
|
||||
#02 abs 0 virt 00000000006bb31b _kDartIsolateSnapshotInstructions+0x4ee12b
|
||||
#03 abs 0 virt 00000000006451b7 _kDartIsolateSnapshotInstructions+0x477fc7
|
||||
Reference in New Issue
Block a user