annotate lisp/ilisp/cmulisp.lisp @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children b82b59fe008d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; -*- Mode: Lisp -*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; cmulisp.lisp --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; This file is part of ILISP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; Version: 5.7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;; Copyright (C) 1990, 1991, 1992, 1993 Chris McConnell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; 1993, 1994 Ivan Vasquez
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; 1994, 1995 Marco Antoniotti and Rick Busdiecker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; Other authors' names for which this Copyright notice also holds
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; may appear later in this file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; Send mail to 'ilisp-request@lehman.com' to be included in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; ILISP mailing list. 'ilisp@lehman.com' is the general ILISP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; mailing list were bugs and improvements are discussed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; ILISP is freely redistributable under the terms found in the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; COPYING.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; Todd Kaufmann May 1990
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Make CMU CL run better within GNU inferior-lisp (by ccm).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (in-package "ILISP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;;% CMU CL does not define defun as a macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (defun ilisp-compile (form package filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 "Compile FORM in PACKAGE recording FILENAME as the source file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (ilisp-errors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (ilisp-eval
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (format nil "(funcall (compile nil '(lambda () ~A)))" form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 package filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;;% Stream settings, when running connected to pipes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;; This fixes a problem when running piped: When CMU is running as a piped
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; process, *terminal-io* really is a terminal; ie, /dev/tty. This means an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;; error will cause lisp to stop and wait for input from /dev/tty, which it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; won't be able to grab, and you'll have to restart your lisp. But we want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; it to use the same input that the user is typing in, ie, the pipe (stdin).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;; This fixes that problem, which only occurs in the CMU cores of this year.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (defvar *Fix-pipe-streams* T
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 "Set to Nil if you want them left alone. And tell me you don't get stuck.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (when (and *Fix-pipe-streams*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (lisp::synonym-stream-p *terminal-io*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (eq (lisp::synonym-stream-symbol *terminal-io*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 'SYSTEM::*TTY*))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (setf *terminal-io* (make-two-way-stream system::*stdin* system::*stdout*))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; *query-io* and *debug-io* are synonym streams to this, so this fixes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; everything.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;;% Debugger extensions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;;%% Implementation of a :pop command for CMU CL debugger
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;; Normally, errors which occur while in the debugger are just ignored, unless
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; the user issues the "flush" command, which toggles this behavior.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (setq debug:*flush-debug-errors* nil) ;; allow multiple error levels.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;; This implementation of "POP" simply looks for the first restart that says
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;; "Return to debug level n" or "Return to top level." and executes it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (debug::def-debug-command "POP" #+:new-compiler ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; find the first "Return to ..." restart
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (if (not (boundp 'debug::*debug-restarts*))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (error "You're not in the debugger; how can you call this!?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (labels ((find-return-to (restart-list num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (let ((first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (member-if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 #'(lambda (restart)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (string= (funcall
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (conditions::restart-report-function restart)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 "Return to " :end1 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 restart-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (cond ((zerop num) (car first))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ((cdr first) (find-return-to (cdr first) (1- num)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (let* ((level (debug::read-if-available 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (first-return-to (find-return-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 debug::*debug-restarts* (1- level))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (if (null first-return-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (format *debug-io* "pop: ~d is too far" level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (debug::invoke-restart-interactively first-return-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;;%% arglist/source-file utils.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (defun get-correct-fn-object (sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 "Deduce how to get the \"right\" function object and return it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (let ((fun (or (macro-function sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (and (fboundp sym) (symbol-function sym)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (cond (fun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (when (and (= (lisp::get-type fun) #.vm:closure-header-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (not (eval:interpreted-function-p fun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (setq fun (lisp::%closure-function fun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (error "Unknown function ~a. Check package." sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (export '(arglist source-file cmulisp-trace))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;;;%% arglist - return arglist of function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (defun arglist (symbol package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (ilisp-errors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (let* ((x (ilisp-find-symbol symbol package))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (fun (get-correct-fn-object x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (cond ((eval:interpreted-function-p fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (eval:interpreted-function-arglist fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ((= (lisp::get-type fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 #.vm:funcallable-instance-header-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; generic function / method
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (pcl::generic-function-pretty-arglist fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ((compiled-function-p fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (let ((string-or-nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (#+CMU17 lisp::%function-arglist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 #-CMU17 lisp::%function-header-arglist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 fun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (if string-or-nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (read-from-string string-or-nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 "No argument info.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (t (error "Unknown type of function")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;;; source-file symbol package type --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;; New version provided by Richard Harris <rharris@chestnut.com> with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;;; suggestions by Larry Hunter <hunter@work.nlm.nih.gov>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (defun source-file (symbol package type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (declare (ignore type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (ilisp-errors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (let* ((x (ilisp-find-symbol symbol package))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (fun (get-correct-fn-object x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (when (and fun (not (eval:interpreted-function-p fun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;; The hack above is necessary because CMUCL does not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; correctly record source file information when 'loading'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;; a non compiled file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; In this case we fall back on the TAGS machinery.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;; (At least as I underestand the code).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; Marco Antoniotti 11/22/94.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (cond (#+CMU17 (pcl::generic-function-p fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 #-CMU17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (= (lisp::get-type fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 #.vm:funcallable-instance-header-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (dolist (method (pcl::generic-function-methods fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (print-simple-source-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (or #+CMU17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (pcl::method-fast-function method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (pcl::method-function method))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (t (print-simple-source-info fun)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;;; Old version. Left here for the time being.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;(defun source-file (symbol package type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ; (declare (ignore type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ; (ilisp-errors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ; (let* ((x (ilisp-find-symbol symbol package))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ; (fun (get-correct-fn-object x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ; (when fun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ; (cond ((= (lisp::get-type fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ; #.vm:funcallable-instance-header-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ; ;; A PCL method! Uh boy!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ; (dolist (method (pcl::generic-function-methods fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ; (print-simple-source-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ; (lisp::%closure-function (pcl::method-function method))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ; t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ; (t (print-simple-source-info fun)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;;; Patch suggested by Richard Harris <rharris@chestnut.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;;; FUN-DEFINED-FROM-PATHNAME takes a symbol or function object. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;;; returns a pathname for the file the function was defined in. If it was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;;; not defined in some file, then nil is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;;; FUN-DEFINED-FROM-PATHNAME is from hemlock/rompsite.lisp (cmucl17f),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;;; with added read-time conditionalization to work in older versions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;;; of cmucl. It may need a little bit more conditionalization for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;;; some older versions of cmucl.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (defun fun-defined-from-pathname (function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 "Returns the file where FUNCTION is defined in (if the file can be found).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 Takes a symbol or function and returns the pathname for the file the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 function was defined in. If it was not defined in some file, nil is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 returned."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (flet ((frob (code)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (let ((info #+CMU17 (kernel:%code-debug-info code)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 #-CMU17 (kernel:code-debug-info code)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (when info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (let ((sources (c::debug-info-source info)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (when sources
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (let ((source (car sources)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (when (eq (c::debug-source-from source) :file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (c::debug-source-name source)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (typecase function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (symbol (fun-defined-from-pathname (fdefinition function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 #+CMU17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (kernel:byte-closure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (fun-defined-from-pathname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (kernel:byte-closure-function function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 #+CMU17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (kernel:byte-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (frob (c::byte-function-component function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (frob (kernel:function-code-header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (kernel:%function-self function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ;;; print-simple-source-info --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;;; Patches suggested by Larry Hunter <hunter@work.nlm.nih.gov> and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;;; Richard Harris <rharris@chestnut.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;;; Nov 21, 1994.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (defun print-simple-source-info (fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (let ((path (fun-defined-from-pathname fun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (when (and path (probe-file path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (print (namestring (truename path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;;; Old version (semi patched). Left here for the time being.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ;(defun print-simple-source-info (fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ; (let ((info (#+CMU17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ; kernel:%code-debug-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ; #-CMU17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ; kernel:code-debug-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ; (kernel:function-code-header fun))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ; (when info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 ; (let ((sources (c::compiled-debug-info-source info)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ; (when sources
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ; (dolist (source sources)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ; (let ((name (c::debug-source-name source)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ; (when (eq (c::debug-source-from source) :file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ; ;; Patch suggested by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ; ;; hunter@work.nlm.nih.gov (Larry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ; ;; Hunter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ; ;; (print (namestring name)) ; old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ; (print (truename name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ; )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ; t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (defun cmulisp-trace (symbol package breakp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 "Trace SYMBOL in PACKAGE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (ilisp-errors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (let ((real-symbol (ilisp-find-symbol symbol package)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (setq breakp (read-from-string breakp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (when real-symbol (eval `(trace ,real-symbol :break ,breakp))))))