Changeset 4190
- Timestamp:
- 10/04/03 10:53:35 (19 years ago)
- Location:
- trunk/j/src/org/armedbear/lisp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/lisp/debug.lisp
r4157 r4190 2 2 ;;; 3 3 ;;; Copyright (C) 2003 Peter Graves 4 ;;; $Id: debug.lisp,v 1. 4 2003-10-01 13:59:23piso Exp $4 ;;; $Id: debug.lisp,v 1.5 2003-10-04 10:53:35 piso Exp $ 5 5 ;;; 6 6 ;;; This program is free software; you can redistribute it and/or … … 20 20 (in-package "SYSTEM") 21 21 22 (defun debug-prompt (stream) 23 (format stream "~%> ")) 22 (defun debug-loop () 23 (let ((tpl::*break-level* (1+ tpl::*break-level*))) 24 (fresh-line *debug-io*) 25 (format *debug-io* "Type :CONTINUE to return from break or :RESET to return to top level.~%") 26 (loop 27 (catch 'debug-loop-catcher 28 (handler-case 29 (tpl::repl) 30 (error (c) (format t "Error: ~S.~%" c) (break) (throw 'debug-loop-catcher nil))))))) 24 31 25 32 (defun invoke-debugger (condition) … … 28 35 (*debugger-hook* nil)) 29 36 (funcall hook-function condition hook-function))) 30 (catch 'continue 31 (debugger-loop))) 32 33 (defun debugger-loop () 34 (fresh-line *debug-io*) 35 (format *debug-io* "Type :continue to continue...") 36 (loop 37 (catch 'debug-loop-catcher 38 (handler-bind ((error (lambda (condition) 39 (format *debug-io* "~%Error: ~S.~%" condition) 40 (throw 'debug-loop-catcher nil)))) 41 (debug-prompt *debug-io*) 42 (finish-output *debug-io*) 43 (let* ((exp (read *debug-io*))) 44 (when (memq exp '(:co :continue)) 45 (return-from debugger-loop)) 46 (let* ((values (multiple-value-list (eval exp))) 47 (*standard-output* *debug-io*)) 48 (fresh-line) 49 (if values (prin1 (car values))) 50 (dolist (x (cdr values)) 51 (fresh-line) 52 (prin1 x)))))))) 37 (catch 'tpl::continue-catcher 38 (debug-loop))) 53 39 54 40 (defun break (&optional format-control &rest format-arguments) 55 41 (fresh-line *debug-io*) 56 (format *debug-io* " break called~%")42 (format *debug-io* "BREAK called.~%") 57 43 (invoke-debugger nil)) -
trunk/j/src/org/armedbear/lisp/top-level.lisp
r4079 r4190 2 2 ;;; 3 3 ;;; Copyright (C) 2003 Peter Graves 4 ;;; $Id: top-level.lisp,v 1. 2 2003-09-26 19:19:14piso Exp $4 ;;; $Id: top-level.lisp,v 1.3 2003-10-04 10:53:26 piso Exp $ 5 5 ;;; 6 6 ;;; This program is free software; you can redistribute it and/or … … 22 22 (in-package "EXTENSIONS") 23 23 24 (export '(*saved-backtrace* bt))24 (export '(*saved-backtrace*)) 25 25 26 26 (defvar *saved-backtrace* nil) 27 27 28 (defun bt (&optional count)29 (let ((count (if (fixnump count) count 7))30 (n 0))31 (dolist (frame *saved-backtrace*)32 (format t " ~D: ~A~%" n frame)33 (incf n)34 (when (>= n count)35 (return))))36 (values))37 38 28 (in-package "TOP-LEVEL") 29 30 (defvar *break-level* 0) 39 31 40 32 (defparameter *command-char* #\:) … … 51 43 (defun repl-prompt-fun (stream) 52 44 (fresh-line stream) 45 (when (> *break-level* 0) 46 (format stream "[~D] " *break-level*)) 53 47 (write-string (prompt-package-name) stream) 54 48 (write-string "(" stream) … … 83 77 (push (subseq string 0 end) res))) 84 78 79 (defun backtrace-command (&optional count) 80 (let ((count (if (fixnump count) count 7)) 81 (n 0)) 82 (dolist (frame *saved-backtrace*) 83 (format t " ~D: ~A~%" n frame) 84 (incf n) 85 (when (>= n count) 86 (return)))) 87 (values)) 88 89 (defun continue-command () 90 (if (> *break-level* 0) 91 (throw 'continue-catcher nil))) 92 93 (defun reset-command () 94 (throw 'top-level-catcher nil)) 95 85 96 (defun process-cmd (form) 86 97 (when (and (stringp form) (> (length form) 1) (eql (char form 0) *command-char*)) … … 92 103 (when (zerop (length args)) 93 104 (setf args nil))) 94 (cond ((string =cmd "ld")105 (cond ((string-equal cmd "ld") 95 106 (let ((files (if args (tokenize args) *last-files-loaded*))) 96 107 (setf *last-files-loaded* files) … … 98 109 (load file))) 99 110 ) 100 ((string =cmd "de")111 ((string-equal cmd "de") 101 112 (let ((obj (eval (read-from-string args)))) 102 113 (describe obj))) 103 ((string =cmd "ap")114 ((string-equal cmd "ap") 104 115 (apropos args)) 105 ((string =cmd "pwd")116 ((string-equal cmd "pwd") 106 117 (format t "~A~%" *default-pathname-defaults*)) 107 ((string =cmd "cd")118 ((string-equal cmd "cd") 108 119 (cond ((or (null args) (string= args "~")) 109 120 (setf args (namestring (user-homedir-pathname)))) … … 118 129 (format *standard-output* "~A" (namestring *default-pathname-defaults*))) 119 130 (format *standard-output* "Error: no such directory (~S).~%" args)))) 120 ((string =cmd "bt")121 (let ((count (or (and args (ignore-errors (parse-integer args))) 7)))122 (b tcount)))123 ((string =cmd "pa")131 ((string-equal cmd "bt") 132 (let ((count (or (and args (ignore-errors (parse-integer args))) most-positive-fixnum))) 133 (backtrace-command count))) 134 ((string-equal cmd "pa") 124 135 (cond ((null args) 125 136 (format *standard-output* "The ~A package is current.~%" … … 133 144 (setf *package* pkg) 134 145 (format *standard-output* "Unknown package ~A.~%" args)))))) 135 ((string= cmd "ex") 146 ((or (string-equal cmd "cont") (string-equal cmd "continue")) 147 (continue-command)) 148 ((or (string-equal cmd "res") (string-equal cmd "reset")) 149 (reset-command)) 150 ((string-equal cmd "ex") 136 151 (format t "Bye!~%") 137 152 (exit)) … … 169 184 (values-list /)) 170 185 171 (defun repl -fun()186 (defun repl () 172 187 (loop 173 188 (funcall *repl-prompt-fun* *standard-output*) … … 181 196 (prin1 result))))) 182 197 183 (defvar *in-top-level-loop* nil)184 185 198 (defun top-level-loop () 186 (setf *in-top-level-loop* t) 187 (loop 188 (catch 'top-level 199 (loop 200 (catch 'top-level-catcher 189 201 (handler-case 190 (repl-fun) 191 (error (c) (format t "Error: ~S.~%" c) (break) (throw 'top-level nil)))))) 202 (repl) 203 (stream-error (c) (return-from top-level-loop)) 204 (error (c) (format t "Error: ~S.~%" c) (break) (throw 'top-level-catcher nil))))))
Note: See TracChangeset
for help on using the changeset viewer.