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

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

Issue 1122503003: Display isolate message queue in Observatory debugger (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
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'; 10 import 'package:observatory/app.dart';
(...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 $['commandline'].debugger = debugger; 1200 $['commandline'].debugger = debugger;
1201 debugger.init(); 1201 debugger.init();
1202 } 1202 }
1203 1203
1204 } 1204 }
1205 1205
1206 @CustomTag('debugger-stack') 1206 @CustomTag('debugger-stack')
1207 class DebuggerStackElement extends ObservatoryElement { 1207 class DebuggerStackElement extends ObservatoryElement {
1208 @published Isolate isolate; 1208 @published Isolate isolate;
1209 @observable bool hasStack = false; 1209 @observable bool hasStack = false;
1210 @observable bool hasMessages = false;
1210 @observable bool isSampled = false; 1211 @observable bool isSampled = false;
1211 @observable int currentFrame; 1212 @observable int currentFrame;
1212 ObservatoryDebugger debugger; 1213 ObservatoryDebugger debugger;
1213 1214
1214 _addFrame(List frameList, ObservableMap frameInfo) { 1215 _addFrame(List frameList, ObservableMap frameInfo) {
1215 DebuggerFrameElement frameElement = new Element.tag('debugger-frame'); 1216 DebuggerFrameElement frameElement = new Element.tag('debugger-frame');
1216 frameElement.frame = frameInfo; 1217 frameElement.frame = frameInfo;
1217 1218
1218 if (frameInfo['depth'] == currentFrame) { 1219 if (frameInfo['depth'] == currentFrame) {
1219 frameElement.setCurrent(true); 1220 frameElement.setCurrent(true);
1220 } else { 1221 } else {
1221 frameElement.setCurrent(false); 1222 frameElement.setCurrent(false);
1222 } 1223 }
1223 1224
1224 var li = new LIElement(); 1225 var li = new LIElement();
1225 li.classes.add('list-group-item'); 1226 li.classes.add('list-group-item');
1226 li.children.insert(0, frameElement); 1227 li.children.insert(0, frameElement);
1227 1228
1228 frameList.insert(0, li); 1229 frameList.insert(0, li);
1229 } 1230 }
1230 1231
1231 void updateStack(ServiceMap newStack, ServiceEvent pauseEvent) { 1232 _addMessage(List messageList, ServiceMap messageInfo) {
1233 DebuggerMessageElement messageElement = new Element.tag('debugger-message');
1234 messageElement.message = messageInfo;
1235
1236 var li = new LIElement();
1237 li.classes.add('list-group-item');
1238 li.children.insert(0, messageElement);
1239
1240 messageList.add(li);
1241 }
1242
1243 void updateStackFrames(ServiceMap newStack) {
1232 List frameElements = $['frameList'].children; 1244 List frameElements = $['frameList'].children;
1233 List newFrames = newStack['frames']; 1245 List newFrames = newStack['frames'];
1234 1246
1235 // Remove any frames whose functions don't match, starting from 1247 // Remove any frames whose functions don't match, starting from
1236 // bottom of stack. 1248 // bottom of stack.
1237 int oldPos = frameElements.length - 1; 1249 int oldPos = frameElements.length - 1;
1238 int newPos = newFrames.length - 1; 1250 int newPos = newFrames.length - 1;
1239 while (oldPos >= 0 && newPos >= 0) { 1251 while (oldPos >= 0 && newPos >= 0) {
1240 if (!frameElements[oldPos].children[0].matchFrame(newFrames[newPos])) { 1252 if (!frameElements[oldPos].children[0].matchFrame(newFrames[newPos])) {
1241 // The rest of the frame elements no longer match. Remove them. 1253 // The rest of the frame elements no longer match. Remove them.
(...skipping 26 matching lines...) Expand all
1268 } 1280 }
1269 } 1281 }
1270 assert(frameElements.length == newFrames.length); 1282 assert(frameElements.length == newFrames.length);
1271 1283
1272 if (frameElements.isNotEmpty) { 1284 if (frameElements.isNotEmpty) {
1273 for (int i = newCount; i < frameElements.length; i++) { 1285 for (int i = newCount; i < frameElements.length; i++) {
1274 frameElements[i].children[0].updateFrame(newFrames[i]); 1286 frameElements[i].children[0].updateFrame(newFrames[i]);
1275 } 1287 }
1276 } 1288 }
1277 1289
1290 hasStack = frameElements.isNotEmpty;
1291 }
1292
1293 void updateStackMessages(ServiceMap newStack) {
1294 List messageElements = $['messageList'].children;
1295 List newMessages = newStack['messages'];
1296
1297 // Remove any extra message elements.
1298 if (messageElements.length > newMessages.length) {
1299 // Remove old messages from the front of the queue.
1300 int removeCount = messageElements.length - newMessages.length;
1301 for (int i = 0; i < removeCount; i++) {
1302 messageElements.removeAt(0);
1303 }
1304 }
1305
1306 // Add any new messages to the tail of the queue.
1307 int newStartingIndex = messageElements.length;
1308 if (messageElements.length < newMessages.length) {
1309 for (int i = newStartingIndex; i < newMessages.length; i++) {
1310 _addMessage(messageElements, newMessages[i]);
1311 }
1312 }
1313 assert(messageElements.length == newMessages.length);
1314
1315 if (messageElements.isNotEmpty) {
1316 // Update old messages.
1317 for (int i = 0; i < newStartingIndex; i++) {
1318 messageElements[i].children[0].updateMessage(newMessages[i]);
1319 }
1320 }
1321
1322 hasMessages = messageElements.isNotEmpty;
1323 }
1324
1325 void updateStack(ServiceMap newStack, ServiceEvent pauseEvent) {
1326 updateStackFrames(newStack);
1327 updateStackMessages(newStack);
1278 isSampled = pauseEvent == null; 1328 isSampled = pauseEvent == null;
1279 hasStack = frameElements.isNotEmpty;
1280 } 1329 }
1281 1330
1282 void setCurrentFrame(int value) { 1331 void setCurrentFrame(int value) {
1283 currentFrame = value; 1332 currentFrame = value;
1284 List frameElements = $['frameList'].children; 1333 List frameElements = $['frameList'].children;
1285 for (var frameElement in frameElements) { 1334 for (var frameElement in frameElements) {
1286 var dbgFrameElement = frameElement.children[0]; 1335 var dbgFrameElement = frameElement.children[0];
1287 if (dbgFrameElement.frame['depth'] == currentFrame) { 1336 if (dbgFrameElement.frame['depth'] == currentFrame) {
1288 dbgFrameElement.setCurrent(true); 1337 dbgFrameElement.setCurrent(true);
1289 } else { 1338 } else {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 frameOuter.classes.add('shadow'); 1442 frameOuter.classes.add('shadow');
1394 } else { 1443 } else {
1395 expanded = false; 1444 expanded = false;
1396 frameOuter.classes.remove('shadow'); 1445 frameOuter.classes.remove('shadow');
1397 } 1446 }
1398 busy = false; 1447 busy = false;
1399 }); 1448 });
1400 } 1449 }
1401 } 1450 }
1402 1451
1452 @CustomTag('debugger-message')
1453 class DebuggerMessageElement extends ObservatoryElement {
1454 @published ServiceMap message;
1455 @observable ServiceObject preview;
1456
1457 // Is this the current message?
1458 bool _current = false;
1459
1460 // Has this message been pinned open?
1461 bool _pinned = false;
1462
1463 void setCurrent(bool value) {
1464 _current = value;
1465 var messageOuter = $['messageOuter'];
1466 if (_current) {
1467 messageOuter.classes.add('current');
1468 expanded = true;
1469 messageOuter.classes.add('shadow');
1470 scrollIntoView();
1471 } else {
1472 messageOuter.classes.remove('current');
1473 if (_pinned) {
1474 expanded = true;
1475 messageOuter.classes.add('shadow');
1476 } else {
1477 expanded = false;
1478 messageOuter.classes.remove('shadow');
1479 }
1480 }
1481 }
1482
1483 @observable String scriptHeight;
1484 @observable bool expanded = false;
1485 @observable bool busy = false;
1486
1487 DebuggerMessageElement.created() : super.created();
1488
1489 void updateMessage(ServiceMap newMessage) {
1490 bool messageChanged =
1491 (message['messageObjectId'] != newMessage['messageObjectId']);
1492 message['depth'] = newMessage['depth'];
1493 message['handlerFunction'] = newMessage['handlerFunction'];
1494 message['messageObjectId'] = newMessage['messageObjectId'];
1495 if (messageChanged) {
1496 // Message object id has changed: clear preview and collapse.
1497 preview = null;
1498 if (expanded) {
1499 toggleExpand(null, null, null);
1500 }
1501 }
1502 }
1503
1504 @override
1505 void attached() {
1506 super.attached();
1507 int windowHeight = window.innerHeight;
1508 scriptHeight = '${windowHeight ~/ 1.6}px';
1509 }
1510
1511 void toggleExpand(var a, var b, var c) {
1512 if (busy) {
1513 return;
1514 }
1515 busy = true;
1516 var function = message['handlerFunction'];
1517 var loadedFunction;
1518 if (function == null) {
1519 // Complete immediately.
1520 loadedFunction = new Future.value(null);
1521 } else {
1522 loadedFunction = function.load();
1523 }
1524 loadedFunction.then((_) {
1525 _pinned = !_pinned;
1526 var messageOuter = $['messageOuter'];
1527 if (_pinned) {
1528 expanded = true;
1529 messageOuter.classes.add('shadow');
1530 } else {
1531 expanded = false;
1532 messageOuter.classes.remove('shadow');
1533 }
1534 busy = false;
1535 });
1536 }
1537
1538 Future<ServiceObject> previewMessage(_) {
1539 return message.isolate.getObject(message['messageObjectId']).then((result) {
1540 preview = result;
1541 return result;
1542 });
1543 }
1544 }
1545
1403 @CustomTag('debugger-console') 1546 @CustomTag('debugger-console')
1404 class DebuggerConsoleElement extends ObservatoryElement { 1547 class DebuggerConsoleElement extends ObservatoryElement {
1405 @published Isolate isolate; 1548 @published Isolate isolate;
1406 1549
1407 DebuggerConsoleElement.created() : super.created(); 1550 DebuggerConsoleElement.created() : super.created();
1408 1551
1409 void print(String line, { bool newline:true }) { 1552 void print(String line, { bool newline:true }) {
1410 var span = new SpanElement(); 1553 var span = new SpanElement();
1411 span.classes.add('normal'); 1554 span.classes.add('normal');
1412 span.appendText(line); 1555 span.appendText(line);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 default: 1642 default:
1500 busy = false; 1643 busy = false;
1501 break; 1644 break;
1502 } 1645 }
1503 }); 1646 });
1504 } 1647 }
1505 1648
1506 DebuggerInputElement.created() : super.created(); 1649 DebuggerInputElement.created() : super.created();
1507 } 1650 }
1508 1651
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/app/location_manager.dart ('k') | runtime/observatory/lib/src/elements/debugger.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698