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

Side by Side Diff: runtime/observatory/lib/src/service/object.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: 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 part of service; 5 part of service;
6 6
7 /// Helper function for canceling a Future<StreamSubscription>. 7 /// Helper function for canceling a Future<StreamSubscription>.
8 Future cancelFutureSubscription( 8 Future cancelFutureSubscription(
9 Future<StreamSubscription> subscriptionFuture) async { 9 Future<StreamSubscription> subscriptionFuture) async {
10 if (subscriptionFuture != null) { 10 if (subscriptionFuture != null) {
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 /// be [loaded]. 425 /// be [loaded].
426 ServiceObject getFromMap(ObservableMap map); 426 ServiceObject getFromMap(ObservableMap map);
427 } 427 }
428 428
429 /// A [SourceLocation] represents a location or range in the source code. 429 /// A [SourceLocation] represents a location or range in the source code.
430 class SourceLocation extends ServiceObject { 430 class SourceLocation extends ServiceObject {
431 Script script; 431 Script script;
432 int tokenPos; 432 int tokenPos;
433 int endTokenPos; 433 int endTokenPos;
434 434
435 Future<int> line() async {
436 await script.load();
437 return script.tokenToLine(tokenPos);
438 }
439
440 Future<int> column() async {
441 await script.load();
442 return script.tokenToCol(tokenPos);
443 }
444
435 SourceLocation._empty(ServiceObject owner) : super._empty(owner); 445 SourceLocation._empty(ServiceObject owner) : super._empty(owner);
436 446
437 void _update(ObservableMap map, bool mapIsRef) { 447 void _update(ObservableMap map, bool mapIsRef) {
438 assert(!mapIsRef); 448 assert(!mapIsRef);
439 _upgradeCollection(map, owner); 449 _upgradeCollection(map, owner);
440 script = map['script']; 450 script = map['script'];
441 tokenPos = map['tokenPos']; 451 tokenPos = map['tokenPos'];
442 assert(script != null && tokenPos != null); 452 assert(script != null && tokenPos != null);
443 endTokenPos = map['endTokenPos']; 453 endTokenPos = map['endTokenPos'];
444 } 454 }
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 // Ignore GC events for now. 1393 // Ignore GC events for now.
1384 break; 1394 break;
1385 1395
1386 default: 1396 default:
1387 // Log unrecognized events. 1397 // Log unrecognized events.
1388 Logger.root.severe('Unrecognized event: $event'); 1398 Logger.root.severe('Unrecognized event: $event');
1389 break; 1399 break;
1390 } 1400 }
1391 } 1401 }
1392 1402
1393 Future<ServiceObject> addBreakpoint(Script script, int line) async { 1403 Future<ServiceObject> addBreakpoint(Script script, int line, [int col]) async {
1394 // TODO(turnidge): Pass line as an int instead of a string. 1404 // TODO(turnidge): Pass line as an int instead of a string.
1395 try { 1405 try {
1396 Map params = { 1406 Map params = {
1397 'scriptId': script.id, 1407 'scriptId': script.id,
1398 'line': '$line', 1408 'line': line.toString(),
1399 }; 1409 };
1410 if (col != null) {
1411 params['column'] = col.toString();
1412 }
1400 Breakpoint bpt = await invokeRpc('addBreakpoint', params); 1413 Breakpoint bpt = await invokeRpc('addBreakpoint', params);
1401 if (bpt.resolved && 1414 if (bpt.resolved &&
1402 script.loaded && 1415 script.loaded &&
1403 script.tokenToLine(bpt.location.tokenPos) != line) { 1416 script.tokenToLine(bpt.location.tokenPos) != line) {
1404 // TODO(turnidge): Can this still happen? 1417 // TODO(turnidge): Can this still happen?
1405 script.getLine(line).possibleBpt = false; 1418 script.getLine(line).possibleBpt = false;
1406 } 1419 }
1407 return bpt; 1420 return bpt;
1408 } on ServerRpcException catch(e) { 1421 } on ServerRpcException catch(e) {
1409 if (e.code == ServerRpcException.kCannotAddBreakpoint) { 1422 if (e.code == ServerRpcException.kCannotAddBreakpoint) {
(...skipping 2410 matching lines...) Expand 10 before | Expand all | Expand 10 after
3820 var v = list[i]; 3833 var v = list[i];
3821 if ((v is ObservableMap) && _isServiceMap(v)) { 3834 if ((v is ObservableMap) && _isServiceMap(v)) {
3822 list[i] = owner.getFromMap(v); 3835 list[i] = owner.getFromMap(v);
3823 } else if (v is ObservableList) { 3836 } else if (v is ObservableList) {
3824 _upgradeObservableList(v, owner); 3837 _upgradeObservableList(v, owner);
3825 } else if (v is ObservableMap) { 3838 } else if (v is ObservableMap) {
3826 _upgradeObservableMap(v, owner); 3839 _upgradeObservableMap(v, owner);
3827 } 3840 }
3828 } 3841 }
3829 } 3842 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698