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

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 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 notifyPropertyChange(#idle, 0, 1); 1140 notifyPropertyChange(#idle, 0, 1);
1141 } 1141 }
1142 1142
1143 @observable ServiceEvent pauseEvent = null; 1143 @observable ServiceEvent pauseEvent = null;
1144 @observable bool paused = false; 1144 @observable bool paused = false;
1145 @observable bool running = false; 1145 @observable bool running = false;
1146 @observable bool idle = false; 1146 @observable bool idle = false;
1147 @observable bool loading = true; 1147 @observable bool loading = true;
1148 @observable bool runnable = false; 1148 @observable bool runnable = false;
1149 @observable bool ioEnabled = false; 1149 @observable bool ioEnabled = false;
1150 @observable bool reloading = false;
1150 1151
1151 final List<String> extensionRPCs = new List<String>(); 1152 final List<String> extensionRPCs = new List<String>();
1152 1153
1153 Map<String,ServiceObject> _cache = new Map<String,ServiceObject>(); 1154 Map<String,ServiceObject> _cache = new Map<String,ServiceObject>();
1154 final TagProfile tagProfile = new TagProfile(20); 1155 final TagProfile tagProfile = new TagProfile(20);
1155 1156
1156 Isolate._empty(ServiceObjectOwner owner) : super._empty(owner) { 1157 Isolate._empty(ServiceObjectOwner owner) : super._empty(owner) {
1157 assert(owner is VM); 1158 assert(owner is VM);
1158 } 1159 }
1159 1160
(...skipping 23 matching lines...) Expand all
1183 } 1184 }
1184 if (startPos != null) { 1185 if (startPos != null) {
1185 params['tokenPos'] = startPos; 1186 params['tokenPos'] = startPos;
1186 } 1187 }
1187 if (endPos != null) { 1188 if (endPos != null) {
1188 params['endTokenPos'] = endPos; 1189 params['endTokenPos'] = endPos;
1189 } 1190 }
1190 return invokeRpc('getSourceReport', params); 1191 return invokeRpc('getSourceReport', params);
1191 } 1192 }
1192 1193
1194 Future<ServiceMap> reloadSources() {
1195 return invokeRpc('_reloadSources', {}).then((_) {
1196 reloading = true;
1197 });
1198 }
1199
1200 void _handleIsolateReloadEvent(ServiceEvent event) {
1201 reloading = false;
1202 if (event.reloadError != null) {
1203 // Failure.
1204 print('Reload failed: ${event.reloadError}');
1205 } else {
1206 _cache.clear();
1207 }
1208 }
1209
1193 /// Fetches and builds the class hierarchy for this isolate. Returns the 1210 /// Fetches and builds the class hierarchy for this isolate. Returns the
1194 /// Object class object. 1211 /// Object class object.
1195 Future<Class> getClassHierarchy() { 1212 Future<Class> getClassHierarchy() {
1196 return invokeRpc('getClassList', {}) 1213 return invokeRpc('getClassList', {})
1197 .then(_loadClasses) 1214 .then(_loadClasses)
1198 .then(_buildClassHierarchy); 1215 .then(_buildClassHierarchy);
1199 } 1216 }
1200 1217
1201 Future<ServiceObject> getPorts() { 1218 Future<ServiceObject> getPorts() {
1202 return invokeRpc('_getPorts', {}); 1219 return invokeRpc('_getPorts', {});
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 } 1505 }
1489 1506
1490 void _onEvent(ServiceEvent event) { 1507 void _onEvent(ServiceEvent event) {
1491 switch(event.kind) { 1508 switch(event.kind) {
1492 case ServiceEvent.kIsolateStart: 1509 case ServiceEvent.kIsolateStart:
1493 case ServiceEvent.kIsolateRunnable: 1510 case ServiceEvent.kIsolateRunnable:
1494 case ServiceEvent.kIsolateExit: 1511 case ServiceEvent.kIsolateExit:
1495 case ServiceEvent.kInspect: 1512 case ServiceEvent.kInspect:
1496 // Handled elsewhere. 1513 // Handled elsewhere.
1497 break; 1514 break;
1498 1515 case ServiceEvent.kIsolateReload:
1516 _handleIsolateReloadEvent(event);
1517 break;
1499 case ServiceEvent.kBreakpointAdded: 1518 case ServiceEvent.kBreakpointAdded:
1500 _addBreakpoint(event.breakpoint); 1519 _addBreakpoint(event.breakpoint);
1501 break; 1520 break;
1502 1521
1503 case ServiceEvent.kIsolateUpdate: 1522 case ServiceEvent.kIsolateUpdate:
1504 case ServiceEvent.kBreakpointResolved: 1523 case ServiceEvent.kBreakpointResolved:
1505 case ServiceEvent.kDebuggerSettingsUpdate: 1524 case ServiceEvent.kDebuggerSettingsUpdate:
1506 // Update occurs as side-effect of caching. 1525 // Update occurs as side-effect of caching.
1507 break; 1526 break;
1508 1527
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 } 1831 }
1813 1832
1814 /// A [ServiceEvent] is an asynchronous event notification from the vm. 1833 /// A [ServiceEvent] is an asynchronous event notification from the vm.
1815 class ServiceEvent extends ServiceObject { 1834 class ServiceEvent extends ServiceObject {
1816 /// The possible 'kind' values. 1835 /// The possible 'kind' values.
1817 static const kVMUpdate = 'VMUpdate'; 1836 static const kVMUpdate = 'VMUpdate';
1818 static const kIsolateStart = 'IsolateStart'; 1837 static const kIsolateStart = 'IsolateStart';
1819 static const kIsolateRunnable = 'IsolateRunnable'; 1838 static const kIsolateRunnable = 'IsolateRunnable';
1820 static const kIsolateExit = 'IsolateExit'; 1839 static const kIsolateExit = 'IsolateExit';
1821 static const kIsolateUpdate = 'IsolateUpdate'; 1840 static const kIsolateUpdate = 'IsolateUpdate';
1841 static const kIsolateReload = 'IsolateReload';
1822 static const kServiceExtensionAdded = 'ServiceExtensionAdded'; 1842 static const kServiceExtensionAdded = 'ServiceExtensionAdded';
1823 static const kPauseStart = 'PauseStart'; 1843 static const kPauseStart = 'PauseStart';
1824 static const kPauseExit = 'PauseExit'; 1844 static const kPauseExit = 'PauseExit';
1825 static const kPauseBreakpoint = 'PauseBreakpoint'; 1845 static const kPauseBreakpoint = 'PauseBreakpoint';
1826 static const kPauseInterrupted = 'PauseInterrupted'; 1846 static const kPauseInterrupted = 'PauseInterrupted';
1827 static const kPauseException = 'PauseException'; 1847 static const kPauseException = 'PauseException';
1828 static const kNone = 'None'; 1848 static const kNone = 'None';
1829 static const kResume = 'Resume'; 1849 static const kResume = 'Resume';
1830 static const kBreakpointAdded = 'BreakpointAdded'; 1850 static const kBreakpointAdded = 'BreakpointAdded';
1831 static const kBreakpointResolved = 'BreakpointResolved'; 1851 static const kBreakpointResolved = 'BreakpointResolved';
(...skipping 11 matching lines...) Expand all
1843 ServiceEvent.connectionClosed(this.reason) : super._empty(null) { 1863 ServiceEvent.connectionClosed(this.reason) : super._empty(null) {
1844 kind = kConnectionClosed; 1864 kind = kConnectionClosed;
1845 } 1865 }
1846 1866
1847 @observable String kind; 1867 @observable String kind;
1848 @observable DateTime timestamp; 1868 @observable DateTime timestamp;
1849 @observable Breakpoint breakpoint; 1869 @observable Breakpoint breakpoint;
1850 @observable Frame topFrame; 1870 @observable Frame topFrame;
1851 @observable String extensionRPC; 1871 @observable String extensionRPC;
1852 @observable Instance exception; 1872 @observable Instance exception;
1873 @observable Instance reloadError;
1853 @observable bool atAsyncSuspension; 1874 @observable bool atAsyncSuspension;
1854 @observable ServiceObject inspectee; 1875 @observable ServiceObject inspectee;
1855 @observable ByteData data; 1876 @observable ByteData data;
1856 @observable int count; 1877 @observable int count;
1857 @observable String reason; 1878 @observable String reason;
1858 @observable String exceptions; 1879 @observable String exceptions;
1859 @observable String bytesAsString; 1880 @observable String bytesAsString;
1860 @observable Map logRecord; 1881 @observable Map logRecord;
1861 @observable String extensionKind; 1882 @observable String extensionKind;
1862 @observable Map extensionData; 1883 @observable Map extensionData;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 } 1935 }
1915 if (map['chunkCount'] != null) { 1936 if (map['chunkCount'] != null) {
1916 chunkCount = map['chunkCount']; 1937 chunkCount = map['chunkCount'];
1917 } 1938 }
1918 if (map['nodeCount'] != null) { 1939 if (map['nodeCount'] != null) {
1919 nodeCount = map['nodeCount']; 1940 nodeCount = map['nodeCount'];
1920 } 1941 }
1921 if (map['count'] != null) { 1942 if (map['count'] != null) {
1922 count = map['count']; 1943 count = map['count'];
1923 } 1944 }
1945 reloadError = map['reloadError'];
1924 if (map['_debuggerSettings'] != null && 1946 if (map['_debuggerSettings'] != null &&
1925 map['_debuggerSettings']['_exceptions'] != null) { 1947 map['_debuggerSettings']['_exceptions'] != null) {
1926 exceptions = map['_debuggerSettings']['_exceptions']; 1948 exceptions = map['_debuggerSettings']['_exceptions'];
1927 } 1949 }
1928 if (map['bytes'] != null) { 1950 if (map['bytes'] != null) {
1929 var bytes = BASE64.decode(map['bytes']); 1951 var bytes = BASE64.decode(map['bytes']);
1930 bytesAsString = UTF8.decode(bytes); 1952 bytesAsString = UTF8.decode(bytes);
1931 } 1953 }
1932 if (map['logRecord'] != null) { 1954 if (map['logRecord'] != null) {
1933 logRecord = map['logRecord']; 1955 logRecord = map['logRecord'];
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
2846 final int line; 2868 final int line;
2847 final int column; 2869 final int column;
2848 final int endColumn; 2870 final int endColumn;
2849 LocalVarLocation(this.line, this.column, this.endColumn); 2871 LocalVarLocation(this.line, this.column, this.endColumn);
2850 } 2872 }
2851 2873
2852 class Script extends HeapObject { 2874 class Script extends HeapObject {
2853 final lines = new ObservableList<ScriptLine>(); 2875 final lines = new ObservableList<ScriptLine>();
2854 @observable String uri; 2876 @observable String uri;
2855 @observable String kind; 2877 @observable String kind;
2878 @observable DateTime loadTime;
2856 @observable int firstTokenPos; 2879 @observable int firstTokenPos;
2857 @observable int lastTokenPos; 2880 @observable int lastTokenPos;
2858 @observable int lineOffset; 2881 @observable int lineOffset;
2859 @observable int columnOffset; 2882 @observable int columnOffset;
2860 @observable Library library; 2883 @observable Library library;
2861 2884
2862 bool get immutable => true; 2885 bool get immutable => true;
2863 2886
2864 String _shortUri; 2887 String _shortUri;
2865 2888
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2948 2971
2949 uri = map['uri']; 2972 uri = map['uri'];
2950 kind = map['_kind']; 2973 kind = map['_kind'];
2951 _shortUri = uri.substring(uri.lastIndexOf('/') + 1); 2974 _shortUri = uri.substring(uri.lastIndexOf('/') + 1);
2952 name = _shortUri; 2975 name = _shortUri;
2953 vmName = uri; 2976 vmName = uri;
2954 if (mapIsRef) { 2977 if (mapIsRef) {
2955 return; 2978 return;
2956 } 2979 }
2957 _loaded = true; 2980 _loaded = true;
2981 int loadTimeMillis = map['_loadTime'];
2982 loadTime = new DateTime.fromMillisecondsSinceEpoch(loadTimeMillis);
2958 lineOffset = map['lineOffset']; 2983 lineOffset = map['lineOffset'];
2959 columnOffset = map['columnOffset']; 2984 columnOffset = map['columnOffset'];
2960 _parseTokenPosTable(map['tokenPosTable']); 2985 _parseTokenPosTable(map['tokenPosTable']);
2961 _processSource(map['source']); 2986 _processSource(map['source']);
2962 library = map['library']; 2987 library = map['library'];
2963 } 2988 }
2964 2989
2965 void _parseTokenPosTable(List<List<int>> table) { 2990 void _parseTokenPosTable(List<List<int>> table) {
2966 if (table == null) { 2991 if (table == null) {
2967 return; 2992 return;
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
4043 var v = list[i]; 4068 var v = list[i];
4044 if ((v is ObservableMap) && _isServiceMap(v)) { 4069 if ((v is ObservableMap) && _isServiceMap(v)) {
4045 list[i] = owner.getFromMap(v); 4070 list[i] = owner.getFromMap(v);
4046 } else if (v is ObservableList) { 4071 } else if (v is ObservableList) {
4047 _upgradeObservableList(v, owner); 4072 _upgradeObservableList(v, owner);
4048 } else if (v is ObservableMap) { 4073 } else if (v is ObservableMap) {
4049 _upgradeObservableMap(v, owner); 4074 _upgradeObservableMap(v, owner);
4050 } 4075 }
4051 } 4076 }
4052 } 4077 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698