Skip to content

Commit

Permalink
Implement support for single stepping out of an async function.
Browse files Browse the repository at this point in the history
BUG=
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2785243003 .
  • Loading branch information
johnmccutchan committed Mar 31, 2017
1 parent 8d340ee commit 193f26d
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 92 deletions.
5 changes: 0 additions & 5 deletions runtime/observatory/tests/service/async_next_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ testMain() {
doAsync(true);
}

asyncNext(Isolate isolate) async {
print('asyncNext');
return asyncStepOver(isolate);
}

var tests = [
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_A),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// 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.
// VMOptions=--error_on_bad_type --error_on_bad_override --verbose_debug

import 'dart:developer';
import 'package:observatory/models.dart' as M;
import 'package:observatory/service_io.dart';
import 'package:unittest/unittest.dart';
import 'service_test_common.dart';
import 'test_helper.dart';

const LINE_A = 20;
const LINE_B = 21;
const LINE_C = 26;
const LINE_D = 27;
const LINE_E = 28;
const LINE_F = 35;
const LINE_G = 38;

helper() async {
print('helper'); // LINE_A.
throw 'a'; // LINE_B.
}

testMain() async {
debugger();
print('mmmmm'); // LINE_C.
try {
await helper(); // LINE_D.
} catch (e) {
// arrive here on error.
print('error: $e'); // LINE_E.
} finally {
// arrive here in both cases.
print('foo'); // LINE_F.
}
print('z'); // LINE_G.
}

var tests = [
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_C),
stepOver, // print.
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_D),
stepInto,
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_A),
stepOver, // print.
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_B), // throw 'a'.
stepInto, // exit helper via a throw.
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_E), // print(error)
stepOver,
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_F), // print(foo)
stepOver,
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_G), // print(z)
resumeIsolate
];

main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain);
49 changes: 49 additions & 0 deletions runtime/observatory/tests/service/async_single_step_out_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// 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.
// VMOptions=--error_on_bad_type --error_on_bad_override --verbose_debug

import 'dart:developer';
import 'package:observatory/models.dart' as M;
import 'package:observatory/service_io.dart';
import 'package:unittest/unittest.dart';
import 'service_test_common.dart';
import 'test_helper.dart';

const LINE_A = 20;
const LINE_B = 21;
const LINE_C = 26;
const LINE_D = 27;
const LINE_E = 28;

helper() async {
print('helper'); // LINE_A.
return null; // LINE_B.
}

testMain() async {
debugger();
print('mmmmm'); // LINE_C.
await helper(); // LINE_D.
print('z'); // LINE_E.
}

var tests = [
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_C),
stepOver, // print.
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_D),
stepInto,
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_A),
stepOver, // print.
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_B), // return null.
stepInto, // exit helper via a single step.
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_E), // arrive after the await.
resumeIsolate
];

main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain);
74 changes: 0 additions & 74 deletions runtime/observatory/tests/service/smart_next_test.dart

This file was deleted.

5 changes: 3 additions & 2 deletions runtime/observatory/tests/service/step_over_await_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'package:unittest/unittest.dart';
const int LINE_A = 22;
const int LINE_B = 24;

// This tests the asyncStepOver command.
// This tests the asyncNext command.
asyncFunction() async {
debugger();
print('a'); // LINE_A
Expand All @@ -38,7 +38,8 @@ var tests = [
(Isolate isolate) async {
expect(M.isAtAsyncSuspension(isolate.pauseEvent), isTrue);
},
asyncStepOver,
asyncNext,
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_B),
resumeIsolate,
];
Expand Down

0 comments on commit 193f26d

Please sign in to comment.