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

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

Issue 1965823002: Initial isolate reload support (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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 24 matching lines...) Expand all
35 static const kInvalidRequest = -32600; 35 static const kInvalidRequest = -32600;
36 static const kMethodNotFound = -32601; 36 static const kMethodNotFound = -32601;
37 static const kInvalidParams = -32602; 37 static const kInvalidParams = -32602;
38 static const kInternalError = -32603; 38 static const kInternalError = -32603;
39 static const kFeatureDisabled = 100; 39 static const kFeatureDisabled = 100;
40 static const kCannotAddBreakpoint = 102; 40 static const kCannotAddBreakpoint = 102;
41 static const kStreamAlreadySubscribed = 103; 41 static const kStreamAlreadySubscribed = 103;
42 static const kStreamNotSubscribed = 104; 42 static const kStreamNotSubscribed = 104;
43 static const kIsolateMustBeRunnable = 105; 43 static const kIsolateMustBeRunnable = 105;
44 static const kIsolateMustBePaused = 106; 44 static const kIsolateMustBePaused = 106;
45 static const kIsolateIsReloading = 107;
45 46
46 int code; 47 int code;
47 Map data; 48 Map data;
48 49
49 static _getMessage(Map errorMap) { 50 static _getMessage(Map errorMap) {
50 Map data = errorMap['data']; 51 Map data = errorMap['data'];
51 if (data != null && data['details'] != null) { 52 if (data != null && data['details'] != null) {
52 return data['details']; 53 return data['details'];
53 } else { 54 } else {
54 return errorMap['message']; 55 return errorMap['message'];
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 notifyPropertyChange(#idle, 0, 1); 1143 notifyPropertyChange(#idle, 0, 1);
1143 } 1144 }
1144 1145
1145 @observable ServiceEvent pauseEvent = null; 1146 @observable ServiceEvent pauseEvent = null;
1146 @observable bool paused = false; 1147 @observable bool paused = false;
1147 @observable bool running = false; 1148 @observable bool running = false;
1148 @observable bool idle = false; 1149 @observable bool idle = false;
1149 @observable bool loading = true; 1150 @observable bool loading = true;
1150 @observable bool runnable = false; 1151 @observable bool runnable = false;
1151 @observable bool ioEnabled = false; 1152 @observable bool ioEnabled = false;
1153 @observable bool reloading = false;
1152 1154
1153 final List<String> extensionRPCs = new List<String>(); 1155 final List<String> extensionRPCs = new List<String>();
1154 1156
1155 Map<String,ServiceObject> _cache = new Map<String,ServiceObject>(); 1157 Map<String,ServiceObject> _cache = new Map<String,ServiceObject>();
1156 final TagProfile tagProfile = new TagProfile(20); 1158 final TagProfile tagProfile = new TagProfile(20);
1157 1159
1158 Isolate._empty(ServiceObjectOwner owner) : super._empty(owner) { 1160 Isolate._empty(ServiceObjectOwner owner) : super._empty(owner) {
1159 assert(owner is VM); 1161 assert(owner is VM);
1160 } 1162 }
1161 1163
(...skipping 23 matching lines...) Expand all
1185 } 1187 }
1186 if (startPos != null) { 1188 if (startPos != null) {
1187 params['tokenPos'] = startPos; 1189 params['tokenPos'] = startPos;
1188 } 1190 }
1189 if (endPos != null) { 1191 if (endPos != null) {
1190 params['endTokenPos'] = endPos; 1192 params['endTokenPos'] = endPos;
1191 } 1193 }
1192 return invokeRpc('getSourceReport', params); 1194 return invokeRpc('getSourceReport', params);
1193 } 1195 }
1194 1196
1197 Future<ServiceMap> reloadSources() {
1198 return invokeRpc('_reloadSources', {}).then((_) {
1199 reloading = true;
1200 });
1201 }
1202
1203 void _handleIsolateReloadEvent(ServiceEvent event) {
1204 reloading = false;
1205 if (event.reloadError != null) {
1206 // Failure.
1207 print('Reload failed: ${event.reloadError}');
1208 } else {
1209 _cache.clear();
1210 }
1211 }
1212
1195 /// Fetches and builds the class hierarchy for this isolate. Returns the 1213 /// Fetches and builds the class hierarchy for this isolate. Returns the
1196 /// Object class object. 1214 /// Object class object.
1197 Future<Class> getClassHierarchy() { 1215 Future<Class> getClassHierarchy() {
1198 return invokeRpc('getClassList', {}) 1216 return invokeRpc('getClassList', {})
1199 .then(_loadClasses) 1217 .then(_loadClasses)
1200 .then(_buildClassHierarchy); 1218 .then(_buildClassHierarchy);
1201 } 1219 }
1202 1220
1203 Future<ServiceObject> getPorts() { 1221 Future<ServiceObject> getPorts() {
1204 return invokeRpc('_getPorts', {}); 1222 return invokeRpc('_getPorts', {});
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 } 1510 }
1493 1511
1494 void _onEvent(ServiceEvent event) { 1512 void _onEvent(ServiceEvent event) {
1495 switch(event.kind) { 1513 switch(event.kind) {
1496 case ServiceEvent.kIsolateStart: 1514 case ServiceEvent.kIsolateStart:
1497 case ServiceEvent.kIsolateRunnable: 1515 case ServiceEvent.kIsolateRunnable:
1498 case ServiceEvent.kIsolateExit: 1516 case ServiceEvent.kIsolateExit:
1499 case ServiceEvent.kInspect: 1517 case ServiceEvent.kInspect:
1500 // Handled elsewhere. 1518 // Handled elsewhere.
1501 break; 1519 break;
1502 1520 case ServiceEvent.kIsolateReload:
1521 _handleIsolateReloadEvent(event);
1522 break;
1503 case ServiceEvent.kBreakpointAdded: 1523 case ServiceEvent.kBreakpointAdded:
1504 _addBreakpoint(event.breakpoint); 1524 _addBreakpoint(event.breakpoint);
1505 break; 1525 break;
1506 1526
1507 case ServiceEvent.kIsolateUpdate: 1527 case ServiceEvent.kIsolateUpdate:
1508 case ServiceEvent.kBreakpointResolved: 1528 case ServiceEvent.kBreakpointResolved:
1509 case ServiceEvent.kDebuggerSettingsUpdate: 1529 case ServiceEvent.kDebuggerSettingsUpdate:
1510 // Update occurs as side-effect of caching. 1530 // Update occurs as side-effect of caching.
1511 break; 1531 break;
1512 1532
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 } 1836 }
1817 1837
1818 /// A [ServiceEvent] is an asynchronous event notification from the vm. 1838 /// A [ServiceEvent] is an asynchronous event notification from the vm.
1819 class ServiceEvent extends ServiceObject { 1839 class ServiceEvent extends ServiceObject {
1820 /// The possible 'kind' values. 1840 /// The possible 'kind' values.
1821 static const kVMUpdate = 'VMUpdate'; 1841 static const kVMUpdate = 'VMUpdate';
1822 static const kIsolateStart = 'IsolateStart'; 1842 static const kIsolateStart = 'IsolateStart';
1823 static const kIsolateRunnable = 'IsolateRunnable'; 1843 static const kIsolateRunnable = 'IsolateRunnable';
1824 static const kIsolateExit = 'IsolateExit'; 1844 static const kIsolateExit = 'IsolateExit';
1825 static const kIsolateUpdate = 'IsolateUpdate'; 1845 static const kIsolateUpdate = 'IsolateUpdate';
1846 static const kIsolateReload = 'IsolateReload';
1826 static const kServiceExtensionAdded = 'ServiceExtensionAdded'; 1847 static const kServiceExtensionAdded = 'ServiceExtensionAdded';
1827 static const kPauseStart = 'PauseStart'; 1848 static const kPauseStart = 'PauseStart';
1828 static const kPauseExit = 'PauseExit'; 1849 static const kPauseExit = 'PauseExit';
1829 static const kPauseBreakpoint = 'PauseBreakpoint'; 1850 static const kPauseBreakpoint = 'PauseBreakpoint';
1830 static const kPauseInterrupted = 'PauseInterrupted'; 1851 static const kPauseInterrupted = 'PauseInterrupted';
1831 static const kPauseException = 'PauseException'; 1852 static const kPauseException = 'PauseException';
1832 static const kNone = 'None'; 1853 static const kNone = 'None';
1833 static const kResume = 'Resume'; 1854 static const kResume = 'Resume';
1834 static const kBreakpointAdded = 'BreakpointAdded'; 1855 static const kBreakpointAdded = 'BreakpointAdded';
1835 static const kBreakpointResolved = 'BreakpointResolved'; 1856 static const kBreakpointResolved = 'BreakpointResolved';
(...skipping 11 matching lines...) Expand all
1847 ServiceEvent.connectionClosed(this.reason) : super._empty(null) { 1868 ServiceEvent.connectionClosed(this.reason) : super._empty(null) {
1848 kind = kConnectionClosed; 1869 kind = kConnectionClosed;
1849 } 1870 }
1850 1871
1851 @observable String kind; 1872 @observable String kind;
1852 @observable DateTime timestamp; 1873 @observable DateTime timestamp;
1853 @observable Breakpoint breakpoint; 1874 @observable Breakpoint breakpoint;
1854 @observable Frame topFrame; 1875 @observable Frame topFrame;
1855 @observable String extensionRPC; 1876 @observable String extensionRPC;
1856 @observable Instance exception; 1877 @observable Instance exception;
1878 @observable Instance reloadError;
1857 @observable bool atAsyncSuspension; 1879 @observable bool atAsyncSuspension;
1858 @observable ServiceObject inspectee; 1880 @observable ServiceObject inspectee;
1859 @observable ByteData data; 1881 @observable ByteData data;
1860 @observable int count; 1882 @observable int count;
1861 @observable String reason; 1883 @observable String reason;
1862 @observable String exceptions; 1884 @observable String exceptions;
1863 @observable String bytesAsString; 1885 @observable String bytesAsString;
1864 @observable Map logRecord; 1886 @observable Map logRecord;
1865 @observable String extensionKind; 1887 @observable String extensionKind;
1866 @observable Map extensionData; 1888 @observable Map extensionData;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 } 1940 }
1919 if (map['chunkCount'] != null) { 1941 if (map['chunkCount'] != null) {
1920 chunkCount = map['chunkCount']; 1942 chunkCount = map['chunkCount'];
1921 } 1943 }
1922 if (map['nodeCount'] != null) { 1944 if (map['nodeCount'] != null) {
1923 nodeCount = map['nodeCount']; 1945 nodeCount = map['nodeCount'];
1924 } 1946 }
1925 if (map['count'] != null) { 1947 if (map['count'] != null) {
1926 count = map['count']; 1948 count = map['count'];
1927 } 1949 }
1950 reloadError = map['reloadError'];
1928 if (map['_debuggerSettings'] != null && 1951 if (map['_debuggerSettings'] != null &&
1929 map['_debuggerSettings']['_exceptions'] != null) { 1952 map['_debuggerSettings']['_exceptions'] != null) {
1930 exceptions = map['_debuggerSettings']['_exceptions']; 1953 exceptions = map['_debuggerSettings']['_exceptions'];
1931 } 1954 }
1932 if (map['bytes'] != null) { 1955 if (map['bytes'] != null) {
1933 var bytes = BASE64.decode(map['bytes']); 1956 var bytes = BASE64.decode(map['bytes']);
1934 bytesAsString = UTF8.decode(bytes); 1957 bytesAsString = UTF8.decode(bytes);
1935 } 1958 }
1936 if (map['logRecord'] != null) { 1959 if (map['logRecord'] != null) {
1937 logRecord = map['logRecord']; 1960 logRecord = map['logRecord'];
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
2850 final int line; 2873 final int line;
2851 final int column; 2874 final int column;
2852 final int endColumn; 2875 final int endColumn;
2853 LocalVarLocation(this.line, this.column, this.endColumn); 2876 LocalVarLocation(this.line, this.column, this.endColumn);
2854 } 2877 }
2855 2878
2856 class Script extends HeapObject { 2879 class Script extends HeapObject {
2857 final lines = new ObservableList<ScriptLine>(); 2880 final lines = new ObservableList<ScriptLine>();
2858 @observable String uri; 2881 @observable String uri;
2859 @observable String kind; 2882 @observable String kind;
2883 @observable DateTime loadTime;
2860 @observable int firstTokenPos; 2884 @observable int firstTokenPos;
2861 @observable int lastTokenPos; 2885 @observable int lastTokenPos;
2862 @observable int lineOffset; 2886 @observable int lineOffset;
2863 @observable int columnOffset; 2887 @observable int columnOffset;
2864 @observable Library library; 2888 @observable Library library;
2865 2889
2866 bool get immutable => true; 2890 bool get immutable => true;
2867 2891
2868 String _shortUri; 2892 String _shortUri;
2869 2893
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2952 2976
2953 uri = map['uri']; 2977 uri = map['uri'];
2954 kind = map['_kind']; 2978 kind = map['_kind'];
2955 _shortUri = uri.substring(uri.lastIndexOf('/') + 1); 2979 _shortUri = uri.substring(uri.lastIndexOf('/') + 1);
2956 name = _shortUri; 2980 name = _shortUri;
2957 vmName = uri; 2981 vmName = uri;
2958 if (mapIsRef) { 2982 if (mapIsRef) {
2959 return; 2983 return;
2960 } 2984 }
2961 _loaded = true; 2985 _loaded = true;
2986 int loadTimeMillis = map['_loadTime'];
2987 loadTime = new DateTime.fromMillisecondsSinceEpoch(loadTimeMillis);
2962 lineOffset = map['lineOffset']; 2988 lineOffset = map['lineOffset'];
2963 columnOffset = map['columnOffset']; 2989 columnOffset = map['columnOffset'];
2964 _parseTokenPosTable(map['tokenPosTable']); 2990 _parseTokenPosTable(map['tokenPosTable']);
2965 _processSource(map['source']); 2991 _processSource(map['source']);
2966 library = map['library']; 2992 library = map['library'];
2967 } 2993 }
2968 2994
2969 void _parseTokenPosTable(List<List<int>> table) { 2995 void _parseTokenPosTable(List<List<int>> table) {
2970 if (table == null) { 2996 if (table == null) {
2971 return; 2997 return;
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
4047 var v = list[i]; 4073 var v = list[i];
4048 if ((v is ObservableMap) && _isServiceMap(v)) { 4074 if ((v is ObservableMap) && _isServiceMap(v)) {
4049 list[i] = owner.getFromMap(v); 4075 list[i] = owner.getFromMap(v);
4050 } else if (v is ObservableList) { 4076 } else if (v is ObservableList) {
4051 _upgradeObservableList(v, owner); 4077 _upgradeObservableList(v, owner);
4052 } else if (v is ObservableMap) { 4078 } else if (v is ObservableMap) {
4053 _upgradeObservableMap(v, owner); 4079 _upgradeObservableMap(v, owner);
4054 } 4080 }
4055 } 4081 }
4056 } 4082 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698