microsoft / vscode-cpptools

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

[linux] debugging with gdb not working anymore #6046

Open A-Debord opened 4 years ago

A-Debord commented 4 years ago
os: ubuntu 20.04
vscode: 1.48.2
cpptools: v0.29.0 (tried both default & insiders channels)
gdb: 9.1

Hi,

i'm trying to launch the debugger it was working fine a month ago (before vacation) now I get an error. The program doesn't seem to start at all, like nothing gets executed. however i can debug it manually using gdb --args myprogram myargs

Terminal :

&"warning: GDB: Failed to set controlling terminal: Operation not permitted\n"
/bin/bash: -c: line 0: unexpected EOF while looking for matching `}'
/bin/bash: -c: line 1: syntax error: unexpected end of file
[1] + Done                       "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-op229nom.ijv" 1>"/tmp/Microsoft-MIEngine-Out-cwku9ms3.0ks"

Debug Console :

1: (959) <-1017-exec-run
1: (960) ->=thread-group-started,id="i1",pid="723395"
1: (960) ->=thread-created,id="1",group-id="i1"
1: (961) ->=thread-exited,id="1",group-id="i1"
1: (961) ->=thread-group-exited,id="i1"
1: (961) ->1017^error,msg="During startup program exited with code 1."
1: (961) ->(gdb)
1: (966) <-1018-thread-info 1
1: (966) ->1018^done,threads=[]
WardenGnaw commented 4 years ago

Are you using the integratedTerminal and what is your default shell set to?

A-Debord commented 4 years ago

Yes I'm using the integrated terminal and I tried with both bash and zsh as default shell (same results).

jpcaram commented 2 years ago

I'm experiencing the same issue.

I really doubt that debugging C/C++ in VSCode on Linux has been broken for almost 2 years. Can anyone shed some light on this?

I'm on Ubuntu 20.04, VSCode 1.67.2, launch.json is:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "/usr/bin/gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description":  "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": {
                "task": "C/C++: gcc build active file to executable"
            }
        },

        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": true
        },

    ]
}

And tasks.json is:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc build library",
            "command": "/usr/bin/gcc",
            "args": [
                "-fdiagnostics-color=always",
                "-shared",
                "-fPIC",
                "-g",
                "-I/usr/include/glib-2.0",
                "-I/usr/lib/x86_64-linux-gnu/glib-2.0/include",
                "-I.",
                "util.c",
                "${file}",
                "-lglib-2.0",
                "-o",
                "${fileDirname}/nlparselib.o"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "compiler: /usr/bin/gcc"
        },
        {
            "type": "cppbuild",
            "label": "C/C++: gcc build active file to executable",
            "command": "/usr/bin/gcc",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "-I/usr/include/glib-2.0",
                "-I/usr/lib/x86_64-linux-gnu/glib-2.0/include",
                "-I.",
                "util.c",
                "nlparselib.c",
                "${file}",
                "-lglib-2.0",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "compiler: /usr/bin/gcc"
        }
    ]
}

My output upon starting debug is even less verbose:

&"warning: GDB: Failed to set controlling terminal: Operation not permitted\n"
[1] + Done                       "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-3ggeoi3f.mjf" 1>"/tmp/Microsoft-MIEngine-Out-fqkgr2tv.ftm"