fatih / vim-go

Go development plugin for Vim
https://www.patreon.com/bhcleek
Other
15.98k stars 1.45k forks source link

I'm getting errors when :GoDebugStart #3543

Closed stephane-archer closed 1 year ago

stephane-archer commented 1 year ago

after adding a breakpoint in the main function with :GoDebugBreakpoint then starting a debug session with :GoDebugStart

Error detected while processing function <SNR>92_on_data[27]..<SNR>92_handleRPCResult[14]..function <SNR>92_on_data[27]..<SNR>92_handleRPCResult:
line    9:
E608: Cannot :throw exceptions with 'Vim' prefix
Press ENTER or type command to continue
Error detected while processing function <SNR>94_on_data:
line   27:
E170: Missing :endfor
Press ENTER or type command to continue
vim-go: could not list variables: unable to find function context
vim-go: could not list function arguments: unable to find function context
Press ENTER or type command to continue
vim-go: No Goroutines Running Now...
Press ENTER or type command to continue
vim-go: failed to sync breakpoints (function <SNR>79_on_stdout[1]..<SNR>79_neocb[61]..<SNR>94_out_cb[9]..<SNR>94_connect[42]..<SNR>94_sync_breakpoints, line 6): Vim(let):E716: Key not present in Dictionar
y: "result.Breakpoints"
Press ENTER or type command to continue

I have no idea why, dlv debug works on my system and the rest of vim-go plugging work as expected

delve Debugger
Version: 1.20.1
Build: $Id: 96e65b6c615845d42e0e31d903f6475b0e4ece6e $
NVIM v0.8.3
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@Ventura

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.8.3/share/nvim"

Run :checkhealth for more info
" vim-plug config (plugin manager)
call plug#begin()
    Plug 'nvim-lua/plenary.nvim'
    Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.1' }
    Plug 'vim-airline/vim-airline'
    Plug 'tomasiser/vim-code-dark'
    Plug 'dag/vim-fish'
    Plug 'jremmen/vim-ripgrep'
    Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
    Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
    Plug 'liuchengxu/vim-which-key'
    Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
    Plug 'neovim/nvim-lspconfig'
    Plug 'stevearc/aerial.nvim'
call plug#end()

let mapleader = "\<Space>"
set clipboard+=unnamedplus
set nowrap
set number
set relativenumber
set timeoutlen=500
let g:airline_theme = 'codedark'
colorscheme codedark
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
let g:deoplete#enable_at_startup = 1
call deoplete#custom#option('omni_patterns', { 'go': '[^. *\t]\.\w*' })
nnoremap <silent> <leader> :WhichKey '<Space>'<CR>
nnoremap <leader>gb :GoBuild<CR>
nnoremap <leader>gt :GoTest<CR>
nnoremap <leader>gd :GoDef<CR>
nnoremap <leader>gD :GoRef<CR>
nnoremap <leader>gk :GoDoc<CR>
nnoremap <leader>gr :GoRename<CR>
nnoremap <leader>F :AerialToggle<CR>
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
nnoremap <leader>fs <cmd>Telescope lsp_document_symbols<cr>
nnoremap <leader>fS <cmd>Telescope lsp_workspace_symbols<cr>
lua << EOF
require'lspconfig'.gopls.setup{}
require'lspconfig'.pyright.setup{}
require("aerial").setup({})
EOF
NickCellino commented 1 year ago

I'm having the same issue.

NVIM v0.9.0
Build type: Release
LuaJIT 2.1.0-beta3

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.9.0/share/nvim"

Run :checkhealth for more info
dlv version
Delve Debugger
Version: 1.20.2
Build: $Id: e0c278ad8e0126a312b553b8e171e81bcbd37f60 $
bhcleek commented 1 year ago

What version of vim-go are you using? I'm unable to duplicate the problem you're describing using Neovim 0.9.0 and latest master of vim-go.

stephane-archer commented 1 year ago

I just updated vim-go using Plug, I was able to set a breakpoint, start and continue, but when I wanted to step I got the following error:

Error detected while processing function <SNR>102_on_data[27]..<SNR>102_handleRPCResult[14]..function <SNR>102_on_data[27]..<SNR>102_handleRPCResult:
line    9:
E608: Cannot :throw exceptions with 'Vim' prefix
Press ENTER or type command to continue
Error detected while processing function <SNR>102_on_data:
line   27:
E170: Missing :endfor
Press ENTER or type command to continue

my version of NVIM v0.8.3 and vim-go should be the latest version I imagine (I ask Plug to update my plugins see my vim config)

bhcleek commented 1 year ago

Can you start delve with logging turned on and then connect? I'd like to know what it think it's sending to vim-go. I'd also like to know the complete contents of your __GODEBUG_OUTPUT__ window after this happens.

stephane-archer commented 1 year ago

Would you explain how to do what you are proposing?

bhcleek commented 1 year ago

You can use something like dlv debug --headless --continue --accept-multiclient --listen=:8181 --api-version=2 main.go at the command line and then execute :GoDebugConnect 8181 in Vim.

stephane-archer commented 1 year ago

term1:

dlv debug --headless --continue --accept-multiclient --listen=:8181 --api-version=2 main.go
API server listening at: [::]:8181
2023-05-04T15:08:11-03:00 warning layer=rpc Listening for remote connections (connections are not authenticated nor encrypted)
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-1400.0.38.17
 for x86_64.
Got a connection, launched process /Users/fractale/photoProxy/__debug_bin (pid = 8739).
Error: not enough args
Exiting.
2023-05-04T15:08:11-03:00 error layer=rpc writing response:write tcp [::1]:8181->[::1]:50260: use of closed network connection
$ echo $__GODEBUG_OUTPUT__
 #empty

nvim:

:GoDebugConnect localhost:8181
vim-go: failed to sync breakpoints (function go#debug#Start[32]..<SNR>93_connect[42]..<SNR>93_sync_breakpoints[51]..<SNR>93_call_jsonrpc, line 32): (let):E716: Key not present in Dictionary: "ch"
Press ENTER or type command to continue
bhcleek commented 1 year ago

It looks like your application wasn't started by dlv. You'll have to adjust the arguments to make sure your application actually starts.

The __GODEBUG_OUTPUT__ window will be in Vim.

lillesvin commented 1 year ago

I'm getting the same errors when I try to start debugging from vim-go, and I'm pretty sure the application is started just fine by dlv, since I can debug with dlv alone and I can initiate the debugging session by directly calling dlv and connect to it through vim-go. But when I try to initiate the session from vim-go, I get the same errors as OP.

NVIM v0.8.3
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by runner@fv-az183-550

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info
$ dlv version
Delve Debugger
Version: 1.20.2
Build: $Id: e0c278ad8e0126a312b553b8e171e81bcbd37f60 $

I ran a succesful :PlugUpdate and :GoUpdateBinaries just before, so I expect everything to be the latest (and greatest) version.

This is what works for me:

This dlv command line (without the --continue flag):

$ dlv debug --log --accept-multiclient --listen=:8181 --api-version=2 . -- url https://google.com

Followed by :GoDebugConnect localhost:8181 in Nvim.

This doesn't work for me:

Adding --continue to the dlv command line, results in this:

$ dlv debug --log --continue --accept-multiclient --listen=:8181 --api-version=2 . -- url https://google.com
API server listening at: [::]:8181
2023-05-11T14:11:12+02:00 warning layer=rpc Listening for remote connections (connections are not authenticated nor encrypted)
2023-05-11T14:11:12+02:00 info layer=debugger launching process with args: [/home/madsen/code/vtcli/__debug_bin url https://google.com]
2023-05-11T14:11:12+02:00 debug layer=debugger continuing
&{data:{ID:u-9d116b1b0c1200ca75016e4c010bc94836366881b021a658ea7f8548b6543c1e-1683807070 Type:analysis Attributes:map[] ContextAttributes:map[] Relationships:map[] Links:0xc0001aa200} jsonq:<nil> modifiedAttributes:[] modifiedData:map[]}
2023-05-11T14:11:13+02:00 error layer=rpc writing response:write tcp [::1]:8181->[::1]:56350: use of closed network connection
###!!! THIS IS WHERE I SWITCH TO NVIM AND RUN ":GoDebugConnect localhost:8181" !!!###
2023-05-11T14:11:58+02:00 debug layer=debugger halting
2023-05-11T14:11:58+02:00 debug layer=debugger detaching
2023-05-11T14:11:58+02:00 debug layer=debugger detaching

Meanwhile in Nvim:

__GODEBUG_OUTPUT__ is completely empty after running :GoDebugConnect localhost:8181, but the Nvim command line says:

vim-go: failed to sync breakpoints (function go#debug#Start[32]..<SNR>83_connect[42]..<SNR>83_sync_breakpoints[51]..<SNR>83_call_jsonrpc, line 32): (let):E716: Key not present in Dictionary: "ch"
stephane-archer commented 1 year ago

Hi,

After running : dlv debug --headless --continue --accept-multiclient --listen=:4242 --api-version=2 main.go I got the following output :

API server listening at: [::]:4242
2023-05-21T15:44:22-04:00 warning layer=rpc Listening for remote
connections (connections are not authenticated nor encrypted)
debugserver-@(#)PROGRAM:LLDB  PROJECT:lldb-1400.0.38.17
 for x86_64.
Got a connection, launched process /Users/fractale/photoProxy/__debug_bin
(pid = 963).
2023-05-21T15:44:53-04:00 error layer=rpc writing response:write tcp
[::1]:4242->[::1]:49523: use of closed network connection

And in nvim after :GoDebugConnect localhost:4242 An orange message appeared but I was not able to read it quickly enough. Then all the debug windows opened and `__GODEBUG_OUTPUT__ˋ was totally empty -- Best Regards,

Stephane Archer

bhcleek commented 1 year ago

Can you give latest master a try? I don't expect it to fully resolve the problem, but I think it may help us understand what's going on better.