| 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 part of service; | 5 part of service; |
| 6 | 6 |
| 7 /// A [ServiceObject] represents a persistent object within the vm. | 7 /// A [ServiceObject] represents a persistent object within the vm. |
| 8 abstract class ServiceObject extends Observable { | 8 abstract class ServiceObject extends Observable { |
| 9 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { | 9 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { |
| 10 return o1.name.compareTo(o2.name); | 10 return o1.name.compareTo(o2.name); |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 var children = _trieData[_trieDataCursor++]; | 1014 var children = _trieData[_trieDataCursor++]; |
| 1015 // Recursively read child nodes. | 1015 // Recursively read child nodes. |
| 1016 for (var i = 0; i < children; i++) { | 1016 for (var i = 0; i < children; i++) { |
| 1017 var child = _readTrieNode(codeTable); | 1017 var child = _readTrieNode(codeTable); |
| 1018 node.children.add(child); | 1018 node.children.add(child); |
| 1019 node.summedChildCount += child.count; | 1019 node.summedChildCount += child.count; |
| 1020 } | 1020 } |
| 1021 return node; | 1021 return node; |
| 1022 } | 1022 } |
| 1023 | 1023 |
| 1024 // TODO(turnidge): Make this an ObservableList instead. | 1024 ObservableList breakpoints = new ObservableList(); |
| 1025 ServiceMap breakpoints; | |
| 1026 | 1025 |
| 1027 void _removeBreakpoint(ServiceMap bpt) { | 1026 void _removeBreakpoint(ServiceMap bpt) { |
| 1028 var script = bpt['location']['script']; | 1027 var script = bpt['location']['script']; |
| 1029 var tokenPos = bpt['location']['tokenPos']; | 1028 var tokenPos = bpt['location']['tokenPos']; |
| 1030 assert(tokenPos != null); | 1029 assert(tokenPos != null); |
| 1031 if (script.loaded) { | 1030 if (script.loaded) { |
| 1032 var line = script.tokenToLine(tokenPos); | 1031 var line = script.tokenToLine(tokenPos); |
| 1033 assert(line != null); | 1032 assert(line != null); |
| 1034 if (script.lines[line - 1] != null) { | 1033 if (script.lines[line - 1] != null) { |
| 1035 assert(script.lines[line - 1].bpt == bpt); | 1034 assert(script.lines[line - 1].bpt == bpt); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1051 // Load the script and then plop in the breakpoint. | 1050 // Load the script and then plop in the breakpoint. |
| 1052 script.load().then((_) { | 1051 script.load().then((_) { |
| 1053 _addBreakpoint(bpt); | 1052 _addBreakpoint(bpt); |
| 1054 }); | 1053 }); |
| 1055 } | 1054 } |
| 1056 } | 1055 } |
| 1057 | 1056 |
| 1058 void _updateBreakpoints(ServiceMap newBreakpoints) { | 1057 void _updateBreakpoints(ServiceMap newBreakpoints) { |
| 1059 // Remove all of the old breakpoints from the Script lines. | 1058 // Remove all of the old breakpoints from the Script lines. |
| 1060 if (breakpoints != null) { | 1059 if (breakpoints != null) { |
| 1061 for (var bpt in breakpoints['breakpoints']) { | 1060 for (var bpt in breakpoints) { |
| 1062 _removeBreakpoint(bpt); | 1061 _removeBreakpoint(bpt); |
| 1063 } | 1062 } |
| 1064 } | 1063 } |
| 1065 // Add all of the new breakpoints to the Script lines. | 1064 // Add all of the new breakpoints to the Script lines. |
| 1066 for (var bpt in newBreakpoints['breakpoints']) { | 1065 for (var bpt in newBreakpoints['breakpoints']) { |
| 1067 _addBreakpoint(bpt); | 1066 _addBreakpoint(bpt); |
| 1068 } | 1067 } |
| 1069 breakpoints = newBreakpoints; | 1068 breakpoints.clear(); |
| 1069 breakpoints.addAll(newBreakpoints['breakpoints']); |
| 1070 |
| 1071 // Sort the breakpoints by breakpointNumber. |
| 1072 breakpoints.sort((a, b) => (a['breakpointNumber'] - b['breakpointNumber'])); |
| 1070 } | 1073 } |
| 1071 | 1074 |
| 1072 Future<ServiceObject> _inProgressReloadBpts; | 1075 Future<ServiceObject> _inProgressReloadBpts; |
| 1073 | 1076 |
| 1074 Future reloadBreakpoints() { | 1077 Future reloadBreakpoints() { |
| 1075 // TODO(turnidge): Can reusing the Future here ever cause us to | 1078 // TODO(turnidge): Can reusing the Future here ever cause us to |
| 1076 // get stale breakpoints? | 1079 // get stale breakpoints? |
| 1077 if (_inProgressReloadBpts == null) { | 1080 if (_inProgressReloadBpts == null) { |
| 1078 _inProgressReloadBpts = | 1081 _inProgressReloadBpts = |
| 1079 invokeRpc('getBreakpoints', {}).then((newBpts) { | 1082 invokeRpc('getBreakpoints', {}).then((newBpts) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 if (pauseEvent != null && | 1118 if (pauseEvent != null && |
| 1116 pauseEvent.breakpoint != null && | 1119 pauseEvent.breakpoint != null && |
| 1117 (pauseEvent.breakpoint['id'] == bpt['id'])) { | 1120 (pauseEvent.breakpoint['id'] == bpt['id'])) { |
| 1118 return isolate.reload(); | 1121 return isolate.reload(); |
| 1119 } else { | 1122 } else { |
| 1120 return reloadBreakpoints(); | 1123 return reloadBreakpoints(); |
| 1121 } | 1124 } |
| 1122 }); | 1125 }); |
| 1123 } | 1126 } |
| 1124 | 1127 |
| 1128 // TODO(turnidge): If the user invokes pause (or other rpcs) twice, |
| 1129 // they could get a race. Consider returning an "in progress" |
| 1130 // future to avoid this. |
| 1125 Future pause() { | 1131 Future pause() { |
| 1126 return invokeRpc('pause', {}).then((result) { | 1132 return invokeRpc('pause', {}).then((result) { |
| 1127 if (result is DartError) { | 1133 if (result is DartError) { |
| 1128 // TODO(turnidge): Handle this more gracefully. | 1134 // TODO(turnidge): Handle this more gracefully. |
| 1129 Logger.root.severe(result.message); | 1135 Logger.root.severe(result.message); |
| 1130 } | 1136 } |
| 1131 return isolate.reload(); | 1137 return isolate.reload(); |
| 1132 }); | 1138 }); |
| 1133 } | 1139 } |
| 1134 | 1140 |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1931 } | 1937 } |
| 1932 } | 1938 } |
| 1933 } | 1939 } |
| 1934 return true; | 1940 return true; |
| 1935 } | 1941 } |
| 1936 | 1942 |
| 1937 ScriptLine(this.script, this.line, this.text) { | 1943 ScriptLine(this.script, this.line, this.text) { |
| 1938 possibleBpt = !_isTrivialLine(text); | 1944 possibleBpt = !_isTrivialLine(text); |
| 1939 | 1945 |
| 1940 // TODO(turnidge): This is not so efficient. Consider improving. | 1946 // TODO(turnidge): This is not so efficient. Consider improving. |
| 1941 for (var bpt in this.script.isolate.breakpoints['breakpoints']) { | 1947 for (var bpt in this.script.isolate.breakpoints) { |
| 1942 var bptScript = bpt['location']['script']; | 1948 var bptScript = bpt['location']['script']; |
| 1943 var bptTokenPos = bpt['location']['tokenPos']; | 1949 var bptTokenPos = bpt['location']['tokenPos']; |
| 1944 if (bptScript == this.script && | 1950 if (bptScript == this.script && |
| 1945 bptScript.tokenToLine(bptTokenPos) == line) { | 1951 bptScript.tokenToLine(bptTokenPos) == line) { |
| 1946 this.bpt = bpt; | 1952 this.bpt = bpt; |
| 1947 } | 1953 } |
| 1948 } | 1954 } |
| 1949 } | 1955 } |
| 1950 } | 1956 } |
| 1951 | 1957 |
| (...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2852 var v = list[i]; | 2858 var v = list[i]; |
| 2853 if ((v is ObservableMap) && _isServiceMap(v)) { | 2859 if ((v is ObservableMap) && _isServiceMap(v)) { |
| 2854 list[i] = owner.getFromMap(v); | 2860 list[i] = owner.getFromMap(v); |
| 2855 } else if (v is ObservableList) { | 2861 } else if (v is ObservableList) { |
| 2856 _upgradeObservableList(v, owner); | 2862 _upgradeObservableList(v, owner); |
| 2857 } else if (v is ObservableMap) { | 2863 } else if (v is ObservableMap) { |
| 2858 _upgradeObservableMap(v, owner); | 2864 _upgradeObservableMap(v, owner); |
| 2859 } | 2865 } |
| 2860 } | 2866 } |
| 2861 } | 2867 } |
| OLD | NEW |