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] is an object known to the VM service and is tied | 7 /// A [ServiceObject] is an object known to the VM service and is tied |
8 /// to an owning [Isolate]. | 8 /// to an owning [Isolate]. |
9 abstract class ServiceObject extends Observable { | 9 abstract class ServiceObject extends Observable { |
10 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { | 10 static int LexicalSortName(ServiceObject o1, ServiceObject o2) { |
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 | 1035 |
1036 Future stepOut() { | 1036 Future stepOut() { |
1037 return get("debug/resume?step=out").then((result) { | 1037 return get("debug/resume?step=out").then((result) { |
1038 if (result is DartError) { | 1038 if (result is DartError) { |
1039 // TODO(turnidge): Handle this more gracefully. | 1039 // TODO(turnidge): Handle this more gracefully. |
1040 Logger.root.severe(result.message); | 1040 Logger.root.severe(result.message); |
1041 } | 1041 } |
1042 return isolate.reload(); | 1042 return isolate.reload(); |
1043 }); | 1043 }); |
1044 } | 1044 } |
| 1045 |
| 1046 String toString() => "Isolate($_id)"; |
1045 } | 1047 } |
1046 | 1048 |
1047 /// A [ServiceObject] which implements [ObservableMap]. | 1049 /// A [ServiceObject] which implements [ObservableMap]. |
1048 class ServiceMap extends ServiceObject implements ObservableMap { | 1050 class ServiceMap extends ServiceObject implements ObservableMap { |
1049 final ObservableMap _map = new ObservableMap(); | 1051 final ObservableMap _map = new ObservableMap(); |
1050 static String objectIdRingPrefix = 'objects/'; | 1052 static String objectIdRingPrefix = 'objects/'; |
1051 | 1053 |
1052 bool get canCache { | 1054 bool get canCache { |
1053 return (_serviceType == 'Class' || | 1055 return (_serviceType == 'Class' || |
1054 _serviceType == 'Function' || | 1056 _serviceType == 'Function' || |
1055 _serviceType == 'Field') && | 1057 _serviceType == 'Field') && |
1056 !_id.startsWith(objectIdRingPrefix); | 1058 !_id.startsWith(objectIdRingPrefix); |
1057 } | 1059 } |
1058 bool get immutable => false; | 1060 bool get immutable => false; |
1059 | 1061 |
1060 ServiceMap._empty(ServiceObjectOwner owner) : super._empty(owner); | 1062 ServiceMap._empty(ServiceObjectOwner owner) : super._empty(owner); |
1061 | 1063 |
1062 String toString() => _map.toString(); | |
1063 | |
1064 void _upgradeValues() { | 1064 void _upgradeValues() { |
1065 assert(owner != null); | 1065 assert(owner != null); |
1066 _upgradeCollection(_map, owner); | 1066 _upgradeCollection(_map, owner); |
1067 } | 1067 } |
1068 | 1068 |
1069 void _update(ObservableMap map, bool mapIsRef) { | 1069 void _update(ObservableMap map, bool mapIsRef) { |
1070 _loaded = !mapIsRef; | 1070 _loaded = !mapIsRef; |
1071 | 1071 |
1072 // TODO(turnidge): Currently _map.clear() prevents us from | 1072 // TODO(turnidge): Currently _map.clear() prevents us from |
1073 // upgrading an already upgraded submap. Is clearing really the | 1073 // upgrading an already upgraded submap. Is clearing really the |
(...skipping 24 matching lines...) Expand all Loading... |
1098 | 1098 |
1099 // Forward ChangeNotifier interface calls. | 1099 // Forward ChangeNotifier interface calls. |
1100 bool deliverChanges() => _map.deliverChanges(); | 1100 bool deliverChanges() => _map.deliverChanges(); |
1101 void notifyChange(ChangeRecord record) => _map.notifyChange(record); | 1101 void notifyChange(ChangeRecord record) => _map.notifyChange(record); |
1102 notifyPropertyChange(Symbol field, Object oldValue, Object newValue) => | 1102 notifyPropertyChange(Symbol field, Object oldValue, Object newValue) => |
1103 _map.notifyPropertyChange(field, oldValue, newValue); | 1103 _map.notifyPropertyChange(field, oldValue, newValue); |
1104 void observed() => _map.observed(); | 1104 void observed() => _map.observed(); |
1105 void unobserved() => _map.unobserved(); | 1105 void unobserved() => _map.unobserved(); |
1106 Stream<List<ChangeRecord>> get changes => _map.changes; | 1106 Stream<List<ChangeRecord>> get changes => _map.changes; |
1107 bool get hasObservers => _map.hasObservers; | 1107 bool get hasObservers => _map.hasObservers; |
| 1108 |
| 1109 String toString() => "ServiceMap($_map)"; |
1108 } | 1110 } |
1109 | 1111 |
1110 /// A [DartError] is peered to a Dart Error object. | 1112 /// A [DartError] is peered to a Dart Error object. |
1111 class DartError extends ServiceObject { | 1113 class DartError extends ServiceObject { |
1112 DartError._empty(ServiceObject owner) : super._empty(owner); | 1114 DartError._empty(ServiceObject owner) : super._empty(owner); |
1113 | 1115 |
1114 @observable String kind; | 1116 @observable String kind; |
1115 @observable String message; | 1117 @observable String message; |
1116 @observable ServiceMap exception; | 1118 @observable ServiceMap exception; |
1117 @observable ServiceMap stacktrace; | 1119 @observable ServiceMap stacktrace; |
1118 | 1120 |
1119 void _update(ObservableMap map, bool mapIsRef) { | 1121 void _update(ObservableMap map, bool mapIsRef) { |
1120 kind = map['kind']; | 1122 kind = map['kind']; |
1121 message = map['message']; | 1123 message = map['message']; |
1122 exception = new ServiceObject._fromMap(owner, map['exception']); | 1124 exception = new ServiceObject._fromMap(owner, map['exception']); |
1123 stacktrace = new ServiceObject._fromMap(owner, map['stacktrace']); | 1125 stacktrace = new ServiceObject._fromMap(owner, map['stacktrace']); |
1124 name = 'DartError $kind'; | 1126 name = 'DartError $kind'; |
1125 vmName = name; | 1127 vmName = name; |
1126 } | 1128 } |
| 1129 |
| 1130 String toString() => 'DartError($message)'; |
1127 } | 1131 } |
1128 | 1132 |
1129 /// A [ServiceError] is an error that was triggered in the service | 1133 /// A [ServiceError] is an error that was triggered in the service |
1130 /// server or client. Errors are prorammer mistakes that could have | 1134 /// server or client. Errors are prorammer mistakes that could have |
1131 /// been prevented, for example, requesting a non-existant path over the | 1135 /// been prevented, for example, requesting a non-existant path over the |
1132 /// service. | 1136 /// service. |
1133 class ServiceError extends ServiceObject { | 1137 class ServiceError extends ServiceObject { |
1134 ServiceError._empty(ServiceObjectOwner owner) : super._empty(owner); | 1138 ServiceError._empty(ServiceObjectOwner owner) : super._empty(owner); |
1135 | 1139 |
1136 @observable String kind; | 1140 @observable String kind; |
1137 @observable String message; | 1141 @observable String message; |
1138 | 1142 |
1139 void _update(ObservableMap map, bool mapIsRef) { | 1143 void _update(ObservableMap map, bool mapIsRef) { |
1140 _loaded = true; | 1144 _loaded = true; |
1141 kind = map['kind']; | 1145 kind = map['kind']; |
1142 message = map['message']; | 1146 message = map['message']; |
1143 name = 'ServiceError $kind'; | 1147 name = 'ServiceError $kind'; |
1144 vmName = name; | 1148 vmName = name; |
1145 } | 1149 } |
| 1150 |
| 1151 String toString() => 'ServiceError($message)'; |
1146 } | 1152 } |
1147 | 1153 |
1148 /// A [ServiceException] is an exception that was triggered in the service | 1154 /// A [ServiceException] is an exception that was triggered in the service |
1149 /// server or client. Exceptions are events that should be handled, | 1155 /// server or client. Exceptions are events that should be handled, |
1150 /// for example, an isolate went away or the connection to the VM was lost. | 1156 /// for example, an isolate went away or the connection to the VM was lost. |
1151 class ServiceException extends ServiceObject { | 1157 class ServiceException extends ServiceObject { |
1152 ServiceException._empty(ServiceObject owner) : super._empty(owner); | 1158 ServiceException._empty(ServiceObject owner) : super._empty(owner); |
1153 | 1159 |
1154 @observable String kind; | 1160 @observable String kind; |
1155 @observable String message; | 1161 @observable String message; |
(...skipping 26 matching lines...) Expand all Loading... |
1182 if (map['breakpoint'] != null) { | 1188 if (map['breakpoint'] != null) { |
1183 breakpoint = map['breakpoint']; | 1189 breakpoint = map['breakpoint']; |
1184 } | 1190 } |
1185 if (map['exception'] != null) { | 1191 if (map['exception'] != null) { |
1186 exception = map['exception']; | 1192 exception = map['exception']; |
1187 } | 1193 } |
1188 if (map['_data'] != null) { | 1194 if (map['_data'] != null) { |
1189 data = map['_data']; | 1195 data = map['_data']; |
1190 } | 1196 } |
1191 } | 1197 } |
1192 | 1198 |
1193 String toString() { | 1199 String toString() { |
1194 return 'ServiceEvent of type $eventType with ' | 1200 return 'ServiceEvent of type $eventType with ' |
1195 '${data == null ? 0 : data.lengthInBytes} bytes of binary data'; | 1201 '${data == null ? 0 : data.lengthInBytes} bytes of binary data'; |
1196 } | 1202 } |
1197 } | 1203 } |
1198 | 1204 |
1199 class Library extends ServiceObject with Coverage { | 1205 class Library extends ServiceObject with Coverage { |
1200 @observable String url; | 1206 @observable String url; |
1201 @reflectable final imports = new ObservableList<Library>(); | 1207 @reflectable final imports = new ObservableList<Library>(); |
1202 @reflectable final scripts = new ObservableList<Script>(); | 1208 @reflectable final scripts = new ObservableList<Script>(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 classes.clear(); | 1240 classes.clear(); |
1235 classes.addAll(map['classes']); | 1241 classes.addAll(map['classes']); |
1236 classes.sort(ServiceObject.LexicalSortName); | 1242 classes.sort(ServiceObject.LexicalSortName); |
1237 variables.clear(); | 1243 variables.clear(); |
1238 variables.addAll(map['variables']); | 1244 variables.addAll(map['variables']); |
1239 variables.sort(ServiceObject.LexicalSortName); | 1245 variables.sort(ServiceObject.LexicalSortName); |
1240 functions.clear(); | 1246 functions.clear(); |
1241 functions.addAll(map['functions']); | 1247 functions.addAll(map['functions']); |
1242 functions.sort(ServiceObject.LexicalSortName); | 1248 functions.sort(ServiceObject.LexicalSortName); |
1243 } | 1249 } |
| 1250 |
| 1251 String toString() => "Library($url)"; |
1244 } | 1252 } |
1245 | 1253 |
1246 class AllocationCount extends Observable { | 1254 class AllocationCount extends Observable { |
1247 @observable int instances = 0; | 1255 @observable int instances = 0; |
1248 @observable int bytes = 0; | 1256 @observable int bytes = 0; |
1249 | 1257 |
1250 void reset() { | 1258 void reset() { |
1251 instances = 0; | 1259 instances = 0; |
1252 bytes = 0; | 1260 bytes = 0; |
1253 } | 1261 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 | 1313 |
1306 @observable Class superclass; | 1314 @observable Class superclass; |
1307 @reflectable final interfaces = new ObservableList<Class>(); | 1315 @reflectable final interfaces = new ObservableList<Class>(); |
1308 @reflectable final subclasses = new ObservableList<Class>(); | 1316 @reflectable final subclasses = new ObservableList<Class>(); |
1309 | 1317 |
1310 bool get canCache => true; | 1318 bool get canCache => true; |
1311 bool get immutable => false; | 1319 bool get immutable => false; |
1312 | 1320 |
1313 Class._empty(ServiceObjectOwner owner) : super._empty(owner); | 1321 Class._empty(ServiceObjectOwner owner) : super._empty(owner); |
1314 | 1322 |
1315 String toString() { | |
1316 return 'Service Class: $vmName'; | |
1317 } | |
1318 | |
1319 void _update(ObservableMap map, bool mapIsRef) { | 1323 void _update(ObservableMap map, bool mapIsRef) { |
1320 name = map['name']; | 1324 name = map['name']; |
1321 vmName = (map.containsKey('vmName') ? map['vmName'] : name); | 1325 vmName = (map.containsKey('vmName') ? map['vmName'] : name); |
1322 | 1326 |
1323 if (mapIsRef) { | 1327 if (mapIsRef) { |
1324 return; | 1328 return; |
1325 } | 1329 } |
1326 | 1330 |
1327 // We are fully loaded. | 1331 // We are fully loaded. |
1328 _loaded = true; | 1332 _loaded = true; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 if (subclasses.contains(subclass)) { | 1384 if (subclasses.contains(subclass)) { |
1381 return; | 1385 return; |
1382 } | 1386 } |
1383 subclasses.add(subclass); | 1387 subclasses.add(subclass); |
1384 subclasses.sort(ServiceObject.LexicalSortName); | 1388 subclasses.sort(ServiceObject.LexicalSortName); |
1385 } | 1389 } |
1386 | 1390 |
1387 Future<ServiceObject> get(String command) { | 1391 Future<ServiceObject> get(String command) { |
1388 return isolate.get(id + "/$command"); | 1392 return isolate.get(id + "/$command"); |
1389 } | 1393 } |
| 1394 |
| 1395 String toString() => 'Class($vmName)'; |
1390 } | 1396 } |
1391 | 1397 |
1392 // TODO(koda): Sync this with VM. | 1398 // TODO(koda): Sync this with VM. |
1393 class FunctionKind { | 1399 class FunctionKind { |
1394 final String _strValue; | 1400 final String _strValue; |
1395 FunctionKind._internal(this._strValue); | 1401 FunctionKind._internal(this._strValue); |
1396 toString() => _strValue; | 1402 toString() => _strValue; |
1397 bool isFake() => [kCollected, kNative, kTag, kReused].contains(this); | 1403 bool isFake() => [kCollected, kNative, kTag, kReused].contains(this); |
1398 | 1404 |
1399 static FunctionKind fromJSON(String value) { | 1405 static FunctionKind fromJSON(String value) { |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2262 var v = list[i]; | 2268 var v = list[i]; |
2263 if ((v is ObservableMap) && _isServiceMap(v)) { | 2269 if ((v is ObservableMap) && _isServiceMap(v)) { |
2264 list[i] = owner.getFromMap(v); | 2270 list[i] = owner.getFromMap(v); |
2265 } else if (v is ObservableList) { | 2271 } else if (v is ObservableList) { |
2266 _upgradeObservableList(v, owner); | 2272 _upgradeObservableList(v, owner); |
2267 } else if (v is ObservableMap) { | 2273 } else if (v is ObservableMap) { |
2268 _upgradeObservableMap(v, owner); | 2274 _upgradeObservableMap(v, owner); |
2269 } | 2275 } |
2270 } | 2276 } |
2271 } | 2277 } |
OLD | NEW |