Debugging sync* and yield
Set position on yield in sync* functions; use yield position in VM. Change-Id: I1c92fd47e3c8d4f747242e076007c122ea0d2186 Reviewed-on: https://dart-review.googlesource.com/68366 Reviewed-by: Aske Simon Christensen <askesc@google.com> Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
f9e50baa0b
commit
164c7e3195
@@ -238,11 +238,12 @@ class SyncStarFunctionRewriter extends ContinuationRewriterBase {
|
||||
return new Block(<Statement>[
|
||||
enclosingFunction.body.accept(this),
|
||||
new ReturnStatement(new BoolLiteral(false))
|
||||
..fileOffset = enclosingFunction.fileEndOffset
|
||||
]);
|
||||
}
|
||||
|
||||
visitYieldStatement(YieldStatement node) {
|
||||
var transformedExpression = node.expression.accept(this);
|
||||
Expression transformedExpression = node.expression.accept(this);
|
||||
|
||||
var statements = <Statement>[];
|
||||
if (node.isYieldStar) {
|
||||
@@ -259,7 +260,8 @@ class SyncStarFunctionRewriter extends ContinuationRewriterBase {
|
||||
helper.syncIteratorCurrent)));
|
||||
}
|
||||
|
||||
statements.add(createContinuationPoint(new BoolLiteral(true)));
|
||||
statements.add(createContinuationPoint(new BoolLiteral(true))
|
||||
..fileOffset = node.fileOffset);
|
||||
return new Block(statements);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,6 @@ add_breakpoint_rpc_test: SkipByDesign # non-kernel specific version of add_break
|
||||
evaluate_activation_in_method_class_test: RuntimeError
|
||||
evaluate_activation_test/instance: RuntimeError
|
||||
evaluate_activation_test/scope: RuntimeError
|
||||
evaluate_in_sync_star_activation_test: RuntimeError
|
||||
step_through_arithmetic_test: RuntimeError # probably constant evaluator pre-evaluating e.g. 1+2
|
||||
unused_changes_in_last_reload_test: RuntimeError
|
||||
|
||||
@@ -235,6 +234,7 @@ evaluate_in_async_activation_test: RuntimeError # Issue #33087
|
||||
evaluate_in_async_star_activation_test: RuntimeError # Issue #33087
|
||||
evaluate_in_frame_rpc_test: RuntimeError # Issue #33087
|
||||
evaluate_in_frame_with_scope_test: RuntimeError # Issue #33087
|
||||
evaluate_in_sync_star_activation_test: RuntimeError # "No incremental compiler available for this isolate"
|
||||
evaluate_with_scope_test: RuntimeError # Issue #33087
|
||||
get_instances_rpc_test: RuntimeError # Issue #33087
|
||||
get_object_rpc_test: RuntimeError # Please triage.
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
// Copyright (c) 2018, 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 'test_helper.dart';
|
||||
import 'service_test_common.dart';
|
||||
|
||||
const int LINE = 11;
|
||||
const String file = "step_through_for_each_sync_star_2_test.dart";
|
||||
|
||||
code() {
|
||||
for (int datapoint in generator()) {
|
||||
print(datapoint);
|
||||
}
|
||||
}
|
||||
|
||||
generator() sync* {
|
||||
var x = 3;
|
||||
var y = 4;
|
||||
yield x;
|
||||
yield x + y;
|
||||
}
|
||||
|
||||
List<String> stops = [];
|
||||
List<String> expected = [
|
||||
"$file:${LINE + 0}:5", // after 'code'
|
||||
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
|
||||
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
|
||||
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
|
||||
|
||||
"$file:${LINE + 6}:10", // after 'generator' (definition line)
|
||||
"$file:${LINE + 7}:9", // on '=' in 'x = 3'
|
||||
"$file:${LINE + 8}:9", // on '=' in 'y = 4'
|
||||
"$file:${LINE + 9}:3", // on yield
|
||||
|
||||
"$file:${LINE + 1}:38", // on '{' in 'for' line
|
||||
"$file:${LINE + 2}:5", // on 'print'
|
||||
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
|
||||
|
||||
"$file:${LINE + 6}:10", // after 'generator' (definition line)
|
||||
"$file:${LINE + 10}:11", // on '+' in 'x + y'
|
||||
"$file:${LINE + 10}:3", // on yield
|
||||
|
||||
"$file:${LINE + 1}:38", // on '{' in 'for' line
|
||||
"$file:${LINE + 2}:5", // on 'print'
|
||||
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
|
||||
|
||||
"$file:${LINE + 6}:10", // after 'generator' (definition line)
|
||||
"$file:${LINE + 11}:1", // on ending '}' of 'generator'
|
||||
|
||||
"$file:${LINE + 4}:1", // on ending '}' of 'code''
|
||||
];
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
hasPausedAtStart,
|
||||
setBreakpointAtLine(LINE),
|
||||
runStepIntoThroughProgramRecordingStops(stops),
|
||||
checkRecordedStops(stops, expected,
|
||||
debugPrint: true, debugPrintFile: file, debugPrintLine: LINE)
|
||||
];
|
||||
|
||||
main(args) {
|
||||
runIsolateTestsSynchronous(args, tests,
|
||||
testeeConcurrent: code, pause_on_start: true, pause_on_exit: true);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
// Copyright (c) 2018, 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 'test_helper.dart';
|
||||
import 'service_test_common.dart';
|
||||
|
||||
const int LINE = 11;
|
||||
const String file = "step_through_for_each_sync_star_test.dart";
|
||||
|
||||
code() {
|
||||
for (int datapoint in generator()) {
|
||||
print(datapoint);
|
||||
}
|
||||
}
|
||||
|
||||
generator() sync* {
|
||||
var x = 3;
|
||||
var y = 4;
|
||||
yield y;
|
||||
var z = x + y;
|
||||
yield z;
|
||||
}
|
||||
|
||||
List<String> stops = [];
|
||||
List<String> expected = [
|
||||
"$file:${LINE + 0}:5", // after 'code'
|
||||
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
|
||||
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
|
||||
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
|
||||
|
||||
"$file:${LINE + 6}:10", // after 'generator' (definition line)
|
||||
"$file:${LINE + 7}:9", // on '=' in 'x = 3'
|
||||
"$file:${LINE + 8}:9", // on '=' in 'y = 4'
|
||||
"$file:${LINE + 9}:3", // on yield
|
||||
|
||||
"$file:${LINE + 1}:38", // on '{' in 'for' line
|
||||
"$file:${LINE + 2}:5", // on 'print'
|
||||
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
|
||||
|
||||
"$file:${LINE + 6}:10", // after 'generator' (definition line)
|
||||
"$file:${LINE + 10}:13", // on '+' in 'z = x + y'
|
||||
"$file:${LINE + 11}:3", // on yield
|
||||
|
||||
"$file:${LINE + 1}:38", // on '{' in 'for' line
|
||||
"$file:${LINE + 2}:5", // on 'print'
|
||||
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
|
||||
|
||||
"$file:${LINE + 6}:10", // after 'generator' (definition line)
|
||||
"$file:${LINE + 12}:1", // on ending '}' of 'generator'
|
||||
|
||||
"$file:${LINE + 4}:1", // on ending '}' of 'code''
|
||||
];
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
hasPausedAtStart,
|
||||
setBreakpointAtLine(LINE),
|
||||
runStepIntoThroughProgramRecordingStops(stops),
|
||||
checkRecordedStops(stops, expected,
|
||||
debugPrint: true, debugPrintFile: file, debugPrintLine: LINE)
|
||||
];
|
||||
|
||||
main(args) {
|
||||
runIsolateTestsSynchronous(args, tests,
|
||||
testeeConcurrent: code, pause_on_start: true, pause_on_exit: true);
|
||||
}
|
||||
@@ -5330,7 +5330,7 @@ Fragment StreamingFlowGraphBuilder::BuildYieldStatement() {
|
||||
StoreLocal(TokenPosition::kNoSource, scopes()->yield_context_variable);
|
||||
instructions += Drop();
|
||||
instructions += BuildExpression(); // read expression.
|
||||
instructions += Return(TokenPosition::kNoSource);
|
||||
instructions += Return(position);
|
||||
|
||||
// Note: DropTempsInstr serves as an anchor instruction. It will not
|
||||
// be linked into the resulting graph.
|
||||
|
||||
Reference in New Issue
Block a user