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 (:constructor %make-definition-source-location
16 (namestring toplevel-form-number form-number
))
18 (:make-load-form-fun just-dump-it-normally
))
19 ;; Namestring of the source file that the definition was compiled from.
20 ;; This is null if the definition was not compiled from a file.
21 (namestring nil
:type
(or string null
) :read-only t
)
22 ;; Toplevel form index
23 (toplevel-form-number nil
:type
(or fixnum null
) :read-only t
)
24 ;; DFO form number within the top-level form
25 (form-number nil
:type
(or fixnum null
) :read-only t
)
26 ;; plist from WITH-COMPILATION-UNIT
27 (plist *source-plist
* :read-only t
))
29 (defun make-definition-source-location ()
30 (let* ((source-info (and (boundp '*source-info
*) *source-info
*))
32 (or *source-namestring
*
34 (make-file-info-namestring
35 *compile-file-pathname
*
36 (get-toplevelish-file-info *source-info
*)))))
39 (last (and source-info
40 (source-info-last-defn-source-loc source-info
))))
41 (acond ((boundp '*current-path
*)
42 (setf tlf-number
(source-path-tlf-number *current-path
*)
43 form-number
(source-path-form-number *current-path
*)))
44 ((and source-info
(source-info-file-info source-info
))
45 (setf tlf-number
(1- (fill-pointer (file-info-forms it
))))))
46 ;; FIXME: Probably can never coalesce entries now that both a tlf number
47 ;; and subform number are stored. Maybe delete this.
49 (eql (definition-source-location-toplevel-form-number last
) tlf-number
)
50 (eql (definition-source-location-form-number last
) form-number
)
51 (string= (definition-source-location-namestring last
) namestring
)
52 (equal (definition-source-location-plist last
) *source-plist
*))
54 (let ((new (%make-definition-source-location namestring tlf-number form-number
)))
56 (setf (source-info-last-defn-source-loc source-info
) new
))
60 (defun lpnify-namestring (untruename dir type
)
61 (let ((src (position "src" dir
:test
#'string
= :from-end t
)))
63 ((and src
(not (string= (car (last dir
)) "output")))
64 (format nil
"SYS:~{~:@(~A~);~}~:@(~A~).~:@(~A~)"
65 (subseq dir src
) (pathname-name untruename
) type
))
66 (t (aver (string-equal (car (last dir
)) "output"))
67 (aver (string-equal (pathname-name untruename
) "stuff-groveled-from-headers"))
68 (format nil
"SYS:OUTPUT;STUFF-GROVELED-FROM-HEADERS.~:@(~A~)" type
)))))
70 (defun make-file-info-namestring (name file-info
)
71 #+sb-xc-host
(declare (ignore name
))
72 (let* ((untruename (file-info-untruename file-info
))
73 (dir (and untruename
(pathname-directory untruename
))))
75 (lpnify-namestring untruename dir
(pathname-type untruename
))
77 (if (and dir
(eq (first dir
) :absolute
))
78 (namestring untruename
)