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 /// An RpcException represents an exceptional event that happened | 7 /// An RpcException represents an exceptional event that happened |
8 /// while invoking an rpc. | 8 /// while invoking an rpc. |
9 abstract class RpcException implements Exception { | 9 abstract class RpcException implements Exception { |
10 RpcException(this.message); | 10 RpcException(this.message); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 bool get isPlainInstance => false; | 124 bool get isPlainInstance => false; |
125 | 125 |
126 /// Has this object been fully loaded? | 126 /// Has this object been fully loaded? |
127 bool get loaded => _loaded; | 127 bool get loaded => _loaded; |
128 bool _loaded = false; | 128 bool _loaded = false; |
129 // TODO(turnidge): Make loaded observable and get rid of loading | 129 // TODO(turnidge): Make loaded observable and get rid of loading |
130 // from Isolate. | 130 // from Isolate. |
131 | 131 |
132 /// Is this object cacheable? That is, is it impossible for the [id] | 132 /// Is this object cacheable? That is, is it impossible for the [id] |
133 /// of this object to change? | 133 /// of this object to change? |
134 bool get canCache => false; | 134 bool _canCache; |
| 135 bool get canCache => _canCache; |
135 | 136 |
136 /// Is this object immutable after it is [loaded]? | 137 /// Is this object immutable after it is [loaded]? |
137 bool get immutable => false; | 138 bool get immutable => false; |
138 | 139 |
139 @observable String name; | 140 @observable String name; |
140 @observable String vmName; | 141 @observable String vmName; |
141 | 142 |
142 /// Creates an empty [ServiceObject]. | 143 /// Creates an empty [ServiceObject]. |
143 ServiceObject._empty(this._owner); | 144 ServiceObject._empty(this._owner); |
144 | 145 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 298 |
298 /// Update [this] using [map] as a source. [map] can be a reference. | 299 /// Update [this] using [map] as a source. [map] can be a reference. |
299 void update(ObservableMap map) { | 300 void update(ObservableMap map) { |
300 assert(_isServiceMap(map)); | 301 assert(_isServiceMap(map)); |
301 | 302 |
302 // Don't allow the type to change on an object update. | 303 // Don't allow the type to change on an object update. |
303 var mapIsRef = _hasRef(map['type']); | 304 var mapIsRef = _hasRef(map['type']); |
304 var mapType = _stripRef(map['type']); | 305 var mapType = _stripRef(map['type']); |
305 assert(_type == null || _type == mapType); | 306 assert(_type == null || _type == mapType); |
306 | 307 |
| 308 _canCache = map['fixedId'] == true; |
307 if (_id != null && _id != map['id']) { | 309 if (_id != null && _id != map['id']) { |
308 // It is only safe to change an id when the object isn't cacheable. | 310 // It is only safe to change an id when the object isn't cacheable. |
309 assert(!canCache); | 311 assert(!canCache); |
310 } | 312 } |
311 _id = map['id']; | 313 _id = map['id']; |
312 | 314 |
313 _type = mapType; | 315 _type = mapType; |
314 | 316 |
315 // When the response specifies a specific vmType, use it. | 317 // When the response specifies a specific vmType, use it. |
316 // Otherwise the vmType of the response is the same as the 'user' | 318 // Otherwise the vmType of the response is the same as the 'user' |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 timers['compile'] = timerMap['time_compilation']; | 1103 timers['compile'] = timerMap['time_compilation']; |
1102 timers['gc'] = 0.0; // TODO(turnidge): Export this from VM. | 1104 timers['gc'] = 0.0; // TODO(turnidge): Export this from VM. |
1103 timers['init'] = (timerMap['time_script_loading'] + | 1105 timers['init'] = (timerMap['time_script_loading'] + |
1104 timerMap['time_creating_snapshot'] + | 1106 timerMap['time_creating_snapshot'] + |
1105 timerMap['time_isolate_initialization'] + | 1107 timerMap['time_isolate_initialization'] + |
1106 timerMap['time_bootstrap']); | 1108 timerMap['time_bootstrap']); |
1107 timers['dart'] = timerMap['time_dart_execution']; | 1109 timers['dart'] = timerMap['time_dart_execution']; |
1108 | 1110 |
1109 updateHeapsFromMap(map['_heaps']); | 1111 updateHeapsFromMap(map['_heaps']); |
1110 _updateBreakpoints(map['breakpoints']); | 1112 _updateBreakpoints(map['breakpoints']); |
| 1113 exceptionsPauseInfo = map['_debuggerSettings']['_exceptions']; |
1111 | 1114 |
1112 pauseEvent = map['pauseEvent']; | 1115 pauseEvent = map['pauseEvent']; |
1113 _updateRunState(); | 1116 _updateRunState(); |
1114 error = map['error']; | 1117 error = map['error']; |
1115 | 1118 |
1116 libraries.clear(); | 1119 libraries.clear(); |
1117 libraries.addAll(map['libraries']); | 1120 libraries.addAll(map['libraries']); |
1118 libraries.sort(ServiceObject.LexicalSortName); | 1121 libraries.sort(ServiceObject.LexicalSortName); |
1119 } | 1122 } |
1120 | 1123 |
1121 Future<TagProfile> updateTagProfile() { | 1124 Future<TagProfile> updateTagProfile() { |
1122 return isolate.invokeRpcNoUpgrade('_getTagProfile', {}).then( | 1125 return isolate.invokeRpcNoUpgrade('_getTagProfile', {}).then( |
1123 (ObservableMap map) { | 1126 (ObservableMap map) { |
1124 var seconds = new DateTime.now().millisecondsSinceEpoch / 1000.0; | 1127 var seconds = new DateTime.now().millisecondsSinceEpoch / 1000.0; |
1125 tagProfile._processTagProfile(seconds, map); | 1128 tagProfile._processTagProfile(seconds, map); |
1126 return tagProfile; | 1129 return tagProfile; |
1127 }); | 1130 }); |
1128 } | 1131 } |
1129 | 1132 |
1130 ObservableMap<int, Breakpoint> breakpoints = new ObservableMap(); | 1133 ObservableMap<int, Breakpoint> breakpoints = new ObservableMap(); |
| 1134 String exceptionsPauseInfo; |
1131 | 1135 |
1132 void _updateBreakpoints(List newBpts) { | 1136 void _updateBreakpoints(List newBpts) { |
1133 // Build a set of new breakpoints. | 1137 // Build a set of new breakpoints. |
1134 var newBptSet = new Set(); | 1138 var newBptSet = new Set(); |
1135 newBpts.forEach((bpt) => newBptSet.add(bpt.number)); | 1139 newBpts.forEach((bpt) => newBptSet.add(bpt.number)); |
1136 | 1140 |
1137 // Remove any old breakpoints which no longer exist. | 1141 // Remove any old breakpoints which no longer exist. |
1138 List toRemove = []; | 1142 List toRemove = []; |
1139 breakpoints.forEach((key, _) { | 1143 breakpoints.forEach((key, _) { |
1140 if (!newBptSet.contains(key)) { | 1144 if (!newBptSet.contains(key)) { |
(...skipping 22 matching lines...) Expand all Loading... |
1163 case ServiceEvent.kInspect: | 1167 case ServiceEvent.kInspect: |
1164 // Handled elsewhere. | 1168 // Handled elsewhere. |
1165 break; | 1169 break; |
1166 | 1170 |
1167 case ServiceEvent.kBreakpointAdded: | 1171 case ServiceEvent.kBreakpointAdded: |
1168 _addBreakpoint(event.breakpoint); | 1172 _addBreakpoint(event.breakpoint); |
1169 break; | 1173 break; |
1170 | 1174 |
1171 case ServiceEvent.kIsolateUpdate: | 1175 case ServiceEvent.kIsolateUpdate: |
1172 case ServiceEvent.kBreakpointResolved: | 1176 case ServiceEvent.kBreakpointResolved: |
| 1177 case ServiceEvent.kDebuggerSettingsUpdate: |
1173 // Update occurs as side-effect of caching. | 1178 // Update occurs as side-effect of caching. |
1174 break; | 1179 break; |
1175 | 1180 |
1176 case ServiceEvent.kBreakpointRemoved: | 1181 case ServiceEvent.kBreakpointRemoved: |
1177 _removeBreakpoint(event.breakpoint); | 1182 _removeBreakpoint(event.breakpoint); |
1178 break; | 1183 break; |
1179 | 1184 |
1180 case ServiceEvent.kPauseStart: | 1185 case ServiceEvent.kPauseStart: |
1181 case ServiceEvent.kPauseExit: | 1186 case ServiceEvent.kPauseExit: |
1182 case ServiceEvent.kPauseBreakpoint: | 1187 case ServiceEvent.kPauseBreakpoint: |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1258 } | 1263 } |
1259 | 1264 |
1260 Future stepOut() { | 1265 Future stepOut() { |
1261 return invokeRpc('resume', {'step': 'Out'}); | 1266 return invokeRpc('resume', {'step': 'Out'}); |
1262 } | 1267 } |
1263 | 1268 |
1264 Future setName(String newName) { | 1269 Future setName(String newName) { |
1265 return invokeRpc('setName', {'name': newName}); | 1270 return invokeRpc('setName', {'name': newName}); |
1266 } | 1271 } |
1267 | 1272 |
| 1273 Future setExceptionPauseInfo(String exceptions) { |
| 1274 return invokeRpc('_setExceptionPauseInfo', {'exceptions': exceptions}); |
| 1275 } |
| 1276 |
1268 Future<ServiceMap> getStack() { | 1277 Future<ServiceMap> getStack() { |
1269 return invokeRpc('getStack', {}); | 1278 return invokeRpc('getStack', {}); |
1270 } | 1279 } |
1271 | 1280 |
1272 Future<ServiceObject> _eval(ServiceObject target, | 1281 Future<ServiceObject> _eval(ServiceObject target, |
1273 String expression) { | 1282 String expression) { |
1274 Map params = { | 1283 Map params = { |
1275 'targetId': target.id, | 1284 'targetId': target.id, |
1276 'expression': expression, | 1285 'expression': expression, |
1277 }; | 1286 }; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1448 name = 'DartError($message)'; | 1457 name = 'DartError($message)'; |
1449 vmName = name; | 1458 vmName = name; |
1450 } | 1459 } |
1451 | 1460 |
1452 String toString() => 'DartError($message)'; | 1461 String toString() => 'DartError($message)'; |
1453 } | 1462 } |
1454 | 1463 |
1455 /// A [ServiceEvent] is an asynchronous event notification from the vm. | 1464 /// A [ServiceEvent] is an asynchronous event notification from the vm. |
1456 class ServiceEvent extends ServiceObject { | 1465 class ServiceEvent extends ServiceObject { |
1457 /// The possible 'kind' values. | 1466 /// The possible 'kind' values. |
1458 static const kIsolateStart = 'IsolateStart'; | 1467 static const kIsolateStart = 'IsolateStart'; |
1459 static const kIsolateExit = 'IsolateExit'; | 1468 static const kIsolateExit = 'IsolateExit'; |
1460 static const kIsolateUpdate = 'IsolateUpdate'; | 1469 static const kIsolateUpdate = 'IsolateUpdate'; |
1461 static const kPauseStart = 'PauseStart'; | 1470 static const kPauseStart = 'PauseStart'; |
1462 static const kPauseExit = 'PauseExit'; | 1471 static const kPauseExit = 'PauseExit'; |
1463 static const kPauseBreakpoint = 'PauseBreakpoint'; | 1472 static const kPauseBreakpoint = 'PauseBreakpoint'; |
1464 static const kPauseInterrupted = 'PauseInterrupted'; | 1473 static const kPauseInterrupted = 'PauseInterrupted'; |
1465 static const kPauseException = 'PauseException'; | 1474 static const kPauseException = 'PauseException'; |
1466 static const kResume = 'Resume'; | 1475 static const kResume = 'Resume'; |
1467 static const kBreakpointAdded = 'BreakpointAdded'; | 1476 static const kBreakpointAdded = 'BreakpointAdded'; |
1468 static const kBreakpointResolved = 'BreakpointResolved'; | 1477 static const kBreakpointResolved = 'BreakpointResolved'; |
1469 static const kBreakpointRemoved = 'BreakpointRemoved'; | 1478 static const kBreakpointRemoved = 'BreakpointRemoved'; |
1470 static const kGraph = '_Graph'; | 1479 static const kGraph = '_Graph'; |
1471 static const kGC = 'GC'; | 1480 static const kGC = 'GC'; |
1472 static const kInspect = 'Inspect'; | 1481 static const kInspect = 'Inspect'; |
1473 static const kConnectionClosed = 'ConnectionClosed'; | 1482 static const kDebuggerSettingsUpdate = '_DebuggerSettingsUpdate'; |
| 1483 static const kConnectionClosed = 'ConnectionClosed'; |
1474 | 1484 |
1475 ServiceEvent._empty(ServiceObjectOwner owner) : super._empty(owner); | 1485 ServiceEvent._empty(ServiceObjectOwner owner) : super._empty(owner); |
1476 | 1486 |
1477 ServiceEvent.connectionClosed(this.reason) : super._empty(null) { | 1487 ServiceEvent.connectionClosed(this.reason) : super._empty(null) { |
1478 kind = kConnectionClosed; | 1488 kind = kConnectionClosed; |
1479 } | 1489 } |
1480 | 1490 |
1481 @observable String kind; | 1491 @observable String kind; |
1482 @observable Breakpoint breakpoint; | 1492 @observable Breakpoint breakpoint; |
1483 @observable Frame topFrame; | 1493 @observable Frame topFrame; |
1484 @observable ServiceMap exception; | 1494 @observable Instance exception; |
1485 @observable ServiceObject inspectee; | 1495 @observable ServiceObject inspectee; |
1486 @observable ByteData data; | 1496 @observable ByteData data; |
1487 @observable int count; | 1497 @observable int count; |
1488 @observable String reason; | 1498 @observable String reason; |
| 1499 @observable String exceptions; |
1489 int chunkIndex, chunkCount, nodeCount; | 1500 int chunkIndex, chunkCount, nodeCount; |
1490 | 1501 |
1491 @observable bool get isPauseEvent { | 1502 @observable bool get isPauseEvent { |
1492 return (kind == kPauseStart || | 1503 return (kind == kPauseStart || |
1493 kind == kPauseExit || | 1504 kind == kPauseExit || |
1494 kind == kPauseBreakpoint || | 1505 kind == kPauseBreakpoint || |
1495 kind == kPauseInterrupted || | 1506 kind == kPauseInterrupted || |
1496 kind == kPauseException); | 1507 kind == kPauseException); |
1497 } | 1508 } |
1498 | 1509 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1530 } | 1541 } |
1531 if (map['chunkCount'] != null) { | 1542 if (map['chunkCount'] != null) { |
1532 chunkCount = map['chunkCount']; | 1543 chunkCount = map['chunkCount']; |
1533 } | 1544 } |
1534 if (map['nodeCount'] != null) { | 1545 if (map['nodeCount'] != null) { |
1535 nodeCount = map['nodeCount']; | 1546 nodeCount = map['nodeCount']; |
1536 } | 1547 } |
1537 if (map['count'] != null) { | 1548 if (map['count'] != null) { |
1538 count = map['count']; | 1549 count = map['count']; |
1539 } | 1550 } |
| 1551 if (map['_debuggerSettings'] != null && |
| 1552 map['_debuggerSettings']['_exceptions'] != null) { |
| 1553 exceptions = map['_debuggerSettings']['_exceptions']; |
| 1554 } |
1540 } | 1555 } |
1541 | 1556 |
1542 String toString() { | 1557 String toString() { |
1543 if (data == null) { | 1558 if (data == null) { |
1544 return "ServiceEvent(owner='${owner.id}', kind='${kind}')"; | 1559 return "ServiceEvent(owner='${owner.id}', kind='${kind}')"; |
1545 } else { | 1560 } else { |
1546 return "ServiceEvent(owner='${owner.id}', kind='${kind}', " | 1561 return "ServiceEvent(owner='${owner.id}', kind='${kind}', " |
1547 "data.lengthInBytes=${data.lengthInBytes})"; | 1562 "data.lengthInBytes=${data.lengthInBytes})"; |
1548 } | 1563 } |
1549 } | 1564 } |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2084 @observable Code unoptimizedCode; | 2099 @observable Code unoptimizedCode; |
2085 @observable bool isOptimizable; | 2100 @observable bool isOptimizable; |
2086 @observable bool isInlinable; | 2101 @observable bool isInlinable; |
2087 @observable FunctionKind kind; | 2102 @observable FunctionKind kind; |
2088 @observable int deoptimizations; | 2103 @observable int deoptimizations; |
2089 @observable String qualifiedName; | 2104 @observable String qualifiedName; |
2090 @observable int usageCounter; | 2105 @observable int usageCounter; |
2091 @observable bool isDart; | 2106 @observable bool isDart; |
2092 @observable ProfileFunction profile; | 2107 @observable ProfileFunction profile; |
2093 | 2108 |
2094 bool get canCache => true; | |
2095 bool get immutable => false; | 2109 bool get immutable => false; |
2096 | 2110 |
2097 ServiceFunction._empty(ServiceObject owner) : super._empty(owner); | 2111 ServiceFunction._empty(ServiceObject owner) : super._empty(owner); |
2098 | 2112 |
2099 void _update(ObservableMap map, bool mapIsRef) { | 2113 void _update(ObservableMap map, bool mapIsRef) { |
2100 name = map['name']; | 2114 name = map['name']; |
2101 vmName = (map.containsKey('vmName') ? map['vmName'] : name); | 2115 vmName = (map.containsKey('vmName') ? map['vmName'] : name); |
2102 | 2116 |
2103 _upgradeCollection(map, isolate); | 2117 _upgradeCollection(map, isolate); |
2104 | 2118 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2337 Set<CallSite> callSites = new Set<CallSite>(); | 2351 Set<CallSite> callSites = new Set<CallSite>(); |
2338 final lines = new ObservableList<ScriptLine>(); | 2352 final lines = new ObservableList<ScriptLine>(); |
2339 final _hits = new Map<int, int>(); | 2353 final _hits = new Map<int, int>(); |
2340 @observable String uri; | 2354 @observable String uri; |
2341 @observable String kind; | 2355 @observable String kind; |
2342 @observable int firstTokenPos; | 2356 @observable int firstTokenPos; |
2343 @observable int lastTokenPos; | 2357 @observable int lastTokenPos; |
2344 @observable int lineOffset; | 2358 @observable int lineOffset; |
2345 @observable int columnOffset; | 2359 @observable int columnOffset; |
2346 @observable Library library; | 2360 @observable Library library; |
2347 bool get canCache => true; | 2361 |
2348 bool get immutable => true; | 2362 bool get immutable => true; |
2349 | 2363 |
2350 String _shortUri; | 2364 String _shortUri; |
2351 | 2365 |
2352 Script._empty(ServiceObjectOwner owner) : super._empty(owner); | 2366 Script._empty(ServiceObjectOwner owner) : super._empty(owner); |
2353 | 2367 |
2354 ScriptLine getLine(int line) { | 2368 ScriptLine getLine(int line) { |
2355 assert(_loaded); | 2369 assert(_loaded); |
2356 assert(line >= 1); | 2370 assert(line >= 1); |
2357 return lines[line - lineOffset - 1]; | 2371 return lines[line - lineOffset - 1]; |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2838 @observable Script script; | 2852 @observable Script script; |
2839 @observable bool isOptimized = false; | 2853 @observable bool isOptimized = false; |
2840 @reflectable int startAddress = 0; | 2854 @reflectable int startAddress = 0; |
2841 @reflectable int endAddress = 0; | 2855 @reflectable int endAddress = 0; |
2842 @reflectable final instructions = new ObservableList<CodeInstruction>(); | 2856 @reflectable final instructions = new ObservableList<CodeInstruction>(); |
2843 @observable ProfileCode profile; | 2857 @observable ProfileCode profile; |
2844 final List<CodeInlineInterval> inlineIntervals = | 2858 final List<CodeInlineInterval> inlineIntervals = |
2845 new List<CodeInlineInterval>(); | 2859 new List<CodeInlineInterval>(); |
2846 final ObservableList<ServiceFunction> inlinedFunctions = | 2860 final ObservableList<ServiceFunction> inlinedFunctions = |
2847 new ObservableList<ServiceFunction>(); | 2861 new ObservableList<ServiceFunction>(); |
2848 bool get canCache => true; | 2862 |
2849 bool get immutable => true; | 2863 bool get immutable => true; |
2850 | 2864 |
2851 Code._empty(ServiceObjectOwner owner) : super._empty(owner); | 2865 Code._empty(ServiceObjectOwner owner) : super._empty(owner); |
2852 | 2866 |
2853 void _updateDescriptors(Script script) { | 2867 void _updateDescriptors(Script script) { |
2854 this.script = script; | 2868 this.script = script; |
2855 for (var instruction in instructions) { | 2869 for (var instruction in instructions) { |
2856 for (var descriptor in instruction.descriptors) { | 2870 for (var descriptor in instruction.descriptors) { |
2857 descriptor.processScript(script); | 2871 descriptor.processScript(script); |
2858 } | 2872 } |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3247 void _update(ObservableMap map, bool mapIsRef) { | 3261 void _update(ObservableMap map, bool mapIsRef) { |
3248 assert(!mapIsRef); | 3262 assert(!mapIsRef); |
3249 _loaded = true; | 3263 _loaded = true; |
3250 _upgradeCollection(map, owner); | 3264 _upgradeCollection(map, owner); |
3251 this.index = map['index']; | 3265 this.index = map['index']; |
3252 this.function = map['function']; | 3266 this.function = map['function']; |
3253 this.location = map['location']; | 3267 this.location = map['location']; |
3254 this.code = map['code']; | 3268 this.code = map['code']; |
3255 this.variables = map['vars']; | 3269 this.variables = map['vars']; |
3256 } | 3270 } |
| 3271 |
| 3272 String toString() => "Frame(${function.qualifiedName})"; |
3257 } | 3273 } |
3258 | 3274 |
3259 | 3275 |
3260 class ServiceMessage extends ServiceObject { | 3276 class ServiceMessage extends ServiceObject { |
3261 @observable int index; | 3277 @observable int index; |
3262 @observable String messageObjectId; | 3278 @observable String messageObjectId; |
3263 @observable int size; | 3279 @observable int size; |
3264 @observable ServiceFunction handler; | 3280 @observable ServiceFunction handler; |
3265 @observable SourceLocation location; | 3281 @observable SourceLocation location; |
3266 | 3282 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3319 var v = list[i]; | 3335 var v = list[i]; |
3320 if ((v is ObservableMap) && _isServiceMap(v)) { | 3336 if ((v is ObservableMap) && _isServiceMap(v)) { |
3321 list[i] = owner.getFromMap(v); | 3337 list[i] = owner.getFromMap(v); |
3322 } else if (v is ObservableList) { | 3338 } else if (v is ObservableList) { |
3323 _upgradeObservableList(v, owner); | 3339 _upgradeObservableList(v, owner); |
3324 } else if (v is ObservableMap) { | 3340 } else if (v is ObservableMap) { |
3325 _upgradeObservableMap(v, owner); | 3341 _upgradeObservableMap(v, owner); |
3326 } | 3342 } |
3327 } | 3343 } |
3328 } | 3344 } |
OLD | NEW |