Fix evaluating in async/sync*/async* methods.

Fixes #27167.

R=hausner@google.com

Review URL: https://codereview.chromium.org/2291293003 .
This commit is contained in:
Ryan Macnak 2016-08-30 15:16:57 -07:00
parent bf7d220741
commit c80b23b7ff
4 changed files with 188 additions and 2 deletions

View file

@ -0,0 +1,57 @@
// Copyright (c) 2016, 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:async';
import 'dart:developer';
import 'package:observatory/service_io.dart';
import 'package:unittest/unittest.dart';
import 'service_test_common.dart';
import 'test_helper.dart';
testFunction() async {
var x = 3;
var y = 4;
debugger();
var z = await new Future(() => x + y);
debugger();
return z;
}
var tests = [
hasStoppedAtBreakpoint,
(Isolate isolate) async {
// Make sure we are in the right place.
var stack = await isolate.getStack();
var topFrame = 0;
expect(stack.type, equals('Stack'));
expect(await stack['frames'][topFrame].location.getLine(), 16);
var result = await isolate.evalFrame(topFrame, "x");
print(result);
expect(result.valueAsString, equals("3"));
},
resumeIsolate,
hasStoppedAtBreakpoint,
(Isolate isolate) async {
// Make sure we are in the right place.
var stack = await isolate.getStack();
var topFrame = 0;
expect(stack.type, equals('Stack'));
expect(await stack['frames'][topFrame].location.getLine(), 18);
var result = await isolate.evalFrame(topFrame, "z");
print(result);
expect(result.valueAsString, equals("7"));
},
resumeIsolate,
];
main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction);

View file

@ -0,0 +1,62 @@
// Copyright (c) 2016, 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:async';
import 'dart:developer';
import 'package:observatory/service_io.dart';
import 'package:unittest/unittest.dart';
import 'service_test_common.dart';
import 'test_helper.dart';
generator() async* {
var x = 3;
var y = 4;
debugger();
yield y;
var z = x + y;
debugger();
yield z;
}
testFunction() async {
await for (var ignored in generator());
}
var tests = [
hasStoppedAtBreakpoint,
(Isolate isolate) async {
// Make sure we are in the right place.
var stack = await isolate.getStack();
var topFrame = 0;
expect(stack.type, equals('Stack'));
expect(await stack['frames'][topFrame].location.getLine(), 16);
var result = await isolate.evalFrame(topFrame, "x");
print(result);
expect(result.valueAsString, equals("3"));
},
resumeIsolate,
hasStoppedAtBreakpoint,
(Isolate isolate) async {
// Make sure we are in the right place.
var stack = await isolate.getStack();
var topFrame = 0;
expect(stack.type, equals('Stack'));
expect(await stack['frames'][topFrame].location.getLine(), 19);
var result = await isolate.evalFrame(topFrame, "z");
print(result);
expect(result.valueAsString, equals("7"));
},
resumeIsolate,
];
main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction);

View file

@ -0,0 +1,62 @@
// Copyright (c) 2016, 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:async';
import 'dart:developer';
import 'package:observatory/service_io.dart';
import 'package:unittest/unittest.dart';
import 'service_test_common.dart';
import 'test_helper.dart';
generator() sync* {
var x = 3;
var y = 4;
debugger();
yield y;
var z = x + y;
debugger();
yield z;
}
testFunction() {
for (var ignored in generator());
}
var tests = [
hasStoppedAtBreakpoint,
(Isolate isolate) async {
// Make sure we are in the right place.
var stack = await isolate.getStack();
var topFrame = 0;
expect(stack.type, equals('Stack'));
expect(await stack['frames'][topFrame].location.getLine(), 16);
var result = await isolate.evalFrame(topFrame, "x");
print(result);
expect(result.valueAsString, equals("3"));
},
resumeIsolate,
hasStoppedAtBreakpoint,
(Isolate isolate) async {
// Make sure we are in the right place.
var stack = await isolate.getStack();
var topFrame = 0;
expect(stack.type, equals('Stack'));
expect(await stack['frames'][topFrame].location.getLine(), 19);
var result = await isolate.evalFrame(topFrame, "z");
print(result);
expect(result.valueAsString, equals("7"));
},
resumeIsolate,
];
main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction);

View file

@ -972,7 +972,12 @@ RawObject* ActivationFrame::GetReceiver() {
}
bool IsPrivateVariableName(const String& var_name) {
static bool IsSyntheticVariableName(const String& var_name) {
return (var_name.Length() >= 1) && (var_name.CharAt(0) == ':');
}
static bool IsPrivateVariableName(const String& var_name) {
return (var_name.Length() >= 1) && (var_name.CharAt(0) == '_');
}
@ -989,7 +994,7 @@ RawObject* ActivationFrame::Evaluate(const String& expr) {
for (intptr_t i = 0; i < num_variables; i++) {
TokenPosition ignore;
VariableAt(i, &name, &ignore, &ignore, &value);
if (!name.Equals(Symbols::This())) {
if (!name.Equals(Symbols::This()) && !IsSyntheticVariableName(name)) {
if (IsPrivateVariableName(name)) {
name = String::ScrubName(name);
}