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

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

Issue 2785553005: Display the awaiter call stack in Observatory (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:svg'; 8 import 'dart:svg';
9 import 'dart:html'; 9 import 'dart:html';
10 import 'dart:math'; 10 import 'dart:math';
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 _setBreakOnException, 593 _setBreakOnException,
594 (debugger, _) => debugger.breakOnException 594 (debugger, _) => debugger.breakOnException
595 ], 595 ],
596 'up-is-down': [ 596 'up-is-down': [
597 _boolValues, 597 _boolValues,
598 _setUpIsDown, 598 _setUpIsDown,
599 (debugger, _) => debugger.upIsDown 599 (debugger, _) => debugger.upIsDown
600 ], 600 ],
601 'causal-async-stacks': [ 601 'causal-async-stacks': [
602 _boolValues, 602 _boolValues,
603 _setSaneAsyncStacks, 603 _setCausalAsyncStacks,
604 (debugger, _) => debugger.saneAsyncStacks 604 (debugger, _) => debugger.saneAsyncStacks
605 ], 605 ],
606 'awaiter-stacks': [
607 _boolValues,
608 _setAwaiterStacks,
609 (debugger, _) => debugger.awaiterStacks
610 ]
606 }; 611 };
607 612
608 static Future _setBreakOnException(debugger, name, value) async { 613 static Future _setBreakOnException(debugger, name, value) async {
609 var result = await debugger.isolate.setExceptionPauseMode(value); 614 var result = await debugger.isolate.setExceptionPauseMode(value);
610 if (result.isError) { 615 if (result.isError) {
611 debugger.console.print(result.toString()); 616 debugger.console.print(result.toString());
612 } else { 617 } else {
613 // Printing will occur elsewhere. 618 // Printing will occur elsewhere.
614 debugger.breakOnException = value; 619 debugger.breakOnException = value;
615 } 620 }
616 } 621 }
617 622
618 static Future _setUpIsDown(debugger, name, value) async { 623 static Future _setUpIsDown(debugger, name, value) async {
619 if (value == 'true') { 624 if (value == 'true') {
620 debugger.upIsDown = true; 625 debugger.upIsDown = true;
621 } else { 626 } else {
622 debugger.upIsDown = false; 627 debugger.upIsDown = false;
623 } 628 }
624 debugger.console.print('${name} = ${value}'); 629 debugger.console.print('${name} = ${value}');
625 } 630 }
626 631
627 static Future _setSaneAsyncStacks(debugger, name, value) async { 632 static Future _setCausalAsyncStacks(debugger, name, value) async {
628 if (value == 'true') { 633 if (value == 'true') {
629 debugger.saneAsyncStacks = true; 634 debugger.causalAsyncStacks = true;
630 } else { 635 } else {
631 debugger.saneAsyncStacks = false; 636 debugger.causalAsyncStacks = false;
632 } 637 }
633 debugger.refreshStack(); 638 debugger.refreshStack();
634 debugger.console.print('${name} = ${value}'); 639 debugger.console.print('${name} = ${value}');
635 } 640 }
636 641
642 static Future _setAwaiterStacks(debugger, name, value) async {
643 debugger.awaiterStacks = (value == 'true');
644 debugger.refreshStack();
645 debugger.console.print('${name} == ${value}');
646 }
647
637 Future run(List<String> args) async { 648 Future run(List<String> args) async {
638 if (args.length == 0) { 649 if (args.length == 0) {
639 for (var name in _options.keys) { 650 for (var name in _options.keys) {
640 var getHandler = _options[name][2]; 651 var getHandler = _options[name][2];
641 var value = await getHandler(debugger, name); 652 var value = await getHandler(debugger, name);
642 debugger.console.print("${name} = ${value}"); 653 debugger.console.print("${name} = ${value}");
643 } 654 }
644 } else if (args.length == 1) { 655 } else if (args.length == 1) {
645 var name = args[0].trim(); 656 var name = args[0].trim();
646 var optionInfo = _options[name]; 657 var optionInfo = _options[name];
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 int _currentFrame = null; 1367 int _currentFrame = null;
1357 1368
1358 bool get upIsDown => _upIsDown; 1369 bool get upIsDown => _upIsDown;
1359 void set upIsDown(bool value) { 1370 void set upIsDown(bool value) {
1360 settings.set('up-is-down', value); 1371 settings.set('up-is-down', value);
1361 _upIsDown = value; 1372 _upIsDown = value;
1362 } 1373 }
1363 1374
1364 bool _upIsDown; 1375 bool _upIsDown;
1365 1376
1366 bool get saneAsyncStacks => _saneAsyncStacks; 1377 bool get causalAsyncStacks => _causalAsyncStacks;
1367 void set saneAsyncStacks(bool value) { 1378 void set causalAsyncStacks(bool value) {
1368 settings.set('causal-async-stacks', value); 1379 settings.set('causal-async-stacks', value);
1369 _saneAsyncStacks = value; 1380 _causalAsyncStacks = value;
1370 } 1381 }
1371 1382
1372 bool _saneAsyncStacks; 1383 bool _causalAsyncStacks;
1373 1384
1385 bool get awaiterStacks => _awaiterStacks;
1386 void set awaiterStacks(bool value) {
1387 settings.set('awaiter-stacks', value);
1388 _causalAsyncStacks = value;
1389 }
1390
1391 bool _awaiterStacks;
1392
1393 static const String kAwaiterStackFrames = 'awaiterFrames';
1374 static const String kAsyncCausalStackFrames = 'asyncCausalFrames'; 1394 static const String kAsyncCausalStackFrames = 'asyncCausalFrames';
1375 static const String kStackFrames = 'frames'; 1395 static const String kStackFrames = 'frames';
1376 1396
1377 void upFrame(int count) { 1397 void upFrame(int count) {
1378 if (_upIsDown) { 1398 if (_upIsDown) {
1379 currentFrame += count; 1399 currentFrame += count;
1380 } else { 1400 } else {
1381 currentFrame -= count; 1401 currentFrame -= count;
1382 } 1402 }
1383 } 1403 }
1384 1404
1385 void downFrame(int count) { 1405 void downFrame(int count) {
1386 if (_upIsDown) { 1406 if (_upIsDown) {
1387 currentFrame -= count; 1407 currentFrame -= count;
1388 } else { 1408 } else {
1389 currentFrame += count; 1409 currentFrame += count;
1390 } 1410 }
1391 } 1411 }
1392 1412
1393 int get stackDepth { 1413 int get stackDepth {
1394 if (saneAsyncStacks) { 1414 if (awaiterStacks) {
1415 var awaiterStackFrames = stack[kAwaiterStackFrames];
1416 if (awaiterStackFrames != null) {
1417 return awaiterStackFrames.length;
1418 }
1419 }
1420 if (causalAsyncStacks) {
1395 var asyncCausalStackFrames = stack[kAsyncCausalStackFrames]; 1421 var asyncCausalStackFrames = stack[kAsyncCausalStackFrames];
1396 var stackFrames = stack[kStackFrames]; 1422 if (asyncCausalStackFrames != null) {
1397 if (asyncCausalStackFrames == null) { 1423 return asyncCausalStackFrames.length;
1398 // No causal frames.
1399 return stackFrames.length;
1400 } 1424 }
1401 return asyncCausalStackFrames.length;
1402 } else {
1403 return stack[kStackFrames].length;
1404 } 1425 }
1426 return stack[kStackFrames].length;
1405 } 1427 }
1406 1428
1407 List get stackFrames { 1429 List get stackFrames {
1408 if (saneAsyncStacks) { 1430 if (awaiterStacks) {
1431 var awaiterStackFrames = stack[kAwaiterStackFrames];
1432 if (awaiterStackFrames != null) {
1433 return awaiterStackFrames;
1434 }
1435 }
1436 if (causalAsyncStacks) {
1409 var asyncCausalStackFrames = stack[kAsyncCausalStackFrames]; 1437 var asyncCausalStackFrames = stack[kAsyncCausalStackFrames];
1410 var stackFrames = stack[kStackFrames]; 1438 if (asyncCausalStackFrames != null) {
1411 if (asyncCausalStackFrames == null) { 1439 return asyncCausalStackFrames;
1412 // No causal frames.
1413 return stackFrames ?? [];
1414 } 1440 }
1415 return asyncCausalStackFrames;
1416 } else {
1417 return stack[kStackFrames] ?? [];
1418 } 1441 }
1442 return stack[kStackFrames] ?? [];
1419 } 1443 }
1420 1444
1421 static final _history = ['']; 1445 static final _history = [''];
1422 1446
1423 ObservatoryDebugger(this.isolate) { 1447 ObservatoryDebugger(this.isolate) {
1424 _loadSettings(); 1448 _loadSettings();
1425 cmd = new RootCommand([ 1449 cmd = new RootCommand([
1426 new AsyncNextCommand(this), 1450 new AsyncNextCommand(this),
1427 new BreakCommand(this), 1451 new BreakCommand(this),
1428 new ClearCommand(this), 1452 new ClearCommand(this),
(...skipping 17 matching lines...) Expand all
1446 new StepCommand(this), 1470 new StepCommand(this),
1447 new SyncNextCommand(this), 1471 new SyncNextCommand(this),
1448 new UpCommand(this), 1472 new UpCommand(this),
1449 new VmCommand(this), 1473 new VmCommand(this),
1450 ], _history); 1474 ], _history);
1451 _consolePrinter = new _ConsoleStreamPrinter(this); 1475 _consolePrinter = new _ConsoleStreamPrinter(this);
1452 } 1476 }
1453 1477
1454 void _loadSettings() { 1478 void _loadSettings() {
1455 _upIsDown = settings.get('up-is-down'); 1479 _upIsDown = settings.get('up-is-down');
1456 _saneAsyncStacks = settings.get('causal-async-stacks') ?? true; 1480 _causalAsyncStacks = settings.get('causal-async-stacks') ?? true;
1481 _awaiterStacks = settings.get('awaiter-stacks') ?? true;
1457 } 1482 }
1458 1483
1459 S.VM get vm => page.app.vm; 1484 S.VM get vm => page.app.vm;
1460 1485
1461 void init() { 1486 void init() {
1462 console.printBold('Debugging isolate isolate ${isolate.number} ' 1487 console.printBold('Debugging isolate isolate ${isolate.number} '
1463 '\'${isolate.name}\' '); 1488 '\'${isolate.name}\' ');
1464 console.printBold('Type \'h\' for help'); 1489 console.printBold('Type \'h\' for help');
1465 // Wait a bit and if polymer still hasn't set up the isolate, 1490 // Wait a bit and if polymer still hasn't set up the isolate,
1466 // report this to the user. 1491 // report this to the user.
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 li.children.insert(0, messageElement); 2290 li.children.insert(0, messageElement);
2266 2291
2267 messageList.add(li); 2292 messageList.add(li);
2268 } 2293 }
2269 2294
2270 ObservatoryApplication get app => ObservatoryApplication.app; 2295 ObservatoryApplication get app => ObservatoryApplication.app;
2271 2296
2272 void updateStackFrames(S.ServiceMap newStack) { 2297 void updateStackFrames(S.ServiceMap newStack) {
2273 List frameElements = _frameList.children; 2298 List frameElements = _frameList.children;
2274 List newFrames; 2299 List newFrames;
2275 if (_debugger.saneAsyncStacks && 2300 if (_debugger.awaiterStacks &&
2301 (newStack[ObservatoryDebugger.kAwaiterStackFrames] != null)) {
2302 newFrames = newStack[ObservatoryDebugger.kAwaiterStackFrames];
2303 } else if (_debugger.causalAsyncStacks &&
2276 (newStack[ObservatoryDebugger.kAsyncCausalStackFrames] != null)) { 2304 (newStack[ObservatoryDebugger.kAsyncCausalStackFrames] != null)) {
2277 newFrames = newStack[ObservatoryDebugger.kAsyncCausalStackFrames]; 2305 newFrames = newStack[ObservatoryDebugger.kAsyncCausalStackFrames];
2278 } else { 2306 } else {
2279 newFrames = newStack[ObservatoryDebugger.kStackFrames]; 2307 newFrames = newStack[ObservatoryDebugger.kStackFrames];
2280 } 2308 }
2281 2309
2282 // Remove any frames whose functions don't match, starting from 2310 // Remove any frames whose functions don't match, starting from
2283 // bottom of stack. 2311 // bottom of stack.
2284 int oldPos = frameElements.length - 1; 2312 int oldPos = frameElements.length - 1;
2285 int newPos = newFrames.length - 1; 2313 int newPos = newFrames.length - 1;
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
3320 ..setAttribute('height', '24') 3348 ..setAttribute('height', '24')
3321 ..children = [ 3349 ..children = [
3322 new PathElement() 3350 new PathElement()
3323 ..setAttribute( 3351 ..setAttribute(
3324 'd', 3352 'd',
3325 'M11 17h2v-6h-2v6zm1-15C6.48 2 2 6.48 2 12s4.48 10 ' 3353 'M11 17h2v-6h-2v6zm1-15C6.48 2 2 6.48 2 12s4.48 10 '
3326 '10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 ' 3354 '10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 '
3327 '0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zM11 ' 3355 '0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zM11 '
3328 '9h2V7h-2v2z') 3356 '9h2V7h-2v2z')
3329 ]; 3357 ];
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698