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

Side by Side Diff: runtime/observatory/lib/src/service/object.dart

Issue 1687293003: Rewrite asyncStepOver to use await (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 part of service; 5 part of service;
6 6
7 // Some value smaller than the object ring, so requesting a large array 7 // Some value smaller than the object ring, so requesting a large array
8 // doesn't result in an expired ref because the elements lapped it in the 8 // doesn't result in an expired ref because the elements lapped it in the
9 // object ring. 9 // object ring.
10 const int kDefaultFieldLimit = 100; 10 const int kDefaultFieldLimit = 100;
(...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 1583
1584 1584
1585 static const int kFirstResume = 0; 1585 static const int kFirstResume = 0;
1586 static const int kSecondResume = 1; 1586 static const int kSecondResume = 1;
1587 /// result[kFirstResume] completes after the inital resume. The UI should 1587 /// result[kFirstResume] completes after the inital resume. The UI should
1588 /// wait on this future because some other breakpoint may be hit before the 1588 /// wait on this future because some other breakpoint may be hit before the
1589 /// async continuation. 1589 /// async continuation.
1590 /// result[kSecondResume] completes after the second resume. Tests should 1590 /// result[kSecondResume] completes after the second resume. Tests should
1591 /// wait on this future to avoid confusing the pause event at the 1591 /// wait on this future to avoid confusing the pause event at the
1592 /// state-machine switch with the pause event after the state-machine switch. 1592 /// state-machine switch with the pause event after the state-machine switch.
1593 List<Future> asyncStepOver() { 1593 Future<List<Future>> asyncStepOver() async {
1594 Completer firstResume = new Completer(); 1594 final Completer firstResume = new Completer();
1595 Completer secondResume = new Completer(); 1595 final Completer secondResume = new Completer();
1596 var subscription; 1596 final List<Future> result = [firstResume.future, secondResume.future];
1597 StreamSubscription subscription;
1597 1598
1599 // Inner error handling function.
1598 handleError(error) { 1600 handleError(error) {
1599 if (subscription != null) { 1601 if (subscription != null) {
1600 subscription.cancel(); 1602 subscription.cancel();
1601 subscription = null; 1603 subscription = null;
1602 } 1604 }
1603 firstResume.completeError(error); 1605 firstResume.completeError(error);
1604 secondResume.completeError(error); 1606 secondResume.completeError(error);
1605 } 1607 }
1606 1608
1607 if ((pauseEvent == null) || 1609 if ((pauseEvent == null) ||
1608 (pauseEvent.kind != ServiceEvent.kPauseBreakpoint) || 1610 (pauseEvent.kind != ServiceEvent.kPauseBreakpoint) ||
1609 (pauseEvent.asyncContinuation == null)) { 1611 (pauseEvent.asyncContinuation == null)) {
1610 handleError(new Exception("No async continuation available")); 1612 handleError(new Exception("No async continuation available"));
1611 } else { 1613 } else {
1612 Instance continuation = pauseEvent.asyncContinuation; 1614 Instance continuation = pauseEvent.asyncContinuation;
1613 assert(continuation.isClosure); 1615 assert(continuation.isClosure);
1614 addBreakOnActivation(continuation).then((Breakpoint continuationBpt) { 1616
1615 vm.getEventStream(VM.kDebugStream).then((stream) { 1617 // Add breakpoint at continuation.
1616 var onResume = firstResume; 1618 Breakpoint continuationBpt;
1617 subscription = stream.listen((ServiceEvent event) { 1619 try {
1618 if ((event.kind == ServiceEvent.kPauseBreakpoint) && 1620 continuationBpt = await addBreakOnActivation(continuation);
1619 (event.breakpoint == continuationBpt)) { 1621 } catch (e) {
1620 // We are stopped before state-machine dispatch; step-over to 1622 handleError(e);
1621 // reach user code. 1623 return result;
1622 removeBreakpoint(continuationBpt).then((_) { 1624 }
1623 onResume = secondResume; 1625
1624 stepOver().catchError(handleError); 1626 // Subscribe to the debugger event stream.
1625 }); 1627 Stream stream;
1626 } else if (event.kind == ServiceEvent.kResume) { 1628 try {
1627 if (onResume == secondResume) { 1629 stream = await vm.getEventStream(VM.kDebugStream);
1628 subscription.cancel(); 1630 } catch (e) {
1629 subscription = null; 1631 handleError(e);
1630 } 1632 return result;
1631 if (onResume != null) { 1633 }
1632 onResume.complete(this); 1634
1633 onResume = null; 1635 Completer onResume = firstResume;
1634 } 1636 subscription = stream.listen((ServiceEvent event) async {
1635 } 1637 if ((event.kind == ServiceEvent.kPauseBreakpoint) &&
1636 }); 1638 (event.breakpoint == continuationBpt)) {
1637 resume().catchError(handleError); 1639 // We are stopped before state-machine dispatch:
1638 }).catchError(handleError); 1640 // 1) Remove the continuation breakpoint.
1639 }).catchError(handleError); 1641 // 2) step over.
1642 // reach user code.
1643 await removeBreakpoint(continuationBpt);
1644 onResume = secondResume;
1645 stepOver().catchError(handleError);
1646 } else if (event.kind == ServiceEvent.kResume) {
1647 // We've resumed.
1648 if (onResume == secondResume) {
1649 // This is our second resume, cancel our subscription to the debug
1650 // stream.
1651 subscription.cancel();
1652 subscription = null;
1653 }
1654 // Complete onResume and clear it.
1655 if (onResume != null) {
1656 onResume.complete(this);
1657 onResume = null;
1658 }
1659 }
1660 });
1661
1662 // Call resume, which will eventually cause us to hit continuationBpt.
1663 resume().catchError(handleError);
1640 } 1664 }
1641 1665 return result;
1642 return [firstResume.future, secondResume.future];
1643 } 1666 }
1644 1667
1645 Future setName(String newName) { 1668 Future setName(String newName) {
1646 return invokeRpc('setName', {'name': newName}); 1669 return invokeRpc('setName', {'name': newName});
1647 } 1670 }
1648 1671
1649 Future setExceptionPauseMode(String mode) { 1672 Future setExceptionPauseMode(String mode) {
1650 return invokeRpc('setExceptionPauseMode', {'mode': mode}); 1673 return invokeRpc('setExceptionPauseMode', {'mode': mode});
1651 } 1674 }
1652 1675
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
2409 oneByteFunction = map['_oneByteFunction']; 2432 oneByteFunction = map['_oneByteFunction'];
2410 twoByteFunction = map['_twoByteFunction']; 2433 twoByteFunction = map['_twoByteFunction'];
2411 externalOneByteFunction = map['_externalOneByteFunction']; 2434 externalOneByteFunction = map['_externalOneByteFunction'];
2412 externalTwoByteFunction = map['_externalTwoByteFunction']; 2435 externalTwoByteFunction = map['_externalTwoByteFunction'];
2413 2436
2414 nativeFields = map['_nativeFields']; 2437 nativeFields = map['_nativeFields'];
2415 fields = map['fields']; 2438 fields = map['fields'];
2416 elements = map['elements']; 2439 elements = map['elements'];
2417 associations = map['associations']; 2440 associations = map['associations'];
2418 if (map['bytes'] != null) { 2441 if (map['bytes'] != null) {
2419 var bytes = BASE64.decode(map['bytes']); 2442 Uint8List bytes = BASE64.decode(map['bytes']);
2420 switch (map['kind']) { 2443 switch (map['kind']) {
2421 case "Uint8ClampedList": 2444 case "Uint8ClampedList":
2422 typedElements = bytes.buffer.asUint8ClampedList(); break; 2445 typedElements = bytes.buffer.asUint8ClampedList(); break;
2423 case "Uint8List": 2446 case "Uint8List":
2424 typedElements = bytes.buffer.asUint8List(); break; 2447 typedElements = bytes.buffer.asUint8List(); break;
2425 case "Uint16List": 2448 case "Uint16List":
2426 typedElements = bytes.buffer.asUint16List(); break; 2449 typedElements = bytes.buffer.asUint16List(); break;
2427 case "Uint32List": 2450 case "Uint32List":
2428 typedElements = bytes.buffer.asUint32List(); break; 2451 typedElements = bytes.buffer.asUint32List(); break;
2429 case "Uint64List": 2452 case "Uint64List":
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
3627 } 3650 }
3628 var function = inlinedFunctionsTable[inline_id]; 3651 var function = inlinedFunctionsTable[inline_id];
3629 codeInlineInterval.functions.add(function); 3652 codeInlineInterval.functions.add(function);
3630 } 3653 }
3631 inlineIntervals.add(codeInlineInterval); 3654 inlineIntervals.add(codeInlineInterval);
3632 } 3655 }
3633 } 3656 }
3634 3657
3635 @observable bool hasDisassembly = false; 3658 @observable bool hasDisassembly = false;
3636 3659
3637 void _processDisassembly(List<String> disassembly){ 3660 void _processDisassembly(List disassembly) {
3638 assert(disassembly != null); 3661 assert(disassembly != null);
3639 instructions.clear(); 3662 instructions.clear();
3640 instructionsByAddressOffset = new List(endAddress - startAddress); 3663 instructionsByAddressOffset = new List(endAddress - startAddress);
3641 3664
3642 assert((disassembly.length % 4) == 0); 3665 assert((disassembly.length % 4) == 0);
3643 for (var i = 0; i < disassembly.length; i += 4) { 3666 for (var i = 0; i < disassembly.length; i += 4) {
3644 var address = 0; // Assume code comment. 3667 var address = 0; // Assume code comment.
3645 var machine = disassembly[i + 1]; 3668 var machine = disassembly[i + 1];
3646 var human = disassembly[i + 2]; 3669 var human = disassembly[i + 2];
3647 var object = disassembly[i + 3]; 3670 var object = disassembly[i + 3];
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
4029 var v = list[i]; 4052 var v = list[i];
4030 if ((v is ObservableMap) && _isServiceMap(v)) { 4053 if ((v is ObservableMap) && _isServiceMap(v)) {
4031 list[i] = owner.getFromMap(v); 4054 list[i] = owner.getFromMap(v);
4032 } else if (v is ObservableList) { 4055 } else if (v is ObservableList) {
4033 _upgradeObservableList(v, owner); 4056 _upgradeObservableList(v, owner);
4034 } else if (v is ObservableMap) { 4057 } else if (v is ObservableMap) {
4035 _upgradeObservableMap(v, owner); 4058 _upgradeObservableMap(v, owner);
4036 } 4059 }
4037 } 4060 }
4038 } 4061 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/debugger.dart ('k') | runtime/observatory/tests/service/async_next_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698