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 --checked | 4 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override --checked |
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } | 66 } |
67 }); | 67 }); |
68 | 68 |
69 // Add the breakpoint. | 69 // Add the breakpoint. |
70 var script = isolate.rootLib.scripts[0]; | 70 var script = isolate.rootLib.scripts[0]; |
71 return isolate.addBreakpoint(script, 18).then((result) { | 71 return isolate.addBreakpoint(script, 18).then((result) { |
72 expect(result is Breakpoint, isTrue); | 72 expect(result is Breakpoint, isTrue); |
73 Breakpoint bpt = result; | 73 Breakpoint bpt = result; |
74 expect(bpt.type, equals('Breakpoint')); | 74 expect(bpt.type, equals('Breakpoint')); |
75 expect(bpt.script.id, equals(script.id)); | 75 expect(bpt.script.id, equals(script.id)); |
76 expect(bpt.tokenPos, equals(66)); | 76 expect(bpt.tokenPos, equals(58)); |
77 expect(isolate.breakpoints.length, equals(1)); | 77 expect(isolate.breakpoints.length, equals(1)); |
78 return completer.future; // Wait for breakpoint events. | 78 return completer.future; // Wait for breakpoint events. |
79 }); | 79 }); |
80 }); | 80 }); |
81 }, | 81 }, |
82 | 82 |
83 // Get the stack trace | 83 // Get the stack trace |
84 (Isolate isolate) { | 84 (Isolate isolate) { |
85 return isolate.getStack().then((ServiceMap stack) { | 85 return isolate.getStack().then((ServiceMap stack) { |
86 expect(stack.type, equals('Stack')); | 86 expect(stack.type, equals('Stack')); |
87 expect(stack['frames'].length, greaterThanOrEqualTo(1)); | 87 expect(stack['frames'].length, greaterThanOrEqualTo(1)); |
88 expect(stack['frames'][0]['function'].name, equals('testFunction')); | 88 expect(stack['frames'][0]['function'].name, equals('testFunction')); |
| 89 expect(stack['frames'][0]['tokenPos'], equals(58)); |
89 }); | 90 }); |
90 }, | 91 }, |
91 | 92 |
92 // Stepping | 93 // Stepping |
93 (Isolate isolate) { | 94 (Isolate isolate) { |
94 // Set up a listener to wait for breakpoint events. | 95 // Set up a listener to wait for breakpoint events. |
95 Completer completer = new Completer(); | 96 Completer completer = new Completer(); |
96 List events = []; | 97 List events = []; |
97 var subscription; | 98 var subscription; |
98 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { | 99 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { |
99 if (event.eventType == ServiceEvent.kPauseBreakpoint) { | 100 if (event.eventType == ServiceEvent.kPauseBreakpoint) { |
100 print('Breakpoint reached'); | 101 print('Breakpoint reached'); |
101 subscription.cancel(); | 102 subscription.cancel(); |
102 completer.complete(); | 103 completer.complete(); |
103 } | 104 } |
104 }); | 105 }); |
105 | 106 |
106 return isolate.stepInto().then((isolate) { | 107 return isolate.stepInto().then((isolate) { |
107 return completer.future; // Wait for breakpoint events. | 108 return completer.future; // Wait for breakpoint events. |
108 }); | 109 }); |
109 }, | 110 }, |
110 | 111 |
111 // Get the stack trace again. We are in 'helper'. | 112 // Get the stack trace again. Our position has updated. |
112 (Isolate isolate) { | 113 (Isolate isolate) { |
113 return isolate.getStack().then((ServiceMap stack) { | 114 return isolate.getStack().then((ServiceMap stack) { |
114 expect(stack.type, equals('Stack')); | 115 expect(stack.type, equals('Stack')); |
115 expect(stack['frames'].length, greaterThanOrEqualTo(2)); | 116 expect(stack['frames'].length, greaterThanOrEqualTo(2)); |
116 expect(stack['frames'][0]['function'].name, equals('helper')); | 117 expect(stack['frames'][0]['function'].name, equals('testFunction')); |
| 118 expect(stack['frames'][0]['tokenPos'], equals(60)); |
117 }); | 119 }); |
118 }, | 120 }, |
119 | 121 |
120 // Remove breakpoint | 122 // Remove breakpoint |
121 (Isolate isolate) { | 123 (Isolate isolate) { |
122 // Set up a listener to wait for breakpoint events. | 124 // Set up a listener to wait for breakpoint events. |
123 Completer completer = new Completer(); | 125 Completer completer = new Completer(); |
124 List events = []; | 126 List events = []; |
125 var subscription; | 127 var subscription; |
126 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { | 128 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 ServiceFunction function = isolate.rootLib.functions.firstWhere( | 173 ServiceFunction function = isolate.rootLib.functions.firstWhere( |
172 (f) => f.name == 'helper'); | 174 (f) => f.name == 'helper'); |
173 expect(function, isNotNull); | 175 expect(function, isNotNull); |
174 | 176 |
175 // Add the breakpoint at function entry | 177 // Add the breakpoint at function entry |
176 return isolate.addBreakpointAtEntry(function).then((result) { | 178 return isolate.addBreakpointAtEntry(function).then((result) { |
177 expect(result is Breakpoint, isTrue); | 179 expect(result is Breakpoint, isTrue); |
178 Breakpoint bpt = result; | 180 Breakpoint bpt = result; |
179 expect(bpt.type, equals('Breakpoint')); | 181 expect(bpt.type, equals('Breakpoint')); |
180 expect(bpt.script.name, equals('debugging_test.dart')); | 182 expect(bpt.script.name, equals('debugging_test.dart')); |
181 expect(bpt.tokenPos, equals(28)); | 183 expect(bpt.tokenPos, equals(29)); |
182 expect(isolate.breakpoints.length, equals(1)); | 184 expect(isolate.breakpoints.length, equals(1)); |
183 return completer.future; // Wait for breakpoint events. | 185 return completer.future; // Wait for breakpoint events. |
184 }); | 186 }); |
185 }, | 187 }, |
186 | 188 |
187 ]; | 189 ]; |
188 | 190 |
189 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); | 191 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); |
OLD | NEW |