microsoft / microsoft/vscode-cpptools

Cannot debug using gdb

Open
#6,703 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Type: Debugger

Describe the bug

  • OS and Version: Windows 10 ver 2004 (OS Build 19041.685)
  • VS Code Version: 1.52.1
  • C/C++ Extension Version: 1.1.3
  • Other extensions you installed (and if the issue persists after disabling them): Bracket Pair Colorizer 2, Matlab.
    Nothing change after disabling them.

I use cygwin64
Compile and run complelety normal on cygwin terminal
Try to debug in vscode and this happen

Sorry for my terrible english

test.c

#include <stdio.h>

int main()
{
    int p;
    p = 123;
    printf("%d", p);
}

launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "gcc.exe build and debug active fileaaaaa",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "c:\\cygwin64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "gcc.exe build active file"
        }
    ]
}

tasks.json

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "gcc.exe build active file",
            "command": "C:\\cygwin64\\bin\\gcc.exe",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:\\cygwin64\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

Debug console output

=thread-group-added,id="i1"
GNU gdb (GDB) (Cygwin 10.1-1) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-cygwin".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"
ERROR: Unable to start debugging. Unexpected GDB output from command "-exec-run". Error creating process /usr/bin/D:\\workspace\\learnC/d:\workspace\learnC\test.exe, (error 2).
The program 'd:\workspace\learnC\test.exe' has exited with code 42 (0x0000002a).

already tried change externalConsole to true

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 with the reported launch.json and tasks.json alongside test.c, then reproduce the failure using the supplied Cygwin paths and debug console output. Trace how the cppdbg configuration passes the program path to GDB on Windows. Done means the sample program starts debugging successfully with the reported setup or the issue is narrowed to a documented configuration limitation.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.