vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

c++ debugger doesn't run

Open zmrocze opened this issue 2 years ago • 5 comments

Environment

  • OS and version: nixos 23.02
  • VS Code: 1.78.2
  • C/C++ extension: 1.17.5
  • OS and version of remote machine (if applicable): -
  • GDB / LLDB version: 13.1

Bug Summary and Steps to Reproduce

Bug Summary:

Launching a c++ debugger from vscode doesn't launch debugger. For a moment the debugging icons show up, but quickly thedDebugger quits doesn't stopping on breakpoints. No error messages show anywhere in vscode console/problems/output.

Steps to reproduce:

  1. Use the default debugger configuration called "g++: build and debug" or configure launch.json like below:
// launch.json
"configurations": [
    {
      "name": "(gdb) Launch 1",
      "type": "cppdbg",
      "request": "launch",
      "program": "${fileDirname}/${fileBasenameNoExtension}",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${fileDirname}",
      "environment": [],
      "externalConsole": false,
      "MIMode": "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
          }
      ]
    },
 ]
}
  1. From withing vs code debugger tab start the debugger (in the example a configuration "(gdb) Launch 1"
  2. Observe how debugger seemingly starts, icons (start/continue/stop) show up for a moment but then disappear and nothing more happens.
  3. Inspect how nothing shows up in problems/output/debug console.

Debugger Configurations

{ "configurations": [
    {
      "name": "(gdb) Launch 1",
      "type": "cppdbg",
      "request": "launch",
      "program": "${fileDirname}/${fileBasenameNoExtension}",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${fileDirname}",
      "environment": [],
      "externalConsole": false,
      "MIMode": "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
          }
      ]
    },
  ]
}

{
  "tasks": [
    {
      "type": "cppbuild",
      "label": "C/C++: g++ build active file",
      "command": "/home/zmrocze/.nix-profile/bin/g++",
      "args": [
        "-fdiagnostics-color=always",
        "-g",
        "${file}",
        "-o",
        "${fileDirname}/${fileBasenameNoExtension}"
      ],
      "options": {
        "cwd": "${fileDirname}"
      },
      "problemMatcher": [
        "$gcc"
      ],
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "detail": "Task generated by Debugger."
    }
  ],
  "version": "2.0.0"
}

Debugger Logs

Nothing shows up anywhere after I enabled logging like hinted ^ above.

Other Extensions

No response

Additional Information

I'm using nixos so it might be bit weirder with the linker, I've hit problems before when the linker couldn't find something during compilation. BUT here this is irrelevant: 1) I can compile succesfully with these compilers, also from within vscode. 2) there's no indication whatsover from vscode that anything failed.

Versions:

$ which gdb
/home/zmrocze/.nix-profile/bin/gdb
$ which g++
/home/zmrocze/.nix-profile/bin/g++
$ g++ (GCC) 13.1.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ GNU gdb (GDB) 13.1
Copyright (C) 2023 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.

zmrocze avatar Oct 13 '23 19:10 zmrocze

Can you provide a screenshot of the button you're clicking to start debugging? Does it run without debugging?

sean-mcmanus avatar Oct 13 '23 22:10 sean-mcmanus

The button: "Run and Debug" section on the left -> "Start debugging (F5)" green play button. Choosing the "(gdb) Launch 1" configuration.

zmrocze avatar Oct 14 '23 18:10 zmrocze

@zmrocze Sorry for the delayed response. I'm not sure what could be going wrong.

@WardenGnaw Do you know what could be going wrong?

sean-mcmanus avatar Oct 28 '23 00:10 sean-mcmanus

I had the same issue and debugger started working again when I downgraded version to 1.6.2.

hwangs12 avatar Feb 17 '24 16:02 hwangs12

same here.

[proc] Executing command: gdb --version

Is the last info, then nothing more happens.

As far as I can see, it does not try to start any gdb process after the version check to get the path.

hifigraz avatar Apr 05 '24 09:04 hifigraz

This is because there is an unpatched binary in the extension. Please see https://discourse.nixos.org/t/cant-run-c-debugger-in-vscode/33609/6

I made really good progress on this using strace

I did:

strace -f -s99999 -e trace=clone,execve code --wait .

Then I tried to click the debugger:

[pid 193326] execve("/home/fmzakari/.vscode/extensions/ms-vscode.cpptools-1.20.5-linux-x64/debugAdapters/bin/OpenDebugAD7", ["/home/fmzakari/.vscode/extensions/ms-vscode.cpptools-1.20.5-linux-x64/debugAdapters/bin/OpenDebugAD7"], 0x2aec0357bc00 /* 92 vars */) = 0
[pid 193326] +++ exited with 127 +++

It tries to run a binary OpenDebugAD7 which is not compatible with NixOS :(

This needs to be rebuilt using NixO

fzakaria avatar Jul 17 '24 03:07 fzakaria