I have a small Rust program that reads and writes to stdin and stdout. This Rust executable is to be called from and interact with a Java program.
The Java program is started from the command line like this:
java -jar ${pathToJar} ${pathToMyRustExecutable} ${otherArgs}
It is a one-and-done kind of program and doesn't run in a loop, which makes it hard for me to attach the debugger to.
I've been reading through VSCode's documentation on tasks.json and launch.json and here's the best I could come up with so far.
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Launch CG Referee",
"type": "shell",
"command": "java",
"args": [
"-jar",
"$HOME/.m2/repository/com/codingame/game/spring-2020/1.0-SNAPSHOT/spring-2020-1.0-SNAPSHOT-fat-tests.jar",
"${workspaceFolder}/target/debug/spring-challenge-2020-rust.exe",
"${workspaceFolder}/target/debug/spring-challenge-2020-rust.exe",
"5842184981578562716"
]
},
{
"type": "cargo",
"subcommand": "build",
"problemMatcher": [
"$rustc"
],
"group": "build",
"label": "Build"
},
{
"label": "Build and Launch CG Referee",
"dependsOn": [
"Build",
"Launch CG Referee"
],
"dependsOrder": "sequence"
}
]
}
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "attach",
"name": "Debug",
"preLaunchTask": "Build and Launch CG Referee",
"program": "${workspaceFolder}/target/debug/spring-challenge-2020-rust.exe",
"sourceLanguages": ["rust"]
}
]
}
This succeeds in building my Rust code and launches the Java process, but it doesn't attach the debugger in time. The process ends before it does. I suspect it is because launch.json waits for the "preLaunchTask" to exit before trying to attach the debugger, but I haven't found anything in the docs that confirms that or a workaround to fix that.
How can I configure this properly?