From: "Mattias Engdegård" <mattias.engdegard@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 66363@debbugs.gnu.org
Subject: bug#66363: gdb-control-commands-regexp issues
Date: Fri, 6 Oct 2023 14:09:01 +0200 [thread overview]
Message-ID: <B1D65711-E90B-424C-B052-1C81142A1A7F@gmail.com> (raw)
In-Reply-To: <83il7k3nru.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 968 bytes --]
5 okt. 2023 kl. 20.52 skrev Eli Zaretskii <eliz@gnu.org>:
> I'm okay with the changes in principle, but someone will have
> to test them by running all of the control commands and verifying they
> work after the fix, before this can be installed. I myself won't have
> the time for doing that any time soon, sorry.
That's fine, I can wait. The bug only affects GDB users so I'm not personally inconvenienced.
Here's an improved version of the patch that also fixes another bug in the original code: the extra match against gdb-python-guile-commands-regexp is both incorrect (not anchored) and superfluous as that information is available in the match just made.
For instance, consider what happens if the command string is "stepping ...". It will match gdb-control-command-regexp and also gdb-python-guile-commands-regexp and set python-or-guile-p, despite not being a Python or Guile command, and prevent gdb-control-level from being incremented.
[-- Attachment #2: gdb-control-commands-regexp-2.diff --]
[-- Type: application/octet-stream, Size: 2744 bytes --]
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index bc0070d2630..3afdc59a67e 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1960,19 +1960,23 @@ 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
- "^\\("
- "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
+ (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")
+ (group ; group 1: Python and Guile commands
+ (or "python" "python-interactive" "pi" "guile" "guile-repl" "gr")))
+ (? (+ blank)
+ (group ; group 2: 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\".")
@@ -2032,15 +2036,13 @@ gdb-send
(setq gdb-continuation nil)))
;; 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)))
- (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)))))
+ (when (string-match gdb-control-commands-regexp string)
+ (let ((python-or-guile-p (match-beginning 1))
+ (command-arg (match-string 2 string)))
+ (when (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.
next prev parent reply other threads:[~2023-10-06 12:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2023-10-29 16:34 ` Mattias Engdegård
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B1D65711-E90B-424C-B052-1C81142A1A7F@gmail.com \
--to=mattias.engdegard@gmail.com \
--cc=66363@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).