sebdah / vim-delve

Neovim / Vim integration for Delve
MIT License
502 stars 24 forks source link

Breakpoint location not found #37

Closed slax0rr closed 4 years ago

slax0rr commented 4 years ago

Hello,

I am running a dlv exec somebin in headless mode outside of vim and then using DlvConnect to connect to delve in order to debug my executable, but my workdir is just a symlink:

/my/workdir/ -> /actual/location

Now, when I run go build .... inside /my/workdir/ this builds the exec with /my/workdir/ path, but, when vim-delve uses expand('%:p') on the file where I want to place a breakpoint it will use the /actual/location/ instead of my symlink, and of course, when delve receives break /actual/location/some.go:123 it throws a not found error.

Here is a possible solution to this issue:

function! delve#getFile()
    if !exists("g:delve_project_root")
        return expand('%:p')
    endif

    return g:delve_project_root . expand('%')
endfunction

Allow the user to set the root dir of the files, then just use this function to get the absolute file path when setting the breakpoints/tracepoints. Since this is a very specific issue, I thought I'd ask here before making a pull request, if you think that this is even worth fixing?

zwiedmann-isp commented 4 years ago

@slax0rr @sebdah This would be useful for DlvConnect in general which relies on local paths matching the debug executable. In addition to symlinks, this is often the case when using docker. Would love to see a feature for overriding the basepath or otherwise translating local->remote paths.