Skip to content

Commit

Permalink
patch 8.0.1599: no error message when gdb does not support debugger
Browse files Browse the repository at this point in the history
Problem:    No error message when gdb does not support the terminal debugger.
Solution:   Check for the response to open the Machine Interface.
  • Loading branch information
brammool committed Mar 11, 2018
1 parent c48369c commit 3e4b84d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 31 additions & 1 deletion runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -105,9 +105,39 @@ func s:StartDebug(cmd)
let s:gdbwin = win_getid(winnr()) let s:gdbwin = win_getid(winnr())


" Connect gdb to the communication pty, using the GDB/MI interface " Connect gdb to the communication pty, using the GDB/MI interface
" If you get an error "undefined command" your GDB is too old.
call term_sendkeys(s:gdbbuf, 'new-ui mi ' . commpty . "\r") call term_sendkeys(s:gdbbuf, 'new-ui mi ' . commpty . "\r")


" Wait for the response to show up, users may not notice the error and wonder
" why the debugger doesn't work.
let try_count = 0
while 1
let response = ''
for lnum in range(1,20)
if term_getline(s:gdbbuf, lnum) =~ 'new-ui mi '
let response = term_getline(s:gdbbuf, lnum + 1)
if response =~ 'Undefined command'
echoerr 'Your gdb does not support the Machine Interface feature'
exe 'bwipe! ' . s:ptybuf
exe 'bwipe! ' . s:commbuf
return
endif
if response =~ 'New UI allocated'
" Success!
break
endif
endif
endfor
if response =~ 'New UI allocated'
break
endif
let try_count += 1
if try_count > 100
echoerr 'Cannot check if your gdb works, continuing anyway'
break
endif
sleep 10m
endwhile

" Interpret commands while the target is running. This should usualy only be " Interpret commands while the target is running. This should usualy only be
" exec-interrupt, since many commands don't work properly while the target is " exec-interrupt, since many commands don't work properly while the target is
" running. " running.
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -766,6 +766,8 @@ static char *(features[]) =


static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1599,
/**/ /**/
1598, 1598,
/**/ /**/
Expand Down

0 comments on commit 3e4b84d

Please sign in to comment.