Skip to content

Instantly share code, notes, and snippets.

@krlohnes
Last active January 27, 2022 18:31
Show Gist options
  • Save krlohnes/2dba0840fa402a0293762fadc949418f to your computer and use it in GitHub Desktop.
Save krlohnes/2dba0840fa402a0293762fadc949418f to your computer and use it in GitHub Desktop.
Debugging with jdb in scala

#Debugging Scala with JDB

It seems impossible to find answers on how to debug Scala with jdb on Google. I wanted to consolidate what I've learned in a easy to digest guide. Please feel free to comment with other tips I may have missed, or corrections to what's here.

##Classes Setting a breakpoint in a class is just like debugging java stop at my.package.ClassName:22

or

stop in my.package.ClassName.methodName

##Objects Setting a breakpoint in an object is usually just as simple as adding a $ to the end of the object/package name.

stop at my.package.ObjectName$:22

##Traits In general break in the implementing class. However, if there's a default implementation that you're trying to break in use the trait path with the suffix $.class for example

stop in my.package.SomeTrait$.class.foo

would set a breakpoint in the default implementation of foo in the Trait SomeTrait

@chipsenkbeil
Copy link

FYI, while it's still early in development, there's a Scala-oriented version of jdb, called sdb, found here: https://scala-debugger.org/

Github page here: https://github.com/ensime/scala-debugger

Disclaimer is that I'm the maintainer of it, but thought I'd spread the word a little bit for those seeking something like it.

Gave a talk at ScalaSphere about the debugging tooling and whatnot. Can be found here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment