1 ;;;; Source location tracking.
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
14 (def!struct (definition-source-location
15 (:make-load-form-fun sb!kernel:just-dump-it-normally))
16 ;; Namestring of the source file that the definition was compiled from.
17 ;; This is null if the definition was not compiled from a file.
19 (when (and (boundp '*source-info*)
21 (make-file-info-namestring *compile-file-pathname*
22 (sb!c:get-toplevelish-file-info *source-info*)))
23 :type (or string null))
24 ;; Toplevel form index
26 (when (boundp '*current-path*)
27 (source-path-tlf-number *current-path*))
28 :type (or fixnum null))
29 ;; plist from WITH-COMPILATION-UNIT
30 (plist *source-plist*))
32 (defun make-file-info-namestring (name file-info)
33 #+sb-xc-host (declare (ignore name))
34 (let* ((untruename (file-info-untruename file-info))
35 (dir (and untruename (pathname-directory untruename))))
37 (let ((src (position "src" dir :test #'string=
40 (format nil "SYS:~{~:@(~A~);~}~:@(~A~).LISP"
41 (subseq dir src) (pathname-name untruename))
42 ;; FIXME: just output/stuff-groveled-from-headers.lisp
43 (namestring untruename)))
45 (if (and dir (eq (first dir) :absolute))
46 (namestring untruename)
51 #!+sb-source-locations
52 (define-compiler-macro source-location (&environment env)
53 (declare (ignore env))
54 #-sb-xc-host (make-definition-source-location))
56 ;; We need a regular definition of SOURCE-LOCATION for calls processed
57 ;; during LOAD on a source file while *EVALUATOR-MODE* is :INTERPRET.
58 #!+sb-source-locations
59 (setf (symbol-function 'source-location)
60 (lambda () (make-definition-source-location)))
62 (/show0 "/Processing source location thunks")
63 #!+sb-source-locations
64 (dolist (fun *source-location-thunks*)
67 ;; Unbind the symbol to ensure that we detect any attempts to add new
69 (makunbound '*source-location-thunks*)
70 (/show0 "/Done with source location thunks")