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

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

Issue 1217823009: Make VM event streams look like real dart streams. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge with master Created 5 years, 5 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';
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 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
923 Future.wait(pending).then((_) { 922 Future.wait(pending).then((_) {
924 if (_subscription == null) {
925 _subscription = vm.events.stream.listen(_onEvent);
926 }
927 _refreshStack(isolate.pauseEvent).then((_) { 923 _refreshStack(isolate.pauseEvent).then((_) {
928 reportStatus(); 924 reportStatus();
929 }); 925 });
930 }).catchError((_) { 926 }).catchError((_) {
931 // Error loading libraries, try and display stack. 927 // Error loading libraries, try and display stack.
932 _refreshStack(isolate.pauseEvent).then((_) { 928 _refreshStack(isolate.pauseEvent).then((_) {
933 reportStatus(); 929 reportStatus();
934 }); 930 });
935 }); 931 });
936 }); 932 });
937 } else { 933 } else {
938 reportStatus(); 934 reportStatus();
939 } 935 }
940 } 936 }
941 937
942 set isolate(Isolate iso) { 938 set isolate(Isolate iso) {
943 // Setting the page's isolate will trigger updateIsolate to be called. 939 // Setting the page's isolate will trigger updateIsolate to be called.
944 // 940 //
945 // TODO(turnidge): Rework ownership of the ObservatoryDebugger in another 941 // TODO(turnidge): Rework ownership of the ObservatoryDebugger in another
946 // change. 942 // change.
947 page.isolate = iso; 943 page.isolate = iso;
948 } 944 }
949 Isolate get isolate => _isolate; 945 Isolate get isolate => _isolate;
950 Isolate _isolate; 946 Isolate _isolate;
951 var _subscription;
952 947
953 void init() { 948 void init() {
954 console.newline(); 949 console.newline();
955 console.printBold("Type 'h' for help"); 950 console.printBold("Type 'h' for help");
956 // Wait a bit and if polymer still hasn't set up the isolate, 951 // Wait a bit and if polymer still hasn't set up the isolate,
957 // report this to the user. 952 // report this to the user.
958 new Timer(const Duration(seconds:1), () { 953 new Timer(const Duration(seconds:1), () {
959 if (isolate == null) { 954 if (isolate == null) {
960 reportStatus(); 955 reportStatus();
961 } 956 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 if (bpt.resolved) { 1068 if (bpt.resolved) {
1074 console.print( 1069 console.print(
1075 'Breakpoint ${bpId} ${verb} at ${script.name}:${line}:${col}'); 1070 'Breakpoint ${bpId} ${verb} at ${script.name}:${line}:${col}');
1076 } else { 1071 } else {
1077 console.print( 1072 console.print(
1078 'Future breakpoint ${bpId} ${verb} at ${script.name}:${line}:${col}' ); 1073 'Future breakpoint ${bpId} ${verb} at ${script.name}:${line}:${col}' );
1079 } 1074 }
1080 }); 1075 });
1081 } 1076 }
1082 1077
1083 void _onEvent(ServiceEvent event) { 1078 void onEvent(ServiceEvent event) {
1084 switch(event.kind) { 1079 switch(event.kind) {
1085 case ServiceEvent.kIsolateStart: 1080 case ServiceEvent.kIsolateStart:
1086 { 1081 {
1087 var iso = event.owner; 1082 var iso = event.owner;
1088 console.print( 1083 console.print(
1089 "Isolate ${iso.number} '${iso.name}' has been created"); 1084 "Isolate ${iso.number} '${iso.name}' has been created");
1090 } 1085 }
1091 break; 1086 break;
1092 1087
1093 case ServiceEvent.kIsolateExit: 1088 case ServiceEvent.kIsolateExit:
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 return cmd.historyPrev(command); 1214 return cmd.historyPrev(command);
1220 } 1215 }
1221 1216
1222 String historyNext(String command) { 1217 String historyNext(String command) {
1223 return cmd.historyNext(command); 1218 return cmd.historyNext(command);
1224 } 1219 }
1225 } 1220 }
1226 1221
1227 @CustomTag('debugger-page') 1222 @CustomTag('debugger-page')
1228 class DebuggerPageElement extends ObservatoryElement { 1223 class DebuggerPageElement extends ObservatoryElement {
1229 @published ObservatoryApplication app;
1230 @published Isolate isolate; 1224 @published Isolate isolate;
1231 1225
1232 isolateChanged(oldValue) { 1226 isolateChanged(oldValue) {
1233 if (isolate != null) { 1227 if (isolate != null) {
1234 debugger.updateIsolate(isolate); 1228 debugger.updateIsolate(isolate);
1235 } 1229 }
1236 } 1230 }
1237 ObservatoryDebugger debugger = new ObservatoryDebugger(); 1231 ObservatoryDebugger debugger = new ObservatoryDebugger();
1238 1232
1239 DebuggerPageElement.created() : super.created() { 1233 DebuggerPageElement.created() : super.created() {
1240 debugger.page = this; 1234 debugger.page = this;
1241 } 1235 }
1242 1236
1237 Future<StreamSubscription> _isolateSubscriptionFuture;
1238 Future<StreamSubscription> _debugSubscriptionFuture;
1239
1243 @override 1240 @override
1244 void attached() { 1241 void attached() {
1245 super.attached(); 1242 super.attached();
1246 1243
1247 var navbarDiv = $['navbarDiv']; 1244 var navbarDiv = $['navbarDiv'];
1248 var stackDiv = $['stackDiv']; 1245 var stackDiv = $['stackDiv'];
1249 var splitterDiv = $['splitterDiv']; 1246 var splitterDiv = $['splitterDiv'];
1250 var cmdDiv = $['commandDiv']; 1247 var cmdDiv = $['commandDiv'];
1251 1248
1252 int navbarHeight = navbarDiv.clientHeight; 1249 int navbarHeight = navbarDiv.clientHeight;
1253 int splitterHeight = splitterDiv.clientHeight; 1250 int splitterHeight = splitterDiv.clientHeight;
1254 int cmdHeight = cmdDiv.clientHeight; 1251 int cmdHeight = cmdDiv.clientHeight;
1255 1252
1256 int windowHeight = window.innerHeight; 1253 int windowHeight = window.innerHeight;
1257 int fixedHeight = navbarHeight + splitterHeight + cmdHeight; 1254 int fixedHeight = navbarHeight + splitterHeight + cmdHeight;
1258 int available = windowHeight - fixedHeight; 1255 int available = windowHeight - fixedHeight;
1259 int stackHeight = available ~/ 1.6; 1256 int stackHeight = available ~/ 1.6;
1260 stackDiv.style.setProperty('height', '${stackHeight}px'); 1257 stackDiv.style.setProperty('height', '${stackHeight}px');
1261 1258
1262 // Wire the debugger object to the stack, console, and command line. 1259 // Wire the debugger object to the stack, console, and command line.
1263 var stackElement = $['stackElement']; 1260 var stackElement = $['stackElement'];
1264 debugger.stackElement = stackElement; 1261 debugger.stackElement = stackElement;
1265 stackElement.debugger = debugger; 1262 stackElement.debugger = debugger;
1266 debugger.console = $['console']; 1263 debugger.console = $['console'];
1267 debugger.input = $['commandline']; 1264 debugger.input = $['commandline'];
1268 debugger.input.debugger = debugger; 1265 debugger.input.debugger = debugger;
1269 debugger.init(); 1266 debugger.init();
1267
1268 _isolateSubscriptionFuture =
1269 app.vm.listenEventStream(VM.kIsolateStream, debugger.onEvent);
1270 _debugSubscriptionFuture =
1271 app.vm.listenEventStream(VM.kDebugStream, debugger.onEvent);
1272 }
1273
1274 @override
1275 void detached() {
1276 cancelFutureSubscription(_isolateSubscriptionFuture);
1277 _isolateSubscriptionFuture = null;
1278 cancelFutureSubscription(_debugSubscriptionFuture);
1279 _debugSubscriptionFuture = null;
1280 super.detached();
1270 } 1281 }
1271 } 1282 }
1272 1283
1273 @CustomTag('debugger-stack') 1284 @CustomTag('debugger-stack')
1274 class DebuggerStackElement extends ObservatoryElement { 1285 class DebuggerStackElement extends ObservatoryElement {
1275 @published Isolate isolate; 1286 @published Isolate isolate;
1276 @observable bool hasStack = false; 1287 @observable bool hasStack = false;
1277 @observable bool hasMessages = false; 1288 @observable bool hasMessages = false;
1278 @observable bool isSampled = false; 1289 @observable bool isSampled = false;
1279 @observable int currentFrame; 1290 @observable int currentFrame;
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 }); 1731 });
1721 } 1732 }
1722 1733
1723 void focus() { 1734 void focus() {
1724 $['textBox'].focus(); 1735 $['textBox'].focus();
1725 } 1736 }
1726 1737
1727 DebuggerInputElement.created() : super.created(); 1738 DebuggerInputElement.created() : super.created();
1728 } 1739 }
1729 1740
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/app/page.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