How To: debug Scala code when outside of an IDE

2019-02-02 23:07发布

问题:

I'm experimenting with using jEdit as my main editor for writing Scala code.

Along side jEdit I'm using Apache Buildr and DTerm. This all works well, except I'm really not sure how I would go about debugging Scala application outside of a large IDE?

Are there recommended practices/tools for debugging outside of an IDE?

回答1:

I am not sure you can debug entirely through the CLI. Any Java-based debug tool should be enough.

This SO question mentions jswat, which also has a console mode.
It is used in this blog entry and can be installed quite easily as illustrated here.



回答2:

Rather than using a debugger, you could run the interpreter (aka REPL) from a point in your application. You can find detailed instructions here



回答3:

There was a stack overflow question from years ago about a CLI Scala debugger. I just posted a new answer to it back in February about a new CLI called sdb that mimics jdb behaviour while providing support for Scala name demangling and other improvements.

Is there a Scala command-line debugger?


The answer from that topic was

Old question, but here is sdb, which is a jdb clone written in Scala using the Ensime debugger api: https://github.com/ensime/scala-debugger/releases/tag/v1.1.0-M3

And the sbt plugin: https://github.com/ensime/scala-debugger/releases/tag/v1.1.0-M3-2