[comp.lang.scheme] debugging compiled code

ram@wb1.cs.cmu.edu (Rob MacLachlan) (08/31/90)

[Is Common Lisp a Scheme dialect?  Probably not, though it meets most of Guy's
criteria.  Anyway, all the interesting Lisp discussion is on
comp.lang.scheme.]

The new CMU Common Lisp system (based on Python, the compiler I wrote)
supports source-level debugging of compiled code.  The capabilities we
currently have are are:
 -- Access of variables by name in compiled code.
 -- Evaluation (in the lexical context of a compiled frame) of forms
    containing arbitrary variable references or assignments.
 -- Precise lifetime information for variables, so that incorrect variable
    values are never displayed due to not being initialized or because the
    location was reused.
 -- Can display the exact source form responsible generating the code at the
    locations seen in the debugger.
 -- Little speed penalty for debuggability.  Nearly all optimizations can be
    done almost invisibly.  Global register allocation of variables is always
    done.
 -- The source level debug-info increases object size about 2x (but of course
    the debug-info is rarely part of the resident set.)

Other features like an "edit this error location" command and an ability to
set breakpoints inside functions are just a small matter of programming.

For example, here is a debugger session using this function:
    (defun test (n)
      (declare (type (integer 0 42) n))
      (when (= n 7)
	(setq n (* n n)))
      (dotimes (i n (1+ -))
	(print i)))

________________________________________________________________
* (test 3)

0 
1 
2 

Error in function TEST.
Wrong type argument, (TEST 3), should have been of type NUMBER.

Restarts:
  0: Return to Top-Level.

Debug  (type H for help)

(TEST 3)
7] source

File: /afs/cs.cmu.edu/project/clisp/new-compiler/tests/bar.lisp

(1+ -) 
7] vsource 2

File: /afs/cs.cmu.edu/project/clisp/new-compiler/tests/bar.lisp

(DOTIMES (I N (#:***HERE*** (1+ -))) (PRINT I)) 
7] q
* (test 7)

Error in function TEST.
Wrong type argument, 49, should have been of type (MOD 43).

Restarts:
  0: Return to Top-Level.

Debug  (type H for help)

(TEST 7)
7] source

File: /afs/cs.cmu.edu/project/clisp/new-compiler/tests/bar.lisp

(SETQ N (* N N)) 
7] (* n n)
49
7] 
________________________________________________________________


The compiler is also optimizing and portable and tail-recursive and block
compiling and all that stuff.  The main other unique feature is the level of
type checking and type inference done.  All type declarations are precisely
checked in safe code (like (integer 42)).  In the above example, fixnum
arithmetic is used for the loop index based on the range of the iteration
count.  DOTIMES is just an ordinary macro.

CMU Common Lisp is in the public domain (i.e. free, and you can copyright,
copyleft, copyup, ...)  The Python compiler system currently only runs under
Mach on the DEC PMAX and IBM RT PC, and is not yet released.  When it is,
we'll let you know.  I suppose we may be getting to the point where we would
consider distributing sources to people seriously interested in doing ports.
We don't currently have any distribution mechanism or porting documentation,
and a port is a major undertaking (expert man months.)

Rob MacLachlan (ram@cs.cmu.edu)  

The CMU Common Lisp Project:
    Making the world safe for symbolic programming...

thompson@CEBAF4.CEBAF.GOV (Al Thompson) (08/31/90)

How doth one acquire CMU Common Lisp? Will it be made available
on an FTP site somewhere. Also, I am interested in porting CMU
to the NeXTStep environment and would like to know how I can get 
CMU sources.