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)"; | |
koda
2014/08/21 18:21:20
Thanks for adding these; I've missed them in the p
| |
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 30 matching lines...) Expand all Loading... | |
1233 classes.clear(); | 1239 classes.clear(); |
1234 classes.addAll(map['classes']); | 1240 classes.addAll(map['classes']); |
1235 classes.sort(ServiceObject.LexicalSortName); | 1241 classes.sort(ServiceObject.LexicalSortName); |
1236 variables.clear(); | 1242 variables.clear(); |
1237 variables.addAll(map['variables']); | 1243 variables.addAll(map['variables']); |
1238 variables.sort(ServiceObject.LexicalSortName); | 1244 variables.sort(ServiceObject.LexicalSortName); |
1239 functions.clear(); | 1245 functions.clear(); |
1240 functions.addAll(map['functions']); | 1246 functions.addAll(map['functions']); |
1241 functions.sort(ServiceObject.LexicalSortName); | 1247 functions.sort(ServiceObject.LexicalSortName); |
1242 } | 1248 } |
1249 | |
1250 String toString() => "Library($url)"; | |
1243 } | 1251 } |
1244 | 1252 |
1245 class AllocationCount extends Observable { | 1253 class AllocationCount extends Observable { |
1246 @observable int instances = 0; | 1254 @observable int instances = 0; |
1247 @observable int bytes = 0; | 1255 @observable int bytes = 0; |
1248 | 1256 |
1249 void reset() { | 1257 void reset() { |
1250 instances = 0; | 1258 instances = 0; |
1251 bytes = 0; | 1259 bytes = 0; |
1252 } | 1260 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1303 @reflectable final subClasses = new ObservableList<Class>(); | 1311 @reflectable final subClasses = new ObservableList<Class>(); |
1304 @reflectable final fields = new ObservableList<ServiceMap>(); | 1312 @reflectable final fields = new ObservableList<ServiceMap>(); |
1305 @reflectable final functions = new ObservableList<ServiceFunction>(); | 1313 @reflectable final functions = new ObservableList<ServiceFunction>(); |
1306 @reflectable final interfaces = new ObservableList<Class>(); | 1314 @reflectable final interfaces = new ObservableList<Class>(); |
1307 | 1315 |
1308 bool get canCache => true; | 1316 bool get canCache => true; |
1309 bool get immutable => false; | 1317 bool get immutable => false; |
1310 | 1318 |
1311 Class._empty(ServiceObjectOwner owner) : super._empty(owner); | 1319 Class._empty(ServiceObjectOwner owner) : super._empty(owner); |
1312 | 1320 |
1313 String toString() { | |
1314 return 'Service Class: $vmName'; | |
1315 } | |
1316 | |
1317 void _update(ObservableMap map, bool mapIsRef) { | 1321 void _update(ObservableMap map, bool mapIsRef) { |
1318 name = map['user_name']; | 1322 name = map['user_name']; |
1319 vmName = map['name']; | 1323 vmName = map['name']; |
1320 | 1324 |
1321 if (mapIsRef) { | 1325 if (mapIsRef) { |
1322 return; | 1326 return; |
1323 } | 1327 } |
1324 | 1328 |
1325 // We are fully loaded. | 1329 // We are fully loaded. |
1326 _loaded = true; | 1330 _loaded = true; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1374 void _addToChildren(Class cls) { | 1378 void _addToChildren(Class cls) { |
1375 if (children.contains(cls)) { | 1379 if (children.contains(cls)) { |
1376 return; | 1380 return; |
1377 } | 1381 } |
1378 children.add(cls); | 1382 children.add(cls); |
1379 } | 1383 } |
1380 | 1384 |
1381 Future<ServiceObject> get(String command) { | 1385 Future<ServiceObject> get(String command) { |
1382 return isolate.get(id + "/$command"); | 1386 return isolate.get(id + "/$command"); |
1383 } | 1387 } |
1388 | |
1389 String toString() => 'Class($vmName)'; | |
1384 } | 1390 } |
1385 | 1391 |
1386 // TODO(koda): Sync this with VM. | 1392 // TODO(koda): Sync this with VM. |
1387 class FunctionKind { | 1393 class FunctionKind { |
1388 final String _strValue; | 1394 final String _strValue; |
1389 FunctionKind._internal(this._strValue); | 1395 FunctionKind._internal(this._strValue); |
1390 toString() => _strValue; | 1396 toString() => _strValue; |
1391 bool isFake() => [kCollected, kNative, kTag, kReused].contains(this); | 1397 bool isFake() => [kCollected, kNative, kTag, kReused].contains(this); |
1392 | 1398 |
1393 static FunctionKind fromJSON(String value) { | 1399 static FunctionKind fromJSON(String value) { |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2256 var v = list[i]; | 2262 var v = list[i]; |
2257 if ((v is ObservableMap) && _isServiceMap(v)) { | 2263 if ((v is ObservableMap) && _isServiceMap(v)) { |
2258 list[i] = owner.getFromMap(v); | 2264 list[i] = owner.getFromMap(v); |
2259 } else if (v is ObservableList) { | 2265 } else if (v is ObservableList) { |
2260 _upgradeObservableList(v, owner); | 2266 _upgradeObservableList(v, owner); |
2261 } else if (v is ObservableMap) { | 2267 } else if (v is ObservableMap) { |
2262 _upgradeObservableMap(v, owner); | 2268 _upgradeObservableMap(v, owner); |
2263 } | 2269 } |
2264 } | 2270 } |
2265 } | 2271 } |
OLD | NEW |