* issue with gdb-mi.el and Guile
@ 2017-06-02 1:37 David Boles
2017-06-03 8:04 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: David Boles @ 2017-06-02 1:37 UTC (permalink / raw)
To: emacs-devel
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,
- db
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 1af520d..438fb75 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1778,6 +1778,9 @@ static char *magick[] = {
As long as GDB is in the recursive reading loop, it does not expect
commands to be prefixed by \"-interpreter-exec console\".")
+(defvar gdb-guile-command-non-empty-regexp "^[[:blank:]]*\\(guile\\)\\([[:blank:]]+[[:graph:]].*\\)$"
+ "Regexp matching a non-empty GDB guile command.")
+
(defun gdb-strip-string-backslash (string)
(replace-regexp-in-string "\\\\$" "" string))
@@ -1831,7 +1834,8 @@ commands to be prefixed by \"-interpreter-exec console\".")
(> gdb-control-level 0))
(setq gdb-control-level (1- gdb-control-level)))
(setq gdb-continuation nil)))
- (if (string-match gdb-control-commands-regexp string)
+ (if (and (string-match gdb-control-commands-regexp string)
+ (not (string-match gdb-guile-command-non-empty-regexp string)))
(setq gdb-control-level (1+ gdb-control-level))))
(defun gdb-mi-quote (string)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: issue with gdb-mi.el and Guile
2017-06-02 1:37 issue with gdb-mi.el and Guile David Boles
@ 2017-06-03 8:04 ` Eli Zaretskii
[not found] ` <512B3559-B3DD-46DE-9E8C-2D0A90260A4D@ieee.org>
0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2017-06-03 8:04 UTC (permalink / raw)
To: David Boles; +Cc: emacs-devel
> From: David Boles <boles@ieee.org>
> 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)
\f
+(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.
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-06-10 8:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-02 1:37 issue with gdb-mi.el and Guile David Boles
2017-06-03 8:04 ` Eli Zaretskii
[not found] ` <512B3559-B3DD-46DE-9E8C-2D0A90260A4D@ieee.org>
2017-06-04 14:20 ` Eli Zaretskii
2017-06-10 8:31 ` Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.