From 1bc33064c86a7dbeb0330f9aedaa23dfc35495bb Mon Sep 17 00:00:00 2001 From: Brian Leung Date: Tue, 20 Jul 2021 00:32:34 -0700 Subject: [PATCH 2/2] Ensure that gud commands for non-GDB debuggers are handled by repeat-mode * lisp/progmodes/gud.el (sdb-repeat-map): Define. (sdb): Set repeat-mode property to the symbol corresponding to the repeat map. (dbx-repeat-map): Define. (dbx): Set repeat-mode property to the symbol corresponding to the repeat map. (xdb-repeat-map): Define. (xdb): Set repeat-mode property to the symbol corresponding to the repeat map. (perldb-repeat-map): Define. (perldb): Set repeat-mode property to the symbol corresponding to the repeat map. (pdb-repeat-map): Define. (pdb): Set repeat-mode property to the symbol corresponding to the repeat map. (guiler-repeat-map): Define. (guiler): Set repeat-mode property to the symbol corresponding to the repeat map. (jdb-repeat-map): Define. (jdb): Set repeat-mode property to the symbol corresponding to the repeat map. --- lisp/progmodes/gud.el | 110 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 3ffae7f2e0..950ee356f4 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -1033,6 +1033,18 @@ gud-sdb-needs-tags (defvar gud-sdb-lastfile nil) +(defvar sdb-repeat-map + (let ((map (make-sparse-keymap))) + (pcase-dolist (`(,key . ,cmd) '(("n" . gud-next) + ("s" . gud-step) + ("i" . gud-stepi) + ("c" . gud-cont) + ("l" . gud-refresh))) + (define-key map key cmd)) + map) + "Keymap to repeat `sdb' stepping instructions `C-x C-a C-n n n'. +Used in `repeat-mode'.") + (defun gud-sdb-marker-filter (string) (setq gud-marker-acc (if gud-marker-acc (concat gud-marker-acc string) string)) @@ -1103,6 +1115,8 @@ sdb (gud-def gud-cont "c" "\C-r" "Continue with display.") (gud-def gud-print "%e/" "\C-p" "Evaluate C expression at point.") + (gud-set-repeat-map-property sdb-repeat-map) + (setq comint-prompt-regexp "\\(^\\|\n\\)\\*") (setq paragraph-start comint-prompt-regexp) (run-hooks 'sdb-mode-hook) @@ -1261,6 +1275,23 @@ gud-dbx-use-stopformat-p ;; whereby `set $stopformat=1' reportedly produces output compatible ;; with `gud-dbx-marker-filter', which we prefer. +(defvar dbx-repeat-map + (let ((map (make-sparse-keymap))) + (pcase-dolist (`(,key . ,cmd) '(("n" . gud-next) + ("s" . gud-step) + ("i" . gud-stepi) + ("c" . gud-cont) + ("l" . gud-refresh) + ("<" . gud-up) + (">" . gud-down))) + (define-key map key cmd)) + (when (or gud-mips-p + gud-irix-p) + (define-key map "f" 'gud-finish)) + map) + "Keymap to repeat `dbx' stepping instructions `C-x C-a C-n n n'. +Used in `repeat-mode'.") + ;; The process filter is also somewhat ;; unreliable, sometimes not spotting the markers; I don't know ;; whether there's anything that can be done about that.] @@ -1408,6 +1439,8 @@ dbx (gud-def gud-print "print %e" "\C-p" "Evaluate C expression at point.") (gud-def gud-run "run" nil "Run the program.") + (gud-set-repeat-map-property dbx-repeat-map) + (setq comint-prompt-regexp "^[^)\n]*dbx) *") (setq paragraph-start comint-prompt-regexp) (run-hooks 'dbx-mode-hook) @@ -1419,6 +1452,21 @@ dbx ;; History of argument lists passed to xdb. (defvar gud-xdb-history nil) +(defvar xdb-repeat-map + (let ((map (make-sparse-keymap))) + (pcase-dolist (`(,key . ,cmd) '(("n" . gud-next) + ("s" . gud-step) + ("i" . gud-stepi) + ("c" . gud-cont) + ("l" . gud-refresh) + ("f" . gud-finish) + ("<" . gud-up) + (">" . gud-down))) + (define-key map key cmd)) + map) + "Keymap to repeat `xdb' stepping instructions `C-x C-a C-n n n'. +Used in `repeat-mode'.") + (defcustom gud-xdb-directories nil "A list of directories that xdb should search for source code. If nil, only source files in the program directory @@ -1484,6 +1532,8 @@ xdb (gud-def gud-finish "bu\\t" "\C-f" "Finish executing current function.") (gud-def gud-print "p %e" "\C-p" "Evaluate C expression at point.") + (gud-set-repeat-map-property xdb-repeat-map) + (setq comint-prompt-regexp "^>") (setq paragraph-start comint-prompt-regexp) (run-hooks 'xdb-mode-hook)) @@ -1494,6 +1544,17 @@ xdb ;; History of argument lists passed to perldb. (defvar gud-perldb-history nil) +(defvar perldb-repeat-map + (let ((map (make-sparse-keymap))) + (pcase-dolist (`(,key . ,cmd) '(("n" . gud-next) + ("s" . gud-step) + ("c" . gud-cont) + ("l" . gud-refresh))) + (define-key map key cmd)) + map) + "Keymap to repeat `perldb' stepping instructions `C-x C-a C-n n n'. +Used in `repeat-mode'.") + (defun gud-perldb-massage-args (_file args) "Convert a command line as would be typed normally to run perldb into one that invokes an Emacs-enabled debugging session. @@ -1636,6 +1697,7 @@ perldb (gud-def gud-print "p %e" "\C-p" "Evaluate perl expression at point.") (gud-def gud-until "c %l" "\C-u" "Continue to current line.") + (gud-set-repeat-map-property perldb-repeat-map) (setq comint-prompt-regexp "^ DB<+[0-9]+>+ ") (setq paragraph-start comint-prompt-regexp) @@ -1664,6 +1726,20 @@ gud-pdb-marker-regexp-fnname-group (defvar gud-pdb-marker-regexp-start "^> ") +(defvar pdb-repeat-map + (let ((map (make-sparse-keymap))) + (pcase-dolist (`(,key . ,cmd) '(("n" . gud-next) + ("s" . gud-step) + ("c" . gud-cont) + ("l" . gud-refresh) + ("f" . gud-finish) + ("<" . gud-up) + (">" . gud-down))) + (define-key map key cmd)) + map) + "Keymap to repeat `pdb' stepping instructions `C-x C-a C-n n n'. +Used in `repeat-mode'.") + ;; There's no guarantee that Emacs will hand the filter the entire ;; marker at once; it could be broken up across several strings. We ;; might even receive a big chunk with several markers in it. If we @@ -1753,6 +1829,8 @@ pdb (gud-def gud-print "p %e" "\C-p" "Evaluate Python expression at point.") (gud-def gud-statement "!%e" "\C-e" "Execute Python statement at point.") + (gud-set-repeat-map-property pdb-repeat-map) + ;; (setq comint-prompt-regexp "^(.*pdb[+]?) *") (setq comint-prompt-regexp "^(Pdb) *") (setq paragraph-start comint-prompt-regexp) @@ -1766,6 +1844,19 @@ gud-guiler-history (defvar gud-guiler-lastfile nil) +(defvar guiler-repeat-map + (let ((map (make-sparse-keymap))) + (pcase-dolist (`(,key . ,cmd) '(("n" . gud-next) + ("s" . gud-step) + ("l" . gud-refresh) + ("f" . gud-finish) + ("<" . gud-up) + (">" . gud-down))) + (define-key map key cmd)) + map) + "Keymap to repeat `guiler' stepping instructions `C-x C-a C-n n n'. +Used in `repeat-mode'.") + (defun gud-guiler-marker-filter (string) (setq gud-marker-acc (if gud-marker-acc (concat gud-marker-acc string) string)) @@ -1831,6 +1922,8 @@ guiler (gud-def gud-down ",down" ">" "Down one stack frame.") (gud-def gud-print "%e" "\C-p" "Evaluate Guile expression at point.") + (gud-set-repeat-map-property guiler-repeat-map) + (setq comint-prompt-regexp "^scheme@([^>]+> ") (setq paragraph-start comint-prompt-regexp) (run-hooks 'guiler-mode-hook)) @@ -2276,6 +2369,21 @@ gud-jdb-find-source-file ;; Note: Reset to this value every time a prompt is seen (defvar gud-jdb-lowest-stack-level 999) +(defvar jdb-repeat-map + (let ((map (make-sparse-keymap))) + (pcase-dolist (`(,key . ,cmd) '(("n" . gud-next) + ("s" . gud-step) + ("i" . gud-stepi) + ("c" . gud-cont) + ("f" . gud-finish) + ("<" . gud-up) + (">" . gud-down) + ("l" . gud-refresh))) + (define-key map key cmd)) + map) + "Keymap to repeat `jdb' stepping instructions `C-x C-a C-n n n'. +Used in `repeat-mode'.") + (defun gud-jdb-find-source-using-classpath (p) "Find source file corresponding to fully qualified class P. Convert P from jdb's output, converted to a pathname @@ -2484,6 +2592,8 @@ jdb (gud-def gud-print "print %e" "\C-p" "Print value of expression at point.") (gud-def gud-pstar "dump %e" nil "Print all object information at point.") + (gud-set-repeat-map-property jdb-repeat-map) + (setq comint-prompt-regexp "^> \\|^[^ ]+\\[[0-9]+\\] ") (setq paragraph-start comint-prompt-regexp) (run-hooks 'jdb-mode-hook) -- 2.32.0