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

Unified Diff: runtime/vm/service.cc

Issue 24075002: Expose field data, use class id, and merge all collections into "objects" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/service.cc
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index d7cea4991ad05a93a842f2cf3b49552bc598a68a..a01f87285843786e83a20e26a7ec38f86858fd5e 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -149,6 +149,14 @@ static void PrintCollectionErrorResponse(const char* collection_name,
}
+static void PrintGenericError(JSONStream* js) {
+ JSONObject jsobj(js);
+ jsobj.AddProperty("type", "error");
+ jsobj.AddProperty("text", "Invalid request.");
+ PrintArgumentsAndOptions(jsobj, js);
+}
+
+
static void HandleName(Isolate* isolate, JSONStream* js) {
JSONObject jsobj(js);
jsobj.AddProperty("type", "IsolateName");
@@ -197,6 +205,7 @@ static void HandleEcho(Isolate* isolate, JSONStream* js) {
PrintArgumentsAndOptions(jsobj, js);
}
+
// Print an error message if there is no ID argument.
#define REQUIRE_COLLECTION_ID(collection) \
if (js->num_arguments() == 1) { \
@@ -204,46 +213,46 @@ static void HandleEcho(Isolate* isolate, JSONStream* js) {
return; \
}
-// Print a Dart object to the stream if found in ring. Otherwise print null.
-#define PRINT_RING_OBJ(type) \
- ASSERT(js->num_arguments() >= 2); \
- ObjectIdRing* ring = isolate->object_id_ring(); \
- ASSERT(ring != NULL); \
- intptr_t id = atoi(js->GetArgument(1)); \
- Object& obj = Object::Handle(ring->GetObjectForId(id)); \
- if (!obj.Is##type()) { \
- /* Object is not type, replace with null. */ \
- obj = Object::null(); \
- } \
- obj.PrintToJSONStream(js, false)
-
-
-static void HandleLibraries(Isolate* isolate, JSONStream* js) {
+
+static void HandleClasses(Isolate* isolate, JSONStream* js) {
if (js->num_arguments() == 1) {
- const Library& lib =
- Library::Handle(isolate->object_store()->root_library());
- lib.PrintToJSONStream(js, true);
+ ClassTable* table = isolate->class_table();
+ table->PrintToJSONStream(js);
+ return;
+ }
+ REQUIRE_COLLECTION_ID("classes");
siva 2013/09/17 17:25:33 We have already checked and processed for 'if (js-
Cutch 2013/09/19 23:57:39 Done.
+ ASSERT(js->num_arguments() >= 2);
+ intptr_t id = atoi(js->GetArgument(1));
+ ClassTable* table = isolate->class_table();
+ if (!table->IsValidIndex(id)) {
+ Object& obj = Object::Handle(Object::null());
+ obj.PrintToJSONStream(js, false);
siva 2013/09/17 17:25:33 You could do this as: Object::null_object().Print
Cutch 2013/09/19 23:57:39 Done.
} else {
- PRINT_RING_OBJ(Library);
+ Class& cls = Class::Handle(table->At(id));
+ cls.PrintToJSONStream(js, false);
}
}
-static void HandleFunctions(Isolate* isolate, JSONStream* js) {
- REQUIRE_COLLECTION_ID("functions");
- PRINT_RING_OBJ(Function);
-}
-
-
-static void HandleClasses(Isolate* isolate, JSONStream* js) {
- REQUIRE_COLLECTION_ID("classes");
- PRINT_RING_OBJ(Class);
+static void HandleLibrary(Isolate* isolate, JSONStream* js) {
+ if (js->num_arguments() == 1) {
+ const Library& lib =
+ Library::Handle(isolate->object_store()->root_library());
+ lib.PrintToJSONStream(js, false);
+ return;
+ }
+ PrintGenericError(js);
}
-static void HandleCodes(Isolate* isolate, JSONStream* js) {
- REQUIRE_COLLECTION_ID("codes");
- PRINT_RING_OBJ(Code);
+static void HandleObjects(Isolate* isolate, JSONStream* js) {
+ REQUIRE_COLLECTION_ID("objects");
+ ASSERT(js->num_arguments() >= 2);
+ ObjectIdRing* ring = isolate->object_id_ring();
+ ASSERT(ring != NULL);
+ intptr_t id = atoi(js->GetArgument(1));
+ Object& obj = Object::Handle(ring->GetObjectForId(id));
+ obj.PrintToJSONStream(js, false);
}
@@ -251,10 +260,9 @@ static ServiceMessageHandlerEntry __message_handlers[] = {
{ "name", HandleName },
{ "stacktrace", HandleStackTrace },
{ "objecthistogram", HandleObjectHistogram},
- { "libraries", HandleLibraries },
- { "functions", HandleFunctions },
+ { "library", HandleLibrary },
{ "classes", HandleClasses },
- { "codes", HandleCodes },
+ { "objects", HandleObjects },
{ "_echo", HandleEcho },
};

Powered by Google App Engine
This is Rietveld 408576698