diff options
| author | Eli Zaretskii | 2012-04-20 13:09:40 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2012-04-20 13:09:40 +0300 |
| commit | 9ee9f4709c53bbf1240a8f4169674172dd458030 (patch) | |
| tree | 2afd45647d16b428c0e7ff3d3b3c7345d0303a7b | |
| parent | feeb6f534509ee6872478331f982d8d906649991 (diff) | |
| download | emacs-9ee9f4709c53bbf1240a8f4169674172dd458030.tar.gz emacs-9ee9f4709c53bbf1240a8f4169674172dd458030.zip | |
Fix bug #11279 with sending command blocks to GDB.
lisp/progmodes/gdb-mi.el (gdb-control-level): New variable.
(gdb): Make it buffer-local and init to zero.
(gdb-control-commands-regexp): New variable.
(gdb-send): Don't wrap in "-interpreter-exec console" if
gdb-control-level is positive. Increment gdb-control-level
whenever the command matches gdb-control-commands-regexp, and
decrement it each time the command is "end". (Bug#11279)
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/progmodes/gdb-mi.el | 30 |
2 files changed, 36 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e139a7b2bba..c5c4d2573b1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2012-04-20 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * progmodes/gdb-mi.el (gdb-control-level): New variable. | ||
| 4 | (gdb): Make it buffer-local and init to zero. | ||
| 5 | (gdb-control-commands-regexp): New variable. | ||
| 6 | (gdb-send): Don't wrap in "-interpreter-exec console" if | ||
| 7 | gdb-control-level is positive. Increment gdb-control-level | ||
| 8 | whenever the command matches gdb-control-commands-regexp, and | ||
| 9 | decrement it each time the command is "end". (Bug#11279) | ||
| 10 | |||
| 1 | 2012-04-20 Martin Rudalics <rudalics@gmx.at> | 11 | 2012-04-20 Martin Rudalics <rudalics@gmx.at> |
| 2 | 12 | ||
| 3 | * window.el (adjust-window-trailing-edge, enlarge-window) | 13 | * window.el (adjust-window-trailing-edge, enlarge-window) |
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index f2d8f1f75b7..b19c828d171 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el | |||
| @@ -603,6 +603,8 @@ NOARG must be t when this macro is used outside `gud-def'" | |||
| 603 | (set (make-local-variable 'gud-marker-filter) #'gud-gdb-marker-filter)) | 603 | (set (make-local-variable 'gud-marker-filter) #'gud-gdb-marker-filter)) |
| 604 | (funcall filter proc string)))) | 604 | (funcall filter proc string)))) |
| 605 | 605 | ||
| 606 | (defvar gdb-control-level 0) | ||
| 607 | |||
| 606 | ;;;###autoload | 608 | ;;;###autoload |
| 607 | (defun gdb (command-line) | 609 | (defun gdb (command-line) |
| 608 | "Run gdb on program FILE in buffer *gud-FILE*. | 610 | "Run gdb on program FILE in buffer *gud-FILE*. |
| @@ -677,6 +679,7 @@ detailed description of this mode. | |||
| 677 | (set-process-filter proc #'gdb--check-interpreter)) | 679 | (set-process-filter proc #'gdb--check-interpreter)) |
| 678 | 680 | ||
| 679 | (set (make-local-variable 'gud-minor-mode) 'gdbmi) | 681 | (set (make-local-variable 'gud-minor-mode) 'gdbmi) |
| 682 | (set (make-local-variable 'gdb-control-level) 0) | ||
| 680 | (setq comint-input-sender 'gdb-send) | 683 | (setq comint-input-sender 'gdb-send) |
| 681 | (when (ring-empty-p comint-input-ring) ; cf shell-mode | 684 | (when (ring-empty-p comint-input-ring) ; cf shell-mode |
| 682 | (let ((hfile (expand-file-name (or (getenv "GDBHISTFILE") | 685 | (let ((hfile (expand-file-name (or (getenv "GDBHISTFILE") |
| @@ -1700,6 +1703,16 @@ static char *magick[] = { | |||
| 1700 | :group 'gdb) | 1703 | :group 'gdb) |
| 1701 | 1704 | ||
| 1702 | 1705 | ||
| 1706 | (defvar gdb-control-commands-regexp | ||
| 1707 | (concat | ||
| 1708 | "^\\(" | ||
| 1709 | "commands\\|if\\|while\\|define\\|document\\|python\\|" | ||
| 1710 | "while-stepping\\|stepping\\|ws\\|actions" | ||
| 1711 | "\\)\\([[:blank:]]+.*\\)?$") | ||
| 1712 | "Regexp matching GDB commands that enter a recursive reading loop. | ||
| 1713 | As long as GDB is in the recursive reading loop, it does not expect | ||
| 1714 | commands to be prefixed by \"-interpreter-exec console\".") | ||
| 1715 | |||
| 1703 | (defun gdb-send (proc string) | 1716 | (defun gdb-send (proc string) |
| 1704 | "A comint send filter for gdb." | 1717 | "A comint send filter for gdb." |
| 1705 | (with-current-buffer gud-comint-buffer | 1718 | (with-current-buffer gud-comint-buffer |
| @@ -1709,11 +1722,15 @@ static char *magick[] = { | |||
| 1709 | (if (not (string= "" string)) | 1722 | (if (not (string= "" string)) |
| 1710 | (setq gdb-last-command string) | 1723 | (setq gdb-last-command string) |
| 1711 | (if gdb-last-command (setq string gdb-last-command))) | 1724 | (if gdb-last-command (setq string gdb-last-command))) |
| 1712 | (if (string-match "^-" string) | 1725 | (if (or (string-match "^-" string) |
| 1713 | ;; MI command | 1726 | (> gdb-control-level 0)) |
| 1727 | ;; Either MI command or we are feeding GDB's recursive reading loop. | ||
| 1714 | (progn | 1728 | (progn |
| 1715 | (setq gdb-first-done-or-error t) | 1729 | (setq gdb-first-done-or-error t) |
| 1716 | (process-send-string proc (concat string "\n"))) | 1730 | (process-send-string proc (concat string "\n")) |
| 1731 | (if (and (string-match "^end$" string) | ||
| 1732 | (> gdb-control-level 0)) | ||
| 1733 | (setq gdb-control-level (1- gdb-control-level)))) | ||
| 1717 | ;; CLI command | 1734 | ;; CLI command |
| 1718 | (if (string-match "\\\\$" string) | 1735 | (if (string-match "\\\\$" string) |
| 1719 | (setq gdb-continuation (concat gdb-continuation string "\n")) | 1736 | (setq gdb-continuation (concat gdb-continuation string "\n")) |
| @@ -1724,7 +1741,12 @@ static char *magick[] = { | |||
| 1724 | (if gdb-enable-debug | 1741 | (if gdb-enable-debug |
| 1725 | (push (cons 'mi-send to-send) gdb-debug-log)) | 1742 | (push (cons 'mi-send to-send) gdb-debug-log)) |
| 1726 | (process-send-string proc to-send)) | 1743 | (process-send-string proc to-send)) |
| 1727 | (setq gdb-continuation nil)))) | 1744 | (if (and (string-match "^end$" string) |
| 1745 | (> gdb-control-level 0)) | ||
| 1746 | (setq gdb-control-level (1- gdb-control-level))) | ||
| 1747 | (setq gdb-continuation nil))) | ||
| 1748 | (if (string-match gdb-control-commands-regexp string) | ||
| 1749 | (setq gdb-control-level (1+ gdb-control-level)))) | ||
| 1728 | 1750 | ||
| 1729 | (defun gdb-mi-quote (string) | 1751 | (defun gdb-mi-quote (string) |
| 1730 | "Return STRING quoted properly as an MI argument. | 1752 | "Return STRING quoted properly as an MI argument. |