Subject: Re: bug#40250: 26.3; gdb-mode incorrectly handles gdb's `explore' command
From: Eli Zaretskii <[email-masked]>
To: Vladimir Nikishkin <[email-masked]>
Cc: [email-masked]
Date: Sat, 04 Apr 2020 14:19:31 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Vladimir Nikishkin <[email-masked]>
> Date: Mon, 30 Mar 2020 22:49:28 +0800
> 
> I'm not sure it matters much. The main thing is that exploration works now.

OK, I've pushed the fix to the master branch.  the full patch appears
below, so you could use it with your version of Emacs right now.

Thanks again for help in testing the fix.

diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 7fb3687..0750683 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1850,7 +1850,8 @@ gdb-control-commands-regexp
    "\\|def\\(i\\(ne?\\)?\\)?\\|doc\\(u\\(m\\(e\\(nt?\\)?\\)?\\)?\\)?\\|"
    gdb-python-guile-commands-regexp
    "\\|while-stepping\\|stepp\\(i\\(ng?\\)?\\)?\\|ws\\|actions"
-   "\\)\\([[:blank:]]+\\([^[:blank:]]*\\)\\)?$")
+   "\\|expl\\(o\\(r\\e?\\)?\\)?"
+   "\\)\\([[:blank:]]+\\([^[:blank:]]*\\)\\)*$")
   "Regexp matching GDB commands that enter a recursive reading loop.
 As long as GDB is in the recursive reading loop, it does not expect
 commands to be prefixed by \"-interpreter-exec console\".")
@@ -2508,7 +2509,13 @@ gud-gdbmi-marker-filter
 
   gdb-filter-output)
 
-(defun gdb-gdb (_output-field))
+(defun gdb-gdb (_output-field)
+  ;; This is needed because the "explore" command is not ended by the
+  ;; likes of "end" or "quit", but instead by a RET at the approriate
+  ;; place, and we know we have exited "explore" when we get the
+  ;; "(gdb)" prompt.
+  (and (> gdb-control-level 0)
+       (setq gdb-control-level (1- gdb-control-level))))
 
 (defun gdb-shell (output-field)
   (setq gdb-filter-output