Vim-go: :GoDebug requires :GoDebugContinue to be called even when breakpoints are set

Created on 4 Mar 2019  路  8Comments  路  Source: fatih/vim-go

What did you do? (required. The issue will be closed when not provided.)

I tried to debug a web server with Go using the command :GoDebugStart

What did you expect to happen?

The server starts with the debugger attached, so if I add a breakpoint the server stops and I can trace errors, see variables, etc.

What happened instead?

The server didn't start. If I make a http request to the server's endpoint, it should give a response

Configuration (MUST fill this out):

  • vim-go version:
    66d06f3
  • vimrc you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):
if has('vim_starting')
  set nocompatible               " Be iMproved
endif

let vimplug_exists=expand('~/.vim/autoload/plug.vim')

let g:vim_bootstrap_langs = ""
let g:vim_bootstrap_editor = "vim"              " nvim or vim

if !filereadable(vimplug_exists)
  if !executable("curl")
    echoerr "You have to install curl or first install vim-plug yourself!"
    execute "q!"
  endif
  echo "Installing Vim-Plug..."
  echo ""
  silent !\curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  let g:not_finish_vimplug = "yes"

  autocmd VimEnter * PlugInstall
endif

" Required:
call plug#begin(expand('~/.vim/plugged'))

" go
Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'}

call plug#end()


" Basic setup
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
set bomb
set binary
set ttyfast

syntax on
set ruler
set number


" Fix backspace indent
set backspace=indent,eol,start

" session management
nnoremap <leader>so :OpenSession<Space>
nnoremap <leader>ss :SaveSession<Space>
nnoremap <leader>sd :DeleteSession<CR>
nnoremap <leader>sc :CloseSession<CR>

let g:session_directory = "~/.vim/session"
let g:session_autoload = "no"
let g:session_autosave = "no"
let g:session_command_aliases = 1

" Remove trailing whitespaces when saving file
autocmd BufWritePre * %s/\s\+$//e

autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 softtabstop=4
  • Vim version (first three lines from :version):
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 10 2018 21:31:58)
Included patches: 1-1453
Modified by [email protected]
  • Go version (go version):
go version go1.11.4 linux/amd64
  • Go environment (go env):
    GOARCH="amd64" GOBIN="" GOCACHE="/home/jecepeda/.cache/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/jecepeda/go" GOPROXY="" GORACE="" GOROOT="/usr/local/go" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build359144130=/tmp/go-build -gno-record-gcc-switches"
debugger

All 8 comments

Can you debug your server using dlv manually?

What happens when you :GoDebugStart?

I can debug manually the program with delve, and set breakpoints. However, when I run the application in the command line I need to type continue so the server can run.

This is what is shown when I call :GoDebugStart

Screenshot at 2019-03-18 11-38-15

There seems to be a bug currently, but in my testing, running :GoDebugContinue allowed me to workaround it and continue debugging as expected.

From reading https://github.com/go-delve/delve/blob/master/Documentation/cli/getting_started.md#debugging-main-packages, I think it's working as expected. The one improvement we could make is to send the continue command automatically if there are any breakpoints already set.

I've just checked :GoDebugContinue and it works perfectly. If this is the normal behaviour with delve, I wouldn't consider this as a bug.

Yeah, sending the continue command if a breakpoint is set is actually a good idea.

Thank you!

I've been taking a closer look at the debugger code in preparation for merging some PRs for it, and I've realized that the behavior you reported actually is a bug, because the code _already_ tries to send continue when the application starts.

I'll resolve this as soon as I can.

edit: I jumped the gun. I know now where to make this change, but the current code doesn't try to do it.

In keeping with dlv's usual workflow, I don't think vim-go should automatically run :GoDebugContinue, but I'm going to give it some more thought before closing this issue.

Perfect @bhcleek !! Either approach is fine to me. Thank you for the efforts of looking at this issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jongillham picture jongillham  路  3Comments

SirmaXX picture SirmaXX  路  3Comments

MattFlower picture MattFlower  路  4Comments

joeblubaugh picture joeblubaugh  路  3Comments

orlangure picture orlangure  路  3Comments