mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
[VM/Service] Print Service IDs by default in PrintSharedInstanceJSON()
This CL adds the parameter `bool include_id` to `PrintSharedInstanceJSON()` and makes it default to true. This CL also removes `AddServiceId()` calls that are now unnecessary due to this change. TEST=CI Change-Id: Ica53757a7fc23c70946be71f88408963e5aeae04 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265041 Reviewed-by: Ben Konyi <bkonyi@google.com>
This commit is contained in:
parent
9ad1e36b17
commit
d6415b2fe0
3 changed files with 28 additions and 45 deletions
|
@ -7698,7 +7698,9 @@ class Instance : public Object {
|
|||
|
||||
protected:
|
||||
#ifndef PRODUCT
|
||||
virtual void PrintSharedInstanceJSON(JSONObject* jsobj, bool ref) const;
|
||||
virtual void PrintSharedInstanceJSON(JSONObject* jsobj,
|
||||
bool ref,
|
||||
bool include_id = true) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
|
|
@ -1097,7 +1097,9 @@ void UnwindError::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
jsobj.AddProperty("_is_user_initiated", is_user_initiated());
|
||||
}
|
||||
|
||||
void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, bool ref) const {
|
||||
void Instance::PrintSharedInstanceJSON(JSONObject* jsobj,
|
||||
bool ref,
|
||||
bool include_id) const {
|
||||
AddCommonObjectProperties(jsobj, "Instance", ref);
|
||||
{
|
||||
NoSafepointScope safepoint_scope;
|
||||
|
@ -1105,6 +1107,9 @@ void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, bool ref) const {
|
|||
Thread::Current(), ptr());
|
||||
jsobj->AddProperty64("identityHashCode", hash_code);
|
||||
}
|
||||
if (include_id) {
|
||||
jsobj->AddServiceId(*this);
|
||||
}
|
||||
if (ref) {
|
||||
return;
|
||||
}
|
||||
|
@ -1164,7 +1169,6 @@ void Instance::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
} else {
|
||||
jsobj.AddProperty("kind", "PlainInstance");
|
||||
}
|
||||
jsobj.AddServiceId(*this);
|
||||
if (IsClosure()) {
|
||||
// TODO(regis): How about closureInstantiatorTypeArguments and
|
||||
// closureFunctionTypeArguments?
|
||||
|
@ -1191,7 +1195,7 @@ void AbstractType::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
|
||||
void Type::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
||||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
PrintSharedInstanceJSON(&jsobj, ref, /*include_id=*/false);
|
||||
jsobj.AddProperty("kind", "Type");
|
||||
const Class& type_cls = Class::Handle(type_class());
|
||||
if (type_cls.DeclarationType() == ptr()) {
|
||||
|
@ -1255,10 +1259,10 @@ void RecordType::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "_RecordType");
|
||||
jsobj.AddServiceId(*this);
|
||||
if (ref) {
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
JSONArray jsarr(&jsobj, "fields");
|
||||
String& name = String::Handle();
|
||||
|
@ -1286,7 +1290,6 @@ void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "TypeRef");
|
||||
jsobj.AddServiceId(*this);
|
||||
const String& user_name = String::Handle(UserVisibleName());
|
||||
const String& vm_name = String::Handle(Name());
|
||||
AddNameProperties(&jsobj, user_name.ToCString(), vm_name.ToCString());
|
||||
|
@ -1300,7 +1303,6 @@ void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "TypeParameter");
|
||||
jsobj.AddServiceId(*this);
|
||||
const String& user_name = String::Handle(UserVisibleName());
|
||||
const String& vm_name = String::Handle(Name());
|
||||
AddNameProperties(&jsobj, user_name.ToCString(), vm_name.ToCString());
|
||||
|
@ -1323,13 +1325,12 @@ void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "Int");
|
||||
jsobj.AddServiceId(*this);
|
||||
jsobj.AddProperty("valueAsString", ToCString());
|
||||
}
|
||||
|
||||
void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
||||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
PrintSharedInstanceJSON(&jsobj, ref, /*include_id=*/false);
|
||||
jsobj.AddProperty("kind", "Int");
|
||||
jsobj.AddFixedServiceId("objects/int-%" Pd "", Value());
|
||||
jsobj.AddPropertyF("valueAsString", "%" Pd "", Value());
|
||||
|
@ -1343,7 +1344,6 @@ void Double::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "Double");
|
||||
jsobj.AddServiceId(*this);
|
||||
jsobj.AddProperty("valueAsString", ToCString());
|
||||
}
|
||||
|
||||
|
@ -1360,7 +1360,6 @@ void String::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
}
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "String");
|
||||
jsobj.AddServiceId(*this);
|
||||
jsobj.AddProperty("length", Length());
|
||||
if (ref) {
|
||||
// String refs always truncate to a fixed count;
|
||||
|
@ -1387,7 +1386,7 @@ void String::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
void Bool::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
||||
const char* str = ToCString();
|
||||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
PrintSharedInstanceJSON(&jsobj, ref, /*include_id=*/false);
|
||||
jsobj.AddProperty("kind", "Bool");
|
||||
jsobj.AddFixedServiceId("objects/bool-%s", str);
|
||||
jsobj.AddPropertyF("valueAsString", "%s", str);
|
||||
|
@ -1397,7 +1396,6 @@ void Array::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "List");
|
||||
jsobj.AddServiceId(*this);
|
||||
jsobj.AddProperty("length", Length());
|
||||
if (ref) {
|
||||
return;
|
||||
|
@ -1427,7 +1425,6 @@ void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "List");
|
||||
jsobj.AddServiceId(*this);
|
||||
jsobj.AddProperty("length", Length());
|
||||
if (ref) {
|
||||
return;
|
||||
|
@ -1457,7 +1454,6 @@ void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "Map");
|
||||
jsobj.AddServiceId(*this);
|
||||
jsobj.AddProperty("length", Length());
|
||||
if (ref) {
|
||||
return;
|
||||
|
@ -1495,7 +1491,6 @@ void LinkedHashSet::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "PlainInstance");
|
||||
jsobj.AddServiceId(*this);
|
||||
jsobj.AddProperty("length", Length());
|
||||
if (ref) {
|
||||
return;
|
||||
|
@ -1530,7 +1525,6 @@ void Float32x4::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "Float32x4");
|
||||
jsobj.AddServiceId(*this);
|
||||
jsobj.AddProperty("valueAsString", ToCString());
|
||||
}
|
||||
|
||||
|
@ -1538,7 +1532,6 @@ void Int32x4::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "Int32x4");
|
||||
jsobj.AddServiceId(*this);
|
||||
jsobj.AddProperty("valueAsString", ToCString());
|
||||
}
|
||||
|
||||
|
@ -1546,7 +1539,6 @@ void Float64x2::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "Float64x2");
|
||||
jsobj.AddServiceId(*this);
|
||||
jsobj.AddProperty("valueAsString", ToCString());
|
||||
}
|
||||
|
||||
|
@ -1560,7 +1552,6 @@ void TypedData::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
const Class& cls = Class::Handle(clazz());
|
||||
const char* kind = cls.UserVisibleNameCString();
|
||||
jsobj.AddProperty("kind", kind);
|
||||
jsobj.AddServiceId(*this);
|
||||
jsobj.AddProperty("length", Length());
|
||||
if (ref) {
|
||||
return;
|
||||
|
@ -1595,7 +1586,6 @@ void ExternalTypedData::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
const Class& cls = Class::Handle(clazz());
|
||||
const char* kind = cls.UserVisibleNameCString();
|
||||
jsobj.AddProperty("kind", kind);
|
||||
jsobj.AddServiceId(*this);
|
||||
jsobj.AddProperty("length", Length());
|
||||
if (ref) {
|
||||
return;
|
||||
|
@ -1638,7 +1628,6 @@ void ReceivePort::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
const StackTrace& allocation_location_ =
|
||||
StackTrace::Handle(allocation_location());
|
||||
const String& debug_name_ = String::Handle(debug_name());
|
||||
obj.AddServiceId(*this);
|
||||
obj.AddProperty("kind", "ReceivePort");
|
||||
obj.AddProperty64("portId", Id());
|
||||
obj.AddProperty("debugName", debug_name_.ToCString());
|
||||
|
@ -1665,7 +1654,6 @@ void Record::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "_Record");
|
||||
jsobj.AddServiceId(*this);
|
||||
if (ref) {
|
||||
return;
|
||||
}
|
||||
|
@ -1698,7 +1686,6 @@ void StackTrace::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "StackTrace");
|
||||
jsobj.AddServiceId(*this);
|
||||
jsobj.AddProperty("valueAsString", ToCString());
|
||||
}
|
||||
|
||||
|
@ -1706,7 +1693,6 @@ void RegExp::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "RegExp");
|
||||
jsobj.AddServiceId(*this);
|
||||
|
||||
jsobj.AddProperty("pattern", String::Handle(pattern()));
|
||||
|
||||
|
@ -1752,7 +1738,6 @@ void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "WeakProperty");
|
||||
jsobj.AddServiceId(*this);
|
||||
if (ref) {
|
||||
return;
|
||||
}
|
||||
|
@ -1767,7 +1752,6 @@ void WeakReference::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "WeakReference");
|
||||
jsobj.AddServiceId(*this);
|
||||
if (ref) {
|
||||
return;
|
||||
}
|
||||
|
@ -1784,7 +1768,6 @@ void Finalizer::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "Finalizer");
|
||||
jsobj.AddServiceId(*this);
|
||||
if (ref) {
|
||||
return;
|
||||
}
|
||||
|
@ -1799,7 +1782,6 @@ void NativeFinalizer::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "NativeFinalizer");
|
||||
jsobj.AddServiceId(*this);
|
||||
if (ref) {
|
||||
return;
|
||||
}
|
||||
|
@ -1818,7 +1800,6 @@ void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
JSONObject jsobj(stream);
|
||||
PrintSharedInstanceJSON(&jsobj, ref);
|
||||
jsobj.AddProperty("kind", "MirrorReference");
|
||||
jsobj.AddServiceId(*this);
|
||||
|
||||
if (ref) {
|
||||
return;
|
||||
|
|
|
@ -6060,7 +6060,7 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) {
|
|||
"patch\\/integers.dart\",\"_kind\":\"kernel\"}"
|
||||
"},\"library\":{\"type\":\"@Library\",\"fixedId\":"
|
||||
"true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":\"dart:core\"}},"
|
||||
"\"identityHashCode\":0,\"kind\":\"Int\",\"id\":\"\",\"valueAsString\":"
|
||||
"\"identityHashCode\":0,\"id\":\"\",\"kind\":\"Int\",\"valueAsString\":"
|
||||
"\"-9223372036854775808\"}",
|
||||
buffer);
|
||||
}
|
||||
|
@ -6084,7 +6084,7 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) {
|
|||
"patch\\/double.dart\",\"_kind\":\"kernel\"}"
|
||||
"},\"library\":{\"type\":\"@Library\",\"fixedId\":"
|
||||
"true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":\"dart:core\"}},"
|
||||
"\"identityHashCode\":0,\"kind\":\"Double\",\"id\":\"\","
|
||||
"\"identityHashCode\":0,\"id\":\"\",\"kind\":\"Double\","
|
||||
"\"valueAsString\":\"0.1234\"}",
|
||||
buffer);
|
||||
}
|
||||
|
@ -6108,7 +6108,7 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) {
|
|||
"patch\\/string_patch.dart\",\"_kind\":\"kernel\"}"
|
||||
"},\"library\":{\"type\":\"@Library\",\"fixedId\":"
|
||||
"true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":\"dart:core\"}},"
|
||||
"\"identityHashCode\":0,\"kind\":\"String\",\"id\":\"\",\"length\":2,"
|
||||
"\"identityHashCode\":0,\"id\":\"\",\"kind\":\"String\",\"length\":2,"
|
||||
"\"valueAsString\":\"dw\"}",
|
||||
buffer);
|
||||
}
|
||||
|
@ -6146,7 +6146,7 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) {
|
|||
buffer);
|
||||
|
||||
EXPECT_SUBSTRING(
|
||||
"\"kind\":\"TypeParameter\",\"id\":\"\",\"name\":\"X0\","
|
||||
"\"id\":\"\",\"kind\":\"TypeParameter\",\"name\":\"X0\","
|
||||
"\"parameterizedClass\":{\"type\":\"@Instance\",\"_vmType\":\"Class\","
|
||||
"\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\",\"name\":"
|
||||
"\"Null\",\"location\":{\"type\":\"SourceLocation\",\"script\":{"
|
||||
|
@ -6156,7 +6156,7 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) {
|
|||
"\"library\":{\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\","
|
||||
"\"name\":\"dart.core\",\"uri\":\"dart:core\"}},\"kind\":\"Null\","
|
||||
"\"fixedId\":true,\"id\":\"\",\"valueAsString\":\"null\"}}]},"
|
||||
"\"identityHashCode\":0,\"kind\":\"List\",\"id\":\"\",\"length\":0}",
|
||||
"\"identityHashCode\":0,\"id\":\"\",\"kind\":\"List\",\"length\":0}",
|
||||
buffer);
|
||||
}
|
||||
OS::PrintErr("\n\n\n");
|
||||
|
@ -6196,8 +6196,8 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) {
|
|||
buffer);
|
||||
|
||||
EXPECT_SUBSTRING(
|
||||
"\"kind\":\"TypeParameter\",\"id\":"
|
||||
"\"\",\"name\":\"X0\",\"parameterizedClass\":{\"type\":\"@Instance\","
|
||||
"\"id\":\"\",\"kind\":\"TypeParameter\",\"name\":\"X0\","
|
||||
"\"parameterizedClass\":{\"type\":\"@Instance\","
|
||||
"\"_vmType\":\"Class\",\"class\":{\"type\":\"@Class\",\"fixedId\":true,"
|
||||
"\"id\":\"\",\"name\":\"Null\",\"location\":{\"type\":"
|
||||
"\"SourceLocation\",\"script\":{\"type\":\"@Script\",\"fixedId\":true,"
|
||||
|
@ -6206,7 +6206,7 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) {
|
|||
"},\"library\":{\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\","
|
||||
"\"name\":\"dart.core\",\"uri\":\"dart:core\"}},\"kind\":\"Null\","
|
||||
"\"fixedId\":true,\"id\":\"\",\"valueAsString\":\"null\"}}]},"
|
||||
"\"identityHashCode\":0,\"kind\":\"List\",\"id\":\"\",\"length\":0}",
|
||||
"\"identityHashCode\":0,\"id\":\"\",\"kind\":\"List\",\"length\":0}",
|
||||
buffer);
|
||||
}
|
||||
// LinkedHashMap reference
|
||||
|
@ -6245,8 +6245,8 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) {
|
|||
buffer);
|
||||
|
||||
EXPECT_SUBSTRING(
|
||||
"\"kind\":\"TypeParameter\",\"id\":"
|
||||
"\"\",\"name\":\"X0\",\"parameterizedClass\":{\"type\":\"@Instance\","
|
||||
"\"id\":\"\",\"kind\":\"TypeParameter\",\"name\":\"X0\","
|
||||
"\"parameterizedClass\":{\"type\":\"@Instance\","
|
||||
"\"_vmType\":\"Class\",\"class\":{\"type\":\"@Class\",\"fixedId\":true,"
|
||||
"\"id\":\"\",\"name\":\"Null\",\"location\":{\"type\":"
|
||||
"\"SourceLocation\",\"script\":{\"type\":\"@Script\",\"fixedId\":true,"
|
||||
|
@ -6267,8 +6267,8 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) {
|
|||
buffer);
|
||||
|
||||
EXPECT_SUBSTRING(
|
||||
"\"kind\":\"TypeParameter\",\"id\":"
|
||||
"\"\",\"name\":\"X1\",\"parameterizedClass\":{\"type\":\"@Instance\","
|
||||
"\"id\":\"\",\"kind\":\"TypeParameter\",\"name\":\"X1\","
|
||||
"\"parameterizedClass\":{\"type\":\"@Instance\","
|
||||
"\"_vmType\":\"Class\",\"class\":{\"type\":\"@Class\",\"fixedId\":true,"
|
||||
"\"id\":\"\",\"name\":\"Null\",\"location\":{\"type\":"
|
||||
"\"SourceLocation\",\"script\":{\"type\":\"@Script\",\"fixedId\":true,"
|
||||
|
@ -6277,7 +6277,7 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) {
|
|||
"},\"library\":{\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\","
|
||||
"\"name\":\"dart.core\",\"uri\":\"dart:core\"}},\"kind\":\"Null\","
|
||||
"\"fixedId\":true,\"id\":\"\",\"valueAsString\":\"null\"}}]},"
|
||||
"\"identityHashCode\":0,\"kind\":\"Map\",\"id\":\"\",\"length\":0}",
|
||||
"\"identityHashCode\":0,\"id\":\"\",\"kind\":\"Map\",\"length\":0}",
|
||||
buffer);
|
||||
}
|
||||
// UserTag reference
|
||||
|
@ -6306,8 +6306,8 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) {
|
|||
"\"identityHashCode\":",
|
||||
buffer);
|
||||
EXPECT_SUBSTRING(
|
||||
"\"kind\":\"PlainInstance\","
|
||||
"\"id\":\"\"}",
|
||||
"\"id\":\"\","
|
||||
"\"kind\":\"PlainInstance\"}",
|
||||
buffer);
|
||||
}
|
||||
// Type reference
|
||||
|
|
Loading…
Reference in a new issue