dart-lang / sdk

The Dart SDK, including the VM, dart2js, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
9.98k stars 1.54k forks source link

Enable debugging for analysis_server without passing the `--no_dds` flag. #49072

Open kenzieschmoll opened 2 years ago

kenzieschmoll commented 2 years ago

In trying to connect analysis_server to Dart DevTools for debugging, https://github.com/flutter/devtools/issues/4116 was discovered. This problem was that DevTools did not support debugging apps that did not have support for the DDS protocol. A workaround was landed in DevTools, but in the long term, we do not want to diverge DevTools functionality for apps that support DDS and for apps that do not.

Long term solution: all ways of running a dart app with the VM Service Protocol supported should also support the DDS protocol. Right now, the two protocols are almost identical with the exception of some extension methods (DevTools uses these, and that is why the exception in https://github.com/flutter/devtools/issues/4116 was being thrown when trying to connect to a dart app that did not support the DDS protocol). In the future, however, DDS is likely to become home to advanced debugging functionality that DevTools will depend on for core functionality, so diverging dds and non-dds support is not sustainable. One example is if the DevTools debugger starts using the DAP support provided by DDS instead of using the VM Service debugging functionality.

What will it take to support running the analysis_server* with DDS?

*This change of always running with DDS will apply to all cases in the SDK with a similar setup of running with the VM Service but not with DDS. analysis_server is just one example and the example that brought this issue to our attention.

kenzieschmoll commented 2 years ago

CC @bkonyi @scheglov @bwilkerson @stereotype441 @pq @jacob314

scheglov commented 2 years ago

I'm not sure how to triage this - is this a server issue? Or an IDE issue? Or a DDS issue?

kenzieschmoll commented 2 years ago

To simplify, the broad question is why does the analysis server have to be ran without DDS, and what would it take to require all dart apps ran with the VM service to also be ran with DDS? @bkonyi

scheglov commented 2 years ago

The specific reason why I run it with --no_dds is that otherwise Observatory does not work.

FYI, here is the process that I have for DAS when using IntelliJ. /Users/scheglov/Source/Dart/sdk.git/sdk/xcodebuild/ReleaseARM64/dart-sdk/bin/dart --no_dds --observe:8181 --pause_isolates_on_unhandled_exceptions=false --pause-isolates-on-exit=true --disable-service-auth-codes --source_lines=true language-server --client-id=IntelliJ-IDEA --client-version=IC-222.2270.31 --protocol=analyzer --diagnostic-port=4000 --analysis-driver-log=file:/Users/scheglov/tmp/das.log --protocol-traffic-log=/Users/scheglov/tmp/das_protocol.log

So, it might be related to the fact that we run dart language-server, which... I don't know :-) Maybe starts a new isolate with the analasis_server snapshot? I still see bin/snapshots/analysis_server.dart.snapshot.