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

Side by Side Diff: runtime/observatory/lib/src/elements/debugger.dart

Issue 1153193006: Standardize on using "kind" to distinguish sub-varieties of a type. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: doc changes Created 5 years, 6 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 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/app.dart'; 10 import 'package:observatory/app.dart';
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 'Syntax: continue\n' 281 'Syntax: continue\n'
282 ' c\n'; 282 ' c\n';
283 } 283 }
284 284
285 class NextCommand extends DebuggerCommand { 285 class NextCommand extends DebuggerCommand {
286 NextCommand(Debugger debugger) : super(debugger, 'next', []); 286 NextCommand(Debugger debugger) : super(debugger, 'next', []);
287 287
288 Future run(List<String> args) { 288 Future run(List<String> args) {
289 if (debugger.isolatePaused()) { 289 if (debugger.isolatePaused()) {
290 var event = debugger.isolate.pauseEvent; 290 var event = debugger.isolate.pauseEvent;
291 if (event.eventType == ServiceEvent.kPauseStart) { 291 if (event.kind == ServiceEvent.kPauseStart) {
292 debugger.console.print("Type 'continue' to start the isolate"); 292 debugger.console.print("Type 'continue' to start the isolate");
293 return new Future.value(null); 293 return new Future.value(null);
294 } 294 }
295 if (event.eventType == ServiceEvent.kPauseExit) { 295 if (event.kind == ServiceEvent.kPauseExit) {
296 debugger.console.print("Type 'continue' to exit the isolate"); 296 debugger.console.print("Type 'continue' to exit the isolate");
297 return new Future.value(null); 297 return new Future.value(null);
298 } 298 }
299 return debugger.isolate.stepOver(); 299 return debugger.isolate.stepOver();
300 } else { 300 } else {
301 debugger.console.print('The program is already running'); 301 debugger.console.print('The program is already running');
302 return new Future.value(null); 302 return new Future.value(null);
303 } 303 }
304 } 304 }
305 305
306 String helpShort = 306 String helpShort =
307 'Continue running the isolate until it reaches the next source location ' 307 'Continue running the isolate until it reaches the next source location '
308 'in the current function'; 308 'in the current function';
309 309
310 String helpLong = 310 String helpLong =
311 'Continue running the isolate until it reaches the next source location ' 311 'Continue running the isolate until it reaches the next source location '
312 'in the current function.\n' 312 'in the current function.\n'
313 '\n' 313 '\n'
314 'Syntax: next\n'; 314 'Syntax: next\n';
315 } 315 }
316 316
317 class StepCommand extends DebuggerCommand { 317 class StepCommand extends DebuggerCommand {
318 StepCommand(Debugger debugger) : super(debugger, 'step', []); 318 StepCommand(Debugger debugger) : super(debugger, 'step', []);
319 319
320 Future run(List<String> args) { 320 Future run(List<String> args) {
321 if (debugger.isolatePaused()) { 321 if (debugger.isolatePaused()) {
322 var event = debugger.isolate.pauseEvent; 322 var event = debugger.isolate.pauseEvent;
323 if (event.eventType == ServiceEvent.kPauseStart) { 323 if (event.kind == ServiceEvent.kPauseStart) {
324 debugger.console.print("Type 'continue' to start the isolate"); 324 debugger.console.print("Type 'continue' to start the isolate");
325 return new Future.value(null); 325 return new Future.value(null);
326 } 326 }
327 if (event.eventType == ServiceEvent.kPauseExit) { 327 if (event.kind == ServiceEvent.kPauseExit) {
328 debugger.console.print("Type 'continue' to exit the isolate"); 328 debugger.console.print("Type 'continue' to exit the isolate");
329 return new Future.value(null); 329 return new Future.value(null);
330 } 330 }
331 return debugger.isolate.stepInto(); 331 return debugger.isolate.stepInto();
332 } else { 332 } else {
333 debugger.console.print('The program is already running'); 333 debugger.console.print('The program is already running');
334 return new Future.value(null); 334 return new Future.value(null);
335 } 335 }
336 } 336 }
337 337
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 reportStatus(); 925 reportStatus();
926 }); 926 });
927 } 927 }
928 928
929 bool isolatePaused() { 929 bool isolatePaused() {
930 // TODO(turnidge): Stop relying on the isolate to track the last 930 // TODO(turnidge): Stop relying on the isolate to track the last
931 // pause event. Since we listen to events directly in the 931 // pause event. Since we listen to events directly in the
932 // debugger, this could introduce a race. 932 // debugger, this could introduce a race.
933 return (isolate != null && 933 return (isolate != null &&
934 isolate.pauseEvent != null && 934 isolate.pauseEvent != null &&
935 isolate.pauseEvent.eventType != ServiceEvent.kResume); 935 isolate.pauseEvent.kind != ServiceEvent.kResume);
936 } 936 }
937 937
938 void warnOutOfDate() { 938 void warnOutOfDate() {
939 // Wait a bit, then tell the user that the stack may be out of date. 939 // Wait a bit, then tell the user that the stack may be out of date.
940 new Timer(const Duration(seconds:2), () { 940 new Timer(const Duration(seconds:2), () {
941 if (!isolatePaused()) { 941 if (!isolatePaused()) {
942 stackElement.isSampled = true; 942 stackElement.isSampled = true;
943 } 943 }
944 }); 944 });
945 } 945 }
(...skipping 21 matching lines...) Expand all
967 console.print("Isolate is running (type 'pause' to interrupt)"); 967 console.print("Isolate is running (type 'pause' to interrupt)");
968 } else if (_isolate.pauseEvent != null) { 968 } else if (_isolate.pauseEvent != null) {
969 _reportPause(_isolate.pauseEvent); 969 _reportPause(_isolate.pauseEvent);
970 } else { 970 } else {
971 console.print('Isolate is in unknown state'); 971 console.print('Isolate is in unknown state');
972 } 972 }
973 warnOutOfDate(); 973 warnOutOfDate();
974 } 974 }
975 975
976 void _reportPause(ServiceEvent event) { 976 void _reportPause(ServiceEvent event) {
977 if (event.eventType == ServiceEvent.kPauseStart) { 977 if (event.kind == ServiceEvent.kPauseStart) {
978 console.print( 978 console.print(
979 "Paused at isolate start (type 'continue' to start the isolate')"); 979 "Paused at isolate start (type 'continue' to start the isolate')");
980 } else if (event.eventType == ServiceEvent.kPauseExit) { 980 } else if (event.kind == ServiceEvent.kPauseExit) {
981 console.print( 981 console.print(
982 "Paused at isolate exit (type 'continue' to exit the isolate')"); 982 "Paused at isolate exit (type 'continue' to exit the isolate')");
983 } 983 }
984 if (stack['frames'].length > 0) { 984 if (stack['frames'].length > 0) {
985 var frame = stack['frames'][0]; 985 var frame = stack['frames'][0];
986 var script = frame['script']; 986 var script = frame['script'];
987 script.load().then((_) { 987 script.load().then((_) {
988 var line = script.tokenToLine(frame['tokenPos']); 988 var line = script.tokenToLine(frame['tokenPos']);
989 var col = script.tokenToCol(frame['tokenPos']); 989 var col = script.tokenToCol(frame['tokenPos']);
990 if (event.breakpoint != null) { 990 if (event.breakpoint != null) {
991 var bpId = event.breakpoint.number; 991 var bpId = event.breakpoint.number;
992 console.print('Paused at breakpoint ${bpId} at ' 992 console.print('Paused at breakpoint ${bpId} at '
993 '${script.name}:${line}:${col}'); 993 '${script.name}:${line}:${col}');
994 } else if (event.exception != null) { 994 } else if (event.exception != null) {
995 // TODO(turnidge): Test this. 995 // TODO(turnidge): Test this.
996 console.print('Paused due to exception ${event.exception} at ' 996 console.print('Paused due to exception ${event.exception} at '
997 '${script.name}:${line}:${col}'); 997 '${script.name}:${line}:${col}');
998 } else { 998 } else {
999 console.print('Paused at ${script.name}:${line}:${col}'); 999 console.print('Paused at ${script.name}:${line}:${col}');
1000 } 1000 }
1001 }); 1001 });
1002 } 1002 }
1003 } 1003 }
1004 1004
1005 Future _reportBreakpointEvent(ServiceEvent event) { 1005 Future _reportBreakpointEvent(ServiceEvent event) {
1006 var bpt = event.breakpoint; 1006 var bpt = event.breakpoint;
1007 var verb = null; 1007 var verb = null;
1008 switch (event.eventType) { 1008 switch (event.kind) {
1009 case ServiceEvent.kBreakpointAdded: 1009 case ServiceEvent.kBreakpointAdded:
1010 verb = 'added'; 1010 verb = 'added';
1011 break; 1011 break;
1012 case ServiceEvent.kBreakpointResolved: 1012 case ServiceEvent.kBreakpointResolved:
1013 verb = 'resolved'; 1013 verb = 'resolved';
1014 break; 1014 break;
1015 case ServiceEvent.kBreakpointRemoved: 1015 case ServiceEvent.kBreakpointRemoved:
1016 verb = 'removed'; 1016 verb = 'removed';
1017 break; 1017 break;
1018 default: 1018 default:
1019 break; 1019 break;
1020 } 1020 }
1021 var script = bpt.script; 1021 var script = bpt.script;
1022 return script.load().then((_) { 1022 return script.load().then((_) {
1023 var bpId = bpt.number; 1023 var bpId = bpt.number;
1024 var tokenPos = bpt.tokenPos; 1024 var tokenPos = bpt.tokenPos;
1025 var line = script.tokenToLine(tokenPos); 1025 var line = script.tokenToLine(tokenPos);
1026 var col = script.tokenToCol(tokenPos); 1026 var col = script.tokenToCol(tokenPos);
1027 if (bpt.resolved) { 1027 if (bpt.resolved) {
1028 console.print( 1028 console.print(
1029 'Breakpoint ${bpId} ${verb} at ${script.name}:${line}:${col}'); 1029 'Breakpoint ${bpId} ${verb} at ${script.name}:${line}:${col}');
1030 } else { 1030 } else {
1031 console.print( 1031 console.print(
1032 'Future breakpoint ${bpId} ${verb} at ${script.name}:${line}:${col}' ); 1032 'Future breakpoint ${bpId} ${verb} at ${script.name}:${line}:${col}' );
1033 } 1033 }
1034 }); 1034 });
1035 } 1035 }
1036 1036
1037 void _onEvent(ServiceEvent event) { 1037 void _onEvent(ServiceEvent event) {
1038 switch(event.eventType) { 1038 switch(event.kind) {
1039 case ServiceEvent.kIsolateStart: 1039 case ServiceEvent.kIsolateStart:
1040 { 1040 {
1041 var iso = event.owner; 1041 var iso = event.owner;
1042 console.print( 1042 console.print(
1043 "Isolate ${iso.number} '${iso.name}' has been created"); 1043 "Isolate ${iso.number} '${iso.name}' has been created");
1044 } 1044 }
1045 break; 1045 break;
1046 1046
1047 case ServiceEvent.kIsolateExit: 1047 case ServiceEvent.kIsolateExit:
1048 { 1048 {
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 default: 1667 default:
1668 busy = false; 1668 busy = false;
1669 break; 1669 break;
1670 } 1670 }
1671 }); 1671 });
1672 } 1672 }
1673 1673
1674 DebuggerInputElement.created() : super.created(); 1674 DebuggerInputElement.created() : super.created();
1675 } 1675 }
1676 1676
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/app/application.dart ('k') | runtime/observatory/lib/src/elements/heap_profile.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698