home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 4
/
FreshFish_May-June1994.bin
/
bbs
/
may94
/
util
/
edit
/
jade.lha
/
Jade
/
lisp
/
debug.jl
< prev
next >
Wrap
Lisp/Scheme
|
1994-04-16
|
3KB
|
105 lines
;;;; debug.jl -- Lisp debugger (well, single-stepper anyway)
;;; Copyright (C) 1993, 1994 John Harper <jsh@ukc.ac.uk>
;;; This file is part of Jade.
;;; Jade is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2, or (at your option)
;;; any later version.
;;; Jade is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;; You should have received a copy of the GNU General Public License
;;; along with Jade; see the file COPYING. If not, write to
;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
(provide 'debug)
(setq
debug-buffer (make-buffer "*debugger*")
debug-keymap (make-keylist))
(set-buffer-special debug-buffer t)
(add-buffer debug-buffer)
(bind-keys debug-keymap
"z" 'debug-step-into
"s" '(debug-set-result nil)
"t" 'debug-step-over
"r" 'debug-full-speed
"b" '(debug-backtrace 2)
"esc" '(debug-set-result (eval (read (prompt "Eval: "))))
"c" '(debug-continue nil)
"d" '(debug-continue t))
(with-buffer debug-buffer
(setq ctrl-c-keymap debug-keymap)
(split-line)
(insert "::Lisp Debugger::\n
ctrl-c z : step into form
ctrl-c s : skip form
ctrl-c t : step over form
ctrl-c r : run full speed
ctrl-c b : print backtrace
ctrl-c esc : set value of form
ctrl-c c : continue after error
ctrl-c d : break after error\n\n"))
(defun debug-entry (debug-obj debug-depth)
(with-buffer debug-buffer
(goto (line-start (file-end)))
(format debug-buffer "%s%S\n" (make-string (* 2 debug-depth)) debug-obj)
(goto (next-line 1 (indent-pos (prev-line))))
(catch 'debug-entry
(recursive-edit))))
(defun debug-exit (debug-val debug-depth)
(with-buffer debug-buffer
(goto (line-start (file-end)))
(format debug-buffer "%s=> %S\n" (make-string (* 2 debug-depth)) debug-val)))
(defun debug-error-entry (error-list)
(with-buffer debug-buffer
(goto (line-start (file-end)))
(format debug-buffer "*** Error: %s: %S\n" (unless (get (car error-list) 'error-message) (car error-list)) (cdr error-list))
(catch 'debug-error-entry
(recursive-edit)
nil)))
(defun debug-step-into ()
(if (boundp 'debug-obj)
(throw 'debug-entry (cons 1 debug-obj))
(beep)))
(defun debug-set-result (value)
(if (boundp 'debug-obj)
(throw 'debug-entry (cons 4 value))
(beep)))
(defun debug-step-over ()
(if (boundp 'debug-obj)
(throw 'debug-entry (cons 2 debug-obj))
(beep)))
(defun debug-full-speed ()
(if (boundp 'debug-obj)
(throw 'debug-entry (cons 3 debug-obj))
(beep)))
(defun debug-continue (&optional break-p)
(if (boundp 'error-list)
(throw 'debug-error-entry break-p)
(beep)))
;; DEPTH is the number of stack frames to discard
(defun debug-backtrace (depth)
(goto (line-start (file-end)))
(let
((old-pos (cursor-pos)))
(backtrace debug-buffer)
(delete-area old-pos (next-line (1+ depth) (dup-pos old-pos)))
(split-line)))