Files
sdk/runtime/tests/vm/dart/use_bare_instructions_flag_test.dart
T
Teagan Strickland 089aeedf56 [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

104 lines
3.0 KiB
Dart

// Copyright (c) 2019, 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.
// This test is ensuring that the flag for --use-bare-instructions given at
// AOT compile-time will be used at runtime (irrespective if other values were
// passed to the runtime).
import "dart:async";
import "dart:io";
import 'package:expect/expect.dart';
import 'package:path/path.dart' as path;
import 'use_flag_test_helper.dart';
main(List<String> args) async {
if (!isAOTRuntime) {
return; // Running in JIT: AOT binaries not available.
}
if (Platform.isAndroid) {
return; // SDK tree and dart_bootstrap not available on the test device.
}
await withTempDir('bare-flag-test', (String tempDir) async {
final script = path.join(sdkDir, 'pkg/kernel/bin/dump.dart');
final scriptDill = path.join(tempDir, 'kernel_dump.dill');
// Compile script to Kernel IR.
await run(genKernel, <String>[
'--aot',
'--platform=$platformDill',
'-o',
scriptDill,
script,
]);
// Run the AOT compiler with/without bare instructions.
final scriptBareSnapshot = path.join(tempDir, 'bare.snapshot');
final scriptNonBareSnapshot = path.join(tempDir, 'non_bare.snapshot');
await Future.wait(<Future>[
run(genSnapshot, <String>[
'--use-bare-instructions',
'--snapshot-kind=app-aot-elf',
'--elf=$scriptBareSnapshot',
scriptDill,
]),
run(genSnapshot, <String>[
'--no-use-bare-instructions',
'--snapshot-kind=app-aot-elf',
'--elf=$scriptNonBareSnapshot',
scriptDill,
]),
]);
// Run the resulting bare-AOT compiled script.
final bareOut1 = path.join(tempDir, 'bare-out1.txt');
final bareOut2 = path.join(tempDir, 'bare-out2.txt');
await Future.wait(<Future>[
run(aotRuntime, <String>[
'--use-bare-instructions',
scriptBareSnapshot,
scriptDill,
bareOut1,
]),
run(aotRuntime, <String>[
'--no-use-bare-instructions',
scriptBareSnapshot,
scriptDill,
bareOut2,
]),
]);
// Run the resulting non-bare-AOT compiled script.
final nonBareOut1 = path.join(tempDir, 'non-bare-out1.txt');
final nonBareOut2 = path.join(tempDir, 'non-bare-out2.txt');
await Future.wait(<Future>[
run(aotRuntime, <String>[
'--use-bare-instructions',
scriptNonBareSnapshot,
scriptDill,
nonBareOut1,
]),
run(aotRuntime, <String>[
'--no-use-bare-instructions',
scriptNonBareSnapshot,
scriptDill,
nonBareOut2,
]),
]);
// Ensure we got 4 times the same result.
final output = await readFile(bareOut1);
Expect.equals(output, await readFile(bareOut2));
Expect.equals(output, await readFile(nonBareOut1));
Expect.equals(output, await readFile(nonBareOut2));
});
}
Future<String> readFile(String file) {
return new File(file).readAsString();
}