dart-sdk/tests/standalone_2/dwarf_stack_trace_test.dart

242 lines
7.6 KiB
Dart
Raw Normal View History

// Copyright (c) 2017, 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.
// @dart = 2.9
[vm/compiler] Reland "Add --save-debugging-info flag to gen_snapshot." Removes an unnecessary change to the names of type testing stubs that allowed name collisions to happen. Old commit message: The flag can be used when creating AOT snapshots. The resulting file can be used with package:vm/dwarf/convert.dart to convert DWARF-based stack traces to stack traces with function, file, and line number information. Currently the saved file will be an ELF file with DWARF debugging information, but this is subject to change in the future. To avoid being affected by any changes in format, read the DWARF information from the file using Dwarf.fromFile() in package:vm/dwarf/dwarf.dart. Also adds --dwarf-stack-traces to the VM global flag list, so its value at compilation will be read out of snapshots by the precompiled runtime. Fixes https://github.com/dart-lang/sdk/issues/39512, which was due to a missing compiler::target:: prefix for Instructions::HeaderSize() in BlobImageWriter::WriteText(). Exposes the information suggested in https://github.com/dart-lang/sdk/issues/39490 so that package:vm/dwarf can appropriately convert absolute PC addresses to the correct virtual address for a given DWARF line number program. Bug: https://github.com/dart-lang/sdk/issues/35851 Change-Id: I6723449dceb0b89c054a1f1e70e7acd7749baf14 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-win-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128730 Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-12-18 14:14:41 +00:00
/// VMOptions=--dwarf-stack-traces --save-debugging-info=dwarf.so
import 'dart:convert';
import 'dart:io';
import 'package:native_stack_traces/native_stack_traces.dart';
import 'package:path/path.dart' as path;
import 'package:expect/expect.dart';
@pragma("vm:prefer-inline")
bar() {
// Keep the 'throw' and its argument on separate lines.
throw // force linebreak with dartfmt
"Hello, Dwarf!";
}
@pragma("vm:never-inline")
foo() {
bar();
}
Future<void> main() async {
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
String rawStack = "";
try {
foo();
} catch (e, st) {
rawStack = st.toString();
}
if (path.basenameWithoutExtension(Platform.executable) !=
"dart_precompiled_runtime") {
[vm/compiler] Reland "Add --save-debugging-info flag to gen_snapshot." Removes an unnecessary change to the names of type testing stubs that allowed name collisions to happen. Old commit message: The flag can be used when creating AOT snapshots. The resulting file can be used with package:vm/dwarf/convert.dart to convert DWARF-based stack traces to stack traces with function, file, and line number information. Currently the saved file will be an ELF file with DWARF debugging information, but this is subject to change in the future. To avoid being affected by any changes in format, read the DWARF information from the file using Dwarf.fromFile() in package:vm/dwarf/dwarf.dart. Also adds --dwarf-stack-traces to the VM global flag list, so its value at compilation will be read out of snapshots by the precompiled runtime. Fixes https://github.com/dart-lang/sdk/issues/39512, which was due to a missing compiler::target:: prefix for Instructions::HeaderSize() in BlobImageWriter::WriteText(). Exposes the information suggested in https://github.com/dart-lang/sdk/issues/39490 so that package:vm/dwarf can appropriately convert absolute PC addresses to the correct virtual address for a given DWARF line number program. Bug: https://github.com/dart-lang/sdk/issues/35851 Change-Id: I6723449dceb0b89c054a1f1e70e7acd7749baf14 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-win-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128730 Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-12-18 14:14:41 +00:00
return; // Not running from an AOT compiled snapshot.
}
[vm/compiler] Reland "Add --save-debugging-info flag to gen_snapshot." Removes an unnecessary change to the names of type testing stubs that allowed name collisions to happen. Old commit message: The flag can be used when creating AOT snapshots. The resulting file can be used with package:vm/dwarf/convert.dart to convert DWARF-based stack traces to stack traces with function, file, and line number information. Currently the saved file will be an ELF file with DWARF debugging information, but this is subject to change in the future. To avoid being affected by any changes in format, read the DWARF information from the file using Dwarf.fromFile() in package:vm/dwarf/dwarf.dart. Also adds --dwarf-stack-traces to the VM global flag list, so its value at compilation will be read out of snapshots by the precompiled runtime. Fixes https://github.com/dart-lang/sdk/issues/39512, which was due to a missing compiler::target:: prefix for Instructions::HeaderSize() in BlobImageWriter::WriteText(). Exposes the information suggested in https://github.com/dart-lang/sdk/issues/39490 so that package:vm/dwarf can appropriately convert absolute PC addresses to the correct virtual address for a given DWARF line number program. Bug: https://github.com/dart-lang/sdk/issues/35851 Change-Id: I6723449dceb0b89c054a1f1e70e7acd7749baf14 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-win-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128730 Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-12-18 14:14:41 +00:00
if (Platform.isAndroid) {
return; // Generated dwarf.so not available on the test device.
}
[vm/compiler] Reland "Add --save-debugging-info flag to gen_snapshot." Removes an unnecessary change to the names of type testing stubs that allowed name collisions to happen. Old commit message: The flag can be used when creating AOT snapshots. The resulting file can be used with package:vm/dwarf/convert.dart to convert DWARF-based stack traces to stack traces with function, file, and line number information. Currently the saved file will be an ELF file with DWARF debugging information, but this is subject to change in the future. To avoid being affected by any changes in format, read the DWARF information from the file using Dwarf.fromFile() in package:vm/dwarf/dwarf.dart. Also adds --dwarf-stack-traces to the VM global flag list, so its value at compilation will be read out of snapshots by the precompiled runtime. Fixes https://github.com/dart-lang/sdk/issues/39512, which was due to a missing compiler::target:: prefix for Instructions::HeaderSize() in BlobImageWriter::WriteText(). Exposes the information suggested in https://github.com/dart-lang/sdk/issues/39490 so that package:vm/dwarf can appropriately convert absolute PC addresses to the correct virtual address for a given DWARF line number program. Bug: https://github.com/dart-lang/sdk/issues/35851 Change-Id: I6723449dceb0b89c054a1f1e70e7acd7749baf14 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-win-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128730 Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-12-18 14:14:41 +00:00
final dwarf = Dwarf.fromFile("dwarf.so");
await checkStackTrace(rawStack, dwarf, expectedCallsInfo);
}
Future<void> checkStackTrace(String rawStack, Dwarf dwarf,
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
List<List<DartCallInfo>> expectedCallsInfo) async {
print("");
print("Raw stack trace:");
print(rawStack);
[vm/compiler] Reland "Add --save-debugging-info flag to gen_snapshot." Removes an unnecessary change to the names of type testing stubs that allowed name collisions to happen. Old commit message: The flag can be used when creating AOT snapshots. The resulting file can be used with package:vm/dwarf/convert.dart to convert DWARF-based stack traces to stack traces with function, file, and line number information. Currently the saved file will be an ELF file with DWARF debugging information, but this is subject to change in the future. To avoid being affected by any changes in format, read the DWARF information from the file using Dwarf.fromFile() in package:vm/dwarf/dwarf.dart. Also adds --dwarf-stack-traces to the VM global flag list, so its value at compilation will be read out of snapshots by the precompiled runtime. Fixes https://github.com/dart-lang/sdk/issues/39512, which was due to a missing compiler::target:: prefix for Instructions::HeaderSize() in BlobImageWriter::WriteText(). Exposes the information suggested in https://github.com/dart-lang/sdk/issues/39490 so that package:vm/dwarf can appropriately convert absolute PC addresses to the correct virtual address for a given DWARF line number program. Bug: https://github.com/dart-lang/sdk/issues/35851 Change-Id: I6723449dceb0b89c054a1f1e70e7acd7749baf14 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-win-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128730 Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-12-18 14:14:41 +00:00
final rawLines =
await Stream.value(rawStack).transform(const LineSplitter()).toList();
final pcOffsets = collectPCOffsets(rawLines).toList();
// We should have at least enough PC addresses to cover the frames we'll be
// checking.
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
Expect.isTrue(pcOffsets.length >= expectedCallsInfo.length);
final virtualAddresses =
pcOffsets.map((o) => dwarf.virtualAddressOf(o)).toList();
// Some double-checks using other information in the non-symbolic stack trace.
final dsoBase = dsoBaseAddresses(rawLines).single;
final absolutes = absoluteAddresses(rawLines);
final relocatedAddresses = absolutes.map((a) => a - dsoBase);
final explicits = explicitVirtualAddresses(rawLines);
// Explicits will be empty if not generating ELF snapshots directly, which
// means we can't depend on virtual addresses in the snapshot lining up with
// those in the separate debugging information.
if (explicits.isNotEmpty) {
// Direct-to-ELF snapshots should have a build ID.
Expect.isNotNull(dwarf.buildId);
Expect.deepEquals(relocatedAddresses, virtualAddresses);
Expect.deepEquals(explicits, virtualAddresses);
}
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
final gotCallsInfo = <List<DartCallInfo>>[];
for (final addr in virtualAddresses) {
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
final externalCallInfo = dwarf.callInfoFor(addr);
Expect.isNotNull(externalCallInfo);
final allCallInfo = dwarf.callInfoFor(addr, includeInternalFrames: true);
Expect.isNotNull(allCallInfo);
for (final call in externalCallInfo) {
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
Expect.isTrue(call is DartCallInfo, "got non-Dart call info ${call}");
Expect.isFalse(call.isInternal);
Expect.isTrue(allCallInfo.contains(call),
"External call info ${call} is not among all calls");
}
for (final call in allCallInfo) {
if (!call.isInternal) {
Expect.isTrue(externalCallInfo.contains(call),
"External call info ${call} is not among external calls");
}
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
}
gotCallsInfo.add(externalCallInfo.cast<DartCallInfo>().toList());
}
print("");
print("Call information for PC addresses:");
for (var i = 0; i < virtualAddresses.length; i++) {
print("For PC 0x${virtualAddresses[i].toRadixString(16)}:");
print(" Calls corresponding to user or library code:");
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
gotCallsInfo[i].forEach((frame) => print(" ${frame}"));
}
// Remove empty entries which correspond to skipped internal frames.
gotCallsInfo.removeWhere((calls) => calls.isEmpty);
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
checkFrames(gotCallsInfo, expectedCallsInfo);
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
final gotSymbolizedLines = await Stream.fromIterable(rawLines)
.transform(DwarfStackTraceDecoder(dwarf, includeInternalFrames: false))
.toList();
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
final gotSymbolizedCalls =
gotSymbolizedLines.where((s) => s.startsWith('#')).toList();
print("");
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
print("Symbolized stack trace:");
gotSymbolizedLines.forEach(print);
print("");
print("Extracted calls:");
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
gotSymbolizedCalls.forEach(print);
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
final expectedStrings = extractCallStrings(expectedCallsInfo);
// There are two strings in the list for each line in the output.
final expectedCallCount = expectedStrings.length ~/ 2;
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
Expect.isTrue(gotSymbolizedCalls.length >= expectedCallCount);
// Strip off any unexpected lines, so we can also make sure we didn't get
// unexpected calls prior to those calls we expect.
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
final gotCallsTrace =
gotSymbolizedCalls.sublist(0, expectedCallCount).join('\n');
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
Expect.stringContainsInOrder(gotCallsTrace, expectedStrings);
}
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
final expectedCallsInfo = <List<DartCallInfo>>[
// The first frame should correspond to the throw in bar, which was inlined
// into foo (so we'll get information for two calls for that PC address).
[
DartCallInfo(
function: "bar",
filename: "dwarf_stack_trace_test.dart",
line: 19,
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
column: 3,
inlined: true),
DartCallInfo(
function: "foo",
filename: "dwarf_stack_trace_test.dart",
line: 25,
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
column: 3,
inlined: false)
],
// The second frame corresponds to call to foo in main.
[
DartCallInfo(
function: "main",
filename: "dwarf_stack_trace_test.dart",
line: 31,
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
column: 5,
inlined: false)
],
// Don't assume anything about any of the frames below the call to foo
// in main, as this makes the test too brittle.
];
void checkFrames(
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
List<List<DartCallInfo>> gotInfo, List<List<DartCallInfo>> expectedInfo) {
// There may be frames below those we check.
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
Expect.isTrue(gotInfo.length >= expectedInfo.length);
// We can't just use deep equality, since we only have the filenames in the
// expected version, not the whole path, and we don't really care if
// non-positive line numbers match, as long as they're both non-positive.
for (var i = 0; i < expectedInfo.length; i++) {
for (var j = 0; j < expectedInfo[i].length; j++) {
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
final got = gotInfo[i][j];
final expected = expectedInfo[i][j];
Expect.equals(expected.function, got.function);
Expect.equals(expected.inlined, got.inlined);
Expect.equals(expected.filename, path.basename(got.filename));
if (expected.isInternal) {
Expect.isTrue(got.isInternal);
} else {
Expect.equals(expected.line, got.line);
}
}
}
}
List<String> extractCallStrings(List<List<CallInfo>> expectedCalls) {
var ret = <String>[];
for (final frame in expectedCalls) {
for (final call in frame) {
if (call is DartCallInfo) {
ret.add(call.function);
if (call.isInternal) {
ret.add("${call.filename}:??");
} else {
ret.add("${call.filename}:${call.line}");
}
}
}
}
return ret;
}
Iterable<int> parseUsingAddressRegExp(RegExp re, Iterable<String> lines) sync* {
for (final line in lines) {
final match = re.firstMatch(line);
[vm/aot] Reland "Keep column information when possible for precompiled mode." Changes: Doing this always in precompiled mode meant increased data segment sizes when CodeSourceMaps are stored, since encoded line/column information is larger in the LEB-like encoding used. Now we only store column information when we produce non-symbolic stacks, since the increased space needed to store the columns is instead in DWARF sections and can be stripped or elided. Original description: Previously, we passed line number information to the stack trace printer and to DWARF by changing the non-special positions in the CodeSourceMap to line numbers in precompiled mode. However, doing this lost column information. We get the column information back in the majority of cases by encoding the line number and column information when neither is too large to pack together into 30 bits. (Here, 20 bits for line and 10 bits for column.) Otherwise, we just store the line information as before, though due to using a bit to encode whether column info exists, it's reduced to 30 bits. If the line info is too big for that, we just return kNoSourcePos. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: Ia8baee71468da6100a170fa305d03059ffd17f78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151822 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-06-19 13:50:03 +00:00
if (match == null) continue;
final s = match.group(1);
if (s == null) continue;
yield int.parse(s, radix: 16);
}
}
final _absRE = RegExp(r'abs ([a-f\d]+)');
Iterable<int> absoluteAddresses(Iterable<String> lines) =>
parseUsingAddressRegExp(_absRE, lines);
final _virtRE = RegExp(r'virt ([a-f\d]+)');
Iterable<int> explicitVirtualAddresses(Iterable<String> lines) =>
parseUsingAddressRegExp(_virtRE, lines);
final _dsoBaseRE = RegExp(r'isolate_dso_base: ([a-f\d]+)');
Iterable<int> dsoBaseAddresses(Iterable<String> lines) =>
parseUsingAddressRegExp(_dsoBaseRE, lines);