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