OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library vmservice; | 5 library vmservice; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 import 'dart:typed_data'; | 10 import 'dart:typed_data'; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 var members = []; | 135 var members = []; |
136 var result = {}; | 136 var result = {}; |
137 clients.forEach((client) { | 137 clients.forEach((client) { |
138 members.add(client.toJson()); | 138 members.add(client.toJson()); |
139 }); | 139 }); |
140 result['type'] = 'ClientList'; | 140 result['type'] = 'ClientList'; |
141 result['members'] = members; | 141 result['members'] = members; |
142 message.setResponse(JSON.encode(result)); | 142 message.setResponse(JSON.encode(result)); |
143 } | 143 } |
144 | 144 |
145 // TODO(johnmccutchan): Turn this into a command line tool that uses the | |
146 // service library. | |
145 Future<String> _getCrashDump() async { | 147 Future<String> _getCrashDump() async { |
146 final perIsolateRequests = [ | 148 final perIsolateRequests = [ |
147 // ?isolateId=<isolate id> will be appended to each of these requests. | 149 // ?isolateId=<isolate id> will be appended to each of these requests. |
148 Uri.parse('getIsolate'), // Isolate information. | 150 // Isolate information. |
149 Uri.parse('_getAllocationProfile'), // State of heap. | 151 Uri.parse('getIsolate?_serviceIdZone=Ring.ExistingId'), |
150 Uri.parse('getStack?full=true'), // Call stack + local variables. | 152 // State of heap. |
153 Uri.parse('_getAllocationProfile?_serviceIdZone=Ring.ExistingId'), | |
154 // Call stack + local variables. | |
155 Uri.parse('getStack?_serviceIdZone=Ring.ExistingId&_full=true'), | |
151 ]; | 156 ]; |
152 | 157 |
153 // Snapshot of running isolates. | 158 // Snapshot of running isolates. |
154 var isolates = runningIsolates.isolates.values.toList(); | 159 var isolates = runningIsolates.isolates.values.toList(); |
155 | 160 |
156 // Collect the mapping from request uris to responses. | 161 // Collect the mapping from request uris to responses. |
157 var responses = { | 162 var responses = { |
158 }; | 163 }; |
159 | 164 |
160 // Request VM. | 165 // Request VM. |
(...skipping 10 matching lines...) Expand all Loading... | |
171 | 176 |
172 // Make requests to each isolate. | 177 // Make requests to each isolate. |
173 for (var isolate in isolates) { | 178 for (var isolate in isolates) { |
174 for (var request in perIsolateRequests) { | 179 for (var request in perIsolateRequests) { |
175 var message = new Message.forIsolate(request, isolate); | 180 var message = new Message.forIsolate(request, isolate); |
176 // Decode the JSON and and insert it into the map. The map key | 181 // Decode the JSON and and insert it into the map. The map key |
177 // is the request Uri. | 182 // is the request Uri. |
178 var response = JSON.decode(await isolate.route(message)); | 183 var response = JSON.decode(await isolate.route(message)); |
179 responses[message.toUri().toString()] = response['result']; | 184 responses[message.toUri().toString()] = response['result']; |
180 } | 185 } |
186 // Dump the object id ring requests. | |
187 var message = | |
188 new Message.forIsolate(Uri.parse('_dumpRingRequests'), isolate); | |
turnidge
2015/05/11 19:48:45
We shouldn't leak the word "Ring" here.
Maybe _du
| |
189 var response = JSON.decode(await isolate.route(message)); | |
190 // Insert object id requests into responses map. | |
191 response['result']['ringRequests'].forEach((k, v) { | |
turnidge
2015/05/11 19:48:45
We shouldn't use the word "ring" here in "ringRequ
| |
192 responses[k + '&isolateId=${isolate.serviceId}'] = v; | |
193 }); | |
181 } | 194 } |
182 | 195 |
183 // Encode the entire crash dump. | 196 // Encode the entire crash dump. |
184 return JSON.encode({ | 197 return JSON.encode({ |
185 'id' : null, | 198 'id' : null, |
186 'result' : responses, | 199 'result' : responses, |
187 }); | 200 }); |
188 } | 201 } |
189 | 202 |
190 Future<String> route(Message message) { | 203 Future<String> route(Message message) { |
(...skipping 21 matching lines...) Expand all Loading... | |
212 } | 225 } |
213 | 226 |
214 void _registerIsolate(int port_id, SendPort sp, String name) { | 227 void _registerIsolate(int port_id, SendPort sp, String name) { |
215 var service = new VMService(); | 228 var service = new VMService(); |
216 service.runningIsolates.isolateStartup(port_id, sp, name); | 229 service.runningIsolates.isolateStartup(port_id, sp, name); |
217 } | 230 } |
218 | 231 |
219 void _onStart() native "VMService_OnStart"; | 232 void _onStart() native "VMService_OnStart"; |
220 | 233 |
221 void _onExit() native "VMService_OnExit"; | 234 void _onExit() native "VMService_OnExit"; |
OLD | NEW |