From 5b3f7990e8db15dae976f1e1d4f119b73701c12c Mon Sep 17 00:00:00 2001 From: Helin Shiah Date: Thu, 22 Jun 2023 21:43:22 +0000 Subject: [PATCH] Revert "Revert "Send DAP events through DDS"" - only check for event handler when DDS URI is also set. Original change reverted due to test failure: https://github.com/dart-lang/sdk/issues/43743#issuecomment-1601278402 This reverts commit 02b10e1321d0d752cd162982140234ec092d685e. Change-Id: Idb2cbffe18342c76d0cc062e5855c10a6df0e8f1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310780 Reviewed-by: Ben Konyi Commit-Queue: Helin Shiah --- pkg/dds/CHANGELOG.md | 1 + .../src/dap/adapters/dds_hosted_adapter.dart | 11 +++++++++++ pkg/dds/lib/src/dap/base_debug_adapter.dart | 4 ++++ pkg/dds/lib/src/dap_handler.dart | 14 ++++++++++++++ pkg/dds/pubspec.yaml | 4 ++-- pkg/dds/test/dap_handler_test.dart | 2 +- pkg/dds_service_extensions/CHANGELOG.md | 3 +++ .../lib/{src => }/dap.dart | 18 ++++++++++++++++++ pkg/dds_service_extensions/pubspec.yaml | 4 ++-- pkg/vm_service/CHANGELOG.md | 3 +++ pkg/vm_service/lib/src/vm_service.dart | 8 ++------ pkg/vm_service/pubspec.yaml | 2 +- 12 files changed, 62 insertions(+), 12 deletions(-) rename pkg/dds_service_extensions/lib/{src => }/dap.dart (74%) diff --git a/pkg/dds/CHANGELOG.md b/pkg/dds/CHANGELOG.md index ca407eefe5b..0d81d777ca4 100644 --- a/pkg/dds/CHANGELOG.md +++ b/pkg/dds/CHANGELOG.md @@ -6,6 +6,7 @@ - [DAP] Fixed an issue that could leave breakpoints unresolved when adding/removing other breakpoints in a file. - Fixed a bug that was preventing clients from receiving `IsolateReload` events (see https://dartbug.com/49491). +- Added notifications for DAP events. # 2.9.0 - Updated DDS protocol to version 1.6. diff --git a/pkg/dds/lib/src/dap/adapters/dds_hosted_adapter.dart b/pkg/dds/lib/src/dap/adapters/dds_hosted_adapter.dart index 7e2d115266d..6e45f149ea9 100644 --- a/pkg/dds/lib/src/dap/adapters/dds_hosted_adapter.dart +++ b/pkg/dds/lib/src/dap/adapters/dds_hosted_adapter.dart @@ -45,6 +45,8 @@ class DdsHostedAdapter extends DartDebugAdapter true; + final _dapEventsController = StreamController(); + @override Future debuggerConnected(vm.VM vmInfo) async {} @@ -121,4 +123,13 @@ class DdsHostedAdapter extends DartDebugAdapter _startAdapter(DdsHostedAdapter adapter) async { adapter.ddsUri = dds.uri; + adapter.setEventHandler(_handleEvent); // TODO(helin24): Most likely we'll want the client to do these // initialization steps so that clients can differentiate capabilities. This diff --git a/pkg/dds/pubspec.yaml b/pkg/dds/pubspec.yaml index 4534ab59b2d..31c3cf58574 100644 --- a/pkg/dds/pubspec.yaml +++ b/pkg/dds/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: async: ^2.4.1 browser_launcher: ^1.0.0 collection: ^1.15.0 - dds_service_extensions: ^1.3.0 + dds_service_extensions: ^1.6.0 dap: ^1.1.0 devtools_shared: ^2.14.1 http_multi_server: ^3.0.0 @@ -27,7 +27,7 @@ dependencies: sse: ^4.0.0 stack_trace: ^1.10.0 stream_channel: ^2.0.0 - vm_service: '>=11.0.0 <12.0.0' + vm_service: '>=11.7.2 <12.0.0' web_socket_channel: ^2.0.0 # We use 'any' version constraints here as we get our package versions from diff --git a/pkg/dds/test/dap_handler_test.dart b/pkg/dds/test/dap_handler_test.dart index 84f7e542a7f..a0becc7120e 100644 --- a/pkg/dds/test/dap_handler_test.dart +++ b/pkg/dds/test/dap_handler_test.dart @@ -7,7 +7,7 @@ import 'dart:io'; import 'package:dap/dap.dart'; import 'package:dds/dds.dart'; -import 'package:dds_service_extensions/src/dap.dart'; +import 'package:dds_service_extensions/dap.dart'; import 'package:test/test.dart'; import 'package:vm_service/vm_service_io.dart'; diff --git a/pkg/dds_service_extensions/CHANGELOG.md b/pkg/dds_service_extensions/CHANGELOG.md index 7a1ba9ae62e..acdab27512e 100644 --- a/pkg/dds_service_extensions/CHANGELOG.md +++ b/pkg/dds_service_extensions/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.6.0 +- Made DAP extensions methods accessible in lib. + ## 1.5.0 - Added `DdsExtension.postEvent`. diff --git a/pkg/dds_service_extensions/lib/src/dap.dart b/pkg/dds_service_extensions/lib/dap.dart similarity index 74% rename from pkg/dds_service_extensions/lib/src/dap.dart rename to pkg/dds_service_extensions/lib/dap.dart index 07ad72464bd..1fb19851ab8 100644 --- a/pkg/dds_service_extensions/lib/src/dap.dart +++ b/pkg/dds_service_extensions/lib/dap.dart @@ -29,6 +29,8 @@ extension DapExtension on vm.VmService { vm.addTypeFactory('DapResponse', DapResponse.parse); _factoriesRegistered = true; } + + Stream get onDAPEvent => onEvent(DapEventStreams.kDAP); } class DapResponse extends vm.Response { @@ -50,3 +52,19 @@ class DapResponse extends vm.Response { final dap.Response dapResponse; } + +extension DapEvents on vm.Event { + dap.Event get dapData { + assert(json != null); + return dap.Event.fromJson(json!['dapData']); + } +} + +abstract class DapEventStreams extends vm.EventStreams { + static const String kDAP = 'DAP'; +} + +abstract class DapEventKind extends vm.EventKind { + /// Notification that a DAP event occurred. + static const String kDAPEvent = 'DAPEvent'; +} diff --git a/pkg/dds_service_extensions/pubspec.yaml b/pkg/dds_service_extensions/pubspec.yaml index cc3f4ceb216..b7701d67111 100644 --- a/pkg/dds_service_extensions/pubspec.yaml +++ b/pkg/dds_service_extensions/pubspec.yaml @@ -1,5 +1,5 @@ name: dds_service_extensions -version: 1.5.0 +version: 1.6.0 description: >- Extension methods for `package:vm_service`, used to make requests a Dart Development Service (DDS) instance. @@ -11,7 +11,7 @@ environment: dependencies: async: ^2.4.1 dap: ^1.0.0 - vm_service: ^11.0.0 + vm_service: ^11.7.2 # We use 'any' version constraints here as we get our package versions from # the dart-lang/sdk repo's DEPS file. Note that this is a special case; the diff --git a/pkg/vm_service/CHANGELOG.md b/pkg/vm_service/CHANGELOG.md index 8363a8880ad..0b881cedff0 100644 --- a/pkg/vm_service/CHANGELOG.md +++ b/pkg/vm_service/CHANGELOG.md @@ -1,3 +1,6 @@ +## 11.7.2 +- Make Event classes abstract to permit `dap` event stream extensions. + ## 11.7.1 - Expose RPC error codes that were defined in `package:dds`. diff --git a/pkg/vm_service/lib/src/vm_service.dart b/pkg/vm_service/lib/src/vm_service.dart index 14c05320e55..79793ad4a3d 100644 --- a/pkg/vm_service/lib/src/vm_service.dart +++ b/pkg/vm_service/lib/src/vm_service.dart @@ -2834,9 +2834,7 @@ class ErrorKind { } /// An enum of available event streams. -class EventStreams { - EventStreams._(); - +abstract class EventStreams { static const String kVM = 'VM'; static const String kIsolate = 'Isolate'; static const String kDebug = 'Debug'; @@ -2853,9 +2851,7 @@ class EventStreams { /// Adding new values to `EventKind` is considered a backwards compatible /// change. Clients should ignore unrecognized events. -class EventKind { - EventKind._(); - +abstract class EventKind { /// Notification that VM identifying information has changed. Currently used /// to notify of changes to the VM debugging name via setVMName. static const String kVMUpdate = 'VMUpdate'; diff --git a/pkg/vm_service/pubspec.yaml b/pkg/vm_service/pubspec.yaml index 8f5274a7f54..863d5394554 100644 --- a/pkg/vm_service/pubspec.yaml +++ b/pkg/vm_service/pubspec.yaml @@ -1,5 +1,5 @@ name: vm_service -version: 11.7.1 +version: 11.7.2 description: >- A library to communicate with a service implementing the Dart VM service protocol.