all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#66363: gdb-control-commands-regexp issues
@ 2023-10-05 15:07 Mattias Engdegård
  2023-10-05 16:29 ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Mattias Engdegård @ 2023-10-05 15:07 UTC (permalink / raw)
  To: 66363

[-- Attachment #1: Type: text/plain, Size: 1063 bytes --]

The variable `gdb-control-commands-regexp` in gdb-mi.el cannot work as currently defined and used. Only group 3 is of  interest, but that group hasn't referred to anything useful for several years.

Group 3 probably refers to a part of the regex's tail where the command argument is matched:

   "\\([[:blank:]]+\\([^[:blank:]]*\\)\\)*$"

However, this seems to be broken as well, because all groups here are inside repetitions. This part of the regexp is also exponential in form if not in practice but we'd better simplify it anyway.

Attached is a suggested patch which makes explicit the command abbreviations matched, and leaves only a single submatch. It also changes the tail to assuming that the command argument doesn't contain non-newlines (or the final eol anchor wouldn't make sense) but that it can contain spaces (which seems reasonable). However, right now the argument is only checked for being non-empty or not.

I don't have a working gdb setup at the moment so if someone would be kind to test it, I would be very grateful for it.


[-- Attachment #2: gdb-control-commands-regexp.diff --]
[-- Type: application/octet-stream, Size: 2185 bytes --]

diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index bc0070d2630..f7e96a2f19e 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1960,19 +1960,28 @@ breakpoint-disabled
   :group 'gdb)
 
 \f
+(rx-define gdb-python-guile-commands
+  (or "python" "python-interactive" "pi" "guile" "guile-repl" "gr"))
+
 (defvar gdb-python-guile-commands-regexp
-  "python\\|python-interactive\\|pi\\|guile\\|guile-repl\\|gr"
+  (rx gdb-python-guile-commands)
   "Regexp that matches Python and Guile commands supported by GDB.")
 
 (defvar gdb-control-commands-regexp
-  (concat
-   "^\\("
-   "comm\\(a\\(n\\(ds?\\)?\\)?\\)?\\|if\\|while"
-   "\\|def\\(i\\(ne?\\)?\\)?\\|doc\\(u\\(m\\(e\\(nt?\\)?\\)?\\)?\\)?\\|"
-   gdb-python-guile-commands-regexp
-   "\\|while-stepping\\|stepp\\(i\\(ng?\\)?\\)?\\|ws\\|actions"
-   "\\|expl\\(o\\(re?\\)?\\)?"
-   "\\)\\([[:blank:]]+\\([^[:blank:]]*\\)\\)*$")
+  (rx bol
+      (or "comm" "comma" "comman" "command" "commands"
+          "if" "while"
+          "def" "defi" "defin" "define"
+          "doc" "docu" "docum" "docume" "documen" "document"
+          "while-stepping"
+          "stepp" "steppi" "steppin" "stepping"
+          "ws" "actions"
+          "expl" "explo" "explor" "explore"
+          gdb-python-guile-commands)
+      (? (+ blank)
+         (group       ; Group 1 contains the command arguments.
+          (* nonl)))
+      eol)
   "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\".")
@@ -2033,7 +2042,7 @@ gdb-send
   ;; 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 (and control-command-p (match-string 3 string)))
+         (command-arg (and control-command-p (match-string 1 string)))
          (python-or-guile-p (string-match gdb-python-guile-commands-regexp
                                           string)))
     (if (and control-command-p

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-10-29 16:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-05 15:07 bug#66363: gdb-control-commands-regexp issues Mattias Engdegård
2023-10-05 16:29 ` Eli Zaretskii
2023-10-05 17:16   ` Mattias Engdegård
2023-10-05 17:43     ` Eli Zaretskii
2023-10-05 18:11       ` Mattias Engdegård
2023-10-05 18:52         ` Eli Zaretskii
2023-10-06 12:09           ` Mattias Engdegård
2023-10-29 16:34             ` Mattias Engdegård

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.