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

Side by Side Diff: runtime/bin/vmservice/running_isolates.dart

Issue 19870006: Support stacktrace and objecthistogram service commands (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/vmservice/running_isolate.dart ('k') | runtime/bin/vmservice/server.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 part of vmservice; 5 part of vmservice;
6 6
7 class RunningIsolates implements ServiceRequestRouter { 7 class RunningIsolates implements ServiceRequestRouter {
8 final Map<int, RunningIsolate> isolates = new Map<int, RunningIsolate>(); 8 final Map<int, RunningIsolate> isolates = new Map<int, RunningIsolate>();
9 9
10 RunningIsolates(); 10 RunningIsolates();
11 11
12 void isolateStartup(SendPort sp) { 12 void isolateStartup(SendPort sp) {
13 if (isolates[sp.hashCode] != null) { 13 if (isolates[sp.hashCode] != null) {
14 throw new StateError('Duplicate isolate startup.'); 14 throw new StateError('Duplicate isolate startup.');
15 } 15 }
16 var ri = new RunningIsolate(sp); 16 var ri = new RunningIsolate(sp);
17 isolates[sp.hashCode] = ri; 17 isolates[sp.hashCode] = ri;
18 ri.sendIdRequest(); 18 ri._sendNameRequest();
19 } 19 }
20 20
21 void isolateShutdown(SendPort sp) { 21 void isolateShutdown(SendPort sp) {
22 if (isolates[sp.hashCode] == null) { 22 if (isolates[sp.hashCode] == null) {
23 throw new StateError('Unknown isolate.'); 23 throw new StateError('Unknown isolate.');
24 } 24 }
25 isolates.remove(sp.hashCode); 25 isolates.remove(sp.hashCode);
26 } 26 }
27 27
28 void _isolateCollectionRequest(ServiceRequest request) { 28 void _isolateCollectionRequest(ServiceRequest request) {
29 var members = []; 29 var members = [];
30 var result = {}; 30 var result = {};
31 isolates.forEach((sp, ri) { 31 isolates.forEach((sp, ri) {
32 members.add({ 32 members.add({
33 'id': sp, 33 'id': sp,
34 'name': ri.id 34 'name': ri.name
35 }); 35 });
36 }); 36 });
37 result['type'] = 'IsolateList'; 37 result['type'] = 'IsolateList';
38 result['members'] = members; 38 result['members'] = members;
39 request.setResponse(JSON.stringify(result)); 39 request.setResponse(JSON.stringify(result));
40 } 40 }
41 41
42 bool route(ServiceRequest request) { 42 Future route(ServiceRequest request) {
43 if (request.pathSegments.length == 0) { 43 if (request.pathSegments.length == 0) {
44 return false; 44 return null;
45 } 45 }
46 if (request.pathSegments[0] != 'isolates') { 46 if (request.pathSegments[0] != 'isolates') {
47 return false; 47 return null;
48 } 48 }
49 if (request.pathSegments.length == 1) { 49 if (request.pathSegments.length == 1) {
50 // Requesting list of running isolates. 50 // Requesting list of running isolates.
51 _isolateCollectionRequest(request); 51 _isolateCollectionRequest(request);
52 return true; 52 return new Future.value(request);
53 } 53 }
54 var isolateId; 54 var isolateId;
55 try { 55 try {
56 isolateId = int.parse(request.pathSegments[1]); 56 isolateId = int.parse(request.pathSegments[1]);
57 } catch (e) { 57 } catch (e) {
58 request.setErrorResponse('Could not parse isolate id: $e'); 58 request.setErrorResponse('Could not parse isolate id: $e');
59 return true; 59 return new Future.value(request);
60 } 60 }
61 var isolate = isolates[isolateId]; 61 var isolate = isolates[isolateId];
62 if (isolate == null) { 62 if (isolate == null) {
63 request.setErrorResponse('Cannot find isolate id: $isolateId'); 63 request.setErrorResponse('Cannot find isolate id: $isolateId');
64 return true; 64 return new Future.value(request);
65 } 65 }
66 // Consume '/isolates/isolateId' 66 // Consume '/isolates/isolateId'
67 request.pathSegments.removeRange(0, 2); 67 request.pathSegments.removeRange(0, 2);
68 if (request.pathSegments.length == 0) {
69 // The request is now empty.
70 request.setErrorResponse('No request for isolate: /isolates/$isolateId');
71 return new Future.value(request);
72 }
68 return isolate.route(request); 73 return isolate.route(request);
69 } 74 }
70 } 75 }
OLDNEW
« no previous file with comments | « runtime/bin/vmservice/running_isolate.dart ('k') | runtime/bin/vmservice/server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698