| 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/cli.dart'; | 11 import 'package:observatory/cli.dart'; |
| 11 import 'package:observatory/debugger.dart'; | 12 import 'package:observatory/debugger.dart'; |
| 12 import 'package:observatory/service.dart'; | 13 import 'package:observatory/service.dart'; |
| 13 import 'package:polymer/polymer.dart'; | 14 import 'package:polymer/polymer.dart'; |
| 14 | 15 |
| 15 // TODO(turnidge): Move Debugger, DebuggerCommand to debugger library. | 16 // TODO(turnidge): Move Debugger, DebuggerCommand to debugger library. |
| 16 abstract class DebuggerCommand extends Command { | 17 abstract class DebuggerCommand extends Command { |
| 17 ObservatoryDebugger debugger; | 18 ObservatoryDebugger debugger; |
| 18 | 19 |
| 19 DebuggerCommand(this.debugger, name, children) | 20 DebuggerCommand(this.debugger, name, children) |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 _isolate.reload().then((response) { | 872 _isolate.reload().then((response) { |
| 872 // TODO(turnidge): Currently the debugger relies on all libs | 873 // TODO(turnidge): Currently the debugger relies on all libs |
| 873 // being loaded. Fix this. | 874 // being loaded. Fix this. |
| 874 var pending = []; | 875 var pending = []; |
| 875 for (var lib in _isolate.libraries) { | 876 for (var lib in _isolate.libraries) { |
| 876 if (!lib.loaded) { | 877 if (!lib.loaded) { |
| 877 pending.add(lib.load()); | 878 pending.add(lib.load()); |
| 878 } | 879 } |
| 879 } | 880 } |
| 880 Future.wait(pending).then((_) { | 881 Future.wait(pending).then((_) { |
| 881 if (_isolateSubscription == null) { | 882 if (_subscription == null) { |
| 882 _isolateSubscription = vm.isolateEvents.listen(_onEvent); | 883 _subscription = vm.events.stream.listen(_onEvent); |
| 883 } | |
| 884 if (_debugSubscription == null) { | |
| 885 _debugSubscription = vm.debugEvents.listen(_onEvent); | |
| 886 } | 884 } |
| 887 _refreshStack(isolate.pauseEvent).then((_) { | 885 _refreshStack(isolate.pauseEvent).then((_) { |
| 888 reportStatus(); | 886 reportStatus(); |
| 889 }); | 887 }); |
| 890 }).catchError((_) { | 888 }).catchError((_) { |
| 891 // Error loading libraries, try and display stack. | 889 // Error loading libraries, try and display stack. |
| 892 _refreshStack(isolate.pauseEvent).then((_) { | 890 _refreshStack(isolate.pauseEvent).then((_) { |
| 893 reportStatus(); | 891 reportStatus(); |
| 894 }); | 892 }); |
| 895 }); | 893 }); |
| 896 }); | 894 }); |
| 897 } else { | 895 } else { |
| 898 reportStatus(); | 896 reportStatus(); |
| 899 } | 897 } |
| 900 } | 898 } |
| 901 | 899 |
| 902 set isolate(Isolate iso) { | 900 set isolate(Isolate iso) { |
| 903 // Setting the page's isolate will trigger updateIsolate to be called. | 901 // Setting the page's isolate will trigger updateIsolate to be called. |
| 904 // | 902 // |
| 905 // TODO(turnidge): Rework ownership of the ObservatoryDebugger in another | 903 // TODO(turnidge): Rework ownership of the ObservatoryDebugger in another |
| 906 // change. | 904 // change. |
| 907 page.isolate = iso; | 905 page.isolate = iso; |
| 908 } | 906 } |
| 909 Isolate get isolate => _isolate; | 907 Isolate get isolate => _isolate; |
| 910 Isolate _isolate; | 908 Isolate _isolate; |
| 911 var _isolateSubscription; | 909 var _subscription; |
| 912 var _debugSubscription; | |
| 913 | 910 |
| 914 void init() { | 911 void init() { |
| 915 console.newline(); | 912 console.newline(); |
| 916 console.printBold("Type 'h' for help"); | 913 console.printBold("Type 'h' for help"); |
| 917 // Wait a bit and if polymer still hasn't set up the isolate, | 914 // Wait a bit and if polymer still hasn't set up the isolate, |
| 918 // report this to the user. | 915 // report this to the user. |
| 919 new Timer(const Duration(seconds:1), () { | 916 new Timer(const Duration(seconds:1), () { |
| 920 if (isolate == null) { | 917 if (isolate == null) { |
| 921 reportStatus(); | 918 reportStatus(); |
| 922 } | 919 } |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 return cmd.historyPrev(command); | 1166 return cmd.historyPrev(command); |
| 1170 } | 1167 } |
| 1171 | 1168 |
| 1172 String historyNext(String command) { | 1169 String historyNext(String command) { |
| 1173 return cmd.historyNext(command); | 1170 return cmd.historyNext(command); |
| 1174 } | 1171 } |
| 1175 } | 1172 } |
| 1176 | 1173 |
| 1177 @CustomTag('debugger-page') | 1174 @CustomTag('debugger-page') |
| 1178 class DebuggerPageElement extends ObservatoryElement { | 1175 class DebuggerPageElement extends ObservatoryElement { |
| 1176 @published ObservatoryApplication app; |
| 1179 @published Isolate isolate; | 1177 @published Isolate isolate; |
| 1180 | 1178 |
| 1181 isolateChanged(oldValue) { | 1179 isolateChanged(oldValue) { |
| 1182 if (isolate != null) { | 1180 if (isolate != null) { |
| 1183 debugger.updateIsolate(isolate); | 1181 debugger.updateIsolate(isolate); |
| 1184 } | 1182 } |
| 1185 } | 1183 } |
| 1186 ObservatoryDebugger debugger = new ObservatoryDebugger(); | 1184 ObservatoryDebugger debugger = new ObservatoryDebugger(); |
| 1187 | 1185 |
| 1188 DebuggerPageElement.created() : super.created() { | 1186 DebuggerPageElement.created() : super.created() { |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1669 default: | 1667 default: |
| 1670 busy = false; | 1668 busy = false; |
| 1671 break; | 1669 break; |
| 1672 } | 1670 } |
| 1673 }); | 1671 }); |
| 1674 } | 1672 } |
| 1675 | 1673 |
| 1676 DebuggerInputElement.created() : super.created(); | 1674 DebuggerInputElement.created() : super.created(); |
| 1677 } | 1675 } |
| 1678 | 1676 |
| OLD | NEW |