Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(628)

Unified Diff: runtime/observatory/tests/service/steal_breakpoint_test.dart

Issue 1113243002: Add the --steal-breakpoints flag. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: switch branch Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/observatory/tests/service/debugging_test.dart ('k') | runtime/vm/debugger.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/tests/service/steal_breakpoint_test.dart
diff --git a/runtime/observatory/tests/service/steal_breakpoint_test.dart b/runtime/observatory/tests/service/steal_breakpoint_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1a2920aa7b9aea510a275d8a541b891d0e4ddbb2
--- /dev/null
+++ b/runtime/observatory/tests/service/steal_breakpoint_test.dart
@@ -0,0 +1,78 @@
+// Copyright (c) 2015, 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=--compile-all --error_on_bad_type --error_on_bad_override --steal-breakpoints
+
+import 'package:observatory/service_io.dart';
+import 'package:unittest/unittest.dart';
+import 'test_helper.dart';
+import 'dart:async';
+
+int counter = 0;
+
+void periodicTask(_) {
+ counter++; // Line 14. We set our breakpoint here.
+ if (counter % 1000 == 0) {
+ print('counter = $counter');
+ }
+}
+
+void startTimer() {
+ new Timer.periodic(const Duration(milliseconds:10), periodicTask);
+}
+
+var tests = [
+
+// Add a breakpoint and wait for it to be reached.
+(Isolate isolate) async {
+ await isolate.rootLib.load();
+
+ // Set up a listener to wait for breakpoint events.
+ Completer completer = new Completer();
+ var subscription;
+ subscription = isolate.vm.events.stream.listen((ServiceEvent event) {
+ if (event.eventType == ServiceEvent.kPauseBreakpoint) {
+ print('Isolate paused at breakpoint');
+ subscription.cancel();
+ completer.complete();
+ }
+ });
+
+ // Add the breakpoint.
+ var script = isolate.rootLib.scripts[0];
+ var result = await isolate.addBreakpoint(script, 14);
+ expect(result is Breakpoint, isTrue);
+
+ await completer.future; // Wait for breakpoint event to fire.
+},
+
+// We are at the breakpoint on line 14.
+(Isolate isolate) async {
+ ServiceMap stack = await isolate.getStack();
+ expect(stack.type, equals('Stack'));
+ expect(stack['frames'].length, greaterThanOrEqualTo(1));
+
+ Script script = stack['frames'][0]['script'];
+ await script.load();
+ expect(script.name,endsWith('steal_breakpoint_test.dart'));
+ expect(script.tokenToLine(stack['frames'][0]['tokenPos']), equals(14));
+},
+
+// Resume
+(Isolate isolate) async {
+ Completer completer = new Completer();
+ var subscription;
+ subscription = isolate.vm.events.stream.listen((ServiceEvent event) {
+ if (event.eventType == ServiceEvent.kResume) {
+ print('Isolate resumed');
+ subscription.cancel();
+ completer.complete();
+ }
+ });
+ isolate.resume();
+ await completer.future;
+},
+
+];
+
+main(args) => runIsolateTests(args, tests, testeeBefore: startTimer);
« no previous file with comments | « runtime/observatory/tests/service/debugging_test.dart ('k') | runtime/vm/debugger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698