Skip to content

Unable to establish a connection to GDB when "externalConsole": falseΒ #2889

@tnqzh123

Description

@tnqzh123

Type: Debugger

(I'm sorry for my poor English)

  • OS and Version: Windows 10 Pro 1809 18290.100
  • VS Code Version: 1.29.1
  • C/C++ Extension Version: 0.20.1

I want to debug with the built-in terminal on VS Code, so I set "externalConsole": false in launch.json.
But when I started debugging, it told me "Unable to establish a connection to GDB". I have already installed MinGW-w64.

snipaste_2018-12-02_18-39-07

This is my launch.json file:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C/C++ Debugging with GDB",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "Compile C/C++"
        }
    ]
}

and tasks.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Compile C/C++",
            "command": "g++",
            "args": [
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}.exe",
                "-g",
                "-Wall",
                "-lm",
                "-std=c++17"
            ],
            "type": "shell",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": true,
                "panel": "shared"
            },
            "problemMatcher": {
                "owner": "cpp",
                "fileLocation": "absolute",
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            }
        }
    ]
}

Steps to reproduce the behavior:

  1. Open a c/cpp file
  2. Navigate to Debug panel
  3. Click "Start Debugging"
  4. Error happened.

This error only happens when "externalConsole": false in launch.json. If "externalConsole": true, it will be normal.

Metadata

Metadata

Assignees

Labels

debuggerfixedCheck the Milestone for the release in which the fix is or will be available.more info neededThe issue report is not actionable in its current state

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions