File tree Expand file tree Collapse file tree
runtime/pack/dist/opt/termdebug/plugin Expand file tree Collapse file tree Original file line number Diff line number Diff 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 10 m
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.
Original file line number Diff line number Diff line change @@ -766,6 +766,8 @@ static char *(features[]) =
766766
767767static int included_patches [] =
768768{ /* Add new patch number below this line */
769+ /**/
770+ 1599 ,
769771/**/
770772 1598 ,
771773/**/
You can’t perform that action at this time.
0 commit comments