Skip to content

Commit 3e4b84d

Browse files
committed
patch 8.0.1599: no error message when gdb does not support debugger
Problem: No error message when gdb does not support the terminal debugger. Solution: Check for the response to open the Machine Interface.
1 parent c48369c commit 3e4b84d

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

runtime/pack/dist/opt/termdebug/plugin/termdebug.vim

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,39 @@ func s:StartDebug(cmd)
105105
let s:gdbwin = win_getid(winnr())
106106

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

110+
" Wait for the response to show up, users may not notice the error and wonder
111+
" why the debugger doesn't work.
112+
let try_count = 0
113+
while 1
114+
let response = ''
115+
for lnum in range(1,20)
116+
if term_getline(s:gdbbuf, lnum) =~ 'new-ui mi '
117+
let response = term_getline(s:gdbbuf, lnum + 1)
118+
if response =~ 'Undefined command'
119+
echoerr 'Your gdb does not support the Machine Interface feature'
120+
exe 'bwipe! ' . s:ptybuf
121+
exe 'bwipe! ' . s:commbuf
122+
return
123+
endif
124+
if response =~ 'New UI allocated'
125+
" Success!
126+
break
127+
endif
128+
endif
129+
endfor
130+
if response =~ 'New UI allocated'
131+
break
132+
endif
133+
let try_count += 1
134+
if try_count > 100
135+
echoerr 'Cannot check if your gdb works, continuing anyway'
136+
break
137+
endif
138+
sleep 10m
139+
endwhile
140+
111141
" Interpret commands while the target is running. This should usualy only be
112142
" exec-interrupt, since many commands don't work properly while the target is
113143
" running.

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ static char *(features[]) =
766766

767767
static int included_patches[] =
768768
{ /* Add new patch number below this line */
769+
/**/
770+
1599,
769771
/**/
770772
1598,
771773
/**/

0 commit comments

Comments
 (0)