thebrowsercompany / swift-build

Swift toolchain builds by The Browser Company
351 stars 10 forks source link

Remote debugging support for Android #170

Open tristanlabelle opened 1 month ago

tristanlabelle commented 1 month ago

We want to support debugging Swift application code running on Android using the existing developer experience in VS Code (F5 debug). LLDB's support for remote debugging is limited and platform-specific, so a better approach is to use Debug Server 2 aka DS2. The project was started at Meta and supported debugging Android, but may be a bit dusty at this point.

The end-to-end debugging setup would look like this:

  1. VS Code starts debugging using a debug adapter provider
  2. The debug adapter provider launches/talks to a local Android Debug Bridge (ADB) process to enumerate available Android devices and emulators, allowing the user to choose which one to use.
  3. The debug adapter provider uses ADB to deploy and launch DS2 as needed on the selected Android device
  4. The debug adapter starts lldb-dap.exe with command line parameters to connect it to the DS2 instance running on the Android device
  5. lldb-dap.exe tells DS2 to start the target process to debug
  6. The debugging chain is established: VSCode <-> lldb-dap.exe <--(ADB+TCP) --> DS2 <-> Process.exe

Preliminary tasks, to be filed on https://github.com/compnerd/ds2: