| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override | 4 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override |
| 5 | 5 |
| 6 import 'package:observatory/service_io.dart'; | 6 import 'package:observatory/service_io.dart'; |
| 7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import 'test_helper.dart'; | 8 import 'test_helper.dart'; |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 }); | 69 }); |
| 70 | 70 |
| 71 var script = isolate.rootLibrary.scripts[0]; | 71 var script = isolate.rootLibrary.scripts[0]; |
| 72 await script.load(); | 72 await script.load(); |
| 73 | 73 |
| 74 // Add the breakpoint. | 74 // Add the breakpoint. |
| 75 var result = await isolate.addBreakpoint(script, 15); | 75 var result = await isolate.addBreakpoint(script, 15); |
| 76 expect(result is Breakpoint, isTrue); | 76 expect(result is Breakpoint, isTrue); |
| 77 Breakpoint bpt = result; | 77 Breakpoint bpt = result; |
| 78 expect(bpt.type, equals('Breakpoint')); | 78 expect(bpt.type, equals('Breakpoint')); |
| 79 expect(bpt.script.id, equals(script.id)); | 79 expect(bpt.location.script.id, equals(script.id)); |
| 80 expect(bpt.script.tokenToLine(bpt.tokenPos), equals(15)); | 80 expect(bpt.location.script.tokenToLine(bpt.location.tokenPos), equals(15)); |
| 81 expect(isolate.breakpoints.length, equals(1)); | 81 expect(isolate.breakpoints.length, equals(1)); |
| 82 | 82 |
| 83 await completer.future; // Wait for breakpoint events. | 83 await completer.future; // Wait for breakpoint events. |
| 84 }, | 84 }, |
| 85 | 85 |
| 86 // We are at the breakpoint on line 15. | 86 // We are at the breakpoint on line 15. |
| 87 (Isolate isolate) async { | 87 (Isolate isolate) async { |
| 88 ServiceMap stack = await isolate.getStack(); | 88 ServiceMap stack = await isolate.getStack(); |
| 89 expect(stack.type, equals('Stack')); | 89 expect(stack.type, equals('Stack')); |
| 90 expect(stack['frames'].length, greaterThanOrEqualTo(1)); | 90 expect(stack['frames'].length, greaterThanOrEqualTo(1)); |
| 91 | 91 |
| 92 Script script = stack['frames'][0]['script']; | 92 Script script = stack['frames'][0].location.script; |
| 93 expect(script.name,endsWith('debugging_test.dart')); | 93 expect(script.name,endsWith('debugging_test.dart')); |
| 94 expect(script.tokenToLine(stack['frames'][0]['tokenPos']), equals(15)); | 94 expect(script.tokenToLine(stack['frames'][0].location.tokenPos), equals(15)); |
| 95 }, | 95 }, |
| 96 | 96 |
| 97 // Stepping | 97 // Stepping |
| 98 (Isolate isolate) async { | 98 (Isolate isolate) async { |
| 99 // Set up a listener to wait for breakpoint events. | 99 // Set up a listener to wait for breakpoint events. |
| 100 Completer completer = new Completer(); | 100 Completer completer = new Completer(); |
| 101 var subscription; | 101 var subscription; |
| 102 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { | 102 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { |
| 103 if (event.kind == ServiceEvent.kPauseBreakpoint) { | 103 if (event.kind == ServiceEvent.kPauseBreakpoint) { |
| 104 print('Breakpoint reached'); | 104 print('Breakpoint reached'); |
| 105 subscription.cancel(); | 105 subscription.cancel(); |
| 106 completer.complete(); | 106 completer.complete(); |
| 107 } | 107 } |
| 108 }); | 108 }); |
| 109 | 109 |
| 110 await isolate.stepOver(); | 110 await isolate.stepOver(); |
| 111 await completer.future; // Wait for breakpoint events. | 111 await completer.future; // Wait for breakpoint events. |
| 112 }, | 112 }, |
| 113 | 113 |
| 114 // We are now at line 16. | 114 // We are now at line 16. |
| 115 (Isolate isolate) async { | 115 (Isolate isolate) async { |
| 116 ServiceMap stack = await isolate.getStack(); | 116 ServiceMap stack = await isolate.getStack(); |
| 117 expect(stack.type, equals('Stack')); | 117 expect(stack.type, equals('Stack')); |
| 118 expect(stack['frames'].length, greaterThanOrEqualTo(1)); | 118 expect(stack['frames'].length, greaterThanOrEqualTo(1)); |
| 119 | 119 |
| 120 Script script = stack['frames'][0]['script']; | 120 Script script = stack['frames'][0].location.script; |
| 121 expect(script.name,endsWith('debugging_test.dart')); | 121 expect(script.name,endsWith('debugging_test.dart')); |
| 122 expect(script.tokenToLine(stack['frames'][0]['tokenPos']), equals(16)); | 122 expect(script.tokenToLine(stack['frames'][0].location.tokenPos), equals(16)); |
| 123 }, | 123 }, |
| 124 | 124 |
| 125 // Remove breakpoint | 125 // Remove breakpoint |
| 126 (Isolate isolate) async { | 126 (Isolate isolate) async { |
| 127 // Set up a listener to wait for breakpoint events. | 127 // Set up a listener to wait for breakpoint events. |
| 128 Completer completer = new Completer(); | 128 Completer completer = new Completer(); |
| 129 var subscription; | 129 var subscription; |
| 130 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { | 130 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { |
| 131 if (event.kind == ServiceEvent.kBreakpointRemoved) { | 131 if (event.kind == ServiceEvent.kBreakpointRemoved) { |
| 132 print('Breakpoint removed'); | 132 print('Breakpoint removed'); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // Find a specific function. | 172 // Find a specific function. |
| 173 ServiceFunction function = isolate.rootLibrary.functions.firstWhere( | 173 ServiceFunction function = isolate.rootLibrary.functions.firstWhere( |
| 174 (f) => f.name == 'periodicTask'); | 174 (f) => f.name == 'periodicTask'); |
| 175 expect(function, isNotNull); | 175 expect(function, isNotNull); |
| 176 | 176 |
| 177 // Add the breakpoint at function entry | 177 // Add the breakpoint at function entry |
| 178 var result = await isolate.addBreakpointAtEntry(function); | 178 var result = await isolate.addBreakpointAtEntry(function); |
| 179 expect(result is Breakpoint, isTrue); | 179 expect(result is Breakpoint, isTrue); |
| 180 Breakpoint bpt = result; | 180 Breakpoint bpt = result; |
| 181 expect(bpt.type, equals('Breakpoint')); | 181 expect(bpt.type, equals('Breakpoint')); |
| 182 expect(bpt.script.name, equals('debugging_test.dart')); | 182 expect(bpt.location.script.name, equals('debugging_test.dart')); |
| 183 expect(bpt.script.tokenToLine(bpt.tokenPos), equals(14)); | 183 expect(bpt.location.script.tokenToLine(bpt.location.tokenPos), equals(14)); |
| 184 expect(isolate.breakpoints.length, equals(1)); | 184 expect(isolate.breakpoints.length, equals(1)); |
| 185 | 185 |
| 186 await completer.future; // Wait for breakpoint events. | 186 await completer.future; // Wait for breakpoint events. |
| 187 }, | 187 }, |
| 188 | 188 |
| 189 // We are now at line 14. | 189 // We are now at line 14. |
| 190 (Isolate isolate) async { | 190 (Isolate isolate) async { |
| 191 ServiceMap stack = await isolate.getStack(); | 191 ServiceMap stack = await isolate.getStack(); |
| 192 expect(stack.type, equals('Stack')); | 192 expect(stack.type, equals('Stack')); |
| 193 expect(stack['frames'].length, greaterThanOrEqualTo(1)); | 193 expect(stack['frames'].length, greaterThanOrEqualTo(1)); |
| 194 | 194 |
| 195 Script script = stack['frames'][0]['script']; | 195 Script script = stack['frames'][0].location.script; |
| 196 expect(script.name,endsWith('debugging_test.dart')); | 196 expect(script.name,endsWith('debugging_test.dart')); |
| 197 expect(script.tokenToLine(stack['frames'][0]['tokenPos']), equals(14)); | 197 expect(script.tokenToLine(stack['frames'][0].location.tokenPos), equals(14)); |
| 198 }, | 198 }, |
| 199 | 199 |
| 200 ]; | 200 ]; |
| 201 | 201 |
| 202 main(args) => runIsolateTests(args, tests, testeeBefore: startTimer); | 202 main(args) => runIsolateTests(args, tests, testeeBefore: startTimer); |
| OLD | NEW |