[plt-scheme] errotrace in 4.0?

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Sep 14 20:43:33 EDT 2008

On Sep 14, Jon Rafkind wrote:
> Eli Barzilay wrote:
> > On Sep 14, Jon Rafkind wrote:
> >   
> >> Nothing happens if I give '-l errortrace' on the command line, and I 
> >> mean my program isn't even run.
> >> $ mzscheme -l errortrace x.ss

Going back to this, it doesn't run your code because you specify a
flag to load errortrace, but no flag to load your code.  Your code is
loaded only if you specify only configuration options before your
file, and `-l' is not a configuration option.  But in any case, I
missed the fact that you want the profiler.

> > http://docs.plt-scheme.org/errortrace/quick-instructions.html
> >
> * Throw away ".zo" versions of your source.
> Done


> * mzscheme -l errortrace ...
> Tried that, doesn't work

Same as above.

> *  (require errortrace)
> Tried that, doesn't work

In the previous email you've put this inside the module -- but that's
too late.  The errortrace tool sets up evaluation hooks to instrument
the code, which is a form of a side-effect, and must be done before
you load the code.  This is what this:

> * The errortrace module is strange; don?t import it into another
>   module. Instead, the errortrace module is meant to be invoked from
>   the top-level, so that it can install an evaluation handler,
>   exception handler, etc.

is telling you to do.

> Ok, so maybe if I run a repl it will work
> $ mzscheme
>  > (require errortrace)
>  > (require "x.ss")
> Same output as before.

Right -- this is because, as the docs say, "Errortrace?s profiling
instrumentation is #f by default".

You need to begin mzscheme and load errortrace like you did here, or
by running "mz -il errortrace", then turn on profiling, then load &
run your code:

  winooski:/tmp eli> mz -il errortrace
  Welcome to MzScheme v4.1.0.3 [3m], Copyright (c) 2004-2008 PLT Scheme Inc.
  -> (profiling-enabled #t)
  -> (require "x.ss")
  -> (output-profile-results #t #t)
  Sorting profile data...
  time = 0 : no. = 201 : foo in #<syntax:/tmp/x.ss:7:0>
  time = 0 : no. = 1 : #f in #<syntax:/tmp/x.ss:12:0>
  Total samples: 0

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.