1.0.0
This is the first release of the scala-debug-adapter and the sbt-debug-adapter.
scala-debug-adapter
The scala-debug-adapter is a server-side implementation of the Debug Adapter Protocol for the Scala language running on the JVM platform. It is based on and extends the microsoft/java-debug implementation.
The project has matured in scalacenter/bloop and is now released independently to be reused in other build tools of the Scala ecosystem. The sbt-debug-adapter plugin detailed below integrates the scala-debug-adapter in sbt 1.4.
Usage
This first release is only available for Scala 2.12. However we are planning to release for Scala 2.13 as soon as requested by the community.
In sbt:
// build.sbt
scalaVersion := "2.12.4",
libraryDependencies += "ch.epfl.scala" %% "scala-debug-adpater" % "1.0.0"
The scala-debug-adapter depends on the Java Debug Interface (JDI). The sbt-jdi-tools plugin ensures that the JDK tools.jar
is loaded.
// project/plugin.sbt
addSbtPlugin("org.scala-debugger" % "sbt-jdi-tools" % "1.1.1")
You can start a debug server by providing with your own instance of DebuggeeRunner
and Logger
import ch.epfl.scala.debugadapter._
import java.net.URI
class MyDebuggeeRunner() extends DebuggeeRunner {
def name: String = "MyDebuggeeRunner"
def run(listener: DebuggeeListener): CancelableFuture[Unit] = {
// start jvm process in debug mode
// call `listener.onListening` with the IP socket address of the java debug server
// pipe the process output streams to `listener.out` and `listener.err`
// return a CancelableFuture corresponding to the debugged process
}
def classFilesMappedTo(origin: Path, lines: Array[Int], columns: Array[Int]): List[Path] = {
// find the class files corresponding to the positions in the `origin` source file
}
}
class MyLogger() extends Logger { ... }
val runner = new MyDebuggeeRunner()
val logger = new MyLogger()
val server = DebugServer(runner, logger)
server.start()
// use `server.uri` for the client to connect
sbt-debug-adapter
sbt-debug-adapter
is an sbt plugin compatible with sbt 1.4 or higher.
It adds the debugSession/start
endpoint, as described in the Bloop reference, to sbt server. This endpoint is intended to be used by Metals for debugging sbt projects.
Usage
// project/plugin.sbt
addSbtPlugin("ch.epfl.scala" % "sbt-debug-adapter" % "1.0.0")
Again the JDK tools.jar
must be loaded, but this time it must be loaded in the classpath of sbt itself.
//project/project/plugin.sbt
addSbtPlugin("org.scala-debugger" % "sbt-jdi-tools" % "1.1.1")