microsoft / microsoft/vscode-cpptools

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

オープン
#7,409 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

debugger
主要言語
TypeScript
スター
6.2k
フォーク
1.7k
平均マージ
14時間 46分
マージ済み PR(30日)
61

説明

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?

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

launch.json と tasks.json の構成から始め、特に cppdbg args input と workbench.action.tasks.runTask command を確認します。trace と traceResponse のログを有効にしたタスク駆動の起動を再現し、動作している raw file input のケースと比較します。デバッガーが起動し、getDebugArgs から生成された引数を受け取れば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
cpp, vscode
領域
devtools
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。