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

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 Breakpoint bpt = result;
257 if (!bpt.resolved) {
258 var script = bpt.script;
259 var bpId = bpt.number;
260 var tokenPos = bpt.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 Breakpoint 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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 // TODO(turnidge): Test this. 689 // TODO(turnidge): Test this.
695 console.print( 690 console.print(
696 'Exception ${event.exception} at ${script.name}:${line}:${col}'); 691 'Exception ${event.exception} at ${script.name}:${line}:${col}');
697 } else { 692 } else {
698 console.print('Paused at ${script.name}:${line}:${col}'); 693 console.print('Paused at ${script.name}:${line}:${col}');
699 } 694 }
700 }); 695 });
701 } 696 }
702 } 697 }
703 698
699 Future _reportBreakpointAdded(Breakpoint bpt) {
700 var script = bpt.script;
701 return script.load().then((_) {
702 var bpId = bpt.number;
703 var tokenPos = bpt.tokenPos;
704 var line = script.tokenToLine(tokenPos);
705 var col = script.tokenToCol(tokenPos);
706 if (bpt.resolved) {
707 // TODO(turnidge): If this was a future breakpoint before, we
708 // should change the message to say that the breakpoint was 'resolved',
709 // rather than 'added'.
710 console.print(
711 'Breakpoint ${bpId} added at ${script.name}:${line}:${col}');
712 } else {
713 console.print(
714 'Future breakpoint ${bpId} added at ${script.name}:${line}:${col}');
715 }
716 });
717 }
718
704 void _onEvent(ServiceEvent event) { 719 void _onEvent(ServiceEvent event) {
705 if (event.owner != isolate) { 720 if (event.owner != isolate) {
706 return; 721 return;
707 } 722 }
708 switch(event.eventType) { 723 switch(event.eventType) {
709 case 'IsolateShutdown': 724 case 'IsolateShutdown':
710 console.print('Isolate shutdown'); 725 console.print('Isolate shutdown');
711 isolate = null; 726 isolate = null;
712 break; 727 break;
713 728
714 case 'BreakpointReached': 729 case 'BreakpointReached':
715 case 'IsolateInterrupted': 730 case 'IsolateInterrupted':
716 case 'ExceptionThrown': 731 case 'ExceptionThrown':
717 _refreshStack(event).then((_) { 732 _refreshStack(event).then((_) {
718 _reportPause(event); 733 _reportPause(event);
719 }); 734 });
720 break; 735 break;
721 736
722 case 'IsolateResumed': 737 case 'IsolateResumed':
723 console.print('Continuing...'); 738 console.print('Continuing...');
724 break; 739 break;
725 740
726 case 'BreakpointResolved': 741 case 'BreakpointResolved':
727 var bpId = event.breakpoint.number; 742 _reportBreakpointAdded(event.breakpoint);
728 var script = event.breakpoint.script;
729 var tokenPos = event.breakpoint.tokenPos;
730 var line = script.tokenToLine(tokenPos);
731 var col = script.tokenToCol(tokenPos);
732 console.print(
733 'Breakpoint ${bpId} added at ${script.name}:${line}:${col}');
734 break; 743 break;
735 744
736 case '_Graph': 745 case '_Graph':
737 case 'IsolateCreated': 746 case 'IsolateCreated':
738 case 'GC': 747 case 'GC':
739 // Ignore these events for now. 748 // Ignore these events for now.
740 break; 749 break;
741 750
742 default: 751 default:
743 console.print('Unrecognized event: $event'); 752 console.print('Unrecognized event: $event');
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 debugger.run(command).whenComplete(_notBusy); 1081 debugger.run(command).whenComplete(_notBusy);
1073 } 1082 }
1074 break; 1083 break;
1075 } 1084 }
1076 }); 1085 });
1077 } 1086 }
1078 1087
1079 DebuggerInputElement.created() : super.created(); 1088 DebuggerInputElement.created() : super.created();
1080 } 1089 }
1081 1090
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/cli/command.dart ('k') | runtime/observatory/lib/src/service/object.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698