microsoft / microsoft/vscode-cpptools

Using an Input Task for complex Launch Args doesn't work

Open
#7,409 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

debugger
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Bug type: Debugger

Describe the bug

  • OS and Version: Host: MacOS, Container: Gentoo
  • VS Code Version: 1.55.2
  • C/C++ Extension Version: 1.3.1

I'm connecting to a Container workspace and trying to launch the debugger within the container. With a static config (without tasks) everything works fine. However, the process I'm trying to debug has complex logic to determine args depending on what input file we give it. So previously I had a launch.json like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug File",
            "type": "cppdbg",
            "request": "launch",
            "program": "/depot/out/cur/process",
            "args": [
                "--read", "${input:filePicker}",
                // ... sometimes gotta add other stuff
            ],
        },
    ],
    "inputs": [
        {
            "id": "filePicker",
            "type": "command",
            "command": "extension.commandvariable.file.pickFile",
            "args": {
                "include": "**/*.txt",
                "display": "fullPath"
            }
        }
    ]
}

Which let us pick the file we wanted to debug. It worked fine, except sometimes we needed to tune the args by hand depending on the file, which is annoying.

Thanks to #4962 I know (and tested) I can pass args in the format {--foo,bar} and they'll be expanded correctly for GDB. So I wrote a little script that, given an input file, spits out the args we want in that format. So I changed my configs:

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug File",
            "type": "cppdbg",
            "request": "launch",
            "program": "/depot/out/cur/process",
            "args": ["${input:getDebugArgs}"],
            "logging": {
                "trace": true,
                "traceResponse": true,
                "engineLogging": true
            }
        }
    ],
    "inputs": [
        {
            "id": "getDebugArgs",
            "type": "command",
            "command": "workbench.action.tasks.runTask",
            "args": "getDebugArgs"
        }
    ]
}

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "getDebugArgs",
            "type": "shell",
            "command": "/depot/test/gen_debug_args -w ${input:filePicker}"
        },
    ],
    "inputs": [
        {
            "id": "filePicker",
            "type": "command",
            "command": "extension.commandvariable.file.pickFile",
            "args": {
                "include": "**/*.txt",
                "display": "fullPath"
            }
        }
    ]
}

The task runs correctly, with output

> Executing task in folder sensor: /depot/test/gen_debug_args -w /depot/test/a.txt <

{--foo,bar}
Terminal will be reused by tasks, press any key to close it.

But the debugger never actually starts. No loading bar, no spinner, no error messages anywhere (terminal, C/C++ output, Debug Console, or Dev Console); it just stops. Like I said, with a raw file input things worked fine, so I don't believe there's any issue with my other debugger settings. Any ideas?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the launch.json and tasks.json configurations, especially the cppdbg args input and the workbench.action.tasks.runTask command. Reproduce the task-driven launch with trace and traceResponse logging enabled, then compare it with the working raw file input case. Done means the debugger starts and receives the generated arguments from getDebugArgs.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, vscode
Domain
devtools
Issue type
Bug
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.