Chromium Code Reviews| 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 | 8 |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/coverage.h" | 10 #include "vm/coverage.h" |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 622 JSONObject jsobj(&jsarr); | 622 JSONObject jsobj(&jsarr); |
| 623 frame->PrintToJSONObject(&jsobj); | 623 frame->PrintToJSONObject(&jsobj); |
| 624 // TODO(turnidge): Implement depth differently -- differentiate | 624 // TODO(turnidge): Implement depth differently -- differentiate |
| 625 // inlined frames. | 625 // inlined frames. |
| 626 jsobj.AddProperty("depth", i); | 626 jsobj.AddProperty("depth", i); |
| 627 } | 627 } |
| 628 return true; | 628 return true; |
| 629 } | 629 } |
| 630 | 630 |
| 631 | 631 |
| 632 static bool HandleIO(Isolate* isolate, JSONStream* js) { | |
| 633 TextBuffer* buffer = js->buffer(); | |
| 634 Dart_Handle io_lib = | |
| 635 Dart_LookupLibrary(Dart_NewStringFromCString("dart:io")); | |
| 636 if (Dart_IsError(io_lib)) Dart_PropagateError(io_lib); | |
| 637 Dart_Handle result = | |
| 638 Dart_Invoke(io_lib, | |
| 639 Dart_NewStringFromCString("_test"), | |
| 640 0, | |
| 641 NULL); | |
| 642 if (Dart_IsError(result)) Dart_PropagateError(result); | |
|
Cutch
2014/02/13 22:42:09
This code is executing inside the users isolate, i
Søren Gjesse
2014/02/14 12:10:13
Done.
| |
| 643 const char *json; | |
| 644 Dart_StringToCString(result, &json); | |
| 645 buffer->AddString(json); | |
| 646 return true; | |
| 647 } | |
| 648 | |
| 649 | |
| 632 static bool HandleObjectHistogram(Isolate* isolate, JSONStream* js) { | 650 static bool HandleObjectHistogram(Isolate* isolate, JSONStream* js) { |
| 633 ObjectHistogram* histogram = Isolate::Current()->object_histogram(); | 651 ObjectHistogram* histogram = Isolate::Current()->object_histogram(); |
| 634 if (histogram == NULL) { | 652 if (histogram == NULL) { |
| 635 JSONObject jsobj(js); | 653 JSONObject jsobj(js); |
| 636 jsobj.AddProperty("type", "Error"); | 654 jsobj.AddProperty("type", "Error"); |
| 637 jsobj.AddProperty("text", "Run with --print_object_histogram"); | 655 jsobj.AddProperty("text", "Run with --print_object_histogram"); |
| 638 return true; | 656 return true; |
| 639 } | 657 } |
| 640 histogram->PrintToJSONStream(js); | 658 histogram->PrintToJSONStream(js); |
| 641 return true; | 659 return true; |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1098 { "classes", HandleClasses }, | 1116 { "classes", HandleClasses }, |
| 1099 { "code", HandleCode }, | 1117 { "code", HandleCode }, |
| 1100 { "coverage", HandleCoverage }, | 1118 { "coverage", HandleCoverage }, |
| 1101 { "debug", HandleDebug }, | 1119 { "debug", HandleDebug }, |
| 1102 { "libraries", HandleLibraries }, | 1120 { "libraries", HandleLibraries }, |
| 1103 { "objecthistogram", HandleObjectHistogram}, | 1121 { "objecthistogram", HandleObjectHistogram}, |
| 1104 { "objects", HandleObjects }, | 1122 { "objects", HandleObjects }, |
| 1105 { "profile", HandleProfile }, | 1123 { "profile", HandleProfile }, |
| 1106 { "scripts", HandleScripts }, | 1124 { "scripts", HandleScripts }, |
| 1107 { "stacktrace", HandleStackTrace }, | 1125 { "stacktrace", HandleStackTrace }, |
| 1126 { "io", HandleIO }, | |
| 1108 }; | 1127 }; |
| 1109 | 1128 |
| 1110 | 1129 |
| 1111 static IsolateMessageHandler FindIsolateMessageHandler(const char* command) { | 1130 static IsolateMessageHandler FindIsolateMessageHandler(const char* command) { |
| 1112 intptr_t num_message_handlers = sizeof(isolate_handlers) / | 1131 intptr_t num_message_handlers = sizeof(isolate_handlers) / |
| 1113 sizeof(isolate_handlers[0]); | 1132 sizeof(isolate_handlers[0]); |
| 1114 for (intptr_t i = 0; i < num_message_handlers; i++) { | 1133 for (intptr_t i = 0; i < num_message_handlers; i++) { |
| 1115 const IsolateMessageHandlerEntry& entry = isolate_handlers[i]; | 1134 const IsolateMessageHandlerEntry& entry = isolate_handlers[i]; |
| 1116 if (!strcmp(command, entry.command)) { | 1135 if (!strcmp(command, entry.command)) { |
| 1117 return entry.handler; | 1136 return entry.handler; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1203 for (intptr_t i = 0; i < num_message_handlers; i++) { | 1222 for (intptr_t i = 0; i < num_message_handlers; i++) { |
| 1204 const RootMessageHandlerEntry& entry = root_handlers[i]; | 1223 const RootMessageHandlerEntry& entry = root_handlers[i]; |
| 1205 if (!strcmp(command, entry.command)) { | 1224 if (!strcmp(command, entry.command)) { |
| 1206 return entry.handler; | 1225 return entry.handler; |
| 1207 } | 1226 } |
| 1208 } | 1227 } |
| 1209 return NULL; | 1228 return NULL; |
| 1210 } | 1229 } |
| 1211 | 1230 |
| 1212 } // namespace dart | 1231 } // namespace dart |
| OLD | NEW |