Subject: Re: bug#40279: 26.3; Error: you did not specify -i=mi on GDB's command line!

From: William Xu <[email-masked]>
Date: Tue, 03 Nov 2020 19:52:41 +0100

Roland Coeurjoly <[email-masked]> writes:

> When doing M-x gdb, I enter "docker-compose -f ~/docker-services/dev/docker-compose.yml exec dev_rhel7 bash -c "gdb -i=mi"", and then
> it shows me the following message.
>
>  Current directory is /home/drcoeurjoly/docker-services/dev/
>
>  Error: you did not specify -i=mi on GDB's command line! WARNING: The MY_UID variable is not set. Defaulting to a blank string.

Is "WARNING: The MY_UID variable is not set. Defaulting to a blank
string." coming from your docker or bash? 

The check of gdb--check-interpreter looks pretty weak, as long as there
is anything that will be written to stdout before the gdb cmd itself, it
will fail with below check:

#+begin_src emacs-lisp
    (unless (memq (aref string 0) '(?^ ?~ ?@ ?& ?* ?=))
#+end_src

which will further set below filter. The filter below seems preventing
the gdb-mi to work: 

#+begin_src emacs-lisp
      (set (make-local-variable 'gud-marker-filter) #'gud-gdb-marker-filter)
#+end_src

One can easily reproduce similar error, by wrapping around gdb with
"echo hi" at the front: 

#+begin_src shell-script
#!/bin/sh

arg="$@"
echo hi
gdb -i=mi ${arg}
#+end_src

IMO, in the above cases, we should not immediately fall back to gud-gdb
filter. The user should at least get a chance (like yes-or-no-p) to
continue with gdb-mi, regardless of the sometimes-false-positive error.

-- 
William