fwcd / kotlin-debug-adapter

Kotlin/JVM debugging for any editor/IDE using the Debug Adapter Protocol
MIT License
110 stars 19 forks source link

Fix crashing issue because of exception when attaching tests #63

Closed themkat closed 2 years ago

themkat commented 2 years ago

Like described in #59, the debug adapter crashes when attaching tests. This is because of a AbsentInformationException when trying to get positions of a breakpoint (due to the Location object not being able to resolve sourcePath and sourceName, and yes, I verified that it had issues with both). For now I have just made the method return null when we get that exception. I found no ways of finding the source file as of now, but I will continue looking for ways to do it. I still think making the debugger not crash is a good way forward for now.

Why merge this? While we won't get position information for breakpoints, we still get variable information for the breakpoint. This means the editor (tested with Emacs dap-mode) won't automatically jump to the source with the breakpoint, but will still show debug information like the variables for that breakpoint. You can also step in the code (without seeing where you are). While this is not perfect, it actually improves debugging tests by a tiny bit (making it possible to some minimal degree without crashing) 🙂 (there are no information on debugging tests as of now, and to my knowledge the attachment way is the only way for now)

fwcd commented 2 years ago

Lgtm, thanks!