microsoft / microsoft/vscode-cpptools

GDB Debugging not working in Codespaces

Open
#8,150 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

debugger
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Bug type: Debugger

Describe the bug

  • OS and Version: Codespaces
  • VS Code Version: 1.60.1
  • C/C++ Extension Version: 1.6.0
  • Other extensions you installed (and if the issue persists after disabling them): Live Share Extension Pack, yes persists.
  • A clear and concise description of what the bug is.

Run & Debug does not run GDB but instead prompts for Environment and then opens existing .vscode/launch.json file.

To Reproduce

  1. Add .vscode/launch.json and .vscode/tasks.json to C++ project.
  2. Add task for compiling shared library object.
  3. Add task for compiling executable that links to shared library object.
  4. Open cpp file for executable and click on Run and Debug menu.
  5. Press Play button to start debugging.
  6. See prompt for Environment followed by .vscode/launch.json file opened in editor.

Additional context

This bug does not exist when running Run and Debug in a local VSCode instance or in a VSCode Remote Container instance. The Remote Container instance uses the same devcontainer as Codespaces so has an identical environment. Running GDB manually in the Codespaces terminal works as expected.

Symptoms appear to show that the .vscode/launch.json file is not being found or being ignored in this environment. Syntax errors in the file do not change anything, although removing it and then following the Environment and Task prompts will recreate the file in the correct location but then exhibit the same symptoms afterwards.

.vscode/launch.json:

{
    "name": "Local",
    "type": "cppdbg",
    "request": "launch",
    "program": "${fileDirname}/${fileBasenameNoExtension}",
    "args": [],
    "stopAtEntry": true,
    "cwd": "${fileDirname}",
    "environment": [],
    "externalConsole": false,
    "MIMode": "gdb",
    "setupCommands": [
        {
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing",
            "ignoreFailures": true
        },
        {
            "description": "Set library path",
            "text": "set env LD_LIBRARY_PATH=${workspaceFolder}",
            "ignoreFailures": false
        }
    ],
    "preLaunchTask": "<Custom Task Name>",
    "miDebuggerPath": "/usr/bin/gdb"
}

** Workaround **

Add VSCode User Setting:

"launch": {
    "configurations": [
        {
            "name": "Global",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set library path",
                    "text": "set env LD_LIBRARY_PATH=${workspaceFolder}",
                    "ignoreFailures": false
                }
            ],
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ],
    "compounds": []
}

Run Build Task Manually
Press F5 to run Debug

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue in Codespaces with the listed VS Code and C/C++ extension versions, using the workspace .vscode/launch.json and .vscode/tasks.json files. Compare Run and Debug with local VS Code and Remote Containers, then trace how the workspace launch configuration is discovered. Done means the existing configuration is honored and GDB starts from Run and Debug without the Environment prompt.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, vscode
Domain
developer-experience, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.