/[slime]/slime/swank-cmucl.lisp
ViewVC logotype

Contents of /slime/swank-cmucl.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.117 - (show annotations)
Wed Sep 15 17:33:57 2004 UTC (9 years, 7 months ago) by mbaringer
Branch: MAIN
Changes since 1.116: +14 -5 lines
(inspect-for-emacs): Insert function object's documentation when it's
available.
1 ;;; -*- indent-tabs-mode: nil; outline-regexp: ";;;;+" -*-
2 ;;;
3 ;;; License: Public Domain
4 ;;;
5 ;;;; Introduction
6 ;;;
7 ;;; This is the CMUCL implementation of the `swank-backend' package.
8
9 (in-package :swank-backend)
10
11 ;;;; "Hot fixes"
12 ;;;
13 ;;; Here are necessary bugfixes to the latest released version of
14 ;;; CMUCL (currently 18e). Any fixes placed here should also be
15 ;;; submitted to the `cmucl-imp' mailing list and confirmed as
16 ;;; good. When a new release is made that includes the fixes we should
17 ;;; promptly delete them from here. It is enough to be compatible with
18 ;;; the latest release.
19
20 (import-to-swank-mop
21 '( ;; classes
22 cl:standard-generic-function
23 pcl:standard-slot-definition
24 cl:method
25 cl:standard-class
26 ;; standard-class readers
27 pcl:class-default-initargs
28 pcl:class-direct-default-initargs
29 pcl:class-direct-slots
30 pcl:class-direct-subclasses
31 pcl:class-direct-superclasses
32 pcl:class-finalized-p
33 cl:class-name
34 pcl:class-precedence-list
35 pcl:class-prototype
36 pcl:class-slots
37 ;; generic function readers
38 pcl:generic-function-argument-precedence-order
39 pcl:generic-function-declarations
40 pcl:generic-function-lambda-list
41 pcl:generic-function-methods
42 pcl:generic-function-method-class
43 pcl:generic-function-method-combination
44 pcl:generic-function-name
45 ;; method readers
46 pcl:method-generic-function
47 pcl:method-function
48 pcl:method-lambda-list
49 pcl:method-specializers
50 pcl:method-qualifiers
51 ;; slot readers
52 pcl:slot-definition-allocation
53 pcl:slot-definition-initargs
54 pcl:slot-definition-initform
55 pcl:slot-definition-initfunction
56 pcl:slot-definition-name
57 pcl:slot-definition-type
58 pcl:slot-definition-readers
59 pcl:slot-definition-writers))
60
61 (defun swank-mop:slot-definition-documentation (slot)
62 (documentation slot t))
63
64 (in-package :lisp)
65
66 ;;; `READ-SEQUENCE' with large sequences has problems in 18e. This new
67 ;;; definition works better.
68
69 #+cmu18e
70 (progn
71 (let ((s (find-symbol (string :*enable-package-locked-errors*) :lisp)))
72 (when s
73 (setf (symbol-value s) nil)))
74
75 (defun read-into-simple-string (s stream start end)
76 (declare (type simple-string s))
77 (declare (type stream stream))
78 (declare (type index start end))
79 (unless (subtypep (stream-element-type stream) 'character)
80 (error 'type-error
81 :datum (read-char stream nil #\Null)
82 :expected-type (stream-element-type stream)
83 :format-control "Trying to read characters from a binary stream."))
84 ;; Let's go as low level as it seems reasonable.
85 (let* ((numbytes (- end start))
86 (total-bytes 0))
87 ;; read-n-bytes may return fewer bytes than requested, so we need
88 ;; to keep trying.
89 (loop while (plusp numbytes) do
90 (let ((bytes-read (system:read-n-bytes stream s start numbytes nil)))
91 (when (zerop bytes-read)
92 (return-from read-into-simple-string total-bytes))
93 (incf total-bytes bytes-read)
94 (incf start bytes-read)
95 (decf numbytes bytes-read)))
96 total-bytes))
97
98 (let ((s (find-symbol (string :*enable-package-locked-errors*) :lisp)))
99 (when s
100 (setf (symbol-value s) t)))
101
102 )
103
104 (in-package :swank-backend)
105
106
107 ;;;; TCP server
108 ;;;
109 ;;; In CMUCL we support all communication styles. By default we use
110 ;;; `:SIGIO' because it is the most responsive, but it's somewhat
111 ;;; dangerous: CMUCL is not in general "signal safe", and you don't
112 ;;; know for sure what you'll be interrupting. Both `:FD-HANDLER' and
113 ;;; `:SPAWN' are reasonable alternatives.
114
115 (defimplementation preferred-communication-style ()
116 :sigio)
117
118 (defimplementation create-socket (host port)
119 #+ppc (declare (ignore host))
120 (ext:create-inet-listener port :stream
121 :reuse-address t
122 #-ppc :host #-ppc (resolve-hostname host)))
123
124 (defimplementation local-port (socket)
125 (nth-value 1 (ext::get-socket-host-and-port (socket-fd socket))))
126
127 (defimplementation close-socket (socket)
128 (sys:invalidate-descriptor socket)
129 (ext:close-socket (socket-fd socket)))
130
131 (defimplementation accept-connection (socket)
132 (make-socket-io-stream (ext:accept-tcp-connection socket)))
133
134 ;;;;; Sockets
135
136 (defun socket-fd (socket)
137 "Return the filedescriptor for the socket represented by SOCKET."
138 (etypecase socket
139 (fixnum socket)
140 (sys:fd-stream (sys:fd-stream-fd socket))))
141
142 (defun resolve-hostname (hostname)
143 "Return the IP address of HOSTNAME as an integer."
144 (let* ((hostent (ext:lookup-host-entry hostname))
145 (address (car (ext:host-entry-addr-list hostent))))
146 (ext:htonl address)))
147
148 (defun make-socket-io-stream (fd)
149 "Create a new input/output fd-stream for FD."
150 (sys:make-fd-stream fd :input t :output t :element-type 'base-char))
151
152 ;;;;; Signal-driven I/O
153
154 (defvar *sigio-handlers* '()
155 "List of (key . function) pairs.
156 All functions are called on SIGIO, and the key is used for removing
157 specific functions.")
158
159 (defun set-sigio-handler ()
160 (sys:enable-interrupt :sigio (lambda (signal code scp)
161 (sigio-handler signal code scp))))
162
163 (defun sigio-handler (signal code scp)
164 (declare (ignore signal code scp))
165 (mapc #'funcall (mapcar #'cdr *sigio-handlers*)))
166
167 (defun fcntl (fd command arg)
168 "fcntl(2) - manipulate a file descriptor."
169 (multiple-value-bind (ok error) (unix:unix-fcntl fd command arg)
170 (unless ok (error "fcntl: ~A" (unix:get-unix-error-msg error)))))
171
172 (defimplementation add-sigio-handler (socket fn)
173 (set-sigio-handler)
174 (let ((fd (socket-fd socket)))
175 (fcntl fd unix:f-setown (unix:unix-getpid))
176 (fcntl fd unix:f-setfl unix:fasync)
177 (push (cons fd fn) *sigio-handlers*)))
178
179 (defimplementation remove-sigio-handlers (socket)
180 (let ((fd (socket-fd socket)))
181 (setf *sigio-handlers* (remove fd *sigio-handlers* :key #'car))
182 (sys:invalidate-descriptor fd))
183 (close socket))
184
185 ;;;;; SERVE-EVENT
186
187 (defimplementation add-fd-handler (socket fn)
188 (let ((fd (socket-fd socket)))
189 (sys:add-fd-handler fd :input (lambda (_)
190 _
191 (funcall fn)))))
192
193 (defimplementation remove-fd-handlers (socket)
194 (sys:invalidate-descriptor (socket-fd socket)))
195
196
197 ;;;; Stream handling
198 ;;; XXX: How come we don't use Gray streams in CMUCL too? -luke (15/May/2004)
199
200 (defimplementation make-fn-streams (input-fn output-fn)
201 (let* ((output (make-slime-output-stream output-fn))
202 (input (make-slime-input-stream input-fn output)))
203 (values input output)))
204
205 (defstruct (slime-output-stream
206 (:include lisp::lisp-stream
207 (lisp::misc #'sos/misc)
208 (lisp::out #'sos/out)
209 (lisp::sout #'sos/sout))
210 (:conc-name sos.)
211 (:print-function %print-slime-output-stream)
212 (:constructor make-slime-output-stream (output-fn)))
213 (output-fn nil :type function)
214 (buffer (make-string 512) :type string)
215 (index 0 :type kernel:index)
216 (column 0 :type kernel:index))
217
218 (defun %print-slime-output-stream (s stream d)
219 (declare (ignore d))
220 (print-unreadable-object (s stream :type t :identity t)))
221
222 (defun sos/out (stream char)
223 (let ((buffer (sos.buffer stream))
224 (index (sos.index stream)))
225 (setf (schar buffer index) char)
226 (setf (sos.index stream) (1+ index))
227 (incf (sos.column stream))
228 (when (char= #\newline char)
229 (setf (sos.column stream) 0))
230 (when (= index (1- (length buffer)))
231 (force-output stream)))
232 char)
233
234 (defun sos/sout (stream string start end)
235 (loop for i from start below end
236 do (sos/out stream (aref string i))))
237
238 (defun sos/misc (stream operation &optional arg1 arg2)
239 (declare (ignore arg1 arg2))
240 (case operation
241 ((:force-output :finish-output)
242 (let ((end (sos.index stream)))
243 (unless (zerop end)
244 (funcall (sos.output-fn stream) (subseq (sos.buffer stream) 0 end))
245 (setf (sos.index stream) 0))))
246 (:charpos (sos.column stream))
247 (:line-length 75)
248 (:file-position nil)
249 (:element-type 'base-char)
250 (:get-command nil)
251 (:close nil)
252 (t (format *terminal-io* "~&~Astream: ~S~%" stream operation))))
253
254 (defstruct (slime-input-stream
255 (:include string-stream
256 (lisp::in #'sis/in)
257 (lisp::misc #'sis/misc))
258 (:conc-name sis.)
259 (:print-function %print-slime-output-stream)
260 (:constructor make-slime-input-stream (input-fn sos)))
261 (input-fn nil :type function)
262 ;; We know our sibling output stream, so that we can force it before
263 ;; requesting input.
264 (sos nil :type slime-output-stream)
265 (buffer "" :type string)
266 (index 0 :type kernel:index))
267
268 (defun sis/in (stream eof-errorp eof-value)
269 (declare (ignore eof-errorp eof-value))
270 (let ((index (sis.index stream))
271 (buffer (sis.buffer stream)))
272 (when (= index (length buffer))
273 (force-output (sis.sos stream))
274 (setf buffer (funcall (sis.input-fn stream)))
275 (setf (sis.buffer stream) buffer)
276 (setf index 0))
277 (prog1 (aref buffer index)
278 (setf (sis.index stream) (1+ index)))))
279
280 (defun sis/misc (stream operation &optional arg1 arg2)
281 (declare (ignore arg2))
282 (ecase operation
283 (:file-position nil)
284 (:file-length nil)
285 (:unread (setf (aref (sis.buffer stream)
286 (decf (sis.index stream)))
287 arg1))
288 (:clear-input
289 (setf (sis.index stream) 0
290 (sis.buffer stream) ""))
291 (:listen (< (sis.index stream) (length (sis.buffer stream))))
292 (:charpos nil)
293 (:line-length nil)
294 (:get-command nil)
295 (:element-type 'base-char)
296 (:close nil)))
297
298
299 ;;;; Compilation Commands
300
301 (defvar *previous-compiler-condition* nil
302 "Used to detect duplicates.")
303
304 (defvar *previous-context* nil
305 "Previous compiler error context.")
306
307 (defvar *buffer-name* nil
308 "The name of the Emacs buffer we are compiling from.
309 NIL if we aren't compiling from a buffer.")
310
311 (defvar *buffer-start-position* nil)
312 (defvar *buffer-substring* nil)
313
314 (defimplementation call-with-compilation-hooks (function)
315 (let ((*previous-compiler-condition* nil)
316 (*previous-context* nil)
317 (*print-readably* nil))
318 (handler-bind ((c::compiler-error #'handle-notification-condition)
319 (c::style-warning #'handle-notification-condition)
320 (c::warning #'handle-notification-condition))
321 (funcall function))))
322
323 (defimplementation swank-compile-file (filename load-p)
324 (clear-xref-info filename)
325 (with-compilation-hooks ()
326 (let ((*buffer-name* nil))
327 (multiple-value-bind (output-file warnings-p failure-p)
328 (compile-file filename :load load-p)
329 (unless failure-p
330 ;; Cache the latest source file for definition-finding.
331 (source-cache-get filename (file-write-date filename)))
332 (values output-file warnings-p failure-p)))))
333
334 (defimplementation swank-compile-string (string &key buffer position directory)
335 (declare (ignore directory))
336 (with-compilation-hooks ()
337 (let ((*buffer-name* buffer)
338 (*buffer-start-position* position)
339 (*buffer-substring* string))
340 (with-input-from-string (stream string)
341 (ext:compile-from-stream
342 stream
343 :source-info `(:emacs-buffer ,buffer
344 :emacs-buffer-offset ,position
345 :emacs-buffer-string ,string))))))
346
347
348 ;;;;; Trapping notes
349 ;;;
350 ;;; We intercept conditions from the compiler and resignal them as
351 ;;; `SWANK:COMPILER-CONDITION's.
352
353 (defun handle-notification-condition (condition)
354 "Handle a condition caused by a compiler warning."
355 (unless (eq condition *previous-compiler-condition*)
356 (let ((context (c::find-error-context nil)))
357 (setq *previous-compiler-condition* condition)
358 (setq *previous-context* context)
359 (signal-compiler-condition condition context))))
360
361 (defun signal-compiler-condition (condition context)
362 (signal (make-condition
363 'compiler-condition
364 :original-condition condition
365 :severity (severity-for-emacs condition)
366 :short-message (brief-compiler-message-for-emacs condition)
367 :message (long-compiler-message-for-emacs condition context)
368 :location (compiler-note-location context))))
369
370 (defun severity-for-emacs (condition)
371 "Return the severity of CONDITION."
372 (etypecase condition
373 (c::compiler-error :error)
374 (c::style-warning :note)
375 (c::warning :warning)))
376
377 (defun brief-compiler-message-for-emacs (condition)
378 "Briefly describe a compiler error for Emacs.
379 When Emacs presents the message it already has the source popped up
380 and the source form highlighted. This makes much of the information in
381 the error-context redundant."
382 (princ-to-string condition))
383
384 (defun long-compiler-message-for-emacs (condition error-context)
385 "Describe a compiler error for Emacs including context information."
386 (declare (type (or c::compiler-error-context null) error-context))
387 (multiple-value-bind (enclosing source)
388 (if error-context
389 (values (c::compiler-error-context-enclosing-source error-context)
390 (c::compiler-error-context-source error-context)))
391 (format nil "~@[--> ~{~<~%--> ~1:;~A~> ~}~%~]~@[~{==>~%~A~^~%~}~]~A"
392 enclosing source condition)))
393
394 (defun compiler-note-location (context)
395 "Derive the location of a complier message from its context.
396 Return a `location' record, or (:error REASON) on failure."
397 (if (null context)
398 (note-error-location)
399 (let ((file (c::compiler-error-context-file-name context))
400 (source (c::compiler-error-context-original-source context))
401 (path
402 (reverse (c::compiler-error-context-original-source-path context))))
403 (or (locate-compiler-note file source path)
404 (note-error-location)))))
405
406 (defun note-error-location ()
407 "Pseudo-location for notes that can't be located."
408 (list :error "No error location available."))
409
410 (defun locate-compiler-note (file source source-path)
411 (cond ((and (eq file :stream) *buffer-name*)
412 ;; Compiling from a buffer
413 (let ((position (+ *buffer-start-position*
414 (source-path-string-position
415 source-path *buffer-substring*))))
416 (make-location (list :buffer *buffer-name*)
417 (list :position position))))
418 ((and (pathnamep file) (null *buffer-name*))
419 ;; Compiling from a file
420 (make-location (list :file (unix-truename file))
421 (list :position
422 (1+ (source-path-file-position
423 source-path file)))))
424 ((and (eq file :lisp) (stringp source))
425 ;; No location known, but we have the source form.
426 ;; XXX How is this case triggered? -luke (16/May/2004)
427 ;; This can happen if the compiler needs to expand a macro
428 ;; but the macro-expander is not yet compiled. Calling the
429 ;; (interpreted) macro-expander triggers IR1 conversion of
430 ;; the lambda expression for the expander and invokes the
431 ;; compiler recursively.
432 (make-location (list :source-form source)
433 (list :position 1)))))
434
435 (defun unix-truename (pathname)
436 (ext:unix-namestring (truename pathname)))
437
438
439 ;;;; XREF
440 ;;;
441 ;;; Cross-reference support is based on the standard CMUCL `XREF'
442 ;;; package. This package has some caveats: XREF information is
443 ;;; recorded during compilation and not preserved in fasl files, and
444 ;;; XREF recording is disabled by default. Redefining functions can
445 ;;; also cause duplicate references to accumulate, but
446 ;;; `swank-compile-file' will automatically clear out any old records
447 ;;; from the same filename.
448 ;;;
449 ;;; To enable XREF recording, set `c:*record-xref-info*' to true. To
450 ;;; clear out the XREF database call `xref:init-xref-database'.
451
452 (defmacro defxref (name function)
453 `(defimplementation ,name (name)
454 (xref-results (,function name))))
455
456 (defxref who-calls xref:who-calls)
457 (defxref who-references xref:who-references)
458 (defxref who-binds xref:who-binds)
459 (defxref who-sets xref:who-sets)
460
461 ;;; More types of XREF information were added since 18e:
462 ;;;
463 #+cmu19
464 (progn
465 (defxref who-macroexpands xref:who-macroexpands)
466 ;; XXX
467 (defimplementation who-specializes (symbol)
468 (let* ((methods (xref::who-specializes (find-class symbol)))
469 (locations (mapcar #'method-location methods)))
470 (mapcar #'list methods locations))))
471
472 (defun xref-results (contexts)
473 (mapcar (lambda (xref)
474 (list (xref:xref-context-name xref)
475 (resolve-xref-location xref)))
476 contexts))
477
478 (defun resolve-xref-location (xref)
479 (let ((name (xref:xref-context-name xref))
480 (file (xref:xref-context-file xref))
481 (source-path (xref:xref-context-source-path xref)))
482 (cond ((and file source-path)
483 (let ((position (source-path-file-position source-path file)))
484 (make-location (list :file (unix-truename file))
485 (list :position (1+ position)))))
486 (file
487 (make-location (list :file (unix-truename file))
488 (list :function-name (string name))))
489 (t
490 `(:error ,(format nil "Unknown source location: ~S ~S ~S "
491 name file source-path))))))
492
493 (defun clear-xref-info (namestring)
494 "Clear XREF notes pertaining to NAMESTRING.
495 This is a workaround for a CMUCL bug: XREF records are cumulative."
496 (when c:*record-xref-info*
497 (let ((filename (truename namestring)))
498 (dolist (db (list xref::*who-calls*
499 #+cmu19 xref::*who-is-called*
500 #+cmu19 xref::*who-macroexpands*
501 xref::*who-references*
502 xref::*who-binds*
503 xref::*who-sets*))
504 (maphash (lambda (target contexts)
505 ;; XXX update during traversal?
506 (setf (gethash target db)
507 (delete filename contexts
508 :key #'xref:xref-context-file
509 :test #'equalp)))
510 db)))))
511
512
513 ;;;; Find callers and callees
514 ;;;
515 ;;; Find callers and callees by looking at the constant pool of
516 ;;; compiled code objects. We assume every fdefn object in the
517 ;;; constant pool corresponds to a call to that function. A better
518 ;;; strategy would be to use the disassembler to find actual
519 ;;; call-sites.
520
521 (declaim (inline map-code-constants))
522 (defun map-code-constants (code fn)
523 "Call FN for each constant in CODE's constant pool."
524 (check-type code kernel:code-component)
525 (loop for i from vm:code-constants-offset below (kernel:get-header-data code)
526 do (funcall fn (kernel:code-header-ref code i))))
527
528 (defun function-callees (function)
529 "Return FUNCTION's callees as a list of functions."
530 (let ((callees '()))
531 (map-code-constants
532 (vm::find-code-object function)
533 (lambda (obj)
534 (when (kernel:fdefn-p obj)
535 (push (kernel:fdefn-function obj) callees))))
536 callees))
537
538 (declaim (ext:maybe-inline map-allocated-code-components))
539 (defun map-allocated-code-components (spaces fn)
540 "Call FN for each allocated code component in one of SPACES. FN
541 receives the object as argument. SPACES should be a list of the
542 symbols :dynamic, :static, or :read-only."
543 (dolist (space spaces)
544 (declare (inline vm::map-allocated-objects))
545 (vm::map-allocated-objects
546 (lambda (obj header size)
547 (declare (type fixnum size) (ignore size))
548 (when (= vm:code-header-type header)
549 (funcall fn obj)))
550 space)))
551
552 (declaim (ext:maybe-inline map-caller-code-components))
553 (defun map-caller-code-components (function spaces fn)
554 "Call FN for each code component with a fdefn for FUNCTION in its
555 constant pool."
556 (let ((function (coerce function 'function)))
557 (declare (inline map-allocated-code-components))
558 (map-allocated-code-components
559 spaces
560 (lambda (obj)
561 (map-code-constants
562 obj
563 (lambda (constant)
564 (when (and (kernel:fdefn-p constant)
565 (eq (kernel:fdefn-function constant)
566 function))
567 (funcall fn obj))))))))
568
569 (defun function-callers (function &optional (spaces '(:read-only :static
570 :dynamic)))
571 "Return FUNCTION's callers. The result is a list of code-objects."
572 (let ((referrers '()))
573 (declare (inline map-caller-code-components))
574 ;;(ext:gc :full t)
575 (map-caller-code-components function spaces
576 (lambda (code) (push code referrers)))
577 referrers))
578
579 (defun debug-info-definitions (debug-info)
580 "Return the defintions for a debug-info. This should only be used
581 for code-object without entry points, i.e., byte compiled
582 code (are theree others?)"
583 ;; This mess has only been tested with #'ext::skip-whitespace, a
584 ;; byte-compiled caller of #'read-char .
585 (check-type debug-info (and (not c::compiled-debug-info) c::debug-info))
586 (let ((name (c::debug-info-name debug-info))
587 (source (c::debug-info-source debug-info)))
588 (destructuring-bind (first) source
589 (ecase (c::debug-source-from first)
590 (:file
591 (list (list name
592 (make-location
593 (list :file (unix-truename (c::debug-source-name first)))
594 (list :function-name name)))))))))
595
596 (defun code-component-entry-points (code)
597 "Return a list ((NAME LOCATION) ...) of function definitons for
598 the code omponent CODE."
599 (delete-duplicates
600 (loop for e = (kernel:%code-entry-points code)
601 then (kernel::%function-next e)
602 while e
603 collect (list (kernel:%function-name e)
604 (function-location e)))
605 :test #'equal))
606
607 (defimplementation list-callers (symbol)
608 "Return a list ((NAME LOCATION) ...) of callers."
609 (let ((components (function-callers symbol))
610 (xrefs '()))
611 (dolist (code components)
612 (let* ((entry (kernel:%code-entry-points code))
613 (defs (if entry
614 (code-component-entry-points code)
615 ;; byte compiled stuff
616 (debug-info-definitions
617 (kernel:%code-debug-info code)))))
618 (setq xrefs (nconc defs xrefs))))
619 xrefs))
620
621 (defimplementation list-callees (symbol)
622 (let ((fns (function-callees symbol)))
623 (mapcar (lambda (fn)
624 (list (kernel:%function-name fn)
625 (function-location fn)))
626 fns)))
627
628
629 ;;;; Resolving source locations
630 ;;;
631 ;;; Our mission here is to "resolve" references to code locations into
632 ;;; actual file/buffer names and character positions. The references
633 ;;; we work from come out of the compiler's statically-generated debug
634 ;;; information, such as `code-location''s and `debug-source''s. For
635 ;;; more details, see the "Debugger Programmer's Interface" section of
636 ;;; the CMUCL manual.
637 ;;;
638 ;;; The first step is usually to find the corresponding "source-path"
639 ;;; for the location. Once we have the source-path we can pull up the
640 ;;; source file and `READ' our way through to the right position. The
641 ;;; main source-code groveling work is done in
642 ;;; `swank-source-path-parser.lisp'.
643
644 (defvar *debug-definition-finding* nil
645 "When true don't handle errors while looking for definitions.
646 This is useful when debugging the definition-finding code.")
647
648 (defvar *source-snippet-size* 256
649 "Maximum number of characters in a snippet of source code.
650 Snippets at the beginning of definitions are used to tell Emacs what
651 the definitions looks like, so that it can accurately find them by
652 text search.")
653
654 (defmacro safe-definition-finding (&body body)
655 "Execute BODY and return the source-location it returns.
656 If an error occurs and `*debug-definition-finding*' is false, then
657 return an error pseudo-location.
658
659 The second return value is NIL if no error occurs, otherwise it is the
660 condition object."
661 `(flet ((body () ,@body))
662 (if *debug-definition-finding*
663 (body)
664 (handler-case (values (progn ,@body) nil)
665 (error (c) (values (list :error (princ-to-string c)) c))))))
666
667 (defun code-location-source-location (code-location)
668 "Safe wrapper around `code-location-from-source-location'."
669 (safe-definition-finding
670 (source-location-from-code-location code-location)))
671
672 (defun source-location-from-code-location (code-location)
673 "Return the source location for CODE-LOCATION."
674 (let ((debug-fun (di:code-location-debug-function code-location)))
675 (when (di::bogus-debug-function-p debug-fun)
676 ;; Those lousy cheapskates! They've put in a bogus debug source
677 ;; because the code was compiled at a low debug setting.
678 (error "Bogus debug function: ~A" debug-fun)))
679 (let* ((debug-source (di:code-location-debug-source code-location))
680 (from (di:debug-source-from debug-source))
681 (name (di:debug-source-name debug-source)))
682 (ecase from
683 (:file
684 (location-in-file name code-location debug-source))
685 (:stream
686 (location-in-stream code-location debug-source))
687 (:lisp
688 ;; The location comes from a form passed to `compile'.
689 ;; The best we can do is return the form itself for printing.
690 (make-location
691 (list :source-form (with-output-to-string (*standard-output*)
692 (debug::print-code-location-source-form
693 code-location 100 t)))
694 (list :position 1))))))
695
696 (defun location-in-file (filename code-location debug-source)
697 "Resolve the source location for CODE-LOCATION in FILENAME."
698 (let* ((code-date (di:debug-source-created debug-source))
699 (source-code (or (source-cache-get filename code-date)
700 (read-file filename))))
701 (make-location (list :file (unix-truename filename)) nil)
702 (with-input-from-string (s source-code)
703 (make-location (list :file (unix-truename filename))
704 (list :position
705 (1+ (code-location-stream-position
706 code-location s)))
707 `(:snippet ,(read-snippet s))))))
708
709 (defun location-in-stream (code-location debug-source)
710 "Resolve the source location for a CODE-LOCATION from a stream.
711 This only succeeds if the code was compiled from an Emacs buffer."
712 (unless (debug-source-info-from-emacs-buffer-p debug-source)
713 (error "The code is compiled from a non-SLIME stream."))
714 (let* ((info (c::debug-source-info debug-source))
715 (string (getf info :emacs-buffer-string))
716 (position (code-location-string-offset
717 code-location
718 string)))
719 (make-location
720 (list :buffer (getf info :emacs-buffer))
721 (list :position (+ (getf info :emacs-buffer-offset) position))
722 (list :snippet (with-input-from-string (s string)
723 (file-position s position)
724 (read-snippet s))))))
725
726 (defun read-file (filename)
727 "Return the entire contents of FILENAME as a string."
728 (with-open-file (s filename :direction :input)
729 (let ((string (make-string (file-length s))))
730 (read-sequence string s)
731 string)))
732
733 (defun read-snippet (stream)
734 "Read a string of upto *SOURCE-SNIPPET-SIZE* characters from STREAM."
735 (read-upto-n-chars stream *source-snippet-size*))
736
737 (defun read-upto-n-chars (stream n)
738 "Return a string of upto N chars from STREAM."
739 (let* ((string (make-string n))
740 (chars (read-sequence string stream)))
741 (subseq string 0 chars)))
742
743 ;;;;; Function-name locations
744 ;;;
745 (defun debug-info-function-name-location (debug-info)
746 "Return a function-name source-location for DEBUG-INFO.
747 Function-name source-locations are a fallback for when precise
748 positions aren't available."
749 (with-struct (c::debug-info- (fname name) source) debug-info
750 (with-struct (c::debug-source- info from name) (car source)
751 (ecase from
752 (:file
753 (make-location (list :file (namestring (truename name)))
754 (list :function-name fname)))
755 (:stream
756 (assert (debug-source-info-from-emacs-buffer-p (car source)))
757 (make-location (list :buffer (getf info :emacs-buffer))
758 (list :function-name fname)))
759 (:lisp
760 (make-location (list :source-form (princ-to-string (aref name 0)))
761 (list :position 1)))))))
762
763 (defun debug-source-info-from-emacs-buffer-p (debug-source)
764 "Does the `info' slot of DEBUG-SOURCE contain an Emacs buffer location?
765 This is true for functions that were compiled directly from buffers."
766 (info-from-emacs-buffer-p (c::debug-source-info debug-source)))
767
768 (defun info-from-emacs-buffer-p (info)
769 (and info
770 (consp info)
771 (eq :emacs-buffer (car info))))
772
773
774 ;;;;; Groveling source-code for positions
775
776 (defun code-location-stream-position (code-location stream)
777 "Return the byte offset of CODE-LOCATION in STREAM. Extract the
778 toplevel-form-number and form-number from CODE-LOCATION and use that
779 to find the position of the corresponding form.
780
781 Finish with STREAM positioned at the start of the code location."
782 (let* ((location (debug::maybe-block-start-location code-location))
783 (tlf-offset (di:code-location-top-level-form-offset location))
784 (form-number (di:code-location-form-number location)))
785 (let ((pos (form-number-stream-position tlf-offset form-number stream)))
786 (file-position stream pos)
787 pos)))
788
789 (defun form-number-stream-position (tlf-number form-number stream)
790 "Return the starting character position of a form in STREAM.
791 TLF-NUMBER is the top-level-form number.
792 FORM-NUMBER is an index into a source-path table for the TLF."
793 (let ((*read-suppress* t))
794 (dotimes (i tlf-number) (read stream))
795 (multiple-value-bind (tlf position-map) (read-and-record-source-map stream)
796 (let* ((path-table (di:form-number-translations tlf 0))
797 (source-path
798 (if (<= (length path-table) form-number) ; source out of sync?
799 (list 0) ; should probably signal a condition
800 (reverse (cdr (aref path-table form-number))))))
801 (source-path-source-position source-path tlf position-map)))))
802
803 (defun code-location-string-offset (code-location string)
804 "Return the byte offset of CODE-LOCATION in STRING.
805 See CODE-LOCATION-STREAM-POSITION."
806 (with-input-from-string (s string)
807 (code-location-stream-position code-location s)))
808
809 ;;;;; Source-file cache
810 ;;;
811 ;;; To robustly find source locations it's useful to have the exact
812 ;;; source code that the loaded code was compiled from. In this source
813 ;;; we can accurately find the right location, and from that location
814 ;;; we can extract a "snippet" of code to show what the definition
815 ;;; looks like. Emacs can use this snippet in a best-match search to
816 ;;; locate the right definition, which works well even if the buffer
817 ;;; has been modified.
818 ;;;
819 ;;; The idea is that if a definition previously started with
820 ;;; `(define-foo bar' then it probably still does.
821 ;;;
822 ;;; Whenever we see that the file on disk has the same
823 ;;; `file-write-date' as a location we're looking for, we cache the
824 ;;; whole file inside Lisp. That way we will still have the matching
825 ;;; version even if the file is later modified on disk. If the file is
826 ;;; later recompiled and reloaded then we replace our cache entry.
827
828 (defvar *cache-sourcecode* t
829 "When true complete source files are cached.
830 The cache is used to keep known good copies of the source text which
831 correspond to the loaded code. Finding definitions is much more
832 reliable when the exact source is available, so we cache it in case it
833 gets edited on disk later.")
834
835 (defvar *source-file-cache* (make-hash-table :test 'equal)
836 "Cache of source file contents.
837 Maps from truename to source-cache-entry structure.")
838
839 (defstruct (source-cache-entry
840 (:conc-name source-cache-entry.)
841 (:constructor make-source-cache-entry (text date)))
842 text date)
843
844 (defun source-cache-get (filename date)
845 "Return the source code for FILENAME as written on DATE in a string.
846 Return NIL if the right version cannot be found."
847 (let ((entry (gethash filename *source-file-cache*)))
848 (cond ((and entry (equal date (source-cache-entry.date entry)))
849 ;; Cache hit.
850 (source-cache-entry.text entry))
851 ((or (null entry)
852 (not (equal date (source-cache-entry.date entry))))
853 ;; Cache miss.
854 (if (equal (file-write-date filename) date)
855 ;; File on disk has the correct version.
856 (let ((source (read-file filename)))
857 (setf (gethash filename *source-file-cache*)
858 (make-source-cache-entry source date))
859 source)
860 nil)))))
861
862 (defun source-cached-p (filename)
863 "Is any version of FILENAME in the source cache?"
864 (if (gethash filename *source-file-cache*) t))
865
866 (defimplementation buffer-first-change (filename)
867 "Load a file into the cache when the user modifies its buffer.
868 This is a win if the user then saves the file and tries to M-. into it."
869 (unless (source-cached-p filename)
870 (ignore-errors (source-cache-get filename (file-write-date filename)))))
871
872
873 ;;;; Finding definitions
874
875 ;;; There are a great many different types of definition for us to
876 ;;; find. We search for definitions of every kind and return them in a
877 ;;; list.
878
879 (defimplementation find-definitions (name)
880 (append (function-definitions name)
881 (setf-definitions name)
882 (variable-definitions name)
883 (class-definitions name)
884 (type-definitions name)
885 (compiler-macro-definitions name)
886 (source-transform-definitions name)
887 (function-info-definitions name)
888 (ir1-translator-definitions name)))
889
890 ;;;;; Functions, macros, generic functions, methods
891 ;;;
892 ;;; We make extensive use of the compile-time debug information that
893 ;;; CMUCL records, in particular "debug functions" and "code
894 ;;; locations." Refer to the "Debugger Programmer's Interface" section
895 ;;; of the CMUCL manual for more details.
896
897 (defun function-definitions (name)
898 "Return definitions for NAME in the \"function namespace\", i.e.,
899 regular functions, generic functions, methods and macros.
900 NAME can any valid function name (e.g, (setf car))."
901 (let ((macro? (and (symbolp name) (macro-function name)))
902 (special? (and (symbolp name) (special-operator-p name)))
903 (function? (and (ext:valid-function-name-p name)
904 (ext:info :function :definition name))))
905 (cond (macro?
906 (list `((defmacro ,name)
907 ,(function-location (macro-function name)))))
908 (special?
909 (list `((:special-operator ,name)
910 (:error ,(format nil "Special operator: ~S" name)))))
911 (function?
912 (let ((function (fdefinition name)))
913 (if (genericp function)
914 (generic-function-definitions name function)
915 (list (list `(function ,name)
916 (function-location function)))))))))
917
918 ;;;;;; Ordinary (non-generic/macro/special) functions
919 ;;;
920 ;;; First we test if FUNCTION is a closure created by defstruct, and
921 ;;; if so extract the defstruct-description (`dd') from the closure
922 ;;; and find the constructor for the struct. Defstruct creates a
923 ;;; defun for the default constructor and we use that as an
924 ;;; approximation to the source location of the defstruct.
925 ;;;
926 ;;; For an ordinary function we return the source location of the
927 ;;; first code-location we find.
928 ;;;
929 (defun function-location (function)
930 "Return the source location for FUNCTION."
931 (cond ((struct-closure-p function)
932 (struct-closure-location function))
933 ((c::byte-function-or-closure-p function)
934 (byte-function-location function))
935 (t
936 (compiled-function-location function))))
937
938 (defun compiled-function-location (function)
939 "Return the location of a regular compiled function."
940 (multiple-value-bind (code-location error)
941 (safe-definition-finding (function-first-code-location function))
942 (cond (error (list :error (princ-to-string error)))
943 (t (code-location-source-location code-location)))))
944
945 (defun function-first-code-location (function)
946 "Return the first code-location we can find for FUNCTION."
947 (and (function-has-debug-function-p function)
948 (di:debug-function-start-location
949 (di:function-debug-function function))))
950
951 (defun function-has-debug-function-p (function)
952 (di:function-debug-function function))
953
954 (defun function-code-object= (closure function)
955 (and (eq (vm::find-code-object closure)
956 (vm::find-code-object function))
957 (not (eq closure function))))
958
959
960 (defun byte-function-location (fn)
961 "Return the location of the byte-compiled function FN."
962 (etypecase fn
963 ((or c::hairy-byte-function c::simple-byte-function)
964 (let* ((component (c::byte-function-component fn))
965 (debug-info (kernel:%code-debug-info component)))
966 (debug-info-function-name-location debug-info)))
967 (c::byte-closure
968 (byte-function-location (c::byte-closure-function fn)))))
969
970 ;;; Here we deal with structure accessors. Note that `dd' is a
971 ;;; "defstruct descriptor" structure in CMUCL. A `dd' describes a
972 ;;; `defstruct''d structure.
973
974 (defun struct-closure-p (function)
975 "Is FUNCTION a closure created by defstruct?"
976 (or (function-code-object= function #'kernel::structure-slot-accessor)
977 (function-code-object= function #'kernel::structure-slot-setter)
978 (function-code-object= function #'kernel::%defstruct)))
979
980 (defun struct-closure-location (function)
981 "Return the location of the structure that FUNCTION belongs to."
982 (assert (struct-closure-p function))
983 (safe-definition-finding
984 (dd-location (struct-closure-dd function))))
985
986 (defun struct-closure-dd (function)
987 "Return the defstruct-definition (dd) of FUNCTION."
988 (assert (= (kernel:get-type function) vm:closure-header-type))
989 (flet ((find-layout (function)
990 (sys:find-if-in-closure
991 (lambda (x)
992 (let ((value (if (di::indirect-value-cell-p x)
993 (c:value-cell-ref x)
994 x)))
995 (when (kernel::layout-p value)
996 (return-from find-layout value))))
997 function)))
998 (kernel:layout-info (find-layout function))))
999
1000 (defun dd-location (dd)
1001 "Return the location of a `defstruct'."
1002 ;; Find the location in a constructor.
1003 (function-location (struct-constructor dd)))
1004
1005 (defun struct-constructor (dd)
1006 "Return a constructor function from a defstruct definition.
1007 Signal an error if no constructor can be found."
1008 (let ((constructor (or (kernel:dd-default-constructor dd)
1009 (car (kernel::dd-constructors dd)))))
1010 (when (or (null constructor)
1011 (and (consp constructor) (null (car constructor))))
1012 (error "Cannot find structure's constructor: ~S"
1013 (kernel::dd-name dd)))
1014 (coerce (if (consp constructor) (first constructor) constructor)
1015 'function)))
1016
1017 ;;;;;; Generic functions and methods
1018
1019 (defun generic-function-definitions (name function)
1020 "Return the definitions of a generic function and its methods."
1021 (cons (list `(defgeneric ,name) (gf-location function))
1022 (gf-method-definitions function)))
1023
1024 (defun gf-location (gf)
1025 "Return the location of the generic function GF."
1026 (definition-source-location gf (pcl::generic-function-name gf)))
1027
1028 (defun gf-method-definitions (gf)
1029 "Return the locations of all methods of the generic function GF."
1030 (mapcar #'method-definition (pcl::generic-function-methods gf)))
1031
1032 (defun method-definition (method)
1033 (list (method-dspec method)
1034 (method-location method)))
1035
1036 (defun method-dspec (method)
1037 "Return a human-readable \"definition specifier\" for METHOD."
1038 (let* ((gf (pcl:method-generic-function method))
1039 (name (pcl:generic-function-name gf))
1040 (specializers (pcl:method-specializers method))
1041 (qualifiers (pcl:method-qualifiers method)))
1042 `(method ,name ,@qualifiers ,(pcl::unparse-specializers specializers))))
1043
1044 ;; XXX maybe special case setters/getters
1045 (defun method-location (method)
1046 (function-location (or (pcl::method-fast-function method)
1047 (pcl:method-function method))))
1048
1049 (defun genericp (fn)
1050 (typep fn 'generic-function))
1051
1052 ;;;;;; Types and classes
1053
1054 (defun type-definitions (name)
1055 "Return `deftype' locations for type NAME."
1056 (maybe-make-definition (ext:info :type :expander name) 'deftype name))
1057
1058 (defun maybe-make-definition (function kind name)
1059 "If FUNCTION is non-nil then return its definition location."
1060 (if function
1061 (list (list `(,kind ,name) (function-location function)))))
1062
1063 (defun class-definitions (name)
1064 "Return the definition locations for the class called NAME."
1065 (if (symbolp name)
1066 (let ((class (kernel::find-class name nil)))
1067 (etypecase class
1068 (null '())
1069 (kernel::structure-class
1070 (list (list `(defstruct ,name) (dd-location (find-dd name)))))
1071 #+(or)
1072 (conditions::condition-class
1073 (list (list `(define-condition ,name)
1074 (condition-class-location class))))
1075 (kernel::standard-class
1076 (list (list `(defclass ,name)
1077 (class-location (find-class name)))))
1078 ((or kernel::built-in-class
1079 conditions::condition-class
1080 kernel:funcallable-structure-class)
1081 (list (list `(kernel::define-type-class ,name)
1082 `(:error
1083 ,(format nil "No source info for ~A" name)))))))))
1084
1085 (defun class-location (class)
1086 "Return the `defclass' location for CLASS."
1087 (definition-source-location class (pcl:class-name class)))
1088
1089 (defun find-dd (name)
1090 "Find the defstruct-definition by the name of its structure-class."
1091 (let ((layout (ext:info :type :compiler-layout name)))
1092 (if layout
1093 (kernel:layout-info layout))))
1094
1095 (defun condition-class-location (class)
1096 (let ((slots (conditions::condition-class-slots class))
1097 (name (conditions::condition-class-name class)))
1098 (cond ((null slots)
1099 `(:error ,(format nil "No location info for condition: ~A" name)))
1100 (t
1101 ;; Find the class via one of its slot-reader methods.
1102 (let* ((slot (first slots))
1103 (gf (fdefinition
1104 (first (conditions::condition-slot-readers slot)))))
1105 (method-location
1106 (first
1107 (pcl:compute-applicable-methods-using-classes
1108 gf (list (find-class name))))))))))
1109
1110 (defun make-name-in-file-location (file string)
1111 (multiple-value-bind (filename c)
1112 (ignore-errors
1113 (unix-truename (merge-pathnames (make-pathname :type "lisp")
1114 file)))
1115 (cond (filename (make-location `(:file ,filename)
1116 `(:function-name ,string)))
1117 (t (list :error (princ-to-string c))))))
1118
1119 (defun source-location-form-numbers (location)
1120 (c::decode-form-numbers (c::form-numbers-form-numbers location)))
1121
1122 (defun source-location-tlf-number (location)
1123 (nth-value 0 (source-location-form-numbers location)))
1124
1125 (defun source-location-form-number (location)
1126 (nth-value 1 (source-location-form-numbers location)))
1127
1128 (defun resolve-file-source-location (location)
1129 (let ((filename (c::file-source-location-pathname location))
1130 (tlf-number (source-location-tlf-number location))
1131 (form-number (source-location-form-number location)))
1132 (with-open-file (s filename)
1133 (let ((pos (form-number-stream-position tlf-number form-number s)))
1134 (make-location `(:file ,(unix-truename filename))
1135 `(:position ,(1+ pos)))))))
1136
1137 (defun resolve-stream-source-location (location)
1138 (let ((info (c::stream-source-location-user-info location))
1139 (tlf-number (source-location-tlf-number location))
1140 (form-number (source-location-form-number location)))
1141 ;; XXX duplication in frame-source-location
1142 (assert (info-from-emacs-buffer-p info))
1143 (destructuring-bind (&key emacs-buffer emacs-buffer-string
1144 emacs-buffer-offset) info
1145 (with-input-from-string (s emacs-buffer-string)
1146 (let ((pos (form-number-stream-position tlf-number form-number s)))
1147 (make-location `(:buffer ,emacs-buffer)
1148 `(:position ,(+ emacs-buffer-offset pos))))))))
1149
1150 ;; XXX predicates for 18e backward compatibilty. Remove them when
1151 ;; we're 19a only.
1152 (defun file-source-location-p (object)
1153 (when (fboundp 'c::file-source-location-p)
1154 (c::file-source-location-p object)))
1155
1156 (defun stream-source-location-p (object)
1157 (when (fboundp 'c::stream-source-location-p)
1158 (c::stream-source-location-p object)))
1159
1160 (defun source-location-p (object)
1161 (or (file-source-location-p object)
1162 (stream-source-location-p object)))
1163
1164 (defun resolve-source-location (location)
1165 (etypecase location
1166 ((satisfies file-source-location-p)
1167 (resolve-file-source-location location))
1168 ((satisfies stream-source-location-p)
1169 (resolve-stream-source-location location))))
1170
1171 (defun definition-source-location (object name)
1172 (let ((source (pcl::definition-source object)))
1173 (etypecase source
1174 (null
1175 `(:error ,(format nil "No source info for: ~A" object)))
1176 ((satisfies source-location-p)
1177 (resolve-source-location source))
1178 (pathname
1179 (make-name-in-file-location source name))
1180 (cons
1181 (destructuring-bind ((dg name) pathname) source
1182 (declare (ignore dg))
1183 (etypecase pathname
1184 (pathname (make-name-in-file-location pathname (string name)))
1185 (null `(:error ,(format nil "Cannot resolve: ~S" source)))))))))
1186
1187 (defun setf-definitions (name)
1188 (let ((function (or (ext:info :setf :inverse name)
1189 (ext:info :setf :expander name))))
1190 (if function
1191 (list (list `(setf ,name)
1192 (function-location (coerce function 'function)))))))
1193
1194
1195 (defun variable-location (symbol)
1196 (multiple-value-bind (location foundp)
1197 ;; XXX for 18e compatibilty. rewrite this when we drop 18e
1198 ;; support.
1199 (ignore-errors (eval `(ext:info :source-location :defvar ',symbol)))
1200 (if (and foundp location)
1201 (resolve-source-location location)
1202 `(:error ,(format nil "No source info for variable ~S" symbol)))))
1203
1204 (defun variable-definitions (name)
1205 (if (symbolp name)
1206 (multiple-value-bind (kind recorded-p) (ext:info :variable :kind name)
1207 (if recorded-p
1208 (list (list `(variable ,kind ,name)
1209 (variable-location name)))))))
1210
1211 (defun compiler-macro-definitions (symbol)
1212 (maybe-make-definition (compiler-macro-function symbol)
1213 'define-compiler-macro
1214 symbol))
1215
1216 (defun source-transform-definitions (name)
1217 (maybe-make-definition (ext:info :function :source-transform name)
1218 'c:def-source-transform
1219 name))
1220
1221 (defun function-info-definitions (name)
1222 (let ((info (ext:info :function :info name)))
1223 (if info
1224 (append (loop for transform in (c::function-info-transforms info)
1225 collect (list `(c:deftransform ,name
1226 ,(c::type-specifier
1227 (c::transform-type transform)))
1228 (function-location (c::transform-function
1229 transform))))
1230 (maybe-make-definition (c::function-info-derive-type info)
1231 'c::derive-type name)
1232 (maybe-make-definition (c::function-info-optimizer info)
1233 'c::optimizer name)
1234 (maybe-make-definition (c::function-info-ltn-annotate info)
1235 'c::ltn-annotate name)
1236 (maybe-make-definition (c::function-info-ir2-convert info)
1237 'c::ir2-convert name)
1238 (loop for template in (c::function-info-templates info)
1239 collect (list `(c::vop ,(c::template-name template))
1240 (function-location
1241 (c::vop-info-generator-function
1242 template))))))))
1243
1244 (defun ir1-translator-definitions (name)
1245 (maybe-make-definition (ext:info :function :ir1-convert name)
1246 'c:def-ir1-translator name))
1247
1248
1249 ;;;; Documentation.
1250
1251 (defimplementation describe-symbol-for-emacs (symbol)
1252 (let ((result '()))
1253 (flet ((doc (kind)
1254 (or (documentation symbol kind) :not-documented))
1255 (maybe-push (property value)
1256 (when value
1257 (setf result (list* property value result)))))
1258 (maybe-push
1259 :variable (multiple-value-bind (kind recorded-p)
1260 (ext:info variable kind symbol)
1261 (declare (ignore kind))
1262 (if (or (boundp symbol) recorded-p)
1263 (doc 'variable))))
1264 (maybe-push
1265 :generic-function
1266 (if (and (fboundp symbol)
1267 (typep (fdefinition symbol) 'generic-function))
1268 (doc 'function)))
1269 (maybe-push
1270 :function (if (and (fboundp symbol)
1271 (not (typep (fdefinition symbol) 'generic-function)))
1272 (doc 'function)))
1273 (maybe-push
1274 :setf (if (or (ext:info setf inverse symbol)
1275 (ext:info setf expander symbol))
1276 (doc 'setf)))
1277 (maybe-push
1278 :type (if (ext:info type kind symbol)
1279 (doc 'type)))
1280 (maybe-push
1281 :class (if (find-class symbol nil)
1282 (doc 'class)))
1283 (maybe-push
1284 :alien-type (if (not (eq (ext:info alien-type kind symbol) :unknown))
1285 (doc 'alien-type)))
1286 (maybe-push
1287 :alien-struct (if (ext:info alien-type struct symbol)
1288 (doc nil)))
1289 (maybe-push
1290 :alien-union (if (ext:info alien-type union symbol)
1291 (doc nil)))
1292 (maybe-push
1293 :alien-enum (if (ext:info alien-type enum symbol)
1294 (doc nil)))
1295 result)))
1296
1297 (defimplementation describe-definition (symbol namespace)
1298 (describe (ecase namespace
1299 (:variable
1300 symbol)
1301 ((:function :generic-function)
1302 (symbol-function symbol))
1303 (:setf
1304 (or (ext:info setf inverse symbol)
1305 (ext:info setf expander symbol)))
1306 (:type
1307 (kernel:values-specifier-type symbol))
1308 (:class
1309 (find-class symbol))
1310 (:alien-struct
1311 (ext:info :alien-type :struct symbol))
1312 (:alien-union
1313 (ext:info :alien-type :union symbol))
1314 (:alien-enum
1315 (ext:info :alien-type :enum symbol))
1316 (:alien-type
1317 (ecase (ext:info :alien-type :kind symbol)
1318 (:primitive
1319 (let ((alien::*values-type-okay* t))
1320 (funcall (ext:info :alien-type :translator symbol)
1321 (list symbol))))
1322 ((:defined)
1323 (ext:info :alien-type :definition symbol))
1324 (:unknown
1325 (return-from describe-definition
1326 (format nil "Unknown alien type: ~S" symbol))))))))
1327
1328 ;;;;; Argument lists
1329
1330 (defimplementation arglist ((name symbol))
1331 (arglist (or (macro-function name)
1332 (symbol-function name)
1333 (error "~S does not name a known function."))))
1334
1335 (defimplementation arglist ((fun function))
1336 (let ((arglist
1337 (cond ((eval:interpreted-function-p fun)
1338 (eval:interpreted-function-arglist fun))
1339 ((pcl::generic-function-p fun)
1340 (pcl:generic-function-lambda-list fun))
1341 ((c::byte-function-or-closure-p fun)
1342 (byte-code-function-arglist fun))
1343 ((kernel:%function-arglist (kernel:%function-self fun))
1344 (handler-case (read-arglist fun)
1345 (error () :not-available)))
1346 ;; this should work both for compiled-debug-function
1347 ;; and for interpreted-debug-function
1348 (t
1349 (handler-case (debug-function-arglist
1350 (di::function-debug-function fun))
1351 (di:unhandled-condition () :not-available))))))
1352 (check-type arglist (or list (member :not-available)))
1353 arglist))
1354
1355 (defimplementation function-name (function)
1356 (cond ((eval:interpreted-function-p function)
1357 (eval:interpreted-function-name function))
1358 ((pcl::generic-function-p function)
1359 (pcl::generic-function-name function))
1360 ((c::byte-function-or-closure-p function)
1361 (c::byte-function-name function))
1362 (t (kernel:%function-name (kernel:%function-self function)))))
1363
1364 ;;; A simple case: the arglist is available as a string that we can
1365 ;;; `read'.
1366
1367 (defun read-arglist (fn)
1368 "Parse the arglist-string of the function object FN."
1369 (let ((string (kernel:%function-arglist
1370 (kernel:%function-self fn)))
1371 (package (find-package
1372 (c::compiled-debug-info-package
1373 (kernel:%code-debug-info
1374 (vm::find-code-object fn))))))
1375 (with-standard-io-syntax
1376 (let ((*package* (or package *package*)))
1377 (read-from-string string)))))
1378
1379 ;;; A harder case: an approximate arglist is derived from available
1380 ;;; debugging information.
1381
1382 (defun debug-function-arglist (debug-function)
1383 "Derive the argument list of DEBUG-FUNCTION from debug info."
1384 (let ((args (di::debug-function-lambda-list debug-function))
1385 (required '())
1386 (optional '())
1387 (rest '())
1388 (key '()))
1389 ;; collect the names of debug-vars
1390 (dolist (arg args)
1391 (etypecase arg
1392 (di::debug-variable
1393 (push (di::debug-variable-symbol arg) required))
1394 ((member :deleted)
1395 (push ':deleted required))
1396 (cons
1397 (ecase (car arg)
1398 (:keyword
1399 (push (second arg) key))
1400 (:optional
1401 (push (debug-variable-symbol-or-deleted (second arg)) optional))
1402 (:rest
1403 (push (debug-variable-symbol-or-deleted (second arg)) rest))))))
1404 ;; intersperse lambda keywords as needed
1405 (append (nreverse required)
1406 (if optional (cons '&optional (nreverse optional)))
1407 (if rest (cons '&rest (nreverse rest)))
1408 (if key (cons '&key (nreverse key))))))
1409
1410 (defun debug-variable-symbol-or-deleted (var)
1411 (etypecase var
1412 (di:debug-variable
1413 (di::debug-variable-symbol var))
1414 ((member :deleted)
1415 '#:deleted)))
1416
1417 (defun symbol-debug-function-arglist (fname)
1418 "Return FNAME's debug-function-arglist and %function-arglist.
1419 A utility for debugging DEBUG-FUNCTION-ARGLIST."
1420 (let ((fn (fdefinition fname)))
1421 (values (debug-function-arglist (di::function-debug-function fn))
1422 (kernel:%function-arglist (kernel:%function-self fn)))))
1423
1424 ;;; Deriving arglists for byte-compiled functions:
1425 ;;;
1426 (defun byte-code-function-arglist (fn)
1427 ;; There doesn't seem to be much arglist information around for
1428 ;; byte-code functions. Use the arg-count and return something like
1429 ;; (arg0 arg1 ...)
1430 (etypecase fn
1431 (c::simple-byte-function
1432 (loop for i from 0 below (c::simple-byte-function-num-args fn)
1433 collect (make-arg-symbol i)))
1434 (c::hairy-byte-function
1435 (hairy-byte-function-arglist fn))
1436 (c::byte-closure
1437 (byte-code-function-arglist (c::byte-closure-function fn)))))
1438
1439 (defun make-arg-symbol (i)
1440 (make-symbol (format nil "~A~D" (string 'arg) i)))
1441
1442 ;;; A "hairy" byte-function is one that takes a variable number of
1443 ;;; arguments. `hairy-byte-function' is a type from the bytecode
1444 ;;; interpreter.
1445 ;;;
1446 (defun hairy-byte-function-arglist (fn)
1447 (let ((counter -1))
1448 (flet ((next-arg () (make-arg-symbol (incf counter))))
1449 (with-struct (c::hairy-byte-function- min-args max-args rest-arg-p
1450 keywords-p keywords) fn
1451 (let ((arglist '())
1452 (optional (- max-args min-args)))
1453 ;; XXX isn't there a better way to write this?
1454 ;; (Looks fine to me. -luke)
1455 (dotimes (i min-args)
1456 (push (next-arg) arglist))
1457 (when (plusp optional)
1458 (push '&optional arglist)
1459 (dotimes (i optional)
1460 (push (next-arg) arglist)))
1461 (when rest-arg-p
1462 (push '&rest arglist)
1463 (push (next-arg) arglist))
1464 (when keywords-p
1465 (push '&key arglist)
1466 (loop for (key _ __) in keywords
1467 do (push key arglist))
1468 (when (eq keywords-p :allow-others)
1469 (push '&allow-other-keys arglist)))
1470 (nreverse arglist))))))
1471
1472
1473 ;;;; Miscellaneous.
1474
1475 (defimplementation macroexpand-all (form)
1476 (walker:macroexpand-all form))
1477
1478 (defimplementation set-default-directory (directory)
1479 (setf (ext:default-directory) (namestring directory))
1480 ;; Setting *default-pathname-defaults* to an absolute directory
1481 ;; makes the behavior of MERGE-PATHNAMES a bit more intuitive.
1482 (setf *default-pathname-defaults* (pathname (ext:default-directory)))
1483 (default-directory))
1484
1485 (defimplementation default-directory ()
1486 (namestring (ext:default-directory)))
1487
1488 (defimplementation call-without-interrupts (fn)
1489 (sys:without-interrupts (funcall fn)))
1490
1491 (defimplementation getpid ()
1492 (unix:unix-getpid))
1493
1494 (defimplementation lisp-implementation-type-name ()
1495 "cmucl")
1496
1497 (defimplementation quit-lisp ()
1498 (ext::quit))
1499
1500 ;;; source-path-{stream,file,string,etc}-position moved into
1501 ;;; swank-source-path-parser
1502
1503
1504 ;;;; Debugging
1505
1506 (defvar *sldb-stack-top*)
1507
1508 (defimplementation call-with-debugging-environment (debugger-loop-fn)
1509 (unix:unix-sigsetmask 0)
1510 (let* ((*sldb-stack-top* (or debug:*stack-top-hint* (di:top-frame)))
1511 (debug:*stack-top-hint* nil))
1512 (handler-bind ((di::unhandled-condition
1513 (lambda (condition)
1514 (error (make-condition
1515 'sldb-condition
1516 :original-condition condition)))))
1517 (funcall debugger-loop-fn))))
1518
1519 (defun frame-down (frame)
1520 (handler-case (di:frame-down frame)
1521 (di:no-debug-info () nil)))
1522
1523 (defun nth-frame (index)
1524 (do ((frame *sldb-stack-top* (frame-down frame))
1525 (i index (1- i)))
1526 ((zerop i) frame)))
1527
1528 (defimplementation compute-backtrace (start end)
1529 (let ((end (or end most-positive-fixnum)))
1530 (loop for f = (nth-frame start) then (frame-down f)
1531 for i from start below end
1532 while f
1533 collect f)))
1534
1535 (defimplementation print-frame (frame stream)
1536 (let ((*standard-output* stream))
1537 (handler-case
1538 (debug::print-frame-call frame :verbosity 1 :number nil)
1539 (error (e)
1540 (ignore-errors (princ e stream))))))
1541
1542 (defimplementation frame-source-location-for-emacs (index)
1543 (code-location-source-location (di:frame-code-location (nth-frame index))))
1544
1545 (defimplementation eval-in-frame (form index)
1546 (di:eval-in-frame (nth-frame index) form))
1547
1548 (defun frame-debug-vars (frame)
1549 "Return a vector of debug-variables in frame."
1550 (di::debug-function-debug-variables (di:frame-debug-function frame)))
1551
1552 (defun debug-var-value (var frame location)
1553 (ecase (di:debug-variable-validity var location)
1554 (:valid (di:debug-variable-value var frame))
1555 ((:invalid :unknown) ':<not-available>)))
1556
1557 (defimplementation frame-locals (index)
1558 (let* ((frame (nth-frame index))
1559 (loc (di:frame-code-location frame))
1560 (vars (frame-debug-vars frame)))
1561 (loop for v across vars collect
1562 (list :name (di:debug-variable-symbol v)
1563 :id (di:debug-variable-id v)
1564 :value (debug-var-value v frame loc)))))
1565
1566 (defimplementation frame-var-value (frame var)
1567 (let* ((frame (nth-frame frame))
1568 (dvar (aref (frame-debug-vars frame) var)))
1569 (debug-var-value dvar frame (di:frame-code-location frame))))
1570
1571 (defimplementation frame-catch-tags (index)
1572 (mapcar #'car (di:frame-catches (nth-frame index))))
1573
1574 (defun set-step-breakpoints (frame)
1575 (when (di:debug-block-elsewhere-p (di:code-location-debug-block
1576 (di:frame-code-location frame)))
1577 (error "Cannot step, in elsewhere code~%"))
1578 (let* ((code-location (di:frame-code-location frame))
1579 (debug::*bad-code-location-types*
1580 (remove :call-site debug::*bad-code-location-types*))
1581 (next (debug::next-code-locations code-location)))
1582 (cond (next
1583 (let ((steppoints '()))
1584 (flet ((hook (frame breakpoint)
1585 (let ((debug:*stack-top-hint* frame))
1586 (mapc #'di:delete-breakpoint steppoints)
1587 (let ((cl (di::breakpoint-what breakpoint)))
1588 (break "Breakpoint: ~S ~S"
1589 (di:code-location-kind cl)
1590 (di::compiled-code-location-pc cl))))))
1591 (dolist (code-location next)
1592 (let ((bp (di:make-breakpoint #'hook code-location
1593 :kind :code-location)))
1594 (di:activate-breakpoint bp)
1595 (push bp steppoints))))))
1596 (t
1597 (flet ((hook (frame breakpoint values cookie)
1598 (declare (ignore cookie))
1599 (di:delete-breakpoint breakpoint)
1600 (let ((debug:*stack-top-hint* frame))
1601 (break "Function-end: ~A ~A" breakpoint values))))
1602 (let* ((debug-function (di:frame-debug-function frame))
1603 (bp (di:make-breakpoint #'hook debug-function
1604 :kind :function-end)))
1605 (di:activate-breakpoint bp)))))))
1606
1607 (defimplementation sldb-step (frame)
1608 (cond ((find-restart 'continue)
1609 (set-step-breakpoints (nth-frame frame))
1610 (continue))
1611 (t
1612 (error "No continue restart."))))
1613
1614 (defun frame-cfp (frame)
1615 "Return the Control-Stack-Frame-Pointer for FRAME."
1616 (etypecase frame
1617 (di::compiled-frame (di::frame-pointer frame))
1618 ((or di::interpreted-frame null) -1)))
1619
1620 (defun frame-ip (frame)
1621 "Return the (absolute) instruction pointer and the relative pc of FRAME."
1622 (if (not frame)
1623 -1
1624 (let ((debug-fun (di::frame-debug-function frame)))
1625 (etypecase debug-fun
1626 (di::compiled-debug-function
1627 (let* ((code-loc (di:frame-code-location frame))
1628 (component (di::compiled-debug-function-component debug-fun))
1629 (pc (di::compiled-code-location-pc code-loc))
1630 (ip (sys:without-gcing
1631 (sys:sap-int
1632 (sys:sap+ (kernel:code-instructions component) pc)))))
1633 (values ip pc)))
1634 ((or di::bogus-debug-function di::interpreted-debug-function)
1635 -1)))))
1636
1637 (defun frame-registers (frame)
1638 "Return the lisp registers CSP, CFP, IP, OCFP, LRA for FRAME-NUMBER."
1639 (let* ((cfp (frame-cfp frame))
1640 (csp (frame-cfp (di::frame-up frame)))
1641 (ip (frame-ip frame))
1642 (ocfp (frame-cfp (di::frame-down frame)))
1643 (lra (frame-ip (di::frame-down frame))))
1644 (values csp cfp ip ocfp lra)))
1645
1646 (defun print-frame-registers (frame-number)
1647 (let ((frame (di::frame-real-frame (nth-frame frame-number))))
1648 (flet ((fixnum (p) (etypecase p
1649 (integer p)
1650 (sys:system-area-pointer (sys:sap-int p)))))
1651 (apply #'format t "~
1652 CSP = ~X
1653 CFP = ~X
1654 IP = ~X
1655 OCFP = ~X
1656 LRA = ~X~%" (mapcar #'fixnum
1657 (multiple-value-list (frame-registers frame)))))))
1658
1659
1660 (defimplementation disassemble-frame (frame-number)
1661 "Return a string with the disassembly of frames code."
1662 (print-frame-registers frame-number)
1663 (terpri)
1664 (let* ((frame (di::frame-real-frame (nth-frame frame-number)))
1665 (debug-fun (di::frame-debug-function frame)))
1666 (etypecase debug-fun
1667 (di::compiled-debug-function
1668 (let* ((component (di::compiled-debug-function-component debug-fun))
1669 (fun (di:debug-function-function debug-fun)))
1670 (if fun
1671 (disassemble fun)
1672 (disassem:disassemble-code-component component))))
1673 (di::bogus-debug-function
1674 (format t "~%[Disassembling bogus frames not implemented]")))))
1675
1676
1677 ;;;; Inspecting
1678
1679 (defclass cmucl-inspector (inspector)
1680 ())
1681
1682 (defimplementation make-default-inspector ()
1683 (make-instance 'cmucl-inspector))
1684
1685 (defconstant +lowtag-symbols+
1686 '(vm:even-fixnum-type
1687 vm:function-pointer-type
1688 vm:other-immediate-0-type
1689 vm:list-pointer-type
1690 vm:odd-fixnum-type
1691 vm:instance-pointer-type
1692 vm:other-immediate-1-type
1693 vm:other-pointer-type)
1694 "Names of the constants that specify type tags.
1695 The `symbol-value' of each element is a type tag.")
1696
1697 (defconstant +header-type-symbols+
1698 (flet ((suffixp (suffix string)
1699 (and (>= (length string) (length suffix))
1700 (string= string suffix :start1 (- (length string)
1701 (length suffix))))))
1702 ;; Is there a convinient place for all those constants?
1703 (remove-if-not
1704 (lambda (x) (and (suffixp "-TYPE" (symbol-name x))
1705 (not (member x +lowtag-symbols+))
1706 (boundp x)
1707 (typep (symbol-value x) 'fixnum)))
1708 (append (apropos-list "-TYPE" "VM" t)
1709 (apropos-list "-TYPE" "BIGNUM" t))))
1710 "A list of names of the type codes in boxed objects.")
1711
1712 (defimplementation describe-primitive-type (object)
1713 (with-output-to-string (*standard-output*)
1714 (let* ((lowtag (kernel:get-lowtag object))
1715 (lowtag-symbol (find lowtag +lowtag-symbols+ :key #'symbol-value)))
1716 (format t "lowtag: ~A" lowtag-symbol)
1717 (when (member lowtag (list vm:other-pointer-type
1718 vm:function-pointer-type
1719 vm:other-immediate-0-type
1720 vm:other-immediate-1-type
1721 ))
1722 (let* ((type (kernel:get-type object))
1723 (type-symbol (find type +header-type-symbols+
1724 :key #'symbol-value)))
1725 (format t ", type: ~A" type-symbol))))))
1726
1727 (defimplementation inspect-for-emacs ((o t) (inspector cmucl-inspector))
1728 (cond ((di::indirect-value-cell-p o)
1729 (values "A value cell."
1730 `("Value: " (:value ,(c:value-cell-ref o)))))
1731 (t
1732 (destructuring-bind (text labeledp . parts)
1733 (inspect::describe-parts o)
1734 (values "A value."
1735 (if labeledp
1736 (loop for (label . value) in parts
1737 collect (princ-to-string label)
1738 collect " = "
1739 collect `(:value ,value)
1740 collect '(:newline))
1741 (loop for value in parts
1742 collect `(:value ,value)
1743 collect '(:newline))))))))
1744
1745 (defmethod inspect-for-emacs ((o function) (inspector cmucl-inspector))
1746 (declare (ignore inspector))
1747 (let ((header (kernel:get-type o)))
1748 (cond ((= header vm:function-header-type)
1749 (values "A function."
1750 `("Name: " (:value ,(kernel:%function-name o))
1751 (:newline)
1752 "Arglist: " (:value ,(kernel:%function-arglist o))
1753 (:newline)
1754 ,@(when (documentation o t)
1755 `("Documentation: " (:newline) ,(documentation o t)))
1756 (:newline)
1757 "Self: " (:value ,(kernel:%function-self o))
1758 (:newline)
1759 "Next: " (:value ,(kernel:%function-next o))
1760 (:newline)
1761 "Type: " (:value ,(kernel:%function-type o))
1762 (:newline)
1763 "Code Object: " (:value ,(kernel:function-code-header o)))))
1764 ((= header vm:closure-header-type)
1765 (values "A closure."
1766 (list*
1767 `("Function: " (:value ,(kernel:%closure-function o))
1768 (:newline)
1769 ,@(when (documentation o t)
1770 `("Documentation: " (:newline) ,(documentation o t) (:newline)))
1771 (loop for i from 0 below (- (kernel:get-closure-length o)
1772 (1- vm:closure-info-offset))
1773 collect (princ-to-string i)
1774 collect " = "
1775 collect (:value ,(kernel:%closure-index-ref o i)))))))
1776 (t (call-next-method o)))))
1777
1778 (defmethod inspect-for-emacs ((o kernel:code-component) (inspector cmucl-inspector))
1779 (declare (ignore inspector))
1780 (values "A code data-block."
1781 `("First entry point: " (:value ,(kernel:%code-entry-points o))
1782 (:newline)
1783 "Constants:" (:newline)
1784 ,@(loop for i from vm:code-constants-offset
1785 below (kernel:get-header-data o)
1786 collect (princ-to-string i)
1787 collect " = "
1788 collect `(:value ,(kernel:code-header-ref o i))
1789 collect '(:newline))
1790 "Debug info: " (:value ,(kernel:%code-debug-info o))
1791 (:newline)
1792 "Instructions: " (:value ,(kernel:code-instructions o))
1793 (:newline)
1794 ,@(when (documentation o t)
1795 `("Documentation: " (:newline) ,(documentation o t)))
1796 (:newline))))
1797
1798 (defmethod inspect-for-emacs ((o kernel:fdefn) (inspector cmucl-inspector))
1799 (declare (ignore inspector))
1800 (values "A fdefn object."
1801 `("Name: " (:value ,(kernel:fdefn-name o))
1802 (:newline)
1803 "Function: " (:value ,(kernel:fdefn-function o)))))
1804
1805
1806 ;;;; Profiling
1807 (defimplementation profile (fname)
1808 (eval `(profile:profile ,fname)))
1809
1810 (defimplementation unprofile (fname)
1811 (eval `(profile:unprofile ,fname)))
1812
1813 (defimplementation unprofile-all ()
1814 (profile:unprofile)
1815 "All functions unprofiled.")
1816
1817 (defimplementation profile-report ()
1818 (profile:report-time))
1819
1820 (defimplementation profile-reset ()
1821 (profile:reset-time)
1822 "Reset profiling counters.")
1823
1824 (defimplementation profiled-functions ()
1825 profile:*timed-functions*)
1826
1827 (defimplementation profile-package (package callers methods)
1828 (profile:profile-all :package package
1829 :callers-p callers
1830 #-cmu18e :methods #-cmu18e methods))
1831
1832
1833 ;;;; Multiprocessing
1834
1835 #+mp
1836 (progn
1837 (defimplementation startup-multiprocessing ()
1838 ;; Threads magic: this never returns! But top-level becomes
1839 ;; available again.
1840 (mp::startup-idle-and-top-level-loops))
1841
1842 (defimplementation spawn (fn &key (name "Anonymous"))
1843 (mp:make-process fn :name name))
1844
1845 (defvar *thread-id-counter* 0)
1846
1847 (defimplementation thread-id (thread)
1848 (or (getf (mp:process-property-list thread) 'id)
1849 (setf (getf (mp:process-property-list thread) 'id)
1850 (incf *thread-id-counter*))))
1851
1852 (defimplementation find-thread (id)
1853 (find id (all-threads)
1854 :key (lambda (p) (getf (mp:process-property-list p) 'id))))
1855
1856 (defimplementation thread-name (thread)
1857 (mp:process-name thread))
1858
1859 (defimplementation thread-status (thread)
1860 (mp:process-whostate thread))
1861
1862 (defimplementation current-thread ()
1863 mp:*current-process*)
1864
1865 (defimplementation all-threads ()
1866 (copy-list mp:*all-processes*))
1867
1868 (defimplementation interrupt-thread (thread fn)
1869 (mp:process-interrupt thread fn))
1870
1871 (defimplementation kill-thread (thread)
1872 (mp:destroy-process thread))
1873
1874 (defvar *mailbox-lock* (mp:make-lock "mailbox lock"))
1875
1876 (defstruct (mailbox (:conc-name mailbox.))
1877 (mutex (mp:make-lock "process mailbox"))
1878 (queue '() :type list))
1879
1880 (defun mailbox (thread)
1881 "Return THREAD's mailbox."
1882 (mp:with-lock-held (*mailbox-lock*)
1883 (or (getf (mp:process-property-list thread) 'mailbox)
1884 (setf (getf (mp:process-property-list thread) 'mailbox)
1885 (make-mailbox)))))
1886
1887 (defimplementation send (thread message)
1888 (let* ((mbox (mailbox thread))
1889 (mutex (mailbox.mutex mbox)))
1890 (mp:with-lock-held (mutex)
1891 (setf (mailbox.queue mbox)
1892 (nconc (mailbox.queue mbox) (list message))))))
1893
1894 (defimplementation receive ()
1895 (let* ((mbox (mailbox mp:*current-process*))
1896 (mutex (mailbox.mutex mbox)))
1897 (mp:process-wait "receive" #'mailbox.queue mbox)
1898 (mp:with-lock-held (mutex)
1899 (pop (mailbox.queue mbox)))))
1900
1901 ) ;; #+mp
1902
1903 ;; Local Variables:
1904 ;; pbook-heading-regexp: "^;;;\\(;+\\)"
1905 ;; pbook-commentary-regexp: "^;;;\\($\\|[^;]\\)"
1906 ;; End:

  ViewVC Help
Powered by ViewVC 1.1.5