[Ecls-list] Line Number of errors ?

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Sat Jul 12 17:51:35 UTC 2008


On Thu, Jul 10, 2008 at 12:21 AM, Tobias C. Rittweiler <tcr at freebits.de> wrote:
>> My current idea is the following: I will add a form (REGISTER-SOURCE
>> object file position). REGISTER-SOURCE will be a macro that will, by
>> default, expand to (PROGN) and, in case you redefine it through slime,
>> it may give rise to a more complicated registration into a database
>> that Slime can use.
>
> This sounds fine. Thanks for your work!

Ok, it is finished. Now there is a global variable
EXT:*REGISTER-WITH-PDE-HOOK* which must contain a function with three
arguments: the file location, the form which is being registered and
an output form. This function has to build a lisp form that, when
executed, does the appropriate job of registering the variable,
function, class, etc, with your database of debug information. The
lisp form has to be such that it executes the output form and returns
its values.

A simple example follows. There are mistakes, since it does not delete
duplicate records, etc.

Juanjo

----- pde.lisp ---

(eval-when (:compile-toplevel :execute :load-toplevel)
  (setf ext:*register-with-pde-hook* nil))

(defparameter *pde-debug-information*
  (make-hash-table :size 128 :test #'eql))

(defun expand-registration-form (location definition output-form)
  (let* ((keyword (first definition))
	 (information (and (member keyword '(DEFUN DEFMACRO)) (third definition)))
	 (name (second definition))
	 (ext:*register-with-pde-hook* nil))
    (format t "~&;;; Registration of: ~S @ ~S" definition location)
    `(progn
       (do-register-debug-information ',name ',keyword ',location ',information)
       ,output-form)))

(defun do-register-debug-information (name keyword location information)
  (let* ((record (gethash name *pde-debug-information*))
	 (ext:*register-with-pde-hook* nil))
    (setf record
	  (cons (list* keyword location information)
		(delete 'DEFMACRO record :key #'first)))
    (format t "~&;;; Registered ~A" record)
    (setf (gethash name *pde-debug-information*) record)
    (values)))

(setf ext:*register-with-pde-hook* 'expand-registration-form)


---- foo.lisp ----
(defun foo (x)
  (cos (+ x 2)))

(defclass a () ())

(defvar *b* "Hola")


--------

> (load "pde.lisp") (compile-file "foo") (load "foo.fas")
;;; Loading "/Users/jjgarcia/src/ecl/build/pde.lisp"
"/Users/jjgarcia/src/ecl/build/pde.lisp"
> ;;; Compiling foo.
;;; Compiling (DEFUN FOO ...).
;;; Registration of: (DEFUN FOO (X) (COS (+ X 2))) @ (#P"foo.lisp" . 0)
;;; Compiling (DEFCLASS A ...).
;;; Registration of: (DEFCLASS A NIL NIL) @ (#P"foo.lisp" . 1)
;;; Registered ((DEFCLASS (foo.lisp . 1)))
;;; Compiling (DEFVAR *B* ...).
;;; Registration of: (DEFVAR *B* "Hola") @ (#P"foo.lisp" . 2)
;;; End of Pass 1.
;;; Note: Emiting FUNCALL for DO-REGISTER-DEBUG-INFORMATION
;;; Emitting code for FOO.
;;; Note: Emiting FUNCALL for DO-REGISTER-DEBUG-INFORMATION
;;; Note: Emiting FUNCALL for DO-REGISTER-DEBUG-INFORMATION
;;; Calling the C compiler...
;;; Note: Invoking external command:
;;; gcc  -g -O2 -fPIC -fno-common  -Ddarwin -O
"-I/Users/jjgarcia/include/" -w -c
"/Users/jjgarcia/src/ecl/build/foo.c" -o
"/Users/jjgarcia/src/ecl/build/foo.o"
;;; Note: Invoking external command:
;;; gcc -o "/Users/jjgarcia/src/ecl/build/foo.fas"
-L"/Users/jjgarcia/lib/" "/Users/jjgarcia/src/ecl/build/foo.o"
-bundle    -lecl   -lm
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=0
;;; Finished compiling foo.
#P"/Users/jjgarcia/src/ecl/build/foo.fas"
NIL
NIL
> ;;; Loading "/Users/jjgarcia/src/ecl/build/foo.fas"
;;; Registered ((DEFUN (foo.lisp . 0) X))
;;; Registered ((DEFCLASS (foo.lisp . 1)))
;;; Registered ((DEFVAR (foo.lisp . 2)))
"/Users/jjgarcia/src/ecl/build/foo.fas"
>

-- 
Facultad de Fisicas, Universidad Complutense,
Ciudad Universitaria s/n Madrid 28040 (Spain)
http://juanjose.garciaripoll.googlepages.com




More information about the ecl-devel mailing list