Chromium Code Reviews| 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 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 913 | 912 |
| 914 _isolate.reload().then((response) { | 913 _isolate.reload().then((response) { |
| 915 // TODO(turnidge): Currently the debugger relies on all libs | 914 // TODO(turnidge): Currently the debugger relies on all libs |
| 916 // being loaded. Fix this. | 915 // being loaded. Fix this. |
| 917 var pending = []; | 916 var pending = []; |
| 918 for (var lib in _isolate.libraries) { | 917 for (var lib in _isolate.libraries) { |
| 919 if (!lib.loaded) { | 918 if (!lib.loaded) { |
| 920 pending.add(lib.load()); | 919 pending.add(lib.load()); |
| 921 } | 920 } |
| 922 } | 921 } |
| 922 | |
| 923 Future.wait(pending).then((_) { | 923 Future.wait(pending).then((_) { |
| 924 if (_subscription == null) { | |
| 925 _subscription = vm.events.stream.listen(_onEvent); | |
| 926 } | |
| 927 _refreshStack(isolate.pauseEvent).then((_) { | 924 _refreshStack(isolate.pauseEvent).then((_) { |
| 928 reportStatus(); | 925 reportStatus(); |
| 929 }); | 926 }); |
| 930 }).catchError((_) { | 927 }).catchError((_) { |
| 931 // Error loading libraries, try and display stack. | 928 // Error loading libraries, try and display stack. |
| 932 _refreshStack(isolate.pauseEvent).then((_) { | 929 _refreshStack(isolate.pauseEvent).then((_) { |
| 933 reportStatus(); | 930 reportStatus(); |
| 934 }); | 931 }); |
| 935 }); | 932 }); |
| 936 }); | 933 }); |
| 937 } else { | 934 } else { |
| 938 reportStatus(); | 935 reportStatus(); |
| 939 } | 936 } |
| 940 } | 937 } |
| 941 | 938 |
| 942 set isolate(Isolate iso) { | 939 set isolate(Isolate iso) { |
| 943 // Setting the page's isolate will trigger updateIsolate to be called. | 940 // Setting the page's isolate will trigger updateIsolate to be called. |
| 944 // | 941 // |
| 945 // TODO(turnidge): Rework ownership of the ObservatoryDebugger in another | 942 // TODO(turnidge): Rework ownership of the ObservatoryDebugger in another |
| 946 // change. | 943 // change. |
| 947 page.isolate = iso; | 944 page.isolate = iso; |
| 948 } | 945 } |
| 949 Isolate get isolate => _isolate; | 946 Isolate get isolate => _isolate; |
| 950 Isolate _isolate; | 947 Isolate _isolate; |
| 951 var _subscription; | |
| 952 | 948 |
| 953 void init() { | 949 void init() { |
| 954 console.newline(); | 950 console.newline(); |
| 955 console.printBold("Type 'h' for help"); | 951 console.printBold("Type 'h' for help"); |
| 956 // Wait a bit and if polymer still hasn't set up the isolate, | 952 // Wait a bit and if polymer still hasn't set up the isolate, |
| 957 // report this to the user. | 953 // report this to the user. |
| 958 new Timer(const Duration(seconds:1), () { | 954 new Timer(const Duration(seconds:1), () { |
| 959 if (isolate == null) { | 955 if (isolate == null) { |
| 960 reportStatus(); | 956 reportStatus(); |
| 961 } | 957 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1073 if (bpt.resolved) { | 1069 if (bpt.resolved) { |
| 1074 console.print( | 1070 console.print( |
| 1075 'Breakpoint ${bpId} ${verb} at ${script.name}:${line}:${col}'); | 1071 'Breakpoint ${bpId} ${verb} at ${script.name}:${line}:${col}'); |
| 1076 } else { | 1072 } else { |
| 1077 console.print( | 1073 console.print( |
| 1078 'Future breakpoint ${bpId} ${verb} at ${script.name}:${line}:${col}' ); | 1074 'Future breakpoint ${bpId} ${verb} at ${script.name}:${line}:${col}' ); |
| 1079 } | 1075 } |
| 1080 }); | 1076 }); |
| 1081 } | 1077 } |
| 1082 | 1078 |
| 1083 void _onEvent(ServiceEvent event) { | 1079 void onEvent(ServiceEvent event) { |
| 1084 switch(event.kind) { | 1080 switch(event.kind) { |
| 1085 case ServiceEvent.kIsolateStart: | 1081 case ServiceEvent.kIsolateStart: |
| 1086 { | 1082 { |
| 1087 var iso = event.owner; | 1083 var iso = event.owner; |
| 1088 console.print( | 1084 console.print( |
| 1089 "Isolate ${iso.number} '${iso.name}' has been created"); | 1085 "Isolate ${iso.number} '${iso.name}' has been created"); |
| 1090 } | 1086 } |
| 1091 break; | 1087 break; |
| 1092 | 1088 |
| 1093 case ServiceEvent.kIsolateExit: | 1089 case ServiceEvent.kIsolateExit: |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1219 return cmd.historyPrev(command); | 1215 return cmd.historyPrev(command); |
| 1220 } | 1216 } |
| 1221 | 1217 |
| 1222 String historyNext(String command) { | 1218 String historyNext(String command) { |
| 1223 return cmd.historyNext(command); | 1219 return cmd.historyNext(command); |
| 1224 } | 1220 } |
| 1225 } | 1221 } |
| 1226 | 1222 |
| 1227 @CustomTag('debugger-page') | 1223 @CustomTag('debugger-page') |
| 1228 class DebuggerPageElement extends ObservatoryElement { | 1224 class DebuggerPageElement extends ObservatoryElement { |
| 1229 @published ObservatoryApplication app; | |
| 1230 @published Isolate isolate; | 1225 @published Isolate isolate; |
| 1231 | 1226 |
| 1232 isolateChanged(oldValue) { | 1227 isolateChanged(oldValue) { |
| 1233 if (isolate != null) { | 1228 if (isolate != null) { |
| 1234 debugger.updateIsolate(isolate); | 1229 debugger.updateIsolate(isolate); |
| 1235 } | 1230 } |
| 1236 } | 1231 } |
| 1237 ObservatoryDebugger debugger = new ObservatoryDebugger(); | 1232 ObservatoryDebugger debugger = new ObservatoryDebugger(); |
| 1238 | 1233 |
| 1239 DebuggerPageElement.created() : super.created() { | 1234 DebuggerPageElement.created() : super.created() { |
| 1240 debugger.page = this; | 1235 debugger.page = this; |
| 1241 } | 1236 } |
| 1242 | 1237 |
| 1238 Future<StreamSubscription> _isolateSubscriptionFuture; | |
| 1239 Future<StreamSubscription> _debugSubscriptionFuture; | |
| 1240 | |
| 1243 @override | 1241 @override |
| 1244 void attached() { | 1242 void attached() { |
| 1245 super.attached(); | 1243 super.attached(); |
| 1246 | 1244 |
| 1247 var navbarDiv = $['navbarDiv']; | 1245 var navbarDiv = $['navbarDiv']; |
| 1248 var stackDiv = $['stackDiv']; | 1246 var stackDiv = $['stackDiv']; |
| 1249 var splitterDiv = $['splitterDiv']; | 1247 var splitterDiv = $['splitterDiv']; |
| 1250 var cmdDiv = $['commandDiv']; | 1248 var cmdDiv = $['commandDiv']; |
| 1251 | 1249 |
| 1252 int navbarHeight = navbarDiv.clientHeight; | 1250 int navbarHeight = navbarDiv.clientHeight; |
| 1253 int splitterHeight = splitterDiv.clientHeight; | 1251 int splitterHeight = splitterDiv.clientHeight; |
| 1254 int cmdHeight = cmdDiv.clientHeight; | 1252 int cmdHeight = cmdDiv.clientHeight; |
| 1255 | 1253 |
| 1256 int windowHeight = window.innerHeight; | 1254 int windowHeight = window.innerHeight; |
| 1257 int fixedHeight = navbarHeight + splitterHeight + cmdHeight; | 1255 int fixedHeight = navbarHeight + splitterHeight + cmdHeight; |
| 1258 int available = windowHeight - fixedHeight; | 1256 int available = windowHeight - fixedHeight; |
| 1259 int stackHeight = available ~/ 1.6; | 1257 int stackHeight = available ~/ 1.6; |
| 1260 stackDiv.style.setProperty('height', '${stackHeight}px'); | 1258 stackDiv.style.setProperty('height', '${stackHeight}px'); |
| 1261 | 1259 |
| 1262 // Wire the debugger object to the stack, console, and command line. | 1260 // Wire the debugger object to the stack, console, and command line. |
| 1263 var stackElement = $['stackElement']; | 1261 var stackElement = $['stackElement']; |
| 1264 debugger.stackElement = stackElement; | 1262 debugger.stackElement = stackElement; |
| 1265 stackElement.debugger = debugger; | 1263 stackElement.debugger = debugger; |
| 1266 debugger.console = $['console']; | 1264 debugger.console = $['console']; |
| 1267 debugger.input = $['commandline']; | 1265 debugger.input = $['commandline']; |
| 1268 debugger.input.debugger = debugger; | 1266 debugger.input.debugger = debugger; |
| 1269 debugger.init(); | 1267 debugger.init(); |
| 1268 | |
| 1269 _isolateSubscriptionFuture = | |
| 1270 app.vm.getIsolateEventStream().then((stream) { | |
| 1271 return stream.listen(debugger.onEvent); | |
| 1272 }); | |
| 1273 _debugSubscriptionFuture = | |
| 1274 app.vm.getDebugEventStream().then((stream) { | |
| 1275 return stream.listen(debugger.onEvent); | |
| 1276 }); | |
| 1277 } | |
| 1278 | |
| 1279 @override | |
| 1280 void detached() { | |
| 1281 _isolateSubscriptionFuture.then((subscription) => subscription.cancel()); | |
|
Cutch
2015/07/07 23:16:09
Bracket with `if (_isolateSubscriptionFuture != nu
turnidge
2015/07/08 20:23:39
Done.
| |
| 1282 _debugSubscriptionFuture.then((subscription) => subscription.cancel()); | |
| 1283 super.detached(); | |
| 1270 } | 1284 } |
| 1271 } | 1285 } |
| 1272 | 1286 |
| 1273 @CustomTag('debugger-stack') | 1287 @CustomTag('debugger-stack') |
| 1274 class DebuggerStackElement extends ObservatoryElement { | 1288 class DebuggerStackElement extends ObservatoryElement { |
| 1275 @published Isolate isolate; | 1289 @published Isolate isolate; |
| 1276 @observable bool hasStack = false; | 1290 @observable bool hasStack = false; |
| 1277 @observable bool hasMessages = false; | 1291 @observable bool hasMessages = false; |
| 1278 @observable bool isSampled = false; | 1292 @observable bool isSampled = false; |
| 1279 @observable int currentFrame; | 1293 @observable int currentFrame; |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1720 }); | 1734 }); |
| 1721 } | 1735 } |
| 1722 | 1736 |
| 1723 void focus() { | 1737 void focus() { |
| 1724 $['textBox'].focus(); | 1738 $['textBox'].focus(); |
| 1725 } | 1739 } |
| 1726 | 1740 |
| 1727 DebuggerInputElement.created() : super.created(); | 1741 DebuggerInputElement.created() : super.created(); |
| 1728 } | 1742 } |
| 1729 | 1743 |
| OLD | NEW |