Index: runtime/vm/service.cc |
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc |
index a9e195704e66462b56188890906b007a7c23498c..1019498aeaa3f4c250d3404d0ea3d72b9fca60f6 100644 |
--- a/runtime/vm/service.cc |
+++ b/runtime/vm/service.cc |
@@ -857,6 +857,16 @@ static bool HandleLibraries(Isolate* isolate, JSONStream* js) { |
} |
+static void PrintPseudoNull(JSONStream* js, |
+ const char* id, |
+ const char* preview) { |
+ JSONObject jsobj(js); |
+ jsobj.AddProperty("type", "Null"); |
+ jsobj.AddProperty("id", id); |
+ jsobj.AddProperty("preview", preview); |
+} |
+ |
+ |
static bool HandleObjects(Isolate* isolate, JSONStream* js) { |
REQUIRE_COLLECTION_ID("objects"); |
ASSERT(js->num_arguments() >= 2); |
@@ -864,13 +874,30 @@ static bool HandleObjects(Isolate* isolate, JSONStream* js) { |
// TODO(turnidge): Handle <optimized out> the same way as other |
// special nulls. |
- if (strcmp(arg, "null") == 0 || |
- strcmp(arg, "not-initialized") == 0 || |
- strcmp(arg, "being-initialized") == 0 || |
- strcmp(arg, "optimized-out") == 0) { |
+ if (strcmp(arg, "null") == 0) { |
Object::null_object().PrintToJSONStream(js, false); |
return true; |
+ } else if (strcmp(arg, "not-initialized") == 0) { |
+ Object::sentinel().PrintToJSONStream(js, false); |
+ return true; |
+ |
+ } else if (strcmp(arg, "being-initialized") == 0) { |
+ Object::transition_sentinel().PrintToJSONStream(js, false); |
+ return true; |
+ |
+ } else if (strcmp(arg, "optimized-out") == 0) { |
+ Symbols::OptimizedOut().PrintToJSONStream(js, false); |
+ return true; |
+ |
+ } else if (strcmp(arg, "collected") == 0) { |
+ PrintPseudoNull(js, "objects/collected", "<collected>"); |
+ return true; |
+ |
+ } else if (strcmp(arg, "expired") == 0) { |
+ PrintPseudoNull(js, "objects/expired", "<expired>"); |
+ return true; |
+ |
} else if (strcmp(arg, "int") == 0) { |
if (js->num_arguments() < 3) { |
PrintError(js, "expected 3 arguments but found %" Pd "\n", |
@@ -917,6 +944,15 @@ static bool HandleObjects(Isolate* isolate, JSONStream* js) { |
return true; |
} |
Object& obj = Object::Handle(ring->GetObjectForId(id)); |
+ if (obj.IsNull()) { |
+ // The object has been collected by the gc. |
+ PrintPseudoNull(js, "objects/collected", "<collected>"); |
+ return true; |
+ } else if (obj.raw() == Object::sentinel().raw()) { |
+ // The object id has expired. |
+ PrintPseudoNull(js, "objects/expired", "<expired>"); |
+ return true; |
+ } |
obj.PrintToJSONStream(js, false); |
return true; |
} |