Search code examples
scaladebuggingsbtread-eval-print-loop

How to get jdb-like features (setting breakpoints or displaying vars) in sbt or REPL for Scala?


Rather than opening up jdb is there a way to get similar functionality within the repl or sbt session?

The features I am seeking:

  • ability to define breakpoints:
    • :bp mySource.scala:79 // stop at line 79 mySource.scala
    • :bp org.mycompany.MyClass:14 // stop at line 14 of myClass (no idea if anyone supports such a thing..)
  • print out vars
    • :p myList
  • evaluate expressions including case statements and bonus points for closures

Solution

  • You can't keep a good idea down -- see the thread A non-runaway-REPL?:

    Maybe it could also use a "safe" mode where it forks a JVM. While we're at it, it's time for a debug command.

    I don't know if the command should be called :forked, :borked, or simply :wtf.