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

Unified Diff: runtime/observatory/test/debugging_test.dart

Issue 920313003: Implement function entry breakpoints in Observatory debugger. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
Index: runtime/observatory/test/debugging_test.dart
diff --git a/runtime/observatory/test/debugging_test.dart b/runtime/observatory/test/debugging_test.dart
index ac6b48c720b8db25aaed46bbcf62eef0c4f05380..d32b140ccd19312670314c2b5d6e3ecb9da33497 100644
--- a/runtime/observatory/test/debugging_test.dart
+++ b/runtime/observatory/test/debugging_test.dart
@@ -7,11 +7,15 @@ import 'package:unittest/unittest.dart';
import 'test_helper.dart';
import 'dart:async';
+void helper(i) {
+ print(i);
+}
+
void testFunction() {
int i = 0;
while (true) {
if (++i % 100000000 == 0) {
- print(i); // line 14
+ helper(i); // line 18
}
}
}
@@ -43,13 +47,15 @@ var tests = [
// Set up a listener to wait for breakpoint events.
Completer completer = new Completer();
List events = [];
- isolate.vm.events.stream.listen((ServiceEvent event) {
+ var subscription;
+ subscription = isolate.vm.events.stream.listen((ServiceEvent event) {
if (event.eventType.startsWith('Breakpoint')) {
events.add(event);
if (events.length == 2) {
expect(events[0].eventType, equals('BreakpointResolved'));
expect(events[1].eventType, equals('BreakpointReached'));
print('Breakpoint reached');
+ subscription.cancel();
completer.complete();
}
}
@@ -57,12 +63,12 @@ var tests = [
// Add the breakpoint.
var script = isolate.rootLib.scripts[0];
- return isolate.addBreakpoint(script, 14).then((ServiceObject bpt) {
+ return isolate.addBreakpoint(script, 18).then((ServiceObject bpt) {
expect(bpt is ServiceMap, isTrue);
ServiceMap m = bpt;
expect(m.type, equals('Breakpoint'));
expect(m['location']['script'].id, equals(script.id));
- expect(m['location']['tokenPos'], equals(51));
+ expect(m['location']['tokenPos'], equals(67));
expect(isolate.breakpoints.length, equals(1));
return completer.future; // Wait for breakpoint events.
});
@@ -83,10 +89,11 @@ var tests = [
// Set up a listener to wait for breakpoint events.
Completer completer = new Completer();
List events = [];
- isolate.vm.events.stream.listen((ServiceEvent event) {
- if (event.eventType.startsWith('Breakpoint')) {
- expect(event.eventType, equals('BreakpointReached'));
+ var subscription;
+ subscription = isolate.vm.events.stream.listen((ServiceEvent event) {
+ if (event.eventType.startsWith('BreakpointReached')) {
print('Breakpoint reached');
+ subscription.cancel();
completer.complete();
}
});
@@ -96,12 +103,12 @@ var tests = [
});
},
-// Get the stack trace again. We are in 'print'.
+// Get the stack trace again. We are in 'helper'.
(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('print'));
+ expect(stack['frames'][0]['function'].name, equals('helper'));
});
},
@@ -114,6 +121,44 @@ var tests = [
});
},
+// Resume
+(Isolate isolate) {
+ return isolate.resume().then((_) {
+ expect(isolate.pauseEvent == null, isTrue);
+ });
+},
+
+// Add breakpoint at function entry
+(Isolate isolate) {
+ // Set up a listener to wait for breakpoint events.
+ Completer completer = new Completer();
+ List events = [];
+ var subscription;
+ subscription = isolate.vm.events.stream.listen((ServiceEvent event) {
+ if (event.eventType.startsWith('BreakpointReached')) {
+ print('Breakpoint reached');
+ subscription.cancel();
+ completer.complete();
+ }
+ });
+
+ // Find a specific function.
+ ServiceFunction function = isolate.rootLib.functions.firstWhere(
+ (f) => f.name == 'helper');
+ expect(function, isNotNull);
+
+ // Add the breakpoint at function entry
+ return isolate.addBreakpointAtEntry(function).then((ServiceObject bpt) {
+ expect(bpt is ServiceMap, isTrue);
+ ServiceMap m = bpt;
+ expect(m.type, equals('Breakpoint'));
+ expect(m['location']['script'].name, equals('debugging_test.dart'));
+ expect(m['location']['tokenPos'], equals(29));
+ expect(isolate.breakpoints.length, equals(1));
+ return completer.future; // Wait for breakpoint events.
+ });
+},
+
];
main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction);

Powered by Google App Engine
This is Rietveld 408576698