Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pick_files() doesn't work on neovim 0.10 #1220

Closed
cryptomilk opened this issue May 23, 2024 · 3 comments · Fixed by #1221
Closed

pick_files() doesn't work on neovim 0.10 #1220

cryptomilk opened this issue May 23, 2024 · 3 comments · Fixed by #1221

Comments

@cryptomilk
Copy link
Contributor

Debug adapter definition and debug configuration

pick_files only gives me an empty list:

local ok, dap = pcall(require, 'dap')
if not ok then
    return
end

local dap_utils = require('dap.utils')

local cwd = vim.fn.getcwd()
local is_samba = cwd:find('samba')

local path = cwd
if is_samba then
    path = cwd .. '/bin'
end

local exec_opts = {
    path = path,
    executables = true,

    filter = function(exec)
        -- Filter out shared libraries
        return not exec:match('%.so([.0-9]*)')
    end,
}

--
-- See
-- https://sourceware.org/gdb/current/onlinedocs/gdb.html/Interpreters.html
-- https://sourceware.org/gdb/current/onlinedocs/gdb.html/Debugger-Adapter-Protocol.html
dap.adapters.gdb = {
    id = 'gdb',
    type = 'executable',
    command = 'gdb',
    args = { '--quiet', '--interpreter=dap' },
    --[[
    args = {
        '-iex',
        'set debug dap-log-file /tmp/gdb-dap.log',
        '--quiet',
        '--interpreter=dap',
    },
]

dap.configurations.c = {
    {
        name = 'Run executable (GDB)',
        type = 'gdb',
        request = 'launch',
        -- This requires special handling of 'run_last', see
        -- https://github.com/mfussenegger/nvim-dap/issues/1025#issuecomment-1695852355
        program = function()
            return dap_utils.pick_file(exec_opts)
        end,
    },
    {
        name = 'Run executable with arguments (GDB)',
        type = 'gdb',
        request = 'launch',
        -- This requires special handling of 'run_last', see
        -- https://github.com/mfussenegger/nvim-dap/issues/1025#issuecomment-1695852355
        program = function()
            return dap_utils.pick_file(exec_opts)
        end,
        args = function()
            local args_str = vim.fn.input({
                prompt = 'Execeutable arguments: ',
            })
            return vim.split(args_str, ' +')
        end,
    },
    {
        name = 'Attach to process (GDB)',
        type = 'gdb',
        request = 'attach',
        processId = require('dap.utils').pick_process,
    },
}

Debug adapter version

master

Steps to Reproduce

  1. Open C file
  2. Set Breakpoint
  3. Try to run it with gdb config
  4. Get executable file list

Expected Result

Get a executable file list

Actual Result

Empty list

If I count the files it walks with vim.fs.dir(), I see it finds 14k files.
If I set exeutables = false it works.

My lua-lanaguage server tells me:

local stat = uv.fs_stat(filepath)     ● Undefined field `fs_stat`.

If I add a bit of more debug:

check file: default/source4/dsdb/samdb/ldb_modules/tests/test_unique_object_sids.c.9.o
no stat

It looks like stat always fails.

@mfussenegger
Copy link
Owner

What permissions do the files have? It's currently checking for user-executable permission

fs_stat should definitely work, it is also used in the vscode launch.json logic and all over the neovim code base.

@mfussenegger
Copy link
Owner

Oh I think I know what's going on. fs_path receives relative paths, which it resolves based on cwd. With a custom path the filtering is therefore broken. I first had absolute paths but changed that to relative to have more readable output in the prompt.

I'll whip up a fix

@mfussenegger
Copy link
Owner

Can you try with #1221 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants