diff options
Diffstat (limited to 'lisp/progmodes/gud.el')
-rw-r--r-- | lisp/progmodes/gud.el | 97 |
1 files changed, 87 insertions, 10 deletions
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 98912ca5acb..a12bdd99f23 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -34,7 +34,8 @@ ;; and added a menu. Brian D. Carlstrom <bdc@ai.mit.edu> combined the IRIX ;; kluge with the gud-xdb-directories hack producing gud-dbx-directories. ;; Derek L. Davies <ddavies@world.std.com> added support for jdb (Java -;; debugger.) +;; debugger.) Jan Nieuwenhuizen added support for the Guile REPL (Guile +;; debugger). ;;; Code: @@ -140,7 +141,7 @@ Used to gray out relevant toolbar icons.") (display-graphic-p) (fboundp 'x-show-tip)) :visible (memq gud-minor-mode - '(gdbmi dbx sdb xdb pdb)) + '(gdbmi guiler dbx sdb xdb pdb)) :button (:toggle . gud-tooltip-mode)) ([refresh] "Refresh" . gud-refresh) ([run] menu-item "Run" gud-run @@ -170,11 +171,11 @@ Used to gray out relevant toolbar icons.") ([up] menu-item "Up Stack" gud-up :enable (not gud-running) :visible (memq gud-minor-mode - '(gdbmi gdb dbx xdb jdb pdb))) + '(gdbmi gdb guiler dbx xdb jdb pdb))) ([down] menu-item "Down Stack" gud-down :enable (not gud-running) :visible (memq gud-minor-mode - '(gdbmi gdb dbx xdb jdb pdb))) + '(gdbmi gdb guiler dbx xdb jdb pdb))) ([pp] menu-item "Print S-expression" gud-pp :enable (and (not gud-running) (bound-and-true-p gdb-active-process)) @@ -195,7 +196,7 @@ Used to gray out relevant toolbar icons.") ([finish] menu-item "Finish Function" gud-finish :enable (not gud-running) :visible (memq gud-minor-mode - '(gdbmi gdb xdb jdb pdb))) + '(gdbmi gdb guiler xdb jdb pdb))) ([stepi] menu-item "Step Instruction" gud-stepi :enable (not gud-running) :visible (memq gud-minor-mode '(gdbmi gdb dbx))) @@ -255,9 +256,8 @@ Used to gray out relevant toolbar icons.") ([menu-bar file] . undefined)))) "Map used in visited files.") -(let ((m (assq 'gud-minor-mode minor-mode-map-alist))) - (if m (setcdr m gud-minor-mode-map) - (push (cons 'gud-minor-mode gud-minor-mode-map) minor-mode-map-alist))) +(setf (alist-get 'gud-minor-mode minor-mode-map-alist) + gud-minor-mode-map) (defvar gud-mode-map ;; Will inherit from comint-mode via define-derived-mode. @@ -803,8 +803,7 @@ directory and source-file directory for your debugger." "Completion table for GDB commands. COMMAND is the prefix for which we seek completion. CONTEXT is the text before COMMAND on the line." - (let* ((start (- (point) (field-beginning))) - (complete-list + (let* ((complete-list (gud-gdb-run-command-fetch-lines (concat "complete " context command) (current-buffer) ;; From string-match above. @@ -1699,6 +1698,83 @@ and source-file directory for your debugger." (run-hooks 'pdb-mode-hook)) ;; ====================================================================== +;; Guile REPL (guiler) functions + +;; History of argument lists passed to guiler. +(defvar gud-guiler-history nil) + +(defvar gud-guiler-lastfile nil) + +(defun gud-guiler-marker-filter (string) + (setq gud-marker-acc (if gud-marker-acc (concat gud-marker-acc string) string)) + + (let ((start 0)) + (while + (cond + ((string-match "^In \\(.*\\):" gud-marker-acc start) + (setq gud-guiler-lastfile (match-string 1 gud-marker-acc))) + ((string-match "^\\([^:\n]+\\):\\([0-9]+\\):\\([0-9]+\\):[^\n]*" + gud-marker-acc start) + (setq gud-guiler-lastfile (match-string 1 gud-marker-acc)) + (setq gud-last-frame + (cons gud-guiler-lastfile + (string-to-number (match-string 2 gud-marker-acc))))) + ((string-match "^[ ]*\\([0-9]+\\):\\([0-9]+\\) [^\n]*" + gud-marker-acc start) + (if gud-guiler-lastfile + (setq gud-last-frame + (cons gud-guiler-lastfile + (string-to-number (match-string 1 gud-marker-acc)))))) + ((string-match comint-prompt-regexp gud-marker-acc start) t) + ((string= (substring gud-marker-acc start) "") nil) + (t nil)) + (setq start (match-end 0))) + + ;; Search for the last incomplete line in this chunk + (while (string-match "\n" gud-marker-acc start) + (setq start (match-end 0))) + + ;; If we have an incomplete line, store it in gud-marker-acc. + (setq gud-marker-acc (substring gud-marker-acc (or start 0)))) + string) + + +(defcustom gud-guiler-command-name "guile" + "File name for executing the Guile debugger. +This should be an executable on your path, or an absolute file name." + :type 'string + :group 'gud) + +;;;###autoload +(defun guiler (command-line) + "Run guiler on program FILE in buffer `*gud-FILE*'. +The directory containing FILE becomes the initial working directory +and source-file directory for your debugger." + (interactive + (list (gud-query-cmdline 'guiler))) + + (gud-common-init command-line nil 'gud-guiler-marker-filter) + (setq-local gud-minor-mode 'guiler) + +;; FIXME: absolute file-names are not grokked yet by Guile's ,break-at-source +;; and relative file names only when relative to %load-path. +;; (gud-def gud-break ",break-at-source %d%f %l" "\C-b" "Set breakpoint at current line.") + (gud-def gud-break ",break-at-source %f %l" "\C-b" "Set breakpoint at current line.") +;; FIXME: remove breakpoint with file-line not yet supported by Guile +;; (gud-def gud-remove ",delete ---> %d%f:%l" "\C-d" "Remove breakpoint at current line") + (gud-def gud-step ",step" "\C-s" "Step one source line with display.") + (gud-def gud-next ",next" "\C-n" "Step one line (skip functions).") +;; (gud-def gud-cont "continue" "\C-r" "Continue with display.") + (gud-def gud-finish ",finish" "\C-f" "Finish executing current function.") + (gud-def gud-up ",up" "<" "Up one stack frame.") + (gud-def gud-down ",down" ">" "Down one stack frame.") + (gud-def gud-print "%e" "\C-p" "Evaluate Guile expression at point.") + + (setq comint-prompt-regexp "^scheme@([^>]+> ") + (setq paragraph-start comint-prompt-regexp) + (run-hooks 'guiler-mode-hook)) + +;; ====================================================================== ;; ;; JDB support. ;; @@ -3445,6 +3521,7 @@ With arg, dereference expr if ARG is positive, otherwise do not dereference." "Return a suitable command to print the expression EXPR." (pcase gud-minor-mode (`gdbmi (concat "-data-evaluate-expression \"" expr "\"")) + (`guiler expr) (`dbx (concat "print " expr)) ((or `xdb `pdb) (concat "p " expr)) (`sdb (concat expr "/")))) |