diff --git a/DEPS b/DEPS index ba077594fe4..68a34a5e988 100644 --- a/DEPS +++ b/DEPS @@ -107,7 +107,7 @@ vars = { "chromedriver_tag": "83.0.4103.39", "dartdoc_rev" : "305713608c25106d95f9114418d895e08d1a9e9c", - "devtools_rev" : "e138d55437a59838607415ef21f20bd6c4955dbc", + "devtools_rev" : "b3bf672474a2bff82f33e1176aa803539baa0d60+1", "jsshell_tag": "version:88.0", "ffi_rev": "f3346299c55669cc0db48afae85b8110088bf8da", "fixnum_rev": "16d3890c6dc82ca629659da1934e412292508bba", diff --git a/pkg/vm_service/CHANGELOG.md b/pkg/vm_service/CHANGELOG.md index 47f3893bdcb..1613626b9dd 100644 --- a/pkg/vm_service/CHANGELOG.md +++ b/pkg/vm_service/CHANGELOG.md @@ -1,4 +1,9 @@ # Changelog + +## 7.1.0 +- Update to version `3.46` of the spec. +- Move `sourcePosition` properties into `ClassRef`, `FieldRef`, and `FuncRef`. + ## 7.0.0 - *breaking bug fix*: Fixed issue where response parsing could fail for `Context`. - Add support for `setBreakpointState` RPC and updated `Breakpoint` class to include diff --git a/pkg/vm_service/example/vm_service_assert.dart b/pkg/vm_service/example/vm_service_assert.dart index c861f827c8e..f9f2d6e8bbd 100644 --- a/pkg/vm_service/example/vm_service_assert.dart +++ b/pkg/vm_service/example/vm_service_assert.dart @@ -317,6 +317,7 @@ vms.ClassRef assertClassRef(vms.ClassRef obj) { assertNotNull(obj); assertString(obj.id!); assertString(obj.name!); + assertLibraryRef(obj.library!); return obj; } @@ -331,10 +332,10 @@ vms.Class assertClass(vms.Class obj) { assertNotNull(obj); assertString(obj.id!); assertString(obj.name!); + assertLibraryRef(obj.library!); assertBool(obj.isAbstract!); assertBool(obj.isConst!); assertBool(obj.traceAllocations!); - assertLibraryRef(obj.library!); assertListOfInstanceRef(obj.interfaces!); assertListOfFieldRef(obj.fields!); assertListOfFuncRef(obj.functions!); diff --git a/pkg/vm_service/java/version.properties b/pkg/vm_service/java/version.properties index d9345163f32..9e3fb907bc8 100644 --- a/pkg/vm_service/java/version.properties +++ b/pkg/vm_service/java/version.properties @@ -1 +1 @@ -version=3.45 +version=3.46 diff --git a/pkg/vm_service/lib/src/dart_io_extensions.dart b/pkg/vm_service/lib/src/dart_io_extensions.dart index 73b3b842654..9e9faaf2b09 100644 --- a/pkg/vm_service/lib/src/dart_io_extensions.dart +++ b/pkg/vm_service/lib/src/dart_io_extensions.dart @@ -485,7 +485,7 @@ class HttpProfileRequestData { HttpProfileRequestData.buildErrorRequest({ required this.error, required this.events, - }) : _connectionInfo = null, + }) : _connectionInfo = null, _contentLength = null, _cookies = [], _followRedirects = null, diff --git a/pkg/vm_service/lib/src/vm_service.dart b/pkg/vm_service/lib/src/vm_service.dart index a42219a453a..a460c69aed1 100644 --- a/pkg/vm_service/lib/src/vm_service.dart +++ b/pkg/vm_service/lib/src/vm_service.dart @@ -26,7 +26,7 @@ export 'snapshot_graph.dart' HeapSnapshotObjectNoData, HeapSnapshotObjectNullData; -const String vmServiceVersion = '3.45.0'; +const String vmServiceVersion = '3.46.0'; /// @optional const String optional = 'optional'; @@ -2690,8 +2690,8 @@ class AllocationProfile extends Response { as List? ?? []); memoryUsage = - createServiceObject(json['memoryUsage']!, const ['MemoryUsage']) - as MemoryUsage; + createServiceObject(json['memoryUsage'], const ['MemoryUsage']) + as MemoryUsage?; dateLastAccumulatorReset = json['dateLastAccumulatorReset'] is String ? int.parse(json['dateLastAccumulatorReset']) : json['dateLastAccumulatorReset']; @@ -2743,9 +2743,9 @@ class BoundField { }); BoundField._fromJson(Map json) { - decl = createServiceObject(json['decl']!, const ['FieldRef']) as FieldRef; + decl = createServiceObject(json['decl'], const ['FieldRef']) as FieldRef?; value = - createServiceObject(json['value']!, const ['InstanceRef', 'Sentinel']) + createServiceObject(json['value'], const ['InstanceRef', 'Sentinel']) as dynamic; } @@ -2800,7 +2800,7 @@ class BoundVariable extends Response { BoundVariable._fromJson(Map json) : super._fromJson(json) { name = json['name'] ?? ''; - value = createServiceObject(json['value']!, + value = createServiceObject(json['value'], const ['InstanceRef', 'TypeArgumentsRef', 'Sentinel']) as dynamic; declarationTokenPos = json['declarationTokenPos'] ?? -1; scopeStartTokenPos = json['scopeStartTokenPos'] ?? -1; @@ -2875,7 +2875,7 @@ class Breakpoint extends Obj { enabled = json['enabled'] ?? false; resolved = json['resolved'] ?? false; isSyntheticAsyncContinuation = json['isSyntheticAsyncContinuation']; - location = createServiceObject(json['location']!, + location = createServiceObject(json['location'], const ['SourceLocation', 'UnresolvedSourceLocation']) as dynamic; } @@ -2914,15 +2914,28 @@ class ClassRef extends ObjRef { /// The name of this class. String? name; + /// The location of this class in the source code. + @optional + SourceLocation? location; + + /// The library which contains this class. + LibraryRef? library; + ClassRef({ required this.name, + required this.library, required String id, + this.location, }) : super( id: id, ); ClassRef._fromJson(Map json) : super._fromJson(json) { name = json['name'] ?? ''; + location = createServiceObject(json['location'], const ['SourceLocation']) + as SourceLocation?; + library = createServiceObject(json['library'], const ['LibraryRef']) + as LibraryRef?; } @override @@ -2934,7 +2947,9 @@ class ClassRef extends ObjRef { json['type'] = type; json.addAll({ 'name': name, + 'library': library?.toJson(), }); + _setIfNotNull(json, 'location', location?.toJson()); return json; } @@ -2942,7 +2957,8 @@ class ClassRef extends ObjRef { operator ==(other) => other is ClassRef && id == other.id; - String toString() => '[ClassRef id: ${id}, name: ${name}]'; + String toString() => + '[ClassRef id: ${id}, name: ${name}, library: ${library}]'; } /// A `Class` provides information about a Dart language class. @@ -2953,6 +2969,13 @@ class Class extends Obj implements ClassRef { /// The name of this class. String? name; + /// The location of this class in the source code. + @optional + SourceLocation? location; + + /// The library which contains this class. + LibraryRef? library; + /// The error which occurred during class finalization, if it exists. @optional ErrorRef? error; @@ -2966,13 +2989,6 @@ class Class extends Obj implements ClassRef { /// Are allocations of this class being traced? bool? traceAllocations; - /// The library which contains this class. - LibraryRef? library; - - /// The location of this class in the source code. - @optional - SourceLocation? location; - /// The superclass of this class, if any. @optional ClassRef? superClass; @@ -3006,17 +3022,17 @@ class Class extends Obj implements ClassRef { Class({ required this.name, + required this.library, required this.isAbstract, required this.isConst, required this.traceAllocations, - required this.library, required this.interfaces, required this.fields, required this.functions, required this.subclasses, required String id, - this.error, this.location, + this.error, this.superClass, this.superType, this.mixin, @@ -3026,14 +3042,14 @@ class Class extends Obj implements ClassRef { Class._fromJson(Map json) : super._fromJson(json) { name = json['name'] ?? ''; + location = createServiceObject(json['location'], const ['SourceLocation']) + as SourceLocation?; + library = createServiceObject(json['library'], const ['LibraryRef']) + as LibraryRef?; error = createServiceObject(json['error'], const ['ErrorRef']) as ErrorRef?; isAbstract = json['abstract'] ?? false; isConst = json['const'] ?? false; traceAllocations = json['traceAllocations'] ?? false; - library = createServiceObject(json['library']!, const ['LibraryRef']) - as LibraryRef; - location = createServiceObject(json['location'], const ['SourceLocation']) - as SourceLocation?; superClass = createServiceObject(json['super'], const ['ClassRef']) as ClassRef?; superType = createServiceObject(json['superType'], const ['InstanceRef']) @@ -3063,17 +3079,17 @@ class Class extends Obj implements ClassRef { json['type'] = type; json.addAll({ 'name': name, + 'library': library?.toJson(), 'abstract': isAbstract, 'const': isConst, 'traceAllocations': traceAllocations, - 'library': library?.toJson(), 'interfaces': interfaces?.map((f) => f.toJson()).toList(), 'fields': fields?.map((f) => f.toJson()).toList(), 'functions': functions?.map((f) => f.toJson()).toList(), 'subclasses': subclasses?.map((f) => f.toJson()).toList(), }); - _setIfNotNull(json, 'error', error?.toJson()); _setIfNotNull(json, 'location', location?.toJson()); + _setIfNotNull(json, 'error', error?.toJson()); _setIfNotNull(json, 'super', superClass?.toJson()); _setIfNotNull(json, 'superType', superType?.toJson()); _setIfNotNull(json, 'mixin', mixin?.toJson()); @@ -3118,7 +3134,7 @@ class ClassHeapStats extends Response { ClassHeapStats._fromJson(Map json) : super._fromJson(json) { classRef = - createServiceObject(json['class']!, const ['ClassRef']) as ClassRef; + createServiceObject(json['class'], const ['ClassRef']) as ClassRef?; accumulatedSize = json['accumulatedSize'] ?? -1; bytesCurrent = json['bytesCurrent'] ?? -1; instancesAccumulated = json['instancesAccumulated'] ?? -1; @@ -3378,7 +3394,7 @@ class ContextElement { ContextElement._fromJson(Map json) { value = - createServiceObject(json['value']!, const ['InstanceRef', 'Sentinel']) + createServiceObject(json['value'], const ['InstanceRef', 'Sentinel']) as dynamic; } @@ -4015,6 +4031,10 @@ class FieldRef extends ObjRef { /// Is this field static? bool? isStatic; + /// The location of this field in the source code. + @optional + SourceLocation? location; + FieldRef({ required this.name, required this.owner, @@ -4023,19 +4043,22 @@ class FieldRef extends ObjRef { required this.isFinal, required this.isStatic, required String id, + this.location, }) : super( id: id, ); FieldRef._fromJson(Map json) : super._fromJson(json) { name = json['name'] ?? ''; - owner = createServiceObject(json['owner']!, const ['ObjRef']) as ObjRef; + owner = createServiceObject(json['owner'], const ['ObjRef']) as ObjRef?; declaredType = - createServiceObject(json['declaredType']!, const ['InstanceRef']) - as InstanceRef; + createServiceObject(json['declaredType'], const ['InstanceRef']) + as InstanceRef?; isConst = json['const'] ?? false; isFinal = json['final'] ?? false; isStatic = json['static'] ?? false; + location = createServiceObject(json['location'], const ['SourceLocation']) + as SourceLocation?; } @override @@ -4053,6 +4076,7 @@ class FieldRef extends ObjRef { 'final': isFinal, 'static': isStatic, }); + _setIfNotNull(json, 'location', location?.toJson()); return json; } @@ -4091,6 +4115,10 @@ class Field extends Obj implements FieldRef { /// Is this field static? bool? isStatic; + /// The location of this field in the source code. + @optional + SourceLocation? location; + /// The value of this field, if the field is static. If uninitialized, this /// will take the value of an uninitialized Sentinel. /// @@ -4098,10 +4126,6 @@ class Field extends Obj implements FieldRef { @optional dynamic staticValue; - /// The location of this field in the source code. - @optional - SourceLocation? location; - Field({ required this.name, required this.owner, @@ -4110,25 +4134,25 @@ class Field extends Obj implements FieldRef { required this.isFinal, required this.isStatic, required String id, - this.staticValue, this.location, + this.staticValue, }) : super( id: id, ); Field._fromJson(Map json) : super._fromJson(json) { name = json['name'] ?? ''; - owner = createServiceObject(json['owner']!, const ['ObjRef']) as ObjRef; + owner = createServiceObject(json['owner'], const ['ObjRef']) as ObjRef?; declaredType = - createServiceObject(json['declaredType']!, const ['InstanceRef']) - as InstanceRef; + createServiceObject(json['declaredType'], const ['InstanceRef']) + as InstanceRef?; isConst = json['const'] ?? false; isFinal = json['final'] ?? false; isStatic = json['static'] ?? false; - staticValue = createServiceObject( - json['staticValue'], const ['InstanceRef', 'Sentinel']) as dynamic; location = createServiceObject(json['location'], const ['SourceLocation']) as SourceLocation?; + staticValue = createServiceObject( + json['staticValue'], const ['InstanceRef', 'Sentinel']) as dynamic; } @override @@ -4146,8 +4170,8 @@ class Field extends Obj implements FieldRef { 'final': isFinal, 'static': isStatic, }); - _setIfNotNull(json, 'staticValue', staticValue?.toJson()); _setIfNotNull(json, 'location', location?.toJson()); + _setIfNotNull(json, 'staticValue', staticValue?.toJson()); return json; } @@ -4328,12 +4352,17 @@ class FuncRef extends ObjRef { /// Is this function const? bool? isConst; + /// The location of this function in the source code. + @optional + SourceLocation? location; + FuncRef({ required this.name, required this.owner, required this.isStatic, required this.isConst, required String id, + this.location, }) : super( id: id, ); @@ -4341,9 +4370,11 @@ class FuncRef extends ObjRef { FuncRef._fromJson(Map json) : super._fromJson(json) { name = json['name'] ?? ''; owner = createServiceObject( - json['owner']!, const ['LibraryRef', 'ClassRef', 'FuncRef']) as dynamic; + json['owner'], const ['LibraryRef', 'ClassRef', 'FuncRef']) as dynamic; isStatic = json['static'] ?? false; isConst = json['const'] ?? false; + location = createServiceObject(json['location'], const ['SourceLocation']) + as SourceLocation?; } @override @@ -4359,6 +4390,7 @@ class FuncRef extends ObjRef { 'static': isStatic, 'const': isConst, }); + _setIfNotNull(json, 'location', location?.toJson()); return json; } @@ -4413,7 +4445,7 @@ class Func extends Obj implements FuncRef { Func._fromJson(Map json) : super._fromJson(json) { name = json['name'] ?? ''; owner = createServiceObject( - json['owner']!, const ['LibraryRef', 'ClassRef', 'FuncRef']) as dynamic; + json['owner'], const ['LibraryRef', 'ClassRef', 'FuncRef']) as dynamic; isStatic = json['static'] ?? false; isConst = json['const'] ?? false; location = createServiceObject(json['location'], const ['SourceLocation']) @@ -4600,7 +4632,7 @@ class InstanceRef extends ObjRef { kind = json['kind'] ?? ''; identityHashCode = json['identityHashCode'] ?? -1; classRef = - createServiceObject(json['class']!, const ['ClassRef']) as ClassRef; + createServiceObject(json['class'], const ['ClassRef']) as ClassRef?; valueAsString = json['valueAsString']; valueAsStringIsTruncated = json['valueAsStringIsTruncated']; length = json['length']; @@ -4984,7 +5016,7 @@ class Instance extends Obj implements InstanceRef { kind = json['kind'] ?? ''; identityHashCode = json['identityHashCode'] ?? -1; classRef = - createServiceObject(json['class']!, const ['ClassRef']) as ClassRef; + createServiceObject(json['class'], const ['ClassRef']) as ClassRef?; valueAsString = json['valueAsString']; valueAsStringIsTruncated = json['valueAsStringIsTruncated']; length = json['length']; @@ -5250,7 +5282,7 @@ class Isolate extends Response implements IsolateRef { livePorts = json['livePorts'] ?? -1; pauseOnExit = json['pauseOnExit'] ?? false; pauseEvent = - createServiceObject(json['pauseEvent']!, const ['Event']) as Event; + createServiceObject(json['pauseEvent'], const ['Event']) as Event?; rootLib = createServiceObject(json['rootLib'], const ['LibraryRef']) as LibraryRef?; libraries = List.from( @@ -5519,7 +5551,7 @@ class InboundReference { }); InboundReference._fromJson(Map json) { - source = createServiceObject(json['source']!, const ['ObjRef']) as ObjRef; + source = createServiceObject(json['source'], const ['ObjRef']) as ObjRef?; parentListIndex = json['parentListIndex']; parentField = createServiceObject(json['parentField'], const ['FieldRef']) as FieldRef?; @@ -5744,8 +5776,8 @@ class LibraryDependency { isImport = json['isImport'] ?? false; isDeferred = json['isDeferred'] ?? false; prefix = json['prefix'] ?? ''; - target = createServiceObject(json['target']!, const ['LibraryRef']) - as LibraryRef; + target = createServiceObject(json['target'], const ['LibraryRef']) + as LibraryRef?; } Map toJson() { @@ -5807,19 +5839,19 @@ class LogRecord extends Response { }); LogRecord._fromJson(Map json) : super._fromJson(json) { - message = createServiceObject(json['message']!, const ['InstanceRef']) - as InstanceRef; + message = createServiceObject(json['message'], const ['InstanceRef']) + as InstanceRef?; time = json['time'] ?? -1; level = json['level'] ?? -1; sequenceNumber = json['sequenceNumber'] ?? -1; - loggerName = createServiceObject(json['loggerName']!, const ['InstanceRef']) - as InstanceRef; - zone = createServiceObject(json['zone']!, const ['InstanceRef']) - as InstanceRef; - error = createServiceObject(json['error']!, const ['InstanceRef']) - as InstanceRef; - stackTrace = createServiceObject(json['stackTrace']!, const ['InstanceRef']) - as InstanceRef; + loggerName = createServiceObject(json['loggerName'], const ['InstanceRef']) + as InstanceRef?; + zone = createServiceObject(json['zone'], const ['InstanceRef']) + as InstanceRef?; + error = createServiceObject(json['error'], const ['InstanceRef']) + as InstanceRef?; + stackTrace = createServiceObject(json['stackTrace'], const ['InstanceRef']) + as InstanceRef?; } @override @@ -5861,10 +5893,10 @@ class MapAssociation { }); MapAssociation._fromJson(Map json) { - key = createServiceObject(json['key']!, const ['InstanceRef', 'Sentinel']) + key = createServiceObject(json['key'], const ['InstanceRef', 'Sentinel']) as dynamic; value = - createServiceObject(json['value']!, const ['InstanceRef', 'Sentinel']) + createServiceObject(json['value'], const ['InstanceRef', 'Sentinel']) as dynamic; } @@ -6051,6 +6083,11 @@ class NullValRef extends InstanceRef { kind: InstanceKind.kNull, classRef: ClassRef( id: 'class/null', + library: LibraryRef( + id: '', + name: 'dart:core', + uri: 'dart:core', + ), name: 'Null', ), ); @@ -6098,6 +6135,11 @@ class NullVal extends Instance implements NullValRef { kind: InstanceKind.kNull, classRef: ClassRef( id: 'class/null', + library: LibraryRef( + id: '', + name: 'dart:core', + uri: 'dart:core', + ), name: 'Null', ), ); @@ -6323,7 +6365,7 @@ class ProfileFunction { exclusiveTicks = json['exclusiveTicks'] ?? -1; resolvedUrl = json['resolvedUrl'] ?? ''; function = - createServiceObject(json['function']!, const ['dynamic']) as dynamic; + createServiceObject(json['function'], const ['dynamic']) as dynamic; } Map toJson() { @@ -6433,8 +6475,8 @@ class ProcessMemoryUsage extends Response { ProcessMemoryUsage._fromJson(Map json) : super._fromJson(json) { - root = createServiceObject(json['root']!, const ['ProcessMemoryItem']) - as ProcessMemoryItem; + root = createServiceObject(json['root'], const ['ProcessMemoryItem']) + as ProcessMemoryItem?; } @override @@ -6562,7 +6604,7 @@ class RetainingObject { }); RetainingObject._fromJson(Map json) { - value = createServiceObject(json['value']!, const ['ObjRef']) as ObjRef; + value = createServiceObject(json['value'], const ['ObjRef']) as ObjRef?; parentListIndex = json['parentListIndex']; parentMapKey = createServiceObject(json['parentMapKey'], const ['ObjRef']) as ObjRef?; @@ -6810,8 +6852,8 @@ class Script extends Obj implements ScriptRef { Script._fromJson(Map json) : super._fromJson(json) { uri = json['uri'] ?? ''; - library = createServiceObject(json['library']!, const ['LibraryRef']) - as LibraryRef; + library = createServiceObject(json['library'], const ['LibraryRef']) + as LibraryRef?; lineOffset = json['lineOffset']; columnOffset = json['columnOffset']; source = json['source']; @@ -6932,7 +6974,7 @@ class SourceLocation extends Response { SourceLocation._fromJson(Map json) : super._fromJson(json) { script = - createServiceObject(json['script']!, const ['ScriptRef']) as ScriptRef; + createServiceObject(json['script'], const ['ScriptRef']) as ScriptRef?; tokenPos = json['tokenPos'] ?? -1; endTokenPos = json['endTokenPos']; } @@ -7235,7 +7277,7 @@ class Timeline extends Response { static Timeline? parse(Map? json) => json == null ? null : Timeline._fromJson(json); - /// A list of timeline events. No order is guarenteed for these events; in + /// A list of timeline events. No order is guaranteed for these events; in /// particular, these events may be unordered with respect to their /// timestamps. List? traceEvents; diff --git a/pkg/vm_service/pubspec.yaml b/pkg/vm_service/pubspec.yaml index a7db2e82b0e..9ea0b773b00 100644 --- a/pkg/vm_service/pubspec.yaml +++ b/pkg/vm_service/pubspec.yaml @@ -3,7 +3,7 @@ description: >- A library to communicate with a service implementing the Dart VM service protocol. -version: 7.0.0 +version: 7.1.0 homepage: https://github.com/dart-lang/sdk/tree/master/pkg/vm_service diff --git a/pkg/vm_service/tool/dart/generate_dart.dart b/pkg/vm_service/tool/dart/generate_dart.dart index 5e348b1e2fe..0f9897fd831 100644 --- a/pkg/vm_service/tool/dart/generate_dart.dart +++ b/pkg/vm_service/tool/dart/generate_dart.dart @@ -1491,6 +1491,8 @@ class Type extends Member { gen.writeln('identityHashCode: 0,'); gen.writeln('kind: InstanceKind.kNull,'); gen.writeln("classRef: ClassRef(id: 'class/null',"); + gen.writeln("library: LibraryRef(id: '', name: 'dart:core',"); + gen.writeln("uri: 'dart:core',),"); gen.writeln("name: 'Null',),"); gen.writeln(')'); } @@ -1640,10 +1642,9 @@ class Type extends Member { } } else { String typesList = _typeRefListToString(field.type.types); - String nullable = - field.optional && field.type.name != 'dynamic' ? '?' : ''; + String nullable = field.type.name != 'dynamic' ? '?' : ''; gen.writeln("${field.generatableName} = " - "createServiceObject(json['${field.name}']${field.optional ? '' : '!'}, " + "createServiceObject(json['${field.name}'], " "$typesList) as ${field.type.name}$nullable;"); } }); diff --git a/runtime/observatory/lib/src/service/object.dart b/runtime/observatory/lib/src/service/object.dart index 4db752a33b1..f3a26e775e7 100644 --- a/runtime/observatory/lib/src/service/object.dart +++ b/runtime/observatory/lib/src/service/object.dart @@ -4755,8 +4755,8 @@ void _upgradeCollection(collection, ServiceObjectOwner? owner) { void _upgradeMap(Map map, ServiceObjectOwner? owner) { map.forEach((k, v) { - if ((v is Map) && _isServiceMap(v)) { - map[k] = owner!.getFromMap(v); + if ((v is Map) && owner != null && _isServiceMap(v)) { + map[k] = owner.getFromMap(v); } else if (v is List) { _upgradeList(v, owner); } else if (v is Map) { diff --git a/runtime/observatory/tests/service/get_version_rpc_test.dart b/runtime/observatory/tests/service/get_version_rpc_test.dart index 1fe66c56493..5ff857b8608 100644 --- a/runtime/observatory/tests/service/get_version_rpc_test.dart +++ b/runtime/observatory/tests/service/get_version_rpc_test.dart @@ -12,7 +12,7 @@ var tests = [ final result = await vm.invokeRpcNoUpgrade('getVersion', {}); expect(result['type'], 'Version'); expect(result['major'], 3); - expect(result['minor'], 45); + expect(result['minor'], 46); expect(result['_privateMajor'], 0); expect(result['_privateMinor'], 0); }, diff --git a/runtime/observatory_2/lib/src/service/object.dart b/runtime/observatory_2/lib/src/service/object.dart index e2acf8a5e80..2baf6d5102f 100644 --- a/runtime/observatory_2/lib/src/service/object.dart +++ b/runtime/observatory_2/lib/src/service/object.dart @@ -4765,7 +4765,7 @@ void _upgradeCollection(collection, ServiceObjectOwner owner) { void _upgradeMap(Map map, ServiceObjectOwner owner) { map.forEach((k, v) { - if ((v is Map) && _isServiceMap(v)) { + if ((v is Map) && owner != null && _isServiceMap(v)) { map[k] = owner.getFromMap(v); } else if (v is List) { _upgradeList(v, owner); diff --git a/runtime/observatory_2/tests/service_2/get_version_rpc_test.dart b/runtime/observatory_2/tests/service_2/get_version_rpc_test.dart index bd9d9b13ead..809085615da 100644 --- a/runtime/observatory_2/tests/service_2/get_version_rpc_test.dart +++ b/runtime/observatory_2/tests/service_2/get_version_rpc_test.dart @@ -12,7 +12,7 @@ var tests = [ var result = await vm.invokeRpcNoUpgrade('getVersion', {}); expect(result['type'], equals('Version')); expect(result['major'], equals(3)); - expect(result['minor'], equals(45)); + expect(result['minor'], equals(46)); expect(result['_privateMajor'], equals(0)); expect(result['_privateMinor'], equals(0)); }, diff --git a/runtime/vm/json_test.cc b/runtime/vm/json_test.cc index db2e2f36db2..60c679e0099 100644 --- a/runtime/vm/json_test.cc +++ b/runtime/vm/json_test.cc @@ -171,23 +171,24 @@ ISOLATE_UNIT_TEST_CASE(JSON_JSONStream_DartObject) { } char buffer[1024]; ElideJSONSubstring("classes", js.ToCString(), buffer); + ElideJSONSubstring("libraries", buffer, buffer); + ElideJSONSubstring("objects", buffer, buffer); EXPECT_STREQ( - "[{\"type\":\"@Instance\"," - "\"_vmType\":\"null\"," - "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"Null\"}," - "\"kind\":\"Null\"," - "\"fixedId\":true," - "\"id\":\"objects\\/null\"," - "\"valueAsString\":\"null\"}," - "{\"object_key\":" - "{\"type\":\"@Instance\"," - "\"_vmType\":\"null\"," - "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"Null\"}," - "\"kind\":\"Null\"," - "\"fixedId\":true," - "\"id\":\"objects\\/null\"," + "[{\"type\":\"@Instance\",\"_vmType\":\"null\",\"class\":{\"type\":\"@" + "Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"Null\",\"location\":{" + "\"type\":\"SourceLocation\",\"script\":{\"type\":\"@Script\"," + "\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core\\/null.dart\",\"_" + "kind\":\"kernel\"},\"tokenPos\":925,\"endTokenPos\":1165},\"library\":{" + "\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\",\"name\":\"dart." + "core\",\"uri\":\"dart:core\"}},\"kind\":\"Null\",\"fixedId\":true," + "\"id\":\"\",\"valueAsString\":\"null\"},{\"object_key\":{\"type\":\"@" + "Instance\",\"_vmType\":\"null\",\"class\":{\"type\":\"@Class\"," + "\"fixedId\":true,\"id\":\"\",\"name\":\"Null\",\"location\":{\"type\":" + "\"SourceLocation\",\"script\":{\"type\":\"@Script\",\"fixedId\":true," + "\"id\":\"\",\"uri\":\"dart:core\\/null.dart\",\"_kind\":\"kernel\"}," + "\"tokenPos\":925,\"endTokenPos\":1165},\"library\":{\"type\":\"@" + "Library\",\"fixedId\":true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":" + "\"dart:core\"}},\"kind\":\"Null\",\"fixedId\":true,\"id\":\"\"," "\"valueAsString\":\"null\"}}]", buffer); } diff --git a/runtime/vm/object_service.cc b/runtime/vm/object_service.cc index cc858f565fd..1c23fa8e76a 100644 --- a/runtime/vm/object_service.cc +++ b/runtime/vm/object_service.cc @@ -87,6 +87,13 @@ void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { const String& scrubbed_name = String::Handle(ScrubbedName()); const String& vm_name = String::Handle(Name()); AddNameProperties(&jsobj, scrubbed_name.ToCString(), vm_name.ToCString()); + const Script& script = Script::Handle(this->script()); + if (!script.IsNull()) { + jsobj.AddLocation(script, token_pos(), end_token_pos()); + } + + jsobj.AddProperty("library", Object::Handle(library())); + if (ref) { return; } @@ -116,11 +123,6 @@ void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { mix ^= interface_array.At(interface_array.Length() - 1); jsobj.AddProperty("mixin", mix); } - jsobj.AddProperty("library", Object::Handle(library())); - const Script& script = Script::Handle(this->script()); - if (!script.IsNull()) { - jsobj.AddLocation(script, token_pos(), end_token_pos()); - } { JSONArray interfaces_array(&jsobj, "interfaces"); Type& interface_type = Type::Handle(); @@ -317,6 +319,12 @@ void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { jsobj.AddProperty("const", is_const()); jsobj.AddProperty("_intrinsic", is_intrinsic()); jsobj.AddProperty("_native", is_native()); + + const Script& script = Script::Handle(this->script()); + if (!script.IsNull()) { + jsobj.AddLocation(script, token_pos(), end_token_pos()); + } + if (ref) { return; } @@ -348,11 +356,6 @@ void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { jsobj.AddProperty("_field", field); } } - - const Script& script = Script::Handle(this->script()); - if (!script.IsNull()) { - jsobj.AddLocation(script, token_pos(), end_token_pos()); - } } void FfiTrampolineData::PrintJSONImpl(JSONStream* stream, bool ref) const { @@ -390,6 +393,12 @@ void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { jsobj.AddProperty("static", is_static()); jsobj.AddProperty("final", is_final()); jsobj.AddProperty("const", is_const()); + + const class Script& script = Script::Handle(Script()); + if (!script.IsNull()) { + jsobj.AddLocation(script, token_pos(), end_token_pos()); + } + if (ref) { return; } @@ -416,10 +425,6 @@ void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { } else { jsobj.AddPropertyF("_guardLength", "%" Pd, guarded_list_length()); } - const class Script& script = Script::Handle(Script()); - if (!script.IsNull()) { - jsobj.AddLocation(script, token_pos()); - } } // See also Dart_ScriptGetTokenInfo. diff --git a/runtime/vm/object_test.cc b/runtime/vm/object_test.cc index 4d2a1fc97f5..6136da2b6bf 100644 --- a/runtime/vm/object_test.cc +++ b/runtime/vm/object_test.cc @@ -4344,8 +4344,16 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) { Class& cls = Class::Handle(isolate->group()->object_store()->bool_class()); cls.PrintJSON(&js, true); ElideJSONSubstring("classes", js.ToCString(), buffer); + ElideJSONSubstring("libraries", buffer, buffer); + EXPECT_STREQ( - "{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"bool\"}", + "{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"bool\"," + "\"location\":{\"type\":\"SourceLocation\",\"script\":{\"type\":\"@" + "Script\"," + "\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core\\/bool.dart\"," + "\"_kind\":\"kernel\"},\"tokenPos\":436,\"endTokenPos\":4432}," + "\"library\":{\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\"," + "\"name\":\"dart.core\",\"uri\":\"dart:core\"}}", buffer); } // Function reference @@ -4359,14 +4367,23 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) { ASSERT(!func.IsNull()); func.PrintJSON(&js, true); ElideJSONSubstring("classes", js.ToCString(), buffer); + ElideJSONSubstring("libraries", buffer, buffer); EXPECT_STREQ( - "{\"type\":\"@Function\",\"fixedId\":true," - "\"id\":\"\",\"name\":\"toString\"," - "\"owner\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"bool\"}," - "\"_kind\":\"RegularFunction\"," - "\"static\":false,\"const\":false," - "\"_intrinsic\":false,\"_native\":false}", + "{\"type\":\"@Function\",\"fixedId\":true,\"id\":\"\"," + "\"name\":\"toString\",\"owner\":{\"type\":\"@Class\"," + "\"fixedId\":true,\"id\":\"\",\"name\":\"bool\"," + "\"location\":{\"type\":\"SourceLocation\"," + "\"script\":{\"type\":\"@Script\",\"fixedId\":true," + "\"id\":\"\",\"uri\":\"dart:core\\/bool.dart\"," + "\"_kind\":\"kernel\"},\"tokenPos\":436,\"endTokenPos\":4432}," + "\"library\":{\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\"," + "\"name\":\"dart.core\",\"uri\":\"dart:core\"}}," + "\"_kind\":\"RegularFunction\",\"static\":false,\"const\":false," + "\"_intrinsic\":false,\"_native\":false," + "\"location\":{\"type\":\"SourceLocation\"," + "\"script\":{\"type\":\"@Script\",\"fixedId\":true,\"id\":\"\"," + "\"uri\":\"dart:core\\/bool.dart\",\"_kind\":\"kernel\"}," + "\"tokenPos\":4372,\"endTokenPos\":4430}}", buffer); } // Library reference @@ -4386,15 +4403,17 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) { JSONStream js; Bool::True().PrintJSON(&js, true); ElideJSONSubstring("classes", js.ToCString(), buffer); + ElideJSONSubstring("libraries", buffer, buffer); EXPECT_STREQ( - "{\"type\":\"@Instance\"," - "\"_vmType\":\"Bool\"," - "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"bool\"}," - "\"identityHashCode\":0," - "\"kind\":\"Bool\"," - "\"fixedId\":true," - "\"id\":\"objects\\/bool-true\",\"valueAsString\":\"true\"}", + "{\"type\":\"@Instance\",\"_vmType\":\"Bool\",\"class\":{\"type\":\"@" + "Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"bool\",\"location\":{" + "\"type\":\"SourceLocation\",\"script\":{\"type\":\"@Script\"," + "\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core\\/bool.dart\",\"_" + "kind\":\"kernel\"},\"tokenPos\":436,\"endTokenPos\":4432},\"library\":" + "{\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\",\"name\":\"dart." + "core\",\"uri\":\"dart:core\"}},\"identityHashCode\":0,\"kind\":" + "\"Bool\",\"fixedId\":true,\"id\":\"objects\\/bool-true\"," + "\"valueAsString\":\"true\"}", buffer); } // Smi reference @@ -4404,16 +4423,17 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) { smi.PrintJSON(&js, true); ElideJSONSubstring("classes", js.ToCString(), buffer); ElideJSONSubstring("_Smi@", buffer, buffer); + ElideJSONSubstring("libraries", buffer, buffer); EXPECT_STREQ( - "{\"type\":\"@Instance\"," - "\"_vmType\":\"Smi\"," - "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"_Smi\"," - "\"_vmName\":\"\"}," - "\"identityHashCode\":0," - "\"kind\":\"Int\"," - "\"fixedId\":true," - "\"id\":\"objects\\/int-7\",\"valueAsString\":\"7\"}", + "{\"type\":\"@Instance\",\"_vmType\":\"Smi\",\"class\":{\"type\":\"@" + "Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_Smi\",\"_vmName\":" + "\"\",\"location\":{\"type\":\"SourceLocation\",\"script\":{\"type\":" + "\"@Script\",\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core-" + "patch\\/integers.dart\",\"_kind\":\"kernel\"},\"tokenPos\":16466," + "\"endTokenPos\":24948},\"library\":{\"type\":\"@Library\",\"fixedId\":" + "true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":\"dart:core\"}}," + "\"identityHashCode\":0,\"kind\":\"Int\",\"fixedId\":true,\"id\":" + "\"objects\\/int-7\",\"valueAsString\":\"7\"}", buffer); } // Mint reference @@ -4423,15 +4443,18 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) { smi.PrintJSON(&js, true); ElideJSONSubstring("classes", js.ToCString(), buffer); ElideJSONSubstring("objects", buffer, buffer); + ElideJSONSubstring("libraries", buffer, buffer); ElideJSONSubstring("_Mint@", buffer, buffer); EXPECT_STREQ( - "{\"type\":\"@Instance\"," - "\"_vmType\":\"Mint\"," - "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"_Mint\",\"_vmName\":\"\"}," - "\"identityHashCode\":0," - "\"kind\":\"Int\"," - "\"id\":\"\",\"valueAsString\":\"-9223372036854775808\"}", + "{\"type\":\"@Instance\",\"_vmType\":\"Mint\",\"class\":{\"type\":\"@" + "Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_Mint\",\"_vmName\":" + "\"\",\"location\":{\"type\":\"SourceLocation\",\"script\":{\"type\":" + "\"@Script\",\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core-" + "patch\\/integers.dart\",\"_kind\":\"kernel\"},\"tokenPos\":25029," + "\"endTokenPos\":25413},\"library\":{\"type\":\"@Library\",\"fixedId\":" + "true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":\"dart:core\"}}," + "\"identityHashCode\":0,\"kind\":\"Int\",\"id\":\"\",\"valueAsString\":" + "\"-9223372036854775808\"}", buffer); } // Double reference @@ -4441,15 +4464,18 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) { dub.PrintJSON(&js, true); ElideJSONSubstring("classes", js.ToCString(), buffer); ElideJSONSubstring("objects", buffer, buffer); + ElideJSONSubstring("libraries", buffer, buffer); ElideJSONSubstring("_Double@", buffer, buffer); EXPECT_STREQ( - "{\"type\":\"@Instance\"," - "\"_vmType\":\"Double\"," - "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"_Double\",\"_vmName\":\"\"}," - "\"identityHashCode\":0," - "\"kind\":\"Double\"," - "\"id\":\"\",\"valueAsString\":\"0.1234\"}", + "{\"type\":\"@Instance\",\"_vmType\":\"Double\",\"class\":{\"type\":\"@" + "Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_Double\",\"_vmName\":" + "\"\",\"location\":{\"type\":\"SourceLocation\",\"script\":{\"type\":" + "\"@Script\",\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core-" + "patch\\/double.dart\",\"_kind\":\"kernel\"},\"tokenPos\":248," + "\"endTokenPos\":12248},\"library\":{\"type\":\"@Library\",\"fixedId\":" + "true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":\"dart:core\"}}," + "\"identityHashCode\":0,\"kind\":\"Double\",\"id\":\"\"," + "\"valueAsString\":\"0.1234\"}", buffer); } // String reference @@ -4459,15 +4485,18 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) { str.PrintJSON(&js, true); ElideJSONSubstring("classes", js.ToCString(), buffer); ElideJSONSubstring("objects", buffer, buffer); + ElideJSONSubstring("libraries", buffer, buffer); ElideJSONSubstring("_OneByteString@", buffer, buffer); EXPECT_STREQ( - "{\"type\":\"@Instance\"," - "\"_vmType\":\"String\"," - "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"_OneByteString\",\"_vmName\":\"\"}," - "\"identityHashCode\":0," - "\"kind\":\"String\"," - "\"id\":\"\",\"length\":2,\"valueAsString\":\"dw\"}", + "{\"type\":\"@Instance\",\"_vmType\":\"String\",\"class\":{\"type\":\"@" + "Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_OneByteString\",\"_" + "vmName\":\"\",\"location\":{\"type\":\"SourceLocation\",\"script\":{" + "\"type\":\"@Script\",\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core-" + "patch\\/string_patch.dart\",\"_kind\":\"kernel\"},\"tokenPos\":32310," + "\"endTokenPos\":44332},\"library\":{\"type\":\"@Library\",\"fixedId\":" + "true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":\"dart:core\"}}," + "\"identityHashCode\":0,\"kind\":\"String\",\"id\":\"\",\"length\":2," + "\"valueAsString\":\"dw\"}", buffer); } // Array reference @@ -4477,15 +4506,17 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) { array.PrintJSON(&js, true); ElideJSONSubstring("classes", js.ToCString(), buffer); ElideJSONSubstring("objects", buffer, buffer); + ElideJSONSubstring("libraries", buffer, buffer); ElideJSONSubstring("_List@", buffer, buffer); EXPECT_STREQ( - "{\"type\":\"@Instance\"," - "\"_vmType\":\"Array\"," - "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"_List\",\"_vmName\":\"\"}," - "\"identityHashCode\":0," - "\"kind\":\"List\"," - "\"id\":\"\",\"length\":0}", + "{\"type\":\"@Instance\",\"_vmType\":\"Array\",\"class\":{\"type\":\"@" + "Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_List\",\"_vmName\":" + "\"\",\"location\":{\"type\":\"SourceLocation\",\"script\":{\"type\":" + "\"@Script\",\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core-" + "patch\\/array.dart\",\"_kind\":\"kernel\"},\"tokenPos\":248," + "\"endTokenPos\":7758},\"library\":{\"type\":\"@Library\",\"fixedId\":" + "true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":\"dart:core\"}}," + "\"identityHashCode\":0,\"kind\":\"List\",\"id\":\"\",\"length\":0}", buffer); } // GrowableObjectArray reference @@ -4496,16 +4527,18 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) { array.PrintJSON(&js, true); ElideJSONSubstring("classes", js.ToCString(), buffer); ElideJSONSubstring("objects", buffer, buffer); + ElideJSONSubstring("libraries", buffer, buffer); ElideJSONSubstring("_GrowableList@", buffer, buffer); EXPECT_STREQ( - "{\"type\":\"@Instance\"," - "\"_vmType\":\"GrowableObjectArray\"," - "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"_GrowableList\"," - "\"_vmName\":\"\"}," - "\"identityHashCode\":0," - "\"kind\":\"List\"," - "\"id\":\"\",\"length\":0}", + "{\"type\":\"@Instance\",\"_vmType\":\"GrowableObjectArray\",\"class\":" + "{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_" + "GrowableList\",\"_vmName\":\"\",\"location\":{\"type\":" + "\"SourceLocation\",\"script\":{\"type\":\"@Script\",\"fixedId\":true," + "\"id\":\"\",\"uri\":\"dart:core-patch\\/growable_array.dart\",\"_" + "kind\":\"kernel\"},\"tokenPos\":248,\"endTokenPos\":18485}," + "\"library\":{\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\"," + "\"name\":\"dart.core\",\"uri\":\"dart:core\"}},\"identityHashCode\":0," + "\"kind\":\"List\",\"id\":\"\",\"length\":0}", buffer); } // LinkedHashMap reference @@ -4516,15 +4549,18 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) { array.PrintJSON(&js, true); ElideJSONSubstring("classes", js.ToCString(), buffer); ElideJSONSubstring("objects", buffer, buffer); + ElideJSONSubstring("libraries", buffer, buffer); ElideJSONSubstring("_InternalLinkedHashMap@", buffer, buffer); EXPECT_STREQ( - "{\"type\":\"@Instance\"," - "\"_vmType\":\"LinkedHashMap\"," - "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"_InternalLinkedHashMap\",\"_vmName\":\"\"}," - "\"identityHashCode\":0," - "\"kind\":\"Map\"," - "\"id\":\"\"," + "{\"type\":\"@Instance\",\"_vmType\":\"LinkedHashMap\",\"class\":{" + "\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_" + "InternalLinkedHashMap\",\"_vmName\":\"\",\"location\":{\"type\":" + "\"SourceLocation\",\"script\":{\"type\":\"@Script\",\"fixedId\":true," + "\"id\":\"\",\"uri\":\"dart:collection-patch\\/" + "compact_hash.dart\",\"_kind\":\"kernel\"},\"tokenPos\":6399," + "\"endTokenPos\":6786},\"library\":{\"type\":\"@Library\",\"fixedId\":" + "true,\"id\":\"\",\"name\":\"dart.collection\",\"uri\":\"dart:" + "collection\"}},\"identityHashCode\":0,\"kind\":\"Map\",\"id\":\"\"," "\"length\":0}", buffer); } @@ -4535,12 +4571,17 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) { tag.PrintJSON(&js, true); ElideJSONSubstring("classes", js.ToCString(), buffer); ElideJSONSubstring("objects", buffer, buffer); + ElideJSONSubstring("libraries", buffer, buffer); ElideJSONSubstring("_UserTag@", buffer, buffer); EXPECT_SUBSTRING( - "{\"type\":\"@Instance\"," - "\"_vmType\":\"UserTag\"," - "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"_UserTag\",\"_vmName\":\"\"}," + "\"type\":\"@Instance\",\"_vmType\":\"UserTag\",\"class\":{\"type\":\"@" + "Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_UserTag\",\"_" + "vmName\":\"\",\"location\":{\"type\":\"SourceLocation\",\"script\":{" + "\"type\":\"@Script\",\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:" + "developer-patch\\/profiler.dart\",\"_kind\":\"kernel\"},\"tokenPos\":" + "414,\"endTokenPos\":672},\"library\":{\"type\":\"@Library\"," + "\"fixedId\":true,\"id\":\"\",\"name\":\"dart.developer\",\"uri\":" + "\"dart:developer\"}}," // Handle non-zero identity hash. "\"identityHashCode\":", buffer); @@ -4558,12 +4599,16 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) { type.PrintJSON(&js, true); ElideJSONSubstring("classes", js.ToCString(), buffer); ElideJSONSubstring("objects", buffer, buffer); + ElideJSONSubstring("libraries", buffer, buffer); ElideJSONSubstring("_Type@", buffer, buffer); EXPECT_SUBSTRING( - "{\"type\":\"@Instance\"," - "\"_vmType\":\"Type\"," - "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"_Type\",\"_vmName\":\"\"}," + "{\"type\":\"@Instance\",\"_vmType\":\"Type\",\"class\":{\"type\":\"@" + "Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"_Type\",\"_vmName\":" + "\"\",\"location\":{\"type\":\"SourceLocation\",\"script\":{\"type\":" + "\"@Script\",\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core-" + "patch\\/type_patch.dart\",\"_kind\":\"kernel\"},\"tokenPos\":493," + "\"endTokenPos\":898},\"library\":{\"type\":\"@Library\",\"fixedId\":" + "true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":\"dart:core\"}}," // Handle non-zero identity hash. "\"identityHashCode\":", buffer); @@ -4571,7 +4616,12 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) { "\"kind\":\"Type\"," "\"fixedId\":true,\"id\":\"\"," "\"typeClass\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"bool\"},\"name\":\"bool\"}", + "\"name\":\"bool\",\"location\":{\"type\":\"SourceLocation\"," + "\"script\":{\"type\":\"@Script\",\"fixedId\":true,\"id\":\"\",\"uri\":" + "\"dart:core\\/bool.dart\",\"_kind\":\"kernel\"},\"tokenPos\":436," + "\"endTokenPos\":4432},\"library\":{\"type\":\"@Library\",\"fixedId\":" + "true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":\"dart:core\"}}," + "\"name\":\"bool\"}", buffer); } // Null reference @@ -4579,15 +4629,16 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) { JSONStream js; Object::null_object().PrintJSON(&js, true); ElideJSONSubstring("classes", js.ToCString(), buffer); + ElideJSONSubstring("libraries", buffer, buffer); EXPECT_STREQ( - "{\"type\":\"@Instance\"," - "\"_vmType\":\"null\"," - "\"class\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"Null\"}," - "\"kind\":\"Null\"," - "\"fixedId\":true," - "\"id\":\"objects\\/null\"," - "\"valueAsString\":\"null\"}", + "{\"type\":\"@Instance\",\"_vmType\":\"null\",\"class\":{\"type\":\"@" + "Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"Null\",\"location\":{" + "\"type\":\"SourceLocation\",\"script\":{\"type\":\"@Script\"," + "\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core\\/null.dart\",\"_" + "kind\":\"kernel\"},\"tokenPos\":925,\"endTokenPos\":1165},\"library\":" + "{\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\",\"name\":\"dart." + "core\",\"uri\":\"dart:core\"}},\"kind\":\"Null\",\"fixedId\":true," + "\"id\":\"objects\\/null\",\"valueAsString\":\"null\"}", buffer); } // Sentinel reference diff --git a/runtime/vm/service.h b/runtime/vm/service.h index 0b94d3d6258..390eee41879 100644 --- a/runtime/vm/service.h +++ b/runtime/vm/service.h @@ -15,7 +15,7 @@ namespace dart { #define SERVICE_PROTOCOL_MAJOR_VERSION 3 -#define SERVICE_PROTOCOL_MINOR_VERSION 45 +#define SERVICE_PROTOCOL_MINOR_VERSION 46 class Array; class EmbedderServiceHandler; diff --git a/runtime/vm/service/service.md b/runtime/vm/service/service.md index bfbf6571e10..c0d874a9f94 100644 --- a/runtime/vm/service/service.md +++ b/runtime/vm/service/service.md @@ -1,8 +1,8 @@ -# Dart VM Service Protocol 3.45 +# Dart VM Service Protocol 3.46 > Please post feedback to the [observatory-discuss group][discuss-list] -This document describes of _version 3.45_ of the Dart VM Service Protocol. This +This document describes of _version 3.46_ of the Dart VM Service Protocol. This protocol is used to communicate with a running Dart Virtual Machine. To use the Service Protocol, start the VM with the *--observe* flag. @@ -1687,6 +1687,12 @@ been loaded (i.e. a deferred library). class @Class extends @Object { // The name of this class. string name; + + // The location of this class in the source code. + SourceLocation location [optional]; + + // The library which contains this class. + @Library library; } ``` @@ -1697,6 +1703,12 @@ class Class extends Object { // The name of this class. string name; + // The location of this class in the source code. + SourceLocation location [optional]; + + // The library which contains this class. + @Library library; + // The error which occurred during class finalization, if it exists. @Error error [optional]; @@ -1709,12 +1721,6 @@ class Class extends Object { // Are allocations of this class being traced? bool traceAllocations; - // The library which contains this class. - @Library library; - - // The location of this class in the source code. - SourceLocation location [optional]; - // The superclass of this class, if any. @Class super [optional]; @@ -2298,6 +2304,9 @@ class @Field extends @Object { // Is this field static? bool static; + + // The location of this field in the source code. + SourceLocation location [optional]; } ``` @@ -2327,12 +2336,12 @@ class Field extends Object { // Is this field static? bool static; + // The location of this field in the source code. + SourceLocation location [optional]; + // The value of this field, if the field is static. If uninitialized, // this will take the value of an uninitialized Sentinel. @Instance|Sentinel staticValue [optional]; - - // The location of this field in the source code. - SourceLocation location [optional]; } ``` @@ -2401,6 +2410,9 @@ class @Function extends @Object { // Is this function const? bool const; + + // The location of this function in the source code. + SourceLocation location [optional]; } ``` @@ -4038,5 +4050,6 @@ version | comments 3.43 | Updated heap snapshot format to include identity hash codes. Added `getAllocationTraces` and `setTraceClassAllocation` RPCs, updated `CpuSample` to include `identityHashCode` and `classId` properties, updated `Class` to include `traceAllocations` property. 3.44 | Added `identityHashCode` property to `@Instance` and `Instance`. 3.45 | Added `setBreakpointState` RPC and `BreakpointUpdated` event kind. +3.46 | Moved `sourceLocation` property into reference types for `Class`, `Field`, and `Function`. [discuss-list]: https://groups.google.com/a/dartlang.org/forum/#!forum/observatory-discuss diff --git a/runtime/vm/source_report_test.cc b/runtime/vm/source_report_test.cc index 9bc1aac859e..f7314c0f803 100644 --- a/runtime/vm/source_report_test.cc +++ b/runtime/vm/source_report_test.cc @@ -501,7 +501,10 @@ ISOLATE_UNIT_TEST_CASE(SourceReport_CallSites_SimpleCall) { "\"name\":\"helper0\",\"owner\":{\"type\":\"@Library\",\"fixedId\":true," "\"id\":\"\",\"name\":\"\",\"uri\":\"file:\\/\\/\\/test-lib\"}," "\"_kind\":\"RegularFunction\",\"static\":true,\"const\":false," - "\"_intrinsic\":false,\"_native\":false},\"count\":1}]}]}]," + "\"_intrinsic\":false,\"_native\":false,\"location\":{\"type\":" + "\"SourceLocation\",\"script\":{\"type\":\"@Script\",\"fixedId\":true," + "\"id\":\"\",\"uri\":\"file:\\/\\/\\/test-lib\",\"_kind\":\"kernel\"}," + "\"tokenPos\":0,\"endTokenPos\":11}},\"count\":1}]}]}]," // One script in the script table. "\"scripts\":[{\"type\":\"@Script\",\"fixedId\":true,\"id\":\"\"," @@ -510,7 +513,7 @@ ISOLATE_UNIT_TEST_CASE(SourceReport_CallSites_SimpleCall) { } ISOLATE_UNIT_TEST_CASE(SourceReport_CallSites_PolymorphicCall) { - char buffer[1024]; + char buffer[4096]; const char* kScript = "class Common {\n" " func() {}\n" @@ -553,27 +556,65 @@ ISOLATE_UNIT_TEST_CASE(SourceReport_CallSites_PolymorphicCall) { // First receiver: "Common", called twice. "{\"receiver\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"Common\"}," + "\"name\":\"Common\"," + "\"location\":{\"type\":\"SourceLocation\"," + "\"script\":{\"type\":\"@Script\"," + "\"fixedId\":true,\"id\":\"\"," + "\"uri\":\"file:\\/\\/\\/test-lib\"," + "\"_kind\":\"kernel\"},\"tokenPos\":0,\"endTokenPos\":27}," + "\"library\":{\"type\":\"@Library\",\"fixedId\":true," + "\"id\":\"\",\"name\":\"\",\"uri\":\"file:\\/\\/\\/test-lib\"}}," "\"target\":{\"type\":\"@Function\",\"fixedId\":true,\"id\":\"\"," "\"name\":\"func\"," "\"owner\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"Common\"},\"_kind\":\"RegularFunction\"," + "\"name\":\"Common\"," + "\"location\":{\"type\":\"SourceLocation\"," + "\"script\":{\"type\":\"@Script\"," + "\"fixedId\":true,\"id\":\"\"," + "\"uri\":\"file:\\/\\/\\/test-lib\"," + "\"_kind\":\"kernel\"},\"tokenPos\":0,\"endTokenPos\":27}," + "\"library\":{\"type\":\"@Library\",\"fixedId\":true," + "\"id\":\"\",\"name\":\"\",\"uri\":\"file:\\/\\/\\/test-lib\"}" + "},\"_kind\":\"RegularFunction\"," "\"static\":false,\"const\":false,\"_intrinsic\":false," - "\"_native\":false}," + "\"_native\":false," + "\"location\":{\"type\":\"SourceLocation\"," + "\"script\":{\"type\":\"@Script\",\"fixedId\":true," + "\"id\":\"\",\"uri\":\"file:\\/\\/\\/test-lib\"," + "\"_kind\":\"kernel\"},\"tokenPos\":17,\"endTokenPos\":25}}," "\"count\":2}," // Second receiver: "Uncommon", called once. "{\"receiver\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"Uncommon\"}," + "\"name\":\"Uncommon\"," + "\"location\":{\"type\":\"SourceLocation\"," + "\"script\":{\"type\":\"@Script\"," + "\"fixedId\":true,\"id\":\"\"," + "\"uri\":\"file:\\/\\/\\/test-lib\"," + "\"_kind\":\"kernel\"},\"tokenPos\":29,\"endTokenPos\":58}," + "\"library\":{\"type\":\"@Library\",\"fixedId\":true," + "\"id\":\"\",\"name\":\"\",\"uri\":\"file:\\/\\/\\/test-lib\"}}," "\"target\":{\"type\":\"@Function\",\"fixedId\":true,\"id\":\"\"," "\"name\":\"func\"," "\"owner\":{\"type\":\"@Class\",\"fixedId\":true,\"id\":\"\"," - "\"name\":\"Uncommon\"},\"_kind\":\"RegularFunction\"," + "\"name\":\"Uncommon\"," + "\"location\":{\"type\":\"SourceLocation\"," + "\"script\":{\"type\":\"@Script\"," + "\"fixedId\":true,\"id\":\"\"," + "\"uri\":\"file:\\/\\/\\/test-lib\"," + "\"_kind\":\"kernel\"},\"tokenPos\":29,\"endTokenPos\":58}," + "\"library\":{\"type\":\"@Library\",\"fixedId\":true," + "\"id\":\"\",\"name\":\"\",\"uri\":\"file:\\/\\/\\/test-lib\"}" + "},\"_kind\":\"RegularFunction\"," "\"static\":false,\"const\":false,\"_intrinsic\":false," - "\"_native\":false}," + "\"_native\":false," + "\"location\":{\"type\":\"SourceLocation\"," + "\"script\":{\"type\":\"@Script\",\"fixedId\":true," + "\"id\":\"\",\"uri\":\"file:\\/\\/\\/test-lib\"," + "\"_kind\":\"kernel\"},\"tokenPos\":48,\"endTokenPos\":56}}," "\"count\":1}]}]}]," @@ -584,7 +625,7 @@ ISOLATE_UNIT_TEST_CASE(SourceReport_CallSites_PolymorphicCall) { } ISOLATE_UNIT_TEST_CASE(SourceReport_MultipleReports) { - char buffer[1024]; + char buffer[2048]; const char* kScript = "helper0() {}\n" "helper1() {}\n" @@ -614,16 +655,18 @@ ISOLATE_UNIT_TEST_CASE(SourceReport_MultipleReports) { // One range not compiled (helper1). "{\"scriptIndex\":0,\"startPos\":13,\"endPos\":24,\"compiled\":false}," - // One range compiled with one callsite (main). + // One range compiled with one callsite (main)m "{\"scriptIndex\":0,\"startPos\":26,\"endPos\":48,\"compiled\":true," - "\"callSites\":[" - "{\"name\":\"helper0\",\"tokenPos\":37,\"cacheEntries\":[" - "{\"target\":{\"type\":\"@Function\",\"fixedId\":true,\"id\":\"\"," + "\"callSites\":[{\"name\":\"helper0\",\"tokenPos\":37,\"cacheEntries\":[{" + "\"target\":{\"type\":\"@Function\",\"fixedId\":true,\"id\":\"\"," "\"name\":\"helper0\",\"owner\":{\"type\":\"@Library\",\"fixedId\":true," - "\"id\":\"\",\"name\":\"\",\"uri\":\"file:\\/\\/\\/test-lib\"}," - "\"_kind\":\"RegularFunction\",\"static\":true,\"const\":false," - "\"_intrinsic\":false,\"_native\":false},\"count\":1}]}]," - "\"coverage\":{\"hits\":[26,37],\"misses\":[]}}]," + "\"id\":\"\",\"name\":\"\",\"uri\":\"file:\\/\\/\\/test-lib\"},\"_" + "kind\":\"RegularFunction\",\"static\":true,\"const\":false,\"_" + "intrinsic\":false,\"_native\":false,\"location\":{\"type\":" + "\"SourceLocation\",\"script\":{\"type\":\"@Script\",\"fixedId\":true," + "\"id\":\"\",\"uri\":\"file:\\/\\/\\/test-lib\",\"_kind\":\"kernel\"}," + "\"tokenPos\":0,\"endTokenPos\":11}},\"count\":1}]}],\"coverage\":{" + "\"hits\":[26,37],\"misses\":[]}}]," // One script in the script table. "\"scripts\":[{\"type\":\"@Script\",\"fixedId\":true,\"id\":\"\"," diff --git a/third_party/devtools/update.sh b/third_party/devtools/update.sh index 077d758c333..ae3aa496f60 100755 --- a/third_party/devtools/update.sh +++ b/third_party/devtools/update.sh @@ -36,5 +36,6 @@ cipd create \ -name dart/third_party/flutter/devtools \ -in cipd_package \ -install-mode copy \ + -preserve-writable \ -tag git_revision:$1