microsoft / microsoft/vscode-cpptools

Launching of custom GDB does not correctly set CWD (breaks relative paths)

オープン
#815 コメント 25 件 リアクション 2 件 担当者 0 名 GitHub で見る

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

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

説明

I'm trying to debug an STM32 microcontroller through OpenOCD in VSCode 1.13.0 on Windows 10.

I have this launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "ARM GDB Launch",
            "logging": { "trace": true, "traceResponse": true, "engineLogging": true },
            "type": "cppdbg",
            "request": "launch",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "program": "${workspaceRoot}/BUILD/DISCO_F407VG/GCC_ARM/tracker.elf",
            "windows": {
                "miDebuggerPath": "arm-none-eabi-gdb.exe"
            },
            "linux": {
                "miDebuggerPath": "arm-none-eabi-gdb"
            },
            "miDebuggerServerAddress": "localhost:3333",
            "targetArchitecture": "arm",
            "customLaunchSetupCommands": [
                {
                    "description": "Set remote target",
                    "text": "file BUILD/DISCO_F407VG/GCC_ARM/tracker.elf"
                },
                {
                    "description": "Set remote target",
                    "text": "target remote localhost:3333"
                },
                {
                    "description": "Set hardware breakpoints",
                    "text": "set remote hardware-breakpoint-limit 6"
                },
                {
                    "description": "Set hardware breakpoints",
                    "text": "set remote hardware-watchpoint-limit 4"
                },
                {
                    "description": "Reset 1",
                    "text": "monitor reset halt"
                },
                {
                    "description": "Load code",
                    "text": "load"
                },
                {
                    "description": "Reset 2",
                    "text": "monitor reset halt"
                }
            ]
        }
    ]
}

However, this doesn't work. I get the following error:

Unable to start debugging. Unexpected GDB output from command "-interpreter-exec console "file BUILD/DISCO_F407VG/GCC_ARM/tracker.elf"". BUILD/DISCO_F407VG/GCC_ARM/tracker.elf: No such file or directory.

However, the file is there, and if I use the full path, it works. (I do consider it bad practice to use full paths in any code, specially code that others might use).

Since it looked like a path problem, I launched SysInternals' Process Explorer and tried to find the arm-none-eabi-gdb.exe process. I found that its Current directory field is just empty! Screenshot:

image

One workaround that I found, at least until the bug is fixed, is to create a batch (.bat) with this content:

@arm-none-eabi-gdb.exe %*

Then I changed the miDebuggerPath setting to:

                "miDebuggerPath": "${workspaceRoot}/wingdb.bat"

Where wingdb.bat is the name of the file I just created.

Curiously, this does work, which suggests that VSCode is not properly setting the debugger's current directory properly.

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

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

はじめの一歩

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

調査の方向性

launch.json の設定、特に cwd と miDebuggerPath から始め、customLaunchSetupCommands 内の相対 file コマンドを使って失敗を再現します。arm-none-eabi-gdb.exe の直接起動と wingdb.bat の回避策を比較します。デバッガープロセスが意図したカレントディレクトリを受け取り、完全なパスやラッパーなしで相対 tracker.elf パスを解決できれば完了です。

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

評価

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

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

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