aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Nieuwenhuizen2014-08-13 21:15:28 +0200
committerJan Nieuwenhuizen2014-08-13 21:15:28 +0200
commit01fe01d59e38636d3950406afed33909e9df55d6 (patch)
tree81c74f9ded5f39ee609482cebf0816dd4450ff00
parent995be0785eb3e6a2e12b3dc2a39f1b192649bc80 (diff)
downloademacs-01fe01d59e38636d3950406afed33909e9df55d6.tar.gz
emacs-01fe01d59e38636d3950406afed33909e9df55d6.zip
Initial Guile REPL (guiler) debugger support for GUD.
* progmodes/gud.el (guiler): New function. Starts the Guile REPL; add Guile debugger support for GUD.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/progmodes/gud.el89
2 files changed, 89 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 41dbe0e91b9..e038ff90cef 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12014-08-13 Jan Nieuwenhuizen <janneke@gnu.org>
2
3 * progmodes/gud.el (guiler): New function. Starts the Guile REPL;
4 add Guile debugger support for GUD.
5
12014-08-13 Stefan Monnier <monnier@iro.umontreal.ca> 62014-08-13 Stefan Monnier <monnier@iro.umontreal.ca>
2 7
3 * obsolete/mouse-sel.el (mouse-sel-mode): Use add/remove-function. 8 * obsolete/mouse-sel.el (mouse-sel-mode): Use add/remove-function.
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index c6fc944bc13..09085f71d62 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -34,7 +34,8 @@
34;; and added a menu. Brian D. Carlstrom <bdc@ai.mit.edu> combined the IRIX 34;; and added a menu. Brian D. Carlstrom <bdc@ai.mit.edu> combined the IRIX
35;; kluge with the gud-xdb-directories hack producing gud-dbx-directories. 35;; kluge with the gud-xdb-directories hack producing gud-dbx-directories.
36;; Derek L. Davies <ddavies@world.std.com> added support for jdb (Java 36;; Derek L. Davies <ddavies@world.std.com> added support for jdb (Java
37;; debugger.) 37;; debugger.) Jan Nieuwenhuizen added support for the Guile REPL (Guile
38;; debugger).
38 39
39;;; Code: 40;;; Code:
40 41
@@ -140,7 +141,7 @@ Used to gray out relevant toolbar icons.")
140 (display-graphic-p) 141 (display-graphic-p)
141 (fboundp 'x-show-tip)) 142 (fboundp 'x-show-tip))
142 :visible (memq gud-minor-mode 143 :visible (memq gud-minor-mode
143 '(gdbmi dbx sdb xdb pdb)) 144 '(gdbmi guiler dbx sdb xdb pdb))
144 :button (:toggle . gud-tooltip-mode)) 145 :button (:toggle . gud-tooltip-mode))
145 ([refresh] "Refresh" . gud-refresh) 146 ([refresh] "Refresh" . gud-refresh)
146 ([run] menu-item "Run" gud-run 147 ([run] menu-item "Run" gud-run
@@ -170,11 +171,11 @@ Used to gray out relevant toolbar icons.")
170 ([up] menu-item "Up Stack" gud-up 171 ([up] menu-item "Up Stack" gud-up
171 :enable (not gud-running) 172 :enable (not gud-running)
172 :visible (memq gud-minor-mode 173 :visible (memq gud-minor-mode
173 '(gdbmi gdb dbx xdb jdb pdb))) 174 '(gdbmi gdb guiler dbx xdb jdb pdb)))
174 ([down] menu-item "Down Stack" gud-down 175 ([down] menu-item "Down Stack" gud-down
175 :enable (not gud-running) 176 :enable (not gud-running)
176 :visible (memq gud-minor-mode 177 :visible (memq gud-minor-mode
177 '(gdbmi gdb dbx xdb jdb pdb))) 178 '(gdbmi gdb guiler dbx xdb jdb pdb)))
178 ([pp] menu-item "Print S-expression" gud-pp 179 ([pp] menu-item "Print S-expression" gud-pp
179 :enable (and (not gud-running) 180 :enable (and (not gud-running)
180 (bound-and-true-p gdb-active-process)) 181 (bound-and-true-p gdb-active-process))
@@ -195,7 +196,7 @@ Used to gray out relevant toolbar icons.")
195 ([finish] menu-item "Finish Function" gud-finish 196 ([finish] menu-item "Finish Function" gud-finish
196 :enable (not gud-running) 197 :enable (not gud-running)
197 :visible (memq gud-minor-mode 198 :visible (memq gud-minor-mode
198 '(gdbmi gdb xdb jdb pdb))) 199 '(gdbmi gdb guiler xdb jdb pdb)))
199 ([stepi] menu-item "Step Instruction" gud-stepi 200 ([stepi] menu-item "Step Instruction" gud-stepi
200 :enable (not gud-running) 201 :enable (not gud-running)
201 :visible (memq gud-minor-mode '(gdbmi gdb dbx))) 202 :visible (memq gud-minor-mode '(gdbmi gdb dbx)))
@@ -1704,6 +1705,83 @@ and source-file directory for your debugger."
1704 (run-hooks 'pdb-mode-hook)) 1705 (run-hooks 'pdb-mode-hook))
1705 1706
1706;; ====================================================================== 1707;; ======================================================================
1708;; Guile REPL (guiler) functions
1709
1710;; History of argument lists passed to guiler.
1711(defvar gud-guiler-history nil)
1712
1713(defvar gud-guiler-lastfile nil)
1714
1715(defun gud-guiler-marker-filter (string)
1716 (setq gud-marker-acc (if gud-marker-acc (concat gud-marker-acc string) string))
1717
1718 (let ((start 0))
1719 (while
1720 (cond
1721 ((string-match "^In \\(.*\\):" gud-marker-acc start)
1722 (setq gud-guiler-lastfile (match-string 1 gud-marker-acc)))
1723 ((string-match "^\\([^:\n]+\\):\\([0-9]+\\):\\([0-9]+\\):[^\n]*"
1724 gud-marker-acc start)
1725 (setq gud-guiler-lastfile (match-string 1 gud-marker-acc))
1726 (setq gud-last-frame
1727 (cons gud-guiler-lastfile
1728 (string-to-number (match-string 2 gud-marker-acc)))))
1729 ((string-match "^[ ]*\\([0-9]+\\):\\([0-9]+\\) [^\n]*"
1730 gud-marker-acc start)
1731 (if gud-guiler-lastfile
1732 (setq gud-last-frame
1733 (cons gud-guiler-lastfile
1734 (string-to-number (match-string 1 gud-marker-acc))))))
1735 ((string-match comint-prompt-regexp gud-marker-acc start) t)
1736 ((string= (substring gud-marker-acc start) "") nil)
1737 (t nil))
1738 (setq start (match-end 0)))
1739
1740 ;; Search for the last incomplete line in this chunk
1741 (while (string-match "\n" gud-marker-acc start)
1742 (setq start (match-end 0)))
1743
1744 ;; If we have an incomplete line, store it in gud-marker-acc.
1745 (setq gud-marker-acc (substring gud-marker-acc (or start 0))))
1746 string)
1747
1748
1749(defcustom gud-guiler-command-name "guile"
1750 "File name for executing the Guile debugger.
1751This should be an executable on your path, or an absolute file name."
1752 :type 'string
1753 :group 'gud)
1754
1755;;;###autoload
1756(defun guiler (command-line)
1757 "Run guiler on program FILE in buffer `*gud-FILE*'.
1758The directory containing FILE becomes the initial working directory
1759and source-file directory for your debugger."
1760 (interactive
1761 (list (gud-query-cmdline 'guiler)))
1762
1763 (gud-common-init command-line nil 'gud-guiler-marker-filter)
1764 (setq-local gud-minor-mode 'guiler)
1765
1766;; FIXME: absolute file-names are not grokked yet by Guile's ,break-at-source
1767;; and relative file names only when relative to %load-path.
1768;; (gud-def gud-break ",break-at-source %d%f %l" "\C-b" "Set breakpoint at current line.")
1769 (gud-def gud-break ",break-at-source %f %l" "\C-b" "Set breakpoint at current line.")
1770;; FIXME: remove breakpoint with file-line not yet supported by Guile
1771;; (gud-def gud-remove ",delete ---> %d%f:%l" "\C-d" "Remove breakpoint at current line")
1772 (gud-def gud-step ",step" "\C-s" "Step one source line with display.")
1773 (gud-def gud-next ",next" "\C-n" "Step one line (skip functions).")
1774;; (gud-def gud-cont "continue" "\C-r" "Continue with display.")
1775 (gud-def gud-finish ",finish" "\C-f" "Finish executing current function.")
1776 (gud-def gud-up ",up" "<" "Up one stack frame.")
1777 (gud-def gud-down ",down" ">" "Down one stack frame.")
1778 (gud-def gud-print "%e" "\C-p" "Evaluate Guile expression at point.")
1779
1780 (setq comint-prompt-regexp "^scheme@([^>]+> ")
1781 (setq paragraph-start comint-prompt-regexp)
1782 (run-hooks 'guiler-mode-hook))
1783
1784;; ======================================================================
1707;; 1785;;
1708;; JDB support. 1786;; JDB support.
1709;; 1787;;
@@ -3450,6 +3528,7 @@ With arg, dereference expr if ARG is positive, otherwise do not dereference."
3450 "Return a suitable command to print the expression EXPR." 3528 "Return a suitable command to print the expression EXPR."
3451 (pcase gud-minor-mode 3529 (pcase gud-minor-mode
3452 (`gdbmi (concat "-data-evaluate-expression \"" expr "\"")) 3530 (`gdbmi (concat "-data-evaluate-expression \"" expr "\""))
3531 (`guiler expr)
3453 (`dbx (concat "print " expr)) 3532 (`dbx (concat "print " expr))
3454 ((or `xdb `pdb) (concat "p " expr)) 3533 ((or `xdb `pdb) (concat "p " expr))
3455 (`sdb (concat expr "/")))) 3534 (`sdb (concat expr "/"))))