crowforkotlin
10/31/2025, 9:59 AMdebug autoservice, the plugin registered by this plugin is printed, but I can't debug it with breakpoints. The implementation of KotlinCompilerPluginSupportPlugin allows for breakpoint debugging, but I don't understand why.PHondogo
10/31/2025, 10:35 AMkotlin.compiler.execution.strategy=in-process
In IDE run configuration specify 'Debug gradle scripts' (Modify options -> Gradle -> Debug gradle scripts)
Be aware that incremental compilation may not call plugin code if decide that nothing have been changed since previous compilation.dmitriy.novozhilov
10/31/2025, 11:08 AM./gradlew -Dkotlin.daemon.jvm.options="-agentlib:jdwp=transport=dt_socket\\,server=n\\,suspend=y\\,address=5005" your-task-to-run
Don't forget to kill existing daemons first.crowforkotlin
11/01/2025, 2:37 AMcrowforkotlin
11/01/2025, 2:38 AM./gradlew -Dorg.gradle.jvmargs="-Xmx3072M -Dfile.encoding=UTF-8 -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:8080" composeApp:compileKotlinJs --rerun-tasks
Using this command, I can successfully hit breakpoints within my Gradle plugin (ZiplinePlugin.kt). However, breakpoints within my IR transformation logic (AdapterGenerator.kt) are never hit.
Furthermore, I observed that after executing the command, the build process hangs indefinitely, which seems to be related to the suspend=y flag. I compared this to an existing project where debugging a test function seems to directly attach to and debug the IR compilation phase. When I try to replicate that behavior, my build also hangs in the same way as my command-line attempt.
Could you please explain why the Gradle plugin breakpoints are hit but the IR breakpoints are notcrowforkotlin
11/01/2025, 2:43 AMdmitriy.novozhilov
11/04/2025, 2:37 PM-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:8080" you've made the gradle worker to attach the debugger.
But the compilation is actually happens inside the separate process, the Kotlin daemon. And to attach the debugger to it, you need to pass -Dkotlin.daemon.jvm.options="-agentlib:jdwp=transport=dt_socket\\,server=n\\,suspend=y\\,address=8080" argument instead.
The -Dkotlin.daemon.jvm.options specifies the jvmargs which would be passed to the kotlin daemon process when gradle starts it.crowforkotlin
11/06/2025, 3:02 AM./gradlew -Dkotlin.daemon.jvm.options="-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:8080" composeApp:compileKotlinJs --rerun-tasks
Okay, I tried the modified command, but the breakpoint still hasn't been executed. Even if a breakpoint was added to the implementation of KotlinCompilerPluginSupportPlugin, it wouldn't be executed. However, if we replace this daemon process with org.gradle.jvmargs, the breakpoint of the implementation of KotlinCompilerPluginSupportPlugin will be executed. But if a breakpoint is added to the code of the following class, it won't be executed. The log shows that it was indeed executed.
@AutoService(CompilerPluginRegistrar::class)
class ServiceCompilerPluginRegistrar : CompilerPluginRegistrar()
I'll skip this question. I'll give up starting with debugging for IR
Anyway, thank you for your replydmitriy.novozhilov
11/06/2025, 7:03 AM./gradlew --stop before running the command with debugger.
As another option I could recommend you using the compiler test framework to setup regular tests for your plugin, which will be debuggable without any additional arguments, just right from IDE. You can check how to setup these tests in the official compiler-plugin-template.crowforkotlin
11/06/2025, 7:16 AMdmitriy.novozhilov
11/06/2025, 7:20 AM# will try to attach to port 5005
./gradlew --no-daemon -Dorg.gradle.debug=true -Dorg.gradle.debug.server=false
The --no-daemon is important there. The debug arguments probably could be replaced with -agentlib=..., as you did before.dmitriy.novozhilov
11/06/2025, 7:21 AM