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

Side by Side Diff: runtime/observatory/tests/service/test_helper.dart

Issue 1312763010: Support column-based breakpoints in the VM and Observatory. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: hausner review Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « runtime/observatory/tests/service/get_version_rpc_test.dart ('k') | runtime/vm/debugger.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 4
5 library test_helper; 5 library test_helper;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'package:observatory/service_io.dart'; 10 import 'package:observatory/service_io.dart';
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 157 }
158 } 158 }
159 159
160 160
161 Future<Isolate> hasStoppedAtBreakpoint(Isolate isolate) { 161 Future<Isolate> hasStoppedAtBreakpoint(Isolate isolate) {
162 // Set up a listener to wait for breakpoint events. 162 // Set up a listener to wait for breakpoint events.
163 Completer completer = new Completer(); 163 Completer completer = new Completer();
164 isolate.vm.getEventStream(VM.kDebugStream).then((stream) { 164 isolate.vm.getEventStream(VM.kDebugStream).then((stream) {
165 var subscription; 165 var subscription;
166 subscription = stream.listen((ServiceEvent event) { 166 subscription = stream.listen((ServiceEvent event) {
167 print("Event: $event");
168 if (event.kind == ServiceEvent.kPauseBreakpoint) { 167 if (event.kind == ServiceEvent.kPauseBreakpoint) {
169 print('Breakpoint reached'); 168 print('Breakpoint reached');
170 subscription.cancel(); 169 subscription.cancel();
171 if (completer != null) { 170 if (completer != null) {
172 // Reload to update isolate.pauseEvent. 171 // Reload to update isolate.pauseEvent.
173 completer.complete(isolate.reload()); 172 completer.complete(isolate.reload());
174 completer = null; 173 completer = null;
175 } 174 }
176 } 175 }
177 }); 176 });
(...skipping 10 matching lines...) Expand all
188 completer = null; 187 completer = null;
189 } 188 }
190 } 189 }
191 }); 190 });
192 }); 191 });
193 192
194 return completer.future; // Will complete when breakpoint hit. 193 return completer.future; // Will complete when breakpoint hit.
195 } 194 }
196 195
197 196
197 Future<Isolate> hasPausedAtStart(Isolate isolate) {
198 // Set up a listener to wait for breakpoint events.
199 Completer completer = new Completer();
200 isolate.vm.getEventStream(VM.kDebugStream).then((stream) {
201 var subscription;
202 subscription = stream.listen((ServiceEvent event) {
203 if (event.kind == ServiceEvent.kPauseStart) {
204 print('Paused at isolate start');
205 subscription.cancel();
206 if (completer != null) {
207 // Reload to update isolate.pauseEvent.
208 completer.complete(isolate.reload());
209 completer = null;
210 }
211 }
212 });
213
214 // Pause may have happened before we subscribed.
215 isolate.reload().then((_) {
216 if ((isolate.pauseEvent != null) &&
217 (isolate.pauseEvent.kind == ServiceEvent.kPauseStart)) {
218 print('Paused at isolate start');
219 subscription.cancel();
220 if (completer != null) {
221 completer.complete(isolate);
222 completer = null;
223 }
224 }
225 });
226 });
227
228 return completer.future;
229 }
230
231
198 // Currying is your friend. 232 // Currying is your friend.
199 IsolateTest setBreakpointAtLine(int line) { 233 IsolateTest setBreakpointAtLine(int line) {
200 return (Isolate isolate) async { 234 return (Isolate isolate) async {
201 print("Setting breakpoint for line $line"); 235 print("Setting breakpoint for line $line");
202 Library lib = await isolate.rootLibrary.load(); 236 Library lib = await isolate.rootLibrary.load();
203 Script script = lib.scripts.single; 237 Script script = lib.scripts.single;
204 238
205 Breakpoint bpt = await isolate.addBreakpoint(script, line); 239 Breakpoint bpt = await isolate.addBreakpoint(script, line);
206 print("Breakpoint is $bpt"); 240 print("Breakpoint is $bpt");
207 expect(bpt, isNotNull); 241 expect(bpt, isNotNull);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 }, onError: (e, st) { 361 }, onError: (e, st) {
328 process.requestExit(); 362 process.requestExit();
329 if (!_isWebSocketDisconnect(e)) { 363 if (!_isWebSocketDisconnect(e)) {
330 print('Unexpected exception in service tests: $e $st'); 364 print('Unexpected exception in service tests: $e $st');
331 throw e; 365 throw e;
332 } 366 }
333 }); 367 });
334 }); 368 });
335 } 369 }
336 } 370 }
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/get_version_rpc_test.dart ('k') | runtime/vm/debugger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698