kotlin: Debugging SpringBoot with jdb
If you start the gradle application with a special flag, --debug-jvm, then jdb can connect.
# Start JVM task via gradle, expecting debugger
./gradlew bootRun --debug-jvm
# ... blocks, waiting for debugger to attach
# In another session, attach
jdb -attach 5005 -sourcepath src/main/kotlin/
# OR even better, use rlwrap to improve the jdb prompt
rlwrap jdb -attach 5005 -sourcepath src/main/kotlin/
Note that the -sourcepath command specifies where the convention based class naming convention starts.
Using jdb
- Add a breakpoint:
stop at com.foo.bar.ClassName.methodName - Remove a breakpoint:
clear com.foo.bar.ClassName.methodName - Show source lines for current point:
list - Show stack trace for current point:
where - Start process running:
run - Step into next command:
step - Step over next command:
next - Get help:
help
Gotchas
- The raw
jdbprompt is rubbish i.e. no readline. Considerrlwrap - Watch for nested class naming convention,
com.foo.Class$Nested
Published on: 14 Nov 2022