fwcd / kotlin-debug-adapter

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

Fail to Run Attach #36

Closed MrRogerHuang closed 3 years ago

MrRogerHuang commented 3 years ago

This is my dev environment: Windows 10 2004 64-bit VS Code: 1.46.0 vscode-kotlin: 0.2.14 Gradle: 6.4.1 OpenJDK: 11 64-bit

I use this repo for testing vscode-kotlin (forked from fwcd/kotlin-quick-start): https://github.com/MrRogerHuang/kotlin-quick-start

I run ./gradlew build Then, I add and run vscode-kotlin's "Kotlin Launch" debug config. Fortunately, it works well. vscode-kotlin successfully stopped at a breakpoint in Main.kt file.

However, unfortunately, vscode-kotlin's "Kotlin Attach" debug config doesn't work. I start MainKt with this command line: java -agentlib:jdwp=transport=dt_socket,server=y,address=12345,suspend=y -jar .\build\libs\kotlin-quick-start-0.1.1.jar This is the "Kotlin Attach" part in launch.json:

        {
            "type": "kotlin",
            "request": "attach",
            "name": "Kotlin Attach",
            "projectRoot": "${workspaceFolder}",
            "hostName": "localhost",
            "port": 12345,
            "timeout": 30000
        }

When I run "Kotlin Attach" config, I get this error in VS Code DEBUG CONSOLE:

[INFO] main      Connected to client
[ERROR] async0    Internal error: org.javacs.ktda.util.KotlinDAException: Sent attach to debug adapter without the required argument'port'
[ERROR] java.util.concurrent.CompletionException: org.javacs.ktda.util.KotlinDAException: Sent attach to debug adapter without the required argument'port'
[ERROR]     at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
[ERROR]     at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
[ERROR]     at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1739)
[ERROR]     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[ERROR]     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[ERROR]     at java.base/java.lang.Thread.run(Thread.java:834)
[ERROR] Caused by: org.javacs.ktda.util.KotlinDAException: Sent attach to debug adapter without the required argument'port'
[ERROR]     at org.javacs.ktda.adapter.KotlinDebugAdapter.missingRequestArgument(KotlinDebugAdapter.kt:116)
[ERROR]     at org.javacs.ktda.adapter.KotlinDebugAdapter.access$missingRequestArgument(KotlinDebugAdapter.kt:37)
[ERROR]     at org.javacs.ktda.adapter.KotlinDebugAdapter$attach$1.invoke(KotlinDebugAdapter.kt:194)
[ERROR]     at org.javacs.ktda.adapter.KotlinDebugAdapter$attach$1.invoke(KotlinDebugAdapter.kt:37)
[ERROR]     at org.javacs.kt.util.AsyncExecutorKt$sam$java_lang_Runnable$0.run(AsyncExecutor.kt)
[ERROR]     at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736)
[ERROR]     ... 3 more

I do specify port argument in the config. Why does kotlin-debug-adapter say no?

MrRogerHuang commented 3 years ago

Additionally, I can use IntelliJ IDEA Community 2020.1 to open the kotlin-quick-start project and to use its debugger to successfully attach to the program run by the same command! java -agentlib:jdwp=transport=dt_socket,server=y,address=12345,suspend=y -jar .\build\libs\kotlin-quick-start-0.1.1.jar