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

Side by Side Diff: runtime/observatory/lib/src/elements/debugger.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 unified diff | Download patch | Annotate | Revision Log
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 library debugger_page_element; 5 library debugger_page_element;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'observatory_element.dart'; 9 import 'observatory_element.dart';
10 import 'package:observatory/cli.dart'; 10 import 'package:observatory/cli.dart';
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 Future run(List<String> args) { 226 Future run(List<String> args) {
227 if (args.length > 1) { 227 if (args.length > 1) {
228 debugger.console.print('not implemented'); 228 debugger.console.print('not implemented');
229 return new Future.value(null); 229 return new Future.value(null);
230 } 230 }
231 var arg = (args.length == 0 ? '' : args[0]); 231 var arg = (args.length == 0 ? '' : args[0]);
232 return SourceLocation.parse(debugger, arg).then((loc) { 232 return SourceLocation.parse(debugger, arg).then((loc) {
233 if (loc.valid) { 233 if (loc.valid) {
234 if (loc.function != null) { 234 if (loc.function != null) {
235 debugger.console.print( 235 return debugger.isolate.addBreakpointAtEntry(loc.function)
236 'Ignoring breakpoint at $loc: ' 236 .then((result) => _handleBreakpointResult(loc, result));
237 'Function entry breakpoints not yet implemented'); 237 } else {
238 return null; 238 assert(loc.script != null);
239 if (loc.col != null) {
240 // TODO(turnidge): Add tokenPos breakpoint support.
241 debugger.console.print(
242 'Ignoring column: '
243 'adding breakpoint at a specific column not yet implemented');
244 }
245 return debugger.isolate.addBreakpoint(loc.script, loc.line)
246 .then((result) => _handleBreakpointResult(loc, result));
239 } 247 }
240 if (loc.col != null) {
241 // TODO(turnidge): Add tokenPos breakpoint support.
242 debugger.console.print(
243 'Ignoring column: '
244 'adding breakpoint at a specific column not yet implemented');
245 }
246 return debugger.isolate.addBreakpoint(loc.script, loc.line).then((result ) {
247 if (result is DartError) {
248 debugger.console.print('Unable to set breakpoint at ${loc}');
249 } else {
250 // TODO(turnidge): Adding a duplicate breakpoint is
251 // currently ignored. May want to change the protocol to
252 // inform us when this happens.
253
254 // The BreakpointResolved event prints resolved
255 // breakpoints already. Just print the unresolved ones here.
256 ServiceMap bpt = result;
257 if (!bpt['resolved']) {
258 var script = bpt['location']['script'];
259 var bpId = bpt['breakpointNumber'];
260 var tokenPos = bpt['location']['tokenPos'];
261 return script.load().then((_) {
262 var line = script.tokenToLine(tokenPos);
263 var col = script.tokenToCol(tokenPos);
264 debugger.console.print(
265 'Future breakpoint ${bpId} added at '
266 '${script.name}:${line}:${col}');
267 });
268 }
269 }
270 });
271 } else { 248 } else {
272 debugger.console.print(loc.errorMessage); 249 debugger.console.print(loc.errorMessage);
273 } 250 }
274 }); 251 });
275 } 252 }
276 253
254 Future _handleBreakpointResult(loc, result) {
255 if (result is DartError) {
256 debugger.console.print('Unable to set breakpoint at ${loc}');
257 } else {
258 // TODO(turnidge): Adding a duplicate breakpoint is
259 // currently ignored. May want to change the protocol to
260 // inform us when this happens.
261
262 // The BreakpointResolved event prints resolved
263 // breakpoints already. Just print the unresolved ones here.
264 ServiceMap bpt = result;
265 if (!bpt['resolved']) {
266 return debugger._reportBreakpointAdded(bpt);
267 }
268 }
269 return new Future.value(null);
270 }
271
277 Future<List<String>> complete(List<String> args) { 272 Future<List<String>> complete(List<String> args) {
278 if (args.length != 1) { 273 if (args.length != 1) {
279 return new Future.value([]); 274 return new Future.value([]);
280 } 275 }
281 // TODO - fix SourceLocation complete 276 // TODO - fix SourceLocation complete
282 return new Future.value(SourceLocation.complete(debugger, args[0])); 277 return new Future.value(SourceLocation.complete(debugger, args[0]));
283 } 278 }
284 279
285 String helpShort = 'Add a breakpoint by source location or function name'; 280 String helpShort = 'Add a breakpoint by source location or function name';
286 281
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 // TODO(turnidge): Test this. 690 // TODO(turnidge): Test this.
696 console.print( 691 console.print(
697 'Exception ${event.exception} at ${script.name}:${line}:${col}'); 692 'Exception ${event.exception} at ${script.name}:${line}:${col}');
698 } else { 693 } else {
699 console.print('Paused at ${script.name}:${line}:${col}'); 694 console.print('Paused at ${script.name}:${line}:${col}');
700 } 695 }
701 }); 696 });
702 } 697 }
703 } 698 }
704 699
700 Future _reportBreakpointAdded(ServiceMap bpt) {
701 var script = bpt['location']['script'];
702 return script.load().then((_) {
703 var bpId = bpt['breakpointNumber'];
704 var tokenPos = bpt['location']['tokenPos'];
705 var line = script.tokenToLine(tokenPos);
706 var col = script.tokenToCol(tokenPos);
707 if (bpt['resolved']) {
708 // TODO(turnidge): If this was a future breakpoint before, we
709 // should change the message to say that the breakpoint was 'resolved',
710 // rather than 'added'.
711 console.print(
712 'Breakpoint ${bpId} added at ${script.name}:${line}:${col}');
713 } else {
714 console.print(
715 'Future breakpoint ${bpId} added at ${script.name}:${line}:${col}');
716 }
717 });
718 }
719
705 void _onEvent(ServiceEvent event) { 720 void _onEvent(ServiceEvent event) {
706 if (event.owner != isolate) { 721 if (event.owner != isolate) {
707 return; 722 return;
708 } 723 }
709 switch(event.eventType) { 724 switch(event.eventType) {
710 case 'IsolateShutdown': 725 case 'IsolateShutdown':
711 console.print('Isolate shutdown'); 726 console.print('Isolate shutdown');
712 isolate = null; 727 isolate = null;
713 break; 728 break;
714 729
715 case 'BreakpointReached': 730 case 'BreakpointReached':
716 case 'IsolateInterrupted': 731 case 'IsolateInterrupted':
717 case 'ExceptionThrown': 732 case 'ExceptionThrown':
718 _refreshStack(event).then((_) { 733 _refreshStack(event).then((_) {
719 _reportPause(event); 734 _reportPause(event);
720 }); 735 });
721 break; 736 break;
722 737
723 case 'IsolateResumed': 738 case 'IsolateResumed':
724 console.print('Continuing...'); 739 console.print('Continuing...');
725 break; 740 break;
726 741
727 case 'BreakpointResolved': 742 case 'BreakpointResolved':
728 var bpId = event.breakpoint['breakpointNumber']; 743 _reportBreakpointAdded(event.breakpoint);
729 var script = event.breakpoint['location']['script'];
730 var tokenPos = event.breakpoint['location']['tokenPos'];
731 var line = script.tokenToLine(tokenPos);
732 var col = script.tokenToCol(tokenPos);
733 console.print(
734 'Breakpoint ${bpId} added at ${script.name}:${line}:${col}');
735 break; 744 break;
736 745
737 case '_Graph': 746 case '_Graph':
738 case 'IsolateCreated': 747 case 'IsolateCreated':
739 case 'GC': 748 case 'GC':
740 // Ignore these events for now. 749 // Ignore these events for now.
741 break; 750 break;
742 751
743 default: 752 default:
744 console.print('Unrecognized event: $event'); 753 console.print('Unrecognized event: $event');
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 debugger.run(command).whenComplete(_notBusy); 1082 debugger.run(command).whenComplete(_notBusy);
1074 } 1083 }
1075 break; 1084 break;
1076 } 1085 }
1077 }); 1086 });
1078 } 1087 }
1079 1088
1080 DebuggerInputElement.created() : super.created(); 1089 DebuggerInputElement.created() : super.created();
1081 } 1090 }
1082 1091
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698