Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 164c7e3

Browse files
jensjohacommit-bot@chromium.org
authored andcommitted
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 <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
1 parent f9e50ba commit 164c7e3

File tree

5 files changed

+137
-4
lines changed

5 files changed

+137
-4
lines changed

pkg/kernel/lib/transformations/continuation.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,12 @@ class SyncStarFunctionRewriter extends ContinuationRewriterBase {
238238
return new Block(<Statement>[
239239
enclosingFunction.body.accept(this),
240240
new ReturnStatement(new BoolLiteral(false))
241+
..fileOffset = enclosingFunction.fileEndOffset
241242
]);
242243
}
243244

244245
visitYieldStatement(YieldStatement node) {
245-
var transformedExpression = node.expression.accept(this);
246+
Expression transformedExpression = node.expression.accept(this);
246247

247248
var statements = <Statement>[];
248249
if (node.isYieldStar) {
@@ -259,7 +260,8 @@ class SyncStarFunctionRewriter extends ContinuationRewriterBase {
259260
helper.syncIteratorCurrent)));
260261
}
261262

262-
statements.add(createContinuationPoint(new BoolLiteral(true)));
263+
statements.add(createContinuationPoint(new BoolLiteral(true))
264+
..fileOffset = node.fileOffset);
263265
return new Block(statements);
264266
}
265267

runtime/observatory/tests/service/service_kernel.status

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ add_breakpoint_rpc_test: SkipByDesign # non-kernel specific version of add_break
119119
evaluate_activation_in_method_class_test: RuntimeError
120120
evaluate_activation_test/instance: RuntimeError
121121
evaluate_activation_test/scope: RuntimeError
122-
evaluate_in_sync_star_activation_test: RuntimeError
123122
step_through_arithmetic_test: RuntimeError # probably constant evaluator pre-evaluating e.g. 1+2
124123
unused_changes_in_last_reload_test: RuntimeError
125124

@@ -235,6 +234,7 @@ evaluate_in_async_activation_test: RuntimeError # Issue #33087
235234
evaluate_in_async_star_activation_test: RuntimeError # Issue #33087
236235
evaluate_in_frame_rpc_test: RuntimeError # Issue #33087
237236
evaluate_in_frame_with_scope_test: RuntimeError # Issue #33087
237+
evaluate_in_sync_star_activation_test: RuntimeError # "No incremental compiler available for this isolate"
238238
evaluate_with_scope_test: RuntimeError # Issue #33087
239239
get_instances_rpc_test: RuntimeError # Issue #33087
240240
get_object_rpc_test: RuntimeError # Please triage.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'test_helper.dart';
6+
import 'service_test_common.dart';
7+
8+
const int LINE = 11;
9+
const String file = "step_through_for_each_sync_star_2_test.dart";
10+
11+
code() {
12+
for (int datapoint in generator()) {
13+
print(datapoint);
14+
}
15+
}
16+
17+
generator() sync* {
18+
var x = 3;
19+
var y = 4;
20+
yield x;
21+
yield x + y;
22+
}
23+
24+
List<String> stops = [];
25+
List<String> expected = [
26+
"$file:${LINE + 0}:5", // after 'code'
27+
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
28+
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
29+
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
30+
31+
"$file:${LINE + 6}:10", // after 'generator' (definition line)
32+
"$file:${LINE + 7}:9", // on '=' in 'x = 3'
33+
"$file:${LINE + 8}:9", // on '=' in 'y = 4'
34+
"$file:${LINE + 9}:3", // on yield
35+
36+
"$file:${LINE + 1}:38", // on '{' in 'for' line
37+
"$file:${LINE + 2}:5", // on 'print'
38+
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
39+
40+
"$file:${LINE + 6}:10", // after 'generator' (definition line)
41+
"$file:${LINE + 10}:11", // on '+' in 'x + y'
42+
"$file:${LINE + 10}:3", // on yield
43+
44+
"$file:${LINE + 1}:38", // on '{' in 'for' line
45+
"$file:${LINE + 2}:5", // on 'print'
46+
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
47+
48+
"$file:${LINE + 6}:10", // after 'generator' (definition line)
49+
"$file:${LINE + 11}:1", // on ending '}' of 'generator'
50+
51+
"$file:${LINE + 4}:1", // on ending '}' of 'code''
52+
];
53+
54+
var tests = <IsolateTest>[
55+
hasPausedAtStart,
56+
setBreakpointAtLine(LINE),
57+
runStepIntoThroughProgramRecordingStops(stops),
58+
checkRecordedStops(stops, expected,
59+
debugPrint: true, debugPrintFile: file, debugPrintLine: LINE)
60+
];
61+
62+
main(args) {
63+
runIsolateTestsSynchronous(args, tests,
64+
testeeConcurrent: code, pause_on_start: true, pause_on_exit: true);
65+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'test_helper.dart';
6+
import 'service_test_common.dart';
7+
8+
const int LINE = 11;
9+
const String file = "step_through_for_each_sync_star_test.dart";
10+
11+
code() {
12+
for (int datapoint in generator()) {
13+
print(datapoint);
14+
}
15+
}
16+
17+
generator() sync* {
18+
var x = 3;
19+
var y = 4;
20+
yield y;
21+
var z = x + y;
22+
yield z;
23+
}
24+
25+
List<String> stops = [];
26+
List<String> expected = [
27+
"$file:${LINE + 0}:5", // after 'code'
28+
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
29+
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
30+
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
31+
32+
"$file:${LINE + 6}:10", // after 'generator' (definition line)
33+
"$file:${LINE + 7}:9", // on '=' in 'x = 3'
34+
"$file:${LINE + 8}:9", // on '=' in 'y = 4'
35+
"$file:${LINE + 9}:3", // on yield
36+
37+
"$file:${LINE + 1}:38", // on '{' in 'for' line
38+
"$file:${LINE + 2}:5", // on 'print'
39+
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
40+
41+
"$file:${LINE + 6}:10", // after 'generator' (definition line)
42+
"$file:${LINE + 10}:13", // on '+' in 'z = x + y'
43+
"$file:${LINE + 11}:3", // on yield
44+
45+
"$file:${LINE + 1}:38", // on '{' in 'for' line
46+
"$file:${LINE + 2}:5", // on 'print'
47+
"$file:${LINE + 1}:25", // on 'generator' (in 'for' line)
48+
49+
"$file:${LINE + 6}:10", // after 'generator' (definition line)
50+
"$file:${LINE + 12}:1", // on ending '}' of 'generator'
51+
52+
"$file:${LINE + 4}:1", // on ending '}' of 'code''
53+
];
54+
55+
var tests = <IsolateTest>[
56+
hasPausedAtStart,
57+
setBreakpointAtLine(LINE),
58+
runStepIntoThroughProgramRecordingStops(stops),
59+
checkRecordedStops(stops, expected,
60+
debugPrint: true, debugPrintFile: file, debugPrintLine: LINE)
61+
];
62+
63+
main(args) {
64+
runIsolateTestsSynchronous(args, tests,
65+
testeeConcurrent: code, pause_on_start: true, pause_on_exit: true);
66+
}

runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5330,7 +5330,7 @@ Fragment StreamingFlowGraphBuilder::BuildYieldStatement() {
53305330
StoreLocal(TokenPosition::kNoSource, scopes()->yield_context_variable);
53315331
instructions += Drop();
53325332
instructions += BuildExpression(); // read expression.
5333-
instructions += Return(TokenPosition::kNoSource);
5333+
instructions += Return(position);
53345334

53355335
// Note: DropTempsInstr serves as an anchor instruction. It will not
53365336
// be linked into the resulting graph.

0 commit comments

Comments
 (0)