Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 325611
b: refs/heads/main
c: 54fb6ce
h: refs/heads/main
i:
  325609: 18488ce
  325607: 7bafed2
  • Loading branch information
bkonyi authored and commit-bot@chromium.org committed May 15, 2020
1 parent 1d8a79b commit 5f3258c
Show file tree
Hide file tree
Showing 20 changed files with 345 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
Expand Up @@ -1994,4 +1994,4 @@ refs/tags/2.14.0-96.0.dev: 1eee24e50fc3028754d9a8e98852b949c04da4e4
refs/tags/2.14.0-97.0.dev: ba9c1636e87fbdcc02b8bc4a584455c32f8378b4
refs/tags/2.14.0-98.0.dev: f2d370c93582bbf4da42b5dd4c906d6145b01ea9
refs/tags/2.14.0-99.0.dev: e722f62b48fb382534efc1f20735def68848006f
refs/heads/main: 22e5856ae561424f55fa5579e5ca14b9916d9ed1
refs/heads/main: 54fb6ce3c07719d72eec0a14c00f905b724873c2
8 changes: 7 additions & 1 deletion trunk/pkg/dds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.1.0-dev
# 1.1.0

- Added `getDartDevelopmentServiceVersion` RPC.
- Added DDS protocol to VM service `getSupportedProtocols` response.
- Added example/example.dart.

# 1.0.0

- Initial release.
2 changes: 0 additions & 2 deletions trunk/pkg/dds/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
_This package is a work in-progress and the API may not be stable. Stay tuned for updates._

A package used to spawn the Dart Developer Service (DDS), which is used to communicate with a Dart VM Service instance and provide extended functionality to the core VM Service Protocol.

# Functionality
Expand Down
16 changes: 16 additions & 0 deletions trunk/pkg/dds/dds_protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ The Service Protocol uses [JSON-RPC 2.0][].
- [Revision History](#revision-history)
- [Public RPCs](#public-rpcs)
- [getClientName](#getclientname)
- [getDartDevelopmentServiceVersion](#getdartdevelopmentserviceversion)
- [getLogHistorySize](#getloghistorysize)
- [requirePermissionToResume](#requirepermissiontoresume)
- [setClientName](#setclientname)
- [setLogHistorySize](#setloghistorysize)
- [Public Types](#public-types)
- [ClientName](#clientname)
- [DartDevelopmentServiceVersion](#dartdevelopmentserviceversion)
- [Size](#size)

## RPCs, Requests, and Responses
Expand Down Expand Up @@ -61,6 +63,18 @@ connected VM service client. If no name was previously set through the

See [ClientName](#clientname)

### getDartDevelopmentServiceVersion

```
Version getDartDevelopmentServiceVersion()
```

The _getDartDevelopmentServiceVersion_ RPC is used to determine what version of
the Dart Development Service Protocol is served by a DDS instance.

See [Version](#version).


### getLogHistorySize

```
Expand Down Expand Up @@ -164,9 +178,11 @@ A simple object representing a size response.
version | comments
------- | --------
1.0 | Initial revision
1.1 | Added `getDartDevelopmentServiceVersion` RPC.

[resume]: https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#resume
[success]: https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#success
[version]: https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#version

[service-protocol]: https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md
[service-protocol-rpcs-requests-and-responses]: https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#rpcs-requests-and-responses
Expand Down
24 changes: 24 additions & 0 deletions trunk/pkg/dds/example/example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:dds/dds.dart';
import 'package:vm_service/vm_service_io.dart';

import '../test/common/test_helper.dart';

Future<void> main() async {
final process = await spawnDartProcess('../test/smoke.dart');
final dds = await DartDevelopmentService.startDartDevelopmentService(
remoteVmServiceUri,
);

// Connect to the DDS instance and make a request using package:vm_service.
final service = await vmServiceConnectUri(dds.wsUri.toString());
final version = await service.getVersion();

print('Service Version: $version');

await dds.shutdown();
process.kill();
}
4 changes: 4 additions & 0 deletions trunk/pkg/dds/lib/dds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ abstract class DartDevelopmentService {
/// Set to `true` if this instance of [DartDevelopmentService] is accepting
/// requests.
bool get isRunning;

/// The version of the DDS protocol supported by this [DartDevelopmentService]
/// instance.
static const String protocolVersion = '1.1';
}

class DartDevelopmentServiceException implements Exception {
Expand Down
6 changes: 2 additions & 4 deletions trunk/pkg/dds/lib/src/binary_compatible_peer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ class _BinaryCompatiblePeer extends json_rpc.Peer {
const metadataOffset = 4;
final dataOffset = bytesView.getUint32(0, Endian.little);
final metadataLength = dataOffset - metadataOffset;
final metadata = Utf8Decoder().convert(new Uint8List.view(
bytesView.buffer,
bytesView.offsetInBytes + metadataOffset,
metadataLength));
final metadata = Utf8Decoder().convert(Uint8List.view(bytesView.buffer,
bytesView.offsetInBytes + metadataOffset, metadataLength));
final decodedMetadata = json.decode(metadata);
streamManager.streamNotify(decodedMetadata['params']['streamId'], data);
}
Expand Down
25 changes: 25 additions & 0 deletions trunk/pkg/dds/lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,31 @@ class _DartDevelopmentServiceClient {
return _RPCResponses.success;
});

_clientPeer.registerMethod('getDartDevelopmentServiceVersion',
(parameters) async {
final ddsVersion = DartDevelopmentService.protocolVersion.split('.');
return <String, dynamic>{
'type': 'Version',
'major': int.parse(ddsVersion[0]),
'minor': int.parse(ddsVersion[1]),
};
});

_clientPeer.registerMethod('getSupportedProtocols', (parameters) async {
final Map<String, dynamic> supportedProtocols =
await _vmServicePeer.sendRequest('getSupportedProtocols');
final ddsVersion = DartDevelopmentService.protocolVersion.split('.');
final ddsProtocol = {
'protocolName': 'DDS',
'major': int.parse(ddsVersion[0]),
'minor': int.parse(ddsVersion[1]),
};
supportedProtocols['protocols']
.cast<Map<String, dynamic>>()
.add(ddsProtocol);
return supportedProtocols;
});

// When invoked within a fallback, the next fallback will start executing.
// The final fallback forwards the request to the VM service directly.
@alwaysThrows
Expand Down
3 changes: 2 additions & 1 deletion trunk/pkg/dds/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: >-
A library used to spawn the Dart Developer Service, used to communicate with
a Dart VM Service instance.
version: 1.0.0
version: 1.1.0

homepage: https://github.com/dart-lang/sdk/tree/master/pkg/dds

Expand All @@ -13,6 +13,7 @@ environment:
dependencies:
async: ^2.4.1
json_rpc_2: ^2.1.0
meta: ^1.1.8
pedantic: ^1.7.0
shelf: ^0.7.5
shelf_proxy: ^0.1.0+7
Expand Down
22 changes: 22 additions & 0 deletions trunk/pkg/vm_service/example/vm_service_assert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,28 @@ List<vms.ProfileFunction> assertListOfProfileFunction(
return list;
}

vms.ProtocolList assertProtocolList(vms.ProtocolList obj) {
assertNotNull(obj);
assertString(obj.type);
assertListOfProtocol(obj.protocols);
return obj;
}

vms.Protocol assertProtocol(vms.Protocol obj) {
assertNotNull(obj);
assertString(obj.protocolName);
assertInt(obj.major);
assertInt(obj.minor);
return obj;
}

List<vms.Protocol> assertListOfProtocol(List<vms.Protocol> list) {
for (vms.Protocol elem in list) {
assertProtocol(elem);
}
return list;
}

vms.ReloadReport assertReloadReport(vms.ReloadReport obj) {
assertNotNull(obj);
assertString(obj.type);
Expand Down
3 changes: 3 additions & 0 deletions trunk/pkg/vm_service/java/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ src/org/dartlang/vm/service/consumer/GetStackConsumer.java
src/org/dartlang/vm/service/consumer/InvokeConsumer.java
src/org/dartlang/vm/service/consumer/KillConsumer.java
src/org/dartlang/vm/service/consumer/PauseConsumer.java
src/org/dartlang/vm/service/consumer/ProtocolListConsumer.java
src/org/dartlang/vm/service/consumer/ReloadSourcesConsumer.java
src/org/dartlang/vm/service/consumer/RemoveBreakpointConsumer.java
src/org/dartlang/vm/service/consumer/RequestHeapSnapshotConsumer.java
Expand Down Expand Up @@ -95,6 +96,8 @@ src/org/dartlang/vm/service/element/NullRef.java
src/org/dartlang/vm/service/element/Obj.java
src/org/dartlang/vm/service/element/ObjRef.java
src/org/dartlang/vm/service/element/ProfileFunction.java
src/org/dartlang/vm/service/element/Protocol.java
src/org/dartlang/vm/service/element/ProtocolList.java
src/org/dartlang/vm/service/element/ReloadReport.java
src/org/dartlang/vm/service/element/Response.java
src/org/dartlang/vm/service/element/RetainingObject.java
Expand Down
2 changes: 1 addition & 1 deletion trunk/pkg/vm_service/java/version.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=3.33
version=3.35
95 changes: 94 additions & 1 deletion trunk/pkg/vm_service/lib/src/vm_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export 'snapshot_graph.dart'
HeapSnapshotObjectNoData,
HeapSnapshotObjectNullData;

const String vmServiceVersion = '3.33.0';
const String vmServiceVersion = '3.35.0';

/// @optional
const String optional = 'optional';
Expand Down Expand Up @@ -158,6 +158,8 @@ Map<String, Function> _typeFactories = {
'@Object': ObjRef.parse,
'Object': Obj.parse,
'ProfileFunction': ProfileFunction.parse,
'ProtocolList': ProtocolList.parse,
'Protocol': Protocol.parse,
'ReloadReport': ReloadReport.parse,
'RetainingObject': RetainingObject.parse,
'RetainingPath': RetainingPath.parse,
Expand Down Expand Up @@ -208,6 +210,7 @@ Map<String, List<String>> _methodReturnTypes = {
'getObject': const ['Obj'],
'getRetainingPath': const ['RetainingPath'],
'getStack': const ['Stack'],
'getSupportedProtocols': const ['ProtocolList'],
'getSourceReport': const ['SourceReport'],
'getVersion': const ['Version'],
'getVM': const ['VM'],
Expand Down Expand Up @@ -731,6 +734,16 @@ abstract class VmServiceInterface {
/// returned.
Future<Stack> getStack(String isolateId);

/// The `getSupportedProtocols` RPC is used to determine which protocols are
/// supported by the current server.
///
/// The result of this call should be intercepted by any middleware that
/// extends the core VM service protocol and should add its own protocol to
/// the list of protocols before forwarding the response to the client.
///
/// See [ProtocolList].
Future<ProtocolList> getSupportedProtocols();

/// The `getSourceReport` RPC is used to generate a set of reports tied to
/// source locations in an isolate.
///
Expand Down Expand Up @@ -1351,6 +1364,9 @@ class VmServerConnection {
params['isolateId'],
);
break;
case 'getSupportedProtocols':
response = await _serviceImplementation.getSupportedProtocols();
break;
case 'getSourceReport':
response = await _serviceImplementation.getSourceReport(
params['isolateId'],
Expand Down Expand Up @@ -1810,6 +1826,10 @@ class VmService implements VmServiceInterface {
Future<Stack> getStack(String isolateId) =>
_call('getStack', {'isolateId': isolateId});

@override
Future<ProtocolList> getSupportedProtocols() =>
_call('getSupportedProtocols');

@override
Future<SourceReport> getSourceReport(
String isolateId,
Expand Down Expand Up @@ -5776,6 +5796,79 @@ class ProfileFunction {
'resolvedUrl: ${resolvedUrl}, function: ${function}]';
}

/// A `ProtocolList` contains a list of all protocols supported by the service
/// instance.
///
/// See [Protocol] and [getSupportedProtocols].
class ProtocolList extends Response {
static ProtocolList parse(Map<String, dynamic> json) =>
json == null ? null : ProtocolList._fromJson(json);

/// A list of supported protocols provided by this service.
List<Protocol> protocols;

ProtocolList({
@required this.protocols,
});

ProtocolList._fromJson(Map<String, dynamic> json) : super._fromJson(json) {
protocols = List<Protocol>.from(
createServiceObject(json['protocols'], const ['Protocol']) ?? []);
}

@override
Map<String, dynamic> toJson() {
var json = <String, dynamic>{};
json['type'] = 'ProtocolList';
json.addAll({
'protocols': protocols.map((f) => f.toJson()).toList(),
});
return json;
}

String toString() => '[ProtocolList type: ${type}, protocols: ${protocols}]';
}

/// See [getSupportedProtocols].
class Protocol {
static Protocol parse(Map<String, dynamic> json) =>
json == null ? null : Protocol._fromJson(json);

/// The name of the supported protocol.
String protocolName;

/// The major revision of the protocol.
int major;

/// The minor revision of the protocol.
int minor;

Protocol({
@required this.protocolName,
@required this.major,
@required this.minor,
});

Protocol._fromJson(Map<String, dynamic> json) {
protocolName = json['protocolName'];
major = json['major'];
minor = json['minor'];
}

Map<String, dynamic> toJson() {
var json = <String, dynamic>{};
json.addAll({
'protocolName': protocolName,
'major': major,
'minor': minor,
});
return json;
}

String toString() => '[Protocol ' //
'protocolName: ${protocolName}, major: ${major}, minor: ${minor}]';
}

class ReloadReport extends Response {
static ReloadReport parse(Map<String, dynamic> json) =>
json == null ? null : ReloadReport._fromJson(json);
Expand Down
1 change: 1 addition & 0 deletions trunk/pkg/vm_service/tool/dart/generate_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,7 @@ vms.Event assertIsolateEvent(vms.Event event) {
'LibraryDependency',
'Message',
'ProfileFunction',
'Protocol',
'RetainingObject',
'SourceReportRange',
'TimelineEvent',
Expand Down
Loading

0 comments on commit 5f3258c

Please sign in to comment.