How do I debug my custom processor? I’ve tried the...
# ksp
p
How do I debug my custom processor? I’ve tried the things discussed here, but haven’t managed to catch a breakpoint. Or is there a more recent piece of information, maybe?
1
z
You haven't really explained what you've tried, so it's hard to advise on the basis of what little you've offered above
p
I tried to run
Copy code
./gradlew :sample:build --no-daemon -Dorg.gradle.debug=true -Pkotlin.compiler.execution.strategy=in-process
where
sample
is the gradle module that uses my processor with
ksp(project(…))
, then launch “Attach to Process” action (pic 1), then chose the only process there was (pic 2), the only thing that happened was that the execution resumed and in the debug console I saw
Copy code
Connected to the target VM, address: pid 2296
Disconnected from the target VM, address: pid 2296
and no breakpoints were hit
Also, I tried with option
Copy code
-Dkotlin.daemon.jvm.options="-Xdebug,-Xrunjdwp:transport=dt_socket\,address=5005\,server=y\,suspend=n"
however I feel like I don’t understand at all where it should go: if it should be appended to the previous one, or if it should be appended to the previous one but without the
--no-daemon
, no idea. Then tried to debug it with a custom debug configuration (pic 1), but nothing happens as a result, I’ve never even seen the
KotlinCompilerDaemon
process
n
I use https://github.com/tschuchortdev/kotlin-compile-testing with success, although it has several KSP-related issues...
e
@Pavel S try a debug run configuration instead and see if that helps. Run from command line
Copy code
./gradlew :sample:build --no-daemon -Dorg.gradle.debug=true -Pkotlin.compiler.execution.strategy=in-process
Then run the Debug config from IDE
Create a debug config by clicking
Edit configurations
and adding a new jvm debug one. Leave the settings at default (and probably name it). Then after running the command in terminal, Debug this new configuration.
In recent IJ versions, I dont even do that manually anymore, I just debug the gradle run configuration and it sets up gradle to debug mode (stlll need to run kotlin compiler in process so I usually just put that inside of my gradle.properties)
n
Oh, sorry, I've misunderstood... I debug my processors only during testing, so I create tests using https://github.com/tschuchortdev/kotlin-compile-testing and debug them as regular JUnit tests.