microsoft / microsoft/vscode-cpptools

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

Aperta
#7,409 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

debugger
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Descrizione

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?

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con le configurazioni launch.json e tasks.json, in particolare con l'input cppdbg args e il comando workbench.action.tasks.runTask. Riproduci l'avvio guidato dall'attività con il logging di trace e traceResponse abilitato, quindi confrontalo con il caso funzionante raw file input. Il lavoro è completato quando il debugger si avvia e riceve gli argomenti generati da getDebugArgs.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp, vscode
Ambito
devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.