vadimcn / codelldb

A native debugger extension for VSCode based on LLDB
https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb
MIT License
2.42k stars 237 forks source link

`args` not working when use `cargo` #1084

Closed J0HN50N133 closed 3 months ago

J0HN50N133 commented 3 months ago

OS: openSUSE Tumbleweed VSCode version: 1.87.2 CodeLLDB version: 1.10 Compiler: rustc 1.76.0-nightly (3f28fe133 2023-12-18) Debuggee: x86_64-linux-gnu

I'm trying to start a debug session with following configuration:

{
    "configurations": [
        {
            "name": "standalone",
            "type": "lldb",
            "request": "launch",
            "cargo": {
                "args": [
                    "run",
                    "--",
                ]
            },
            "args": [
                "standalone",
                "start"
            ],
            "cwd": "${workspaceFolder}",
        },
    ]
}

I would like to debug the command cargo run -- standalone start. However, the args fields are not working. image

I've check the related issues #452, but it didn't help.

Running `cargo run --message-format=json --`... Finished dev [unoptimized + debuginfo] target(s) in 0.57s Running `target/debug/greptime` error: 'greptime' requires a subcommand but one was not provided [subcommands: datanode, frontend, metasrv, standalone, cli, help] Usage: greptime [OPTIONS] For more information, try '--help'. Error: Cargo invocation failed. at t.Cargo.getCargoArtifacts (/home/ljx/.vscode/extensions/vadimcn.vscode-lldb-1.10.0/extension.js:1:14943) at Object.open (/home/ljx/.vscode/extensions/vadimcn.vscode-lldb-1.10.0/extension.js:1:13253) Caused by: Error: exit code: 2. at ChildProcess. (/home/ljx/.vscode/extensions/vadimcn.vscode-lldb-1.10.0/extension.js:1:16610) at ChildProcess.emit (node:events:514:28) at maybeClose (node:internal/child_process:1091:16) at Socket. (node:internal/child_process:449:11) at Socket.emit (node:events:514:28) at Pipe. (node:net:323:12) Verbose log
elenakrittik commented 3 months ago

cargo.args is used to pass arguments to cargo, not to your final binary, and vice versa w.r.t. args. Your config should instead be (assuming you have only one runnable target):

{
    "configurations": [
        {
            "name": "standalone",
            "type": "lldb",
            "request": "launch",
            "cargo": {
                "args": ["build"],
            },
            "args": ["standalone", "start"],
            "cwd": "${workspaceFolder}",
        },
    ]
}