| OLD | NEW |
| 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 | 359 |
| 360 String helpShort = | 360 String helpShort = |
| 361 'Continue running the isolate until the current function exits'; | 361 'Continue running the isolate until the current function exits'; |
| 362 | 362 |
| 363 String helpLong = | 363 String helpLong = |
| 364 'Continue running the isolate until the current function exits.\n' | 364 'Continue running the isolate until the current function exits.\n' |
| 365 '\n' | 365 '\n' |
| 366 'Syntax: finish\n'; | 366 'Syntax: finish\n'; |
| 367 } | 367 } |
| 368 | 368 |
| 369 class SetCommand extends DebuggerCommand { |
| 370 SetCommand(Debugger debugger) |
| 371 : super(debugger, 'set', []); |
| 372 |
| 373 Future run(List<String> args) async { |
| 374 if (args.length == 2) { |
| 375 var option = args[0].trim(); |
| 376 if (option == 'break-on-exceptions') { |
| 377 var result = await debugger.isolate.setExceptionPauseInfo(args[1]); |
| 378 if (result.isError) { |
| 379 debugger.console.print(result.toString()); |
| 380 } |
| 381 } else { |
| 382 debugger.console.print("unknown option '$option'"); |
| 383 } |
| 384 } else { |
| 385 debugger.console.print("set expects 2 arguments"); |
| 386 } |
| 387 } |
| 388 |
| 389 String helpShort = |
| 390 'Set a debugger option'; |
| 391 |
| 392 String helpLong = |
| 393 'Set a debugger option' |
| 394 '\n' |
| 395 'Syntax: set break-on-exceptions "all" | "none" | "unhandled"\n'; |
| 396 } |
| 397 |
| 369 class BreakCommand extends DebuggerCommand { | 398 class BreakCommand extends DebuggerCommand { |
| 370 BreakCommand(Debugger debugger) : super(debugger, 'break', []); | 399 BreakCommand(Debugger debugger) : super(debugger, 'break', []); |
| 371 | 400 |
| 372 Future run(List<String> args) async { | 401 Future run(List<String> args) async { |
| 373 if (args.length > 1) { | 402 if (args.length > 1) { |
| 374 debugger.console.print('not implemented'); | 403 debugger.console.print('not implemented'); |
| 375 return new Future.value(null); | 404 return new Future.value(null); |
| 376 } | 405 } |
| 377 var arg = (args.length == 0 ? '' : args[0]); | 406 var arg = (args.length == 0 ? '' : args[0]); |
| 378 var loc = await DebuggerLocation.parse(debugger, arg); | 407 var loc = await DebuggerLocation.parse(debugger, arg); |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 'Syntax: refresh <subcommand>\n'; | 850 'Syntax: refresh <subcommand>\n'; |
| 822 } | 851 } |
| 823 | 852 |
| 824 // Tracks the state for an isolate debugging session. | 853 // Tracks the state for an isolate debugging session. |
| 825 class ObservatoryDebugger extends Debugger { | 854 class ObservatoryDebugger extends Debugger { |
| 826 RootCommand cmd; | 855 RootCommand cmd; |
| 827 DebuggerPageElement page; | 856 DebuggerPageElement page; |
| 828 DebuggerConsoleElement console; | 857 DebuggerConsoleElement console; |
| 829 DebuggerStackElement stackElement; | 858 DebuggerStackElement stackElement; |
| 830 ServiceMap stack; | 859 ServiceMap stack; |
| 860 String exceptions = "none"; // Last known setting. |
| 831 | 861 |
| 832 int get currentFrame => _currentFrame; | 862 int get currentFrame => _currentFrame; |
| 833 void set currentFrame(int value) { | 863 void set currentFrame(int value) { |
| 834 if (value != null && (value < 0 || value >= stackDepth)) { | 864 if (value != null && (value < 0 || value >= stackDepth)) { |
| 835 throw new RangeError.range(value, 0, stackDepth); | 865 throw new RangeError.range(value, 0, stackDepth); |
| 836 } | 866 } |
| 837 _currentFrame = value; | 867 _currentFrame = value; |
| 838 if (stackElement != null) { | 868 if (stackElement != null) { |
| 839 stackElement.setCurrentFrame(value); | 869 stackElement.setCurrentFrame(value); |
| 840 } | 870 } |
| 841 } | 871 } |
| 842 int _currentFrame = null; | 872 int _currentFrame = null; |
| 843 | 873 |
| 844 int get stackDepth => stack['frames'].length; | 874 int get stackDepth => stack['frames'].length; |
| 845 | 875 |
| 846 ObservatoryDebugger() { | 876 ObservatoryDebugger() { |
| 847 cmd = new RootCommand([ | 877 cmd = new RootCommand([ |
| 848 new HelpCommand(this), | 878 new HelpCommand(this), |
| 849 new PrintCommand(this), | 879 new PrintCommand(this), |
| 850 new DownCommand(this), | 880 new DownCommand(this), |
| 851 new UpCommand(this), | 881 new UpCommand(this), |
| 852 new FrameCommand(this), | 882 new FrameCommand(this), |
| 853 new PauseCommand(this), | 883 new PauseCommand(this), |
| 854 new ContinueCommand(this), | 884 new ContinueCommand(this), |
| 855 new NextCommand(this), | 885 new NextCommand(this), |
| 856 new StepCommand(this), | 886 new StepCommand(this), |
| 857 new FinishCommand(this), | 887 new FinishCommand(this), |
| 858 new BreakCommand(this), | 888 new BreakCommand(this), |
| 889 new SetCommand(this), |
| 859 new ClearCommand(this), | 890 new ClearCommand(this), |
| 860 new DeleteCommand(this), | 891 new DeleteCommand(this), |
| 861 new InfoCommand(this), | 892 new InfoCommand(this), |
| 862 new IsolateCommand(this), | 893 new IsolateCommand(this), |
| 863 new RefreshCommand(this), | 894 new RefreshCommand(this), |
| 864 ]); | 895 ]); |
| 865 } | 896 } |
| 866 | 897 |
| 867 VM get vm => page.app.vm; | 898 VM get vm => page.app.vm; |
| 868 | 899 |
| 869 void updateIsolate(Isolate iso) { | 900 void updateIsolate(Isolate iso) { |
| 870 _isolate = iso; | 901 _isolate = iso; |
| 871 if (_isolate != null) { | 902 if (_isolate != null) { |
| 903 if (exceptions != iso.exceptionsPauseInfo) { |
| 904 exceptions = iso.exceptionsPauseInfo; |
| 905 console.print("Now pausing for $exceptions exceptions"); |
| 906 } |
| 907 |
| 872 _isolate.reload().then((response) { | 908 _isolate.reload().then((response) { |
| 873 // TODO(turnidge): Currently the debugger relies on all libs | 909 // TODO(turnidge): Currently the debugger relies on all libs |
| 874 // being loaded. Fix this. | 910 // being loaded. Fix this. |
| 875 var pending = []; | 911 var pending = []; |
| 876 for (var lib in _isolate.libraries) { | 912 for (var lib in _isolate.libraries) { |
| 877 if (!lib.loaded) { | 913 if (!lib.loaded) { |
| 878 pending.add(lib.load()); | 914 pending.add(lib.load()); |
| 879 } | 915 } |
| 880 } | 916 } |
| 881 Future.wait(pending).then((_) { | 917 Future.wait(pending).then((_) { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 Frame frame = stack['frames'][0]; | 1021 Frame frame = stack['frames'][0]; |
| 986 var script = frame.location.script; | 1022 var script = frame.location.script; |
| 987 script.load().then((_) { | 1023 script.load().then((_) { |
| 988 var line = script.tokenToLine(frame.location.tokenPos); | 1024 var line = script.tokenToLine(frame.location.tokenPos); |
| 989 var col = script.tokenToCol(frame.location.tokenPos); | 1025 var col = script.tokenToCol(frame.location.tokenPos); |
| 990 if (event.breakpoint != null) { | 1026 if (event.breakpoint != null) { |
| 991 var bpId = event.breakpoint.number; | 1027 var bpId = event.breakpoint.number; |
| 992 console.print('Paused at breakpoint ${bpId} at ' | 1028 console.print('Paused at breakpoint ${bpId} at ' |
| 993 '${script.name}:${line}:${col}'); | 1029 '${script.name}:${line}:${col}'); |
| 994 } else if (event.exception != null) { | 1030 } else if (event.exception != null) { |
| 995 // TODO(turnidge): Test this. | 1031 console.print('Paused due to exception at ' |
| 996 console.print('Paused due to exception ${event.exception} at ' | |
| 997 '${script.name}:${line}:${col}'); | 1032 '${script.name}:${line}:${col}'); |
| 1033 // This seems to be missing if we are paused-at-exception after |
| 1034 // paused-at-isolate-exit. Maybe we shutdown part of the debugger too |
| 1035 // soon? |
| 1036 console.printRef(event.exception); |
| 998 } else { | 1037 } else { |
| 999 console.print('Paused at ${script.name}:${line}:${col}'); | 1038 console.print('Paused at ${script.name}:${line}:${col}'); |
| 1000 } | 1039 } |
| 1001 }); | 1040 }); |
| 1002 } | 1041 } |
| 1003 } | 1042 } |
| 1004 | 1043 |
| 1005 Future _reportBreakpointEvent(ServiceEvent event) { | 1044 Future _reportBreakpointEvent(ServiceEvent event) { |
| 1006 var bpt = event.breakpoint; | 1045 var bpt = event.breakpoint; |
| 1007 var verb = null; | 1046 var verb = null; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 var iso = event.owner; | 1088 var iso = event.owner; |
| 1050 if (iso == isolate) { | 1089 if (iso == isolate) { |
| 1051 console.print("The current isolate has exited"); | 1090 console.print("The current isolate has exited"); |
| 1052 } else { | 1091 } else { |
| 1053 console.print( | 1092 console.print( |
| 1054 "Isolate ${iso.number} '${iso.name}' has exited"); | 1093 "Isolate ${iso.number} '${iso.name}' has exited"); |
| 1055 } | 1094 } |
| 1056 } | 1095 } |
| 1057 break; | 1096 break; |
| 1058 | 1097 |
| 1098 case ServiceEvent.kDebuggerSettingsUpdate: |
| 1099 if (exceptions != event.exceptions) { |
| 1100 exceptions = event.exceptions; |
| 1101 console.print("Now pausing for $exceptions exceptions"); |
| 1102 } |
| 1103 break; |
| 1104 |
| 1059 case ServiceEvent.kIsolateUpdate: | 1105 case ServiceEvent.kIsolateUpdate: |
| 1060 var iso = event.owner; | 1106 var iso = event.owner; |
| 1061 console.print("Isolate ${iso.number} renamed to '${iso.name}'"); | 1107 console.print("Isolate ${iso.number} renamed to '${iso.name}'"); |
| 1062 break; | 1108 break; |
| 1063 | 1109 |
| 1064 case ServiceEvent.kPauseStart: | 1110 case ServiceEvent.kPauseStart: |
| 1065 case ServiceEvent.kPauseExit: | 1111 case ServiceEvent.kPauseExit: |
| 1066 case ServiceEvent.kPauseBreakpoint: | 1112 case ServiceEvent.kPauseBreakpoint: |
| 1067 case ServiceEvent.kPauseInterrupted: | 1113 case ServiceEvent.kPauseInterrupted: |
| 1068 case ServiceEvent.kPauseException: | 1114 case ServiceEvent.kPauseException: |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 default: | 1709 default: |
| 1664 busy = false; | 1710 busy = false; |
| 1665 break; | 1711 break; |
| 1666 } | 1712 } |
| 1667 }); | 1713 }); |
| 1668 } | 1714 } |
| 1669 | 1715 |
| 1670 DebuggerInputElement.created() : super.created(); | 1716 DebuggerInputElement.created() : super.created(); |
| 1671 } | 1717 } |
| 1672 | 1718 |
| OLD | NEW |