| 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 #include "vm/service.h" | 5 #include "vm/service.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/globals.h" | 8 #include "platform/globals.h" |
| 9 | 9 |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 2248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2259 return true; | 2259 return true; |
| 2260 } | 2260 } |
| 2261 | 2261 |
| 2262 | 2262 |
| 2263 static bool HandleHeapMap(Isolate* isolate, JSONStream* js) { | 2263 static bool HandleHeapMap(Isolate* isolate, JSONStream* js) { |
| 2264 isolate->heap()->PrintHeapMapToJSONStream(isolate, js); | 2264 isolate->heap()->PrintHeapMapToJSONStream(isolate, js); |
| 2265 return true; | 2265 return true; |
| 2266 } | 2266 } |
| 2267 | 2267 |
| 2268 | 2268 |
| 2269 static bool HandleGraph(Isolate* isolate, JSONStream* js) { |
| 2270 Service::SendGraphEvent(isolate); |
| 2271 // TODO(koda): Provide some id that ties this request to async response(s). |
| 2272 JSONObject jsobj(js); |
| 2273 jsobj.AddProperty("type", "OK"); |
| 2274 jsobj.AddProperty("id", "ok"); |
| 2275 return true; |
| 2276 } |
| 2277 |
| 2278 |
| 2279 void Service::SendGraphEvent(Isolate* isolate) { |
| 2280 uint8_t* buffer = NULL; |
| 2281 WriteStream stream(&buffer, &allocator, 1 * MB); |
| 2282 ObjectGraph graph(isolate); |
| 2283 graph.Serialize(&stream); |
| 2284 JSONStream js; |
| 2285 { |
| 2286 JSONObject jsobj(&js); |
| 2287 jsobj.AddProperty("type", "ServiceEvent"); |
| 2288 jsobj.AddPropertyF("id", "_graphEvent"); |
| 2289 jsobj.AddProperty("eventType", "_Graph"); |
| 2290 jsobj.AddProperty("isolate", isolate); |
| 2291 } |
| 2292 const String& message = String::Handle(String::New(js.ToCString())); |
| 2293 SendEvent(kEventFamilyDebug, message, buffer, stream.bytes_written()); |
| 2294 } |
| 2295 |
| 2296 |
| 2269 class ContainsAddressVisitor : public FindObjectVisitor { | 2297 class ContainsAddressVisitor : public FindObjectVisitor { |
| 2270 public: | 2298 public: |
| 2271 ContainsAddressVisitor(Isolate* isolate, uword addr) | 2299 ContainsAddressVisitor(Isolate* isolate, uword addr) |
| 2272 : FindObjectVisitor(isolate), addr_(addr) { } | 2300 : FindObjectVisitor(isolate), addr_(addr) { } |
| 2273 virtual ~ContainsAddressVisitor() { } | 2301 virtual ~ContainsAddressVisitor() { } |
| 2274 | 2302 |
| 2275 virtual uword filter_addr() const { return addr_; } | 2303 virtual uword filter_addr() const { return addr_; } |
| 2276 | 2304 |
| 2277 virtual bool FindObject(RawObject* obj) const { | 2305 virtual bool FindObject(RawObject* obj) const { |
| 2278 // Free list elements are not real objects, so skip them. | 2306 // Free list elements are not real objects, so skip them. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2331 { "_malformedjson", HandleMalformedJson }, | 2359 { "_malformedjson", HandleMalformedJson }, |
| 2332 { "_malformedobject", HandleMalformedObject }, | 2360 { "_malformedobject", HandleMalformedObject }, |
| 2333 { "_echo", HandleIsolateEcho }, | 2361 { "_echo", HandleIsolateEcho }, |
| 2334 { "", HandleIsolate }, | 2362 { "", HandleIsolate }, |
| 2335 { "address", HandleAddress }, | 2363 { "address", HandleAddress }, |
| 2336 { "allocationprofile", HandleAllocationProfile }, | 2364 { "allocationprofile", HandleAllocationProfile }, |
| 2337 { "classes", HandleClasses }, | 2365 { "classes", HandleClasses }, |
| 2338 { "code", HandleCode }, | 2366 { "code", HandleCode }, |
| 2339 { "coverage", HandleCoverage }, | 2367 { "coverage", HandleCoverage }, |
| 2340 { "debug", HandleDebug }, | 2368 { "debug", HandleDebug }, |
| 2369 { "graph", HandleGraph }, |
| 2341 { "heapmap", HandleHeapMap }, | 2370 { "heapmap", HandleHeapMap }, |
| 2342 { "libraries", HandleLibraries }, | 2371 { "libraries", HandleLibraries }, |
| 2343 { "metrics", HandleMetrics }, | 2372 { "metrics", HandleMetrics }, |
| 2344 { "objects", HandleObjects }, | 2373 { "objects", HandleObjects }, |
| 2345 { "profile", HandleProfile }, | 2374 { "profile", HandleProfile }, |
| 2346 { "scripts", HandleScripts }, | 2375 { "scripts", HandleScripts }, |
| 2347 { "stacktrace", HandleStackTrace }, | 2376 { "stacktrace", HandleStackTrace }, |
| 2348 { "typearguments", HandleTypeArguments }, | 2377 { "typearguments", HandleTypeArguments }, |
| 2349 }; | 2378 }; |
| 2350 | 2379 |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2716 while (current != NULL) { | 2745 while (current != NULL) { |
| 2717 if (strcmp(name, current->name()) == 0) { | 2746 if (strcmp(name, current->name()) == 0) { |
| 2718 return current; | 2747 return current; |
| 2719 } | 2748 } |
| 2720 current = current->next(); | 2749 current = current->next(); |
| 2721 } | 2750 } |
| 2722 return NULL; | 2751 return NULL; |
| 2723 } | 2752 } |
| 2724 | 2753 |
| 2725 } // namespace dart | 2754 } // namespace dart |
| OLD | NEW |