]> granicus.if.org Git - vim/commitdiff
patch 8.0.1599: no error message when gdb does not support debugger v8.0.1599
authorBram Moolenaar <Bram@vim.org>
Sun, 11 Mar 2018 19:51:52 +0000 (20:51 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 11 Mar 2018 19:51:52 +0000 (20:51 +0100)
Problem:    No error message when gdb does not support the terminal debugger.
Solution:   Check for the response to open the Machine Interface.

runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
src/version.c

index add0de981714242b7ede9149243a62439c6a1720..65765bb31bbf324294eeba615686dee1d03efc84 100644 (file)
@@ -105,9 +105,39 @@ func s:StartDebug(cmd)
   let s:gdbwin = win_getid(winnr())
 
   " 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")
 
+  " 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
   " exec-interrupt, since many commands don't work properly while the target is
   " running.
index 4c192717fc2a097cb7d8edca59a956ef6a650aea..eabf6fb3105af0c802abc50f7c91a1e97967ce0a 100644 (file)
@@ -766,6 +766,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1599,
 /**/
     1598,
 /**/