emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: issue with gdb-mi.el and Guile


From: Eli Zaretskii
Subject: Re: issue with gdb-mi.el and Guile
Date: Sat, 03 Jun 2017 11:04:05 +0300

> From: David Boles <address@hidden>
> Date: Thu, 1 Jun 2017 20:37:46 -0500
> 
> When using the guile command at the gdb prompt within emacs, it is easy to 
> end up in a state in which the behavior of repeating the previous gdb command 
> when hitting return is disabled. Basically, the gdb-send function in 
> gdb-mi.el thinks that if you’ve entered “guile” at the gdb command prompt, 
> then you must be in guile mode until it sees you enter a “,q”, “,quit”, or 
> “end”.
> 
> Most of the time I use the guile control command to execute single Guile 
> expressions (otherwise, I’d enter the guile repl). The patch below modifies 
> this behavior in gdb-mi.el. I am decidedly not a “real Emacs Lisp” developer 
> so there may well be a better/cleaner way to accomplish the same task. 
> Nevertheless, this patch greatly improves the experience of using Guile 
> within gdb within Emacs. The diff below is against a fresh tree a few days 
> old.

Thanks.  Can you try the following patch, after reverting your changes
to gdb-mi.el, and see if it gives good results?

diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 1af520d..cc9205c 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1767,13 +1767,17 @@ breakpoint-disabled
   :group 'gdb)
 
 
+(defvar gdb-python-guile-commands-regexp
+  "python\\|python-interactive\\|pi\\|guile\\|guile-repl\\|gr"
+  "Regexp that matches Python and Guile commands supported by GDB.")
+
 (defvar gdb-control-commands-regexp
   (concat
    "^\\("
    "commands\\|if\\|while\\|define\\|document\\|"
-   "python\\|python-interactive\\|pi\\|guile\\|guile-repl\\|gr\\|"
-   "while-stepping\\|stepping\\|ws\\|actions"
-   "\\)\\([[:blank:]]+.*\\)?$")
+   gdb-python-guile-commands-regexp
+   "\\|while-stepping\\|stepping\\|ws\\|actions"
+   "\\)\\([[: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\".")
@@ -1831,8 +1835,17 @@ gdb-send
               (> gdb-control-level 0))
          (setq gdb-control-level (1- gdb-control-level)))
       (setq gdb-continuation nil)))
-  (if (string-match gdb-control-commands-regexp string)
-      (setq gdb-control-level (1+ gdb-control-level))))
+  ;; Python and Guile commands that have an argument don't enter the
+  ;; recursive reading loop.
+  (let* ((control-command-p (string-match gdb-control-commands-regexp string))
+         (command-arg (match-string 3 string))
+         (python-or-guile-p (string-match gdb-python-guile-commands-regexp
+                                          string)))
+    (if (and control-command-p
+             (or (not python-or-guile-p)
+                 (null command-arg)
+                 (zerop (length command-arg))))
+        (setq gdb-control-level (1+ gdb-control-level)))))
 
 (defun gdb-mi-quote (string)
   "Return STRING quoted properly as an MI argument.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]