mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim
GNU General Public License v3.0
5.17k stars 180 forks source link

Server rejected breakpoint when using nvim-dap #1029

Closed EdwardWong1994 closed 10 months ago

EdwardWong1994 commented 10 months ago

Debug adapter definition and debug configuration

local dap = require('dap')
dap.adapters.codelldb = {
    type = 'server',
    host = '127.0.0.1',
    port = "${port}",
    executable = {
        -- CHANGE THIS to your path!
        command = '/Users/wangchenchen/.local/share/nvim/mason/bin/codelldb',
        args = {"--port", "${port}"},

        -- On windows you may have to uncomment this:
        -- detached = false,
    }
}
dap.configurations.cpp = {
    {
        name = "Launch file",
        type = "codelldb",
        request = "launch",
        program = function()
            return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
        end,
        cwd = '${workspaceFolder}',
        stopOnEntry = false,
    },
}
dap.configurations.c = dap.configurations.cpp
dap.configurations.rust = dap.configurations.cpp

Debug adapter version

V1.9.2

Steps to Reproduce

My example test case is very simple:

#include <stdio.h>

int main(int argc, char *argv[])
{
    for (size_t i = 0; i < 10; i++) {
        printf("i=%ld\n",i);
    }
    printf ("wcc shi shen");
    return 0;
}

My breakpoint is like the following screenshot:

image

When i enter continue the code, the dap-ui automatically occur but with seconds, it will automatically disappear. I also try to debug python, it won't have such problem. Only with this problem when i debug c/cpp.

Expected Result

Suspected it won't automatically close and can successfully debug.

Actual Result

The dap.log file attach here:

[ INFO ] 2023-08-31T17:46:48Z+0800 ] ...fig/nvim/pack/plugins/start/nvim-dap/lua/dap/session.lua:888 ]  "Server rejected breakpoint"    {
  id = 1,
  message = "Resolved locations: 0",
  verified = false
}
[ INFO ] 2023-08-31T17:46:48Z+0800 ] ...fig/nvim/pack/plugins/start/nvim-dap/lua/dap/session.lua:888 ]  "Server rejected breakpoint"    {
  id = 3,
  message = "Resolved locations: 0",
  verified = false
}
mfussenegger commented 10 months ago

Make sure you compile the executable with debug symbols