microsoft / microsoft/vscode-cpptools

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

Offen
#7,409 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

debugger
Vorherrschende Sprache
TypeScript
Sterne
6.2k
Forks
1.7k
Ø Merge
14 Std. 46 Min.
Gemergte PRs (30 T.)
61

Beschreibung

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?

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit den Konfigurationen launch.json und tasks.json, insbesondere mit dem cppdbg args input und dem workbench.action.tasks.runTask command. Reproduziere den aufgabengetriebenen Start mit aktiviertem trace- und traceResponse-Logging und vergleiche ihn anschließend mit dem funktionierenden Fall der raw file input. Als erledigt gilt die Aufgabe, wenn der Debugger startet und die generierten Argumente von getDebugArgs erhält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp, vscode
Bereich
devtools
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.