fwcd / fwcd/kotlin-debug-adapter

Ability to debug a Kotlin program (JVM, not Native), without gradle or maven

Open
#62 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
150
Forks
29
PR merge metrics
No merged PRs in 30d

Description

### Suggestion

I would like to be able to debug (VS Code > Run > Start Debugging) a Kotlin/JVM program - without gradle or maven. Using VS Code's Run > Start Debugging, with a breakpoint set, the program simply runs to competion without stopping.

This is akin to [#15. Ability to writing kotlin code without gradle or maven](https://github.com/fwcd/vscode-kotlin/issues/15).

I am using your great extension (THANKS!!) in the experimental way - with a standalone Kotlin JVM compiler, no gradle, no maven. I hope to get this working - I am new at VS Code and Kotlin, but I love them both. I plan to write simple programs with it, so I don't want to use Gradle if I can avoid it. I am coming from the slow-starting IntelliJ IDEA (CE), and so far am loving the quick VS Code tool!

So if you can, please suggest any missing files, folders, or name changes I could do to get this working (short of installing Gradle and using it), and if possible, make fixes to your debug adapter where it might be expecting a gradle artifact.

Following are some details. Please let me know if you need anything else.

Thanks so much!
Kim

### 1. SOURCE - Main.kt
```
fun main() {
println("main: hello world, it's Kotlin/JVM!")
println()
}
```

### 2. BUILDING - works

With VS Code, your extension, and a build task, I can successfully compile a simple program from VS Code.
```
kotlinc-jvm "...\src\Main.kt"
-> ...\build\classes\kotlin\main\MainKt.class
```

### 3. EXECUTING - works

I started with source and .class files in the workspace root dir. There were errors in VS Code's Output Pane, Kotlin channel, that reported files missing from expected locations (dictated by gradle, I'm guessing). Based on those, I moved my source code to the 'src' subfolder and class files to the 'build\classes\kotlin\main' subfolder. That allowed me to execute the program from VS Code's Run > Run without Debugging. VS Code's Debug Console gave:
```
main: hello world, it's Kotlin/JVM!
```

SIDE NOTE:
It would be great if you could append a note to your "Support for Kotlin source files with a standalone compiler (kotlinc) is experimental." - the note could say to put your stuff into 'src' and 'build' folders.

### 4. DEBUGGING - fails to stop at breakpoint

The program simply runs to completion. I saw no errors that would lead me to a correct setup of files, folders, or other gradle-like setup.

Debug Console:
```
[INFO] main Connected to client
[INFO] async1 Could not resolve kotlin-stdlib using Maven: null
[INFO] async1 Could not resolve kotlin-stdlib using Gradle: C:\Users\Kim\.gradle\caches
[INFO] async1 Found kotlinc.bat at C:\Program Files\Kotlin\kotlin-jvm-1.6.10\bin\kotlinc.bat
[INFO] async1 Starting JVM debug session with main class MainKt
main: hello world, it's Kotlin/JVM!

[INFO] eventBus Sent exit event
[INFO] async0 Exiting JDI session
```
launch config:
```
"configurations": [
{
"type": "kotlin",
"request": "launch",
"name": "Kotlin Launch",
"projectRoot": "${workspaceFolder}",
"mainClass": "MainKt"
//"cwd": "${workspaceRoot}",
//"stopOnEntry": "true"
}
]
```

### 5. MY ENVIRONMENT
* 'Kotlin' extension version 0.2.24 (fwcd.vscode-kotlin)
* VS Code 1.65.2
* Windows 10
* JDK 11 installed and in the PATH
* standalone Kotlin/JVM 1.6.10 installed; kotlinc.bat and kotlin.bat bin in the PATH
* no gradle or maven installed

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the issue with the provided Main.kt example, standalone kotlinc setup, and launch configuration, then read the debug output around the JVM debug session and JDI connection. Done means a breakpoint pauses the standalone Kotlin/JVM program without Gradle or Maven, while the existing run configuration still executes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin, vscode
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.