Git Product home page Git Product logo

Comments (19)

mikedawson avatar mikedawson commented on May 8, 2024 4

I don't understand why this is "P3". Trying to develop without a working debugger is not fun.

It is possible using some combination of arguments (e.g. ./gradlew :module:taskName --no-daemon -Dorg.gradle.debug=true -Pkotlin.compiler.execution.strategy=in-process).

I think use of debugging needs to be supported and documented ASAP. This issue appears to have been open for three years.

from ksp.

ting-yuan avatar ting-yuan commented on May 8, 2024 2

A page for how to debug has been added very recently. Specifically, this section shows how to pass necessary flags to KotlinCompileDaemon and how to find it.

from ksp.

ting-yuan avatar ting-yuan commented on May 8, 2024 1

If debugging without daemon is too slow (it has to start jvm everytime), ./gradlew -Dkotlin.daemon.jvm.options="-Xdebug,-Xrunjdwp:transport=dt_socket\,address=8765\,server=y\,suspend=n" ... and attach to the KotlinCompileDaemon process in the debugger might worth trying.

And thanks for the feedback! We'll investigate how to make debugging easier.

from ksp.

ting-yuan avatar ting-yuan commented on May 8, 2024 1

Did you pass the following system property while running Gradle? So that KotlinCompileDaemon can be attached.

-Dkotlin.daemon.jvm.options="-Xdebug,-Xrunjdwp:transport=dt_socket\,address=5005\,server=y\,suspend=n"

I haven't tried to attach it in the way of the screenshot; Instead, I use [run] -> [Attach to Process...] in IntelliJ and the popup window prompts a list that contains the KotlinCompileDaemon process.

from ksp.

neetopia avatar neetopia commented on May 8, 2024 1

Sorry to dig the grave.

Can you help to confirm if these are the right step?

  1. Run the command ./gardlew -Dkotlin.daemon.jvm.options="-Xdebug,-Xrunjdwp:transport=dt_socket\,address=5005\,server=y\,suspend=n".
  2. Two ways to attach debug process to daemon:
    a. In Intellij, click Attach to Process..., and select KotlinCompileDaemon. For whatever reason, once it is attached, it runs into a break point and I cannot continue.
    image

b. create a remove JVM debug configuration: image

But I cannot attach it, only shows Error running 'ksp': Unable to open debugger port (localhost:5005): java.net.ConnectException "Connection refused: connect"

Your screenshot looks more like general JDWP debugging issue to me. By searching the file you are stuck in I can get some existing issues like this one https://stackoverflow.com/questions/18992181/intellij-idea-breakpoints-stop-in-jars-instead-of-source-code-of-my-project

I would suggest looking into the JDWP set up part.

from ksp.

ZacSweers avatar ZacSweers commented on May 8, 2024

@yigit recently contributed KSP testing support to kotlin-compile-testing here https://github.com/tschuchortdev/kotlin-compile-testing#kotlin-symbol-processing-api-support

from ksp.

neetopia avatar neetopia commented on May 8, 2024

As you mentioned there is KSP support in kotlin-compile-testing now. Keep this issue for tracking related works like keep kotlin-compile-testing update to date with KSP or intaking more ideas.

from ksp.

elect86 avatar elect86 commented on May 8, 2024

attach to the KotlinCompileDaemon process in the debugger might worth trying.

How?

Because I cant get it working, this is my debug setup (pretty vanilla)

Screenshot from 2021-10-13 09-40-10

from ksp.

elect86 avatar elect86 commented on May 8, 2024

I'm not using those exactly, but the ones suggested by the remote configuration for jdk9+, that is

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005

First difference, I see that you have some backslashes in there.. are those mandatory?

Second, this is what happens on mine:

  1. something uses jdk15, where both JavaCompile and KotlinCompile are set to use 1.8 both in processor and consume module
tasks {
    withType<JavaCompile> {
        sourceCompatibility = "1.8"
        targetCompatibility = "1.8"
    }
    withType<KotlinCompile> {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }
}

I have jdk11 default on PATH

elect@5800x:~$ java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2, mixed mode, sharing)

  1. It stops in this Reference.class, I have no idea why

  2. attaching on the daemon requires me to type in the admin pwd everytime

Here a gif to better illustrate my situation

Peek 2021-10-16 10-59

Ps: without a daemon as Zac suggested works fine though (but as you said, it's too slow)

from ksp.

ToxicMushroom avatar ToxicMushroom commented on May 8, 2024

My compilation completes before I can attach my intellij debugger ?
I tried
gradlew -Dkotlin.daemon.jvm.options="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=n" clean assemble
output: https://gist.github.com/ToxicMushroom/eb19fac25e2acf9a5fd0dc554e5da408

I was able to get this to work last week on my laptop though so I am a bit confused what I'm doing different/wrong.

from ksp.

ting-yuan avatar ting-yuan commented on May 8, 2024

@ToxicMushroom that's because suspend=n. The daemon should stick around for a while (IIRC 3 hours) and you can attach, and run gradlew again.

from ksp.

DHosseiny avatar DHosseiny commented on May 8, 2024

Can you please explain it step by step? I didn't get it. I just ran the commands on this page but I do not know what to do next. @ZacSweers

from ksp.

neetopia avatar neetopia commented on May 8, 2024

after running ksp task with JDWP, you should be able to attach a debugger via run -> attach to process

from ksp.

zeroarst avatar zeroarst commented on May 8, 2024

Sorry to dig the grave.

Can you help to confirm if these are the right step?

  1. Run the command ./gardlew -Dkotlin.daemon.jvm.options="-Xdebug,-Xrunjdwp:transport=dt_socket\,address=5005\,server=y\,suspend=n".
  2. Two ways to attach debug process to daemon:
    a. In Intellij, click Attach to Process..., and select KotlinCompileDaemon. For whatever reason, once it is attached, it runs into a break point and I cannot continue.
    image

b. create a remove JVM debug configuration:
image

But I cannot attach it, only shows Error running 'ksp': Unable to open debugger port (localhost:5005): java.net.ConnectException "Connection refused: connect"

from ksp.

carl10086 avatar carl10086 commented on May 8, 2024

The debugger did not stop at the breakpoint.

Commands:

  1. ./gradlew --no-daemon -Dorg.gradle.debug=true -Dkotlin.daemon.jvm.options="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005" :dm-lib:clean :dm-lib:assemble`.
  2. run attach the process

env:

  • gradle : 7.5.1
  • kotlin : 1.8.10
  • ksp : 1.8.10-1.0.9
  • java: openjdk version "17.0.4.1" 2022-08-12 LTS

from ksp.

ZacSweers avatar ZacSweers commented on May 8, 2024

@mikedawson the approach I described in my OP plus the existence of compilation testing libraries means debugging works fine. You're not blocked, it's unclear what you're even asking for as I don't know what else they could do other than what I explained above.

I'm actually somewhat inclined to close this issue as I don't really feel it's an issue at this point, other than maybe just adding a debugging wiki explaining the above.

from ksp.

mikedawson avatar mikedawson commented on May 8, 2024

Hi @ZacSweers yes I am able to debug, which is good. My personal suggestion would be to put this in the documentation : either in the Quickstart section or the FAQ. I think anyone who is developing a non-trivial processor will likely need to use it. A debugging Wiki would also be helpful, but I think how to debug is essential info, and thus deserves to be included in the docs themselves.

What I mean by "support" - I mean to add it to the official docs / Wiki and to update those docs if/when the procedure changes.

from ksp.

zption avatar zption commented on May 8, 2024

How to attach KotlinCompileDaemon? Does anybody know. I have tried many times and I still can not debug KSP. would anyone post the screenshot of detail steps ? Thanks。

from ksp.

zption avatar zption commented on May 8, 2024

@ting-yuan hi, thanks for answering my question.
After executing the cmd ./gradlew :app:kspDebugKotlin --rerun-tasks -Dkotlin.daemon.jvm.options="-Xdebug,-Xrunjdwp:transport=dt_socket\,address=8765\,server=y\,suspend=n".
Then I click run -> Attach to process... and select KotlinCompileDaemon, and then Android studio show the error below:
"Error running 'localhost:'8765' CCannot run 'localhost:8765' on 'Pixel XL API33'"

from ksp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.