mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

C/C++/Rust (via vscode-cpptools) not working

Mohamed-Fathy-Salah opened this issue · comments

Debug adapter definition and debug configuration

OS : Arch Linux
installed vscode-cpptools cpptools-linux-aarch64.vsix
unpacked it int ~/.local/share/cpptools/ using command unzip cpptools-linux-aarch64.vsix
ran chmod +x extension/debugAdapters/bin/OpenDebugAD7 to make it executable

    local dap = require('dap')

    dap.adapters.cppdbg = {
        type = 'executable',
        command = '/home/mofasa/.local/share/cpptools/extension/debugAdapters/bin/OpenDebugAD7', 
        id = 'cppdbg',
    }

     dap.configurations.cpp = {
        {
            name = "g++ - Build and debug active file",
            type = "cppdbg",
            request = "launch",
            program = "${fileDirname}/${fileBasenameNoExtension}",
            stopAtEntry = false,
            cwd = "${workspaceFolder}",
            console = "externalTerminal",
            MIMode = "gdb",
            setupCommands = {
                {
                    description = "Enable pretty-printing for gdb",
                    text = "-enable-pretty-printing",
                    ignoreFailures = true
                }
            },
            preLaunchTask = "C/C++: g++ build active file",
            miDebuggerPath = "/usr/bin/gdb"
        }
    },

Debug adapter version

1.9.8

Steps to Reproduce

a simple hello world program compiled with g++ -g a.cpp
make breakpoints in the code :lua require'dap'.toggle_breakpoint()
start debugging :lua require'dap'.continue()

Expected Result

start debugging

Actual Result

when i start debugger i get the following
image
~/.cache/nvim/dap.log

[ ERROR ] 2022-05-31T12:50:41Z+0200 ] ...a/.local/share/nvim/plugged/nvim-dap/lua/dap/session.lua:970 ]	"stderr"	{
  command = "/home/mofasa/.local/share/cpptools/extension/debugAdapters/bin/OpenDebugAD7",
  id = "cppdbg",
  type = "executable"
}	"/home/mofasa/.local/share/cpptools/extension/debugAdapters/bin/OpenDebugAD7: /home/mofasa/.local/share/cpptools/extension/debugAdapters/bin/OpenDebugAD7: cannot execute binary file\n"
[ INFO ] 2022-05-31T12:50:41Z+0200 ] ...a/.local/share/nvim/plugged/nvim-dap/lua/dap/session.lua:938 ]	"Closed all handles"
[ INFO ] 2022-05-31T12:50:41Z+0200 ] ...a/.local/share/nvim/plugged/nvim-dap/lua/dap/session.lua:941 ]	"Process closed"	85370	false

Are you sure you downloaded the right file? cpptools-linux-aarch64.vsix is for ARM, if you're on AMD/Intel you need the x86_64 version.

The error message indicates you've a wrong binary:

/home/mofasa/.local/share/cpptools/extension/debugAdapters/bin/OpenDebugAD7: cannot execute binary file

thank you. that was the problem.
solved by downloading the appropriate file.