microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.52k stars 1.55k forks source link

Unable to start debugging. Unexpected GDB output from command "-environment-cd" #10543

Open Vincent0706 opened 1 year ago

Vincent0706 commented 1 year ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: I can't debug with (gdb) Bash on Windows Launch

I get such error: image

Debugger Configurations

// tasks.json
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe 生成活动文件",
            "command": "D:\\MinGW64\\bin\\g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ],
    "version": "2.0.0"
}

// launch.json
{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Windows 上的 Bash 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "pipeTransport": {
                "debuggerPath": "/usr/bin/gdb",
                "pipeProgram": "${env:windir}\\system32\\bash.exe",
                "pipeArgs": ["-c"],
                "pipeCwd": ""
            },
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

Debugger Logs

The program 'F:\CodeTest\C++STL-Learning/a.exe' has exited with code 42 (0x0000002a).

Other Extensions

No response

Additional Information

No response

WardenGnaw commented 1 year ago

The issue here is bash does not understand the Windows drive F: also GDB does not like symbols like + or -, you may want to modify your path to be letters/numbers.

Vincent0706 commented 1 year ago

I have changed the file name, but it still error. image

Crystal-RainSlide commented 1 year ago

It seems this -environment-cd command is added here by the MIEngine:

https://github.com/microsoft/MIEngine/blob/c8c71f394db710b931c833b962289b324fd1b915/src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs#L778

Also see: