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

Unified Diff: runtime/observatory/tests/service/debugging_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 | « no previous file | runtime/observatory/tests/service/steal_breakpoint_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/tests/service/debugging_test.dart
diff --git a/runtime/observatory/tests/service/debugging_test.dart b/runtime/observatory/tests/service/debugging_test.dart
index e99c60b418d69337317c6d9d0d2e2fb4273291d3..a98702169656303aa3aea2a4d29b09a9e907a7f0 100644
--- a/runtime/observatory/tests/service/debugging_test.dart
+++ b/runtime/observatory/tests/service/debugging_test.dart
@@ -8,23 +8,25 @@ import 'package:unittest/unittest.dart';
import 'test_helper.dart';
import 'dart:async';
-void helper(i) {
- print(i);
+int counter = 0;
+
+void periodicTask(_) {
+ counter++;
+ counter++; // Line 15. We set our breakpoint here.
+ counter++;
+ if (counter % 300 == 0) {
+ print('counter = $counter');
+ }
}
-void testFunction() {
- int i = 0;
- while (true) {
- if (++i % 100000000 == 0) {
- helper(i); // line 18
- }
- }
+void startTimer() {
+ new Timer.periodic(const Duration(milliseconds:10), periodicTask);
}
var tests = [
// Pause
-(Isolate isolate) {
+(Isolate isolate) async {
Completer completer = new Completer();
var subscription;
subscription = isolate.vm.events.stream.listen((ServiceEvent event) {
@@ -34,11 +36,11 @@ var tests = [
}
});
isolate.pause();
- return completer.future;
+ await completer.future;
},
// Resume
-(Isolate isolate) {
+(Isolate isolate) async {
Completer completer = new Completer();
var subscription;
subscription = isolate.vm.events.stream.listen((ServiceEvent event) {
@@ -48,49 +50,52 @@ var tests = [
}
});
isolate.resume();
- return completer.future;
+ await completer.future;
},
// Add breakpoint
-(Isolate isolate) {
- return isolate.rootLib.load().then((_) {
- // 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('Breakpoint reached');
- subscription.cancel();
- completer.complete();
- }
- });
-
- // Add the breakpoint.
- var script = isolate.rootLib.scripts[0];
- return isolate.addBreakpoint(script, 18).then((result) {
- expect(result is Breakpoint, isTrue);
- Breakpoint bpt = result;
- expect(bpt.type, equals('Breakpoint'));
- expect(bpt.script.id, equals(script.id));
- expect(bpt.tokenPos, equals(58));
- expect(isolate.breakpoints.length, equals(1));
- return completer.future; // Wait for breakpoint events.
- });
- });
-},
+(Isolate isolate) async {
+ await isolate.rootLib.load();
-// Get the stack trace
-(Isolate isolate) {
- return isolate.getStack().then((ServiceMap stack) {
- expect(stack.type, equals('Stack'));
- expect(stack['frames'].length, greaterThanOrEqualTo(1));
- expect(stack['frames'][0]['function'].name, equals('testFunction'));
- expect(stack['frames'][0]['tokenPos'], equals(58));
+ // 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('Breakpoint reached');
+ subscription.cancel();
+ completer.complete();
+ }
});
+
+ var script = isolate.rootLib.scripts[0];
+ await script.load();
+
+ // Add the breakpoint.
+ var result = await isolate.addBreakpoint(script, 15);
+ expect(result is Breakpoint, isTrue);
+ Breakpoint bpt = result;
+ expect(bpt.type, equals('Breakpoint'));
+ expect(bpt.script.id, equals(script.id));
+ expect(bpt.script.tokenToLine(bpt.tokenPos), equals(15));
+ expect(isolate.breakpoints.length, equals(1));
+
+ await completer.future; // Wait for breakpoint events.
+},
+
+// We are at the breakpoint on line 15.
+(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'];
+ expect(script.name,endsWith('debugging_test.dart'));
+ expect(script.tokenToLine(stack['frames'][0]['tokenPos']), equals(15));
},
// Stepping
-(Isolate isolate) {
+(Isolate isolate) async {
// Set up a listener to wait for breakpoint events.
Completer completer = new Completer();
var subscription;
@@ -102,23 +107,23 @@ var tests = [
}
});
- return isolate.stepInto().then((isolate) {
- return completer.future; // Wait for breakpoint events.
- });
+ await isolate.stepOver();
+ await completer.future; // Wait for breakpoint events.
},
-// Get the stack trace again. Our position has updated.
-(Isolate isolate) {
- return isolate.getStack().then((ServiceMap stack) {
- expect(stack.type, equals('Stack'));
- expect(stack['frames'].length, greaterThanOrEqualTo(2));
- expect(stack['frames'][0]['function'].name, equals('testFunction'));
- expect(stack['frames'][0]['tokenPos'], equals(60));
- });
+// We are now at line 16.
+(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'];
+ expect(script.name,endsWith('debugging_test.dart'));
+ expect(script.tokenToLine(stack['frames'][0]['tokenPos']), equals(16));
},
// Remove breakpoint
-(Isolate isolate) {
+(Isolate isolate) async {
// Set up a listener to wait for breakpoint events.
Completer completer = new Completer();
var subscription;
@@ -133,13 +138,12 @@ var tests = [
expect(isolate.breakpoints.length, equals(1));
var bpt = isolate.breakpoints.values.first;
- return isolate.removeBreakpoint(bpt).then((_) {
- return completer.future;
- });
+ await isolate.removeBreakpoint(bpt);
+ await completer.future;
},
// Resume
-(Isolate isolate) {
+(Isolate isolate) async {
Completer completer = new Completer();
var subscription;
subscription = isolate.vm.events.stream.listen((ServiceEvent event) {
@@ -149,11 +153,11 @@ var tests = [
}
});
isolate.resume();
- return completer.future;
+ await completer.future;
},
// Add breakpoint at function entry
-(Isolate isolate) {
+(Isolate isolate) async {
// Set up a listener to wait for breakpoint events.
Completer completer = new Completer();
var subscription;
@@ -167,21 +171,32 @@ var tests = [
// Find a specific function.
ServiceFunction function = isolate.rootLib.functions.firstWhere(
- (f) => f.name == 'helper');
+ (f) => f.name == 'periodicTask');
expect(function, isNotNull);
// Add the breakpoint at function entry
- return isolate.addBreakpointAtEntry(function).then((result) {
- expect(result is Breakpoint, isTrue);
- Breakpoint bpt = result;
- expect(bpt.type, equals('Breakpoint'));
- expect(bpt.script.name, equals('debugging_test.dart'));
- expect(bpt.tokenPos, equals(29));
- expect(isolate.breakpoints.length, equals(1));
- return completer.future; // Wait for breakpoint events.
- });
+ var result = await isolate.addBreakpointAtEntry(function);
+ expect(result is Breakpoint, isTrue);
+ Breakpoint bpt = result;
+ expect(bpt.type, equals('Breakpoint'));
+ expect(bpt.script.name, equals('debugging_test.dart'));
+ expect(bpt.script.tokenToLine(bpt.tokenPos), equals(14));
+ expect(isolate.breakpoints.length, equals(1));
+
+ await completer.future; // Wait for breakpoint events.
+},
+
+// We are now at 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'];
+ expect(script.name,endsWith('debugging_test.dart'));
+ expect(script.tokenToLine(stack['frames'][0]['tokenPos']), equals(14));
},
];
-main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction);
+main(args) => runIsolateTests(args, tests, testeeBefore: startTimer);
« no previous file with comments | « no previous file | runtime/observatory/tests/service/steal_breakpoint_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698