[plt-scheme] Getting stack traces

From: Robby Findler (robby at cs.uchicago.edu)
Date: Mon Mar 17 12:37:16 EST 2003

There are two things to do. First, separate your code (as much as
possible) from the tool that wires it into DrScheme and test it there.
That's probably the easiest thing to do and will help the most with
long term maintenence. 

Assuming that you've already done that, you want to use the PLTDRDEBUG
environment variable. It's documented in the drscheme manual, but the
idea is that you throw away *all* of your .zo files (run setup-plt -c),
set the environment variable, and then drscheme installs errortrace for
all of its code as it starts up. This takes a while, so you don't want
to use it lightly. This is also setup for profiling, which makes it yet
slower (set the variable to have the value "profile" without the

In some sense, the PLTDRDEBUG environment variable turns on a mode in
drscheme that corresponds to turning on the "debugging" checkbox in the
language dialog. You could also do that, but you still have to throw
away your .zo files in that case.

You don't want to (require (lib "errortrace.ss" "errortrace")) in the
front of your module. Ever. It makes no sense -- in fact, requiring
that library has a side-effect -- one the mzscheme compiler, no less.
Sadly, by the time that the side-effect happens (in the case you are
using the require in your module) your code is already compiled so it
does nothing for you. It only makes sense at the toplevel, where
evaluation and compilation are interleaved.


At 17 Mar 2003 12:26:27 -0500, Guillaume Marceau wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> Hello list,
> I am writing a type checker for DrScheme. I am packaging it as a tool,
> just like the current Syntax Checker. That mean I am loading it
> throught the PLTCOLLECTS environment variable and I have a spiffy
> button on DrScheme's toolbar.
> Unfortunatly, if I make a mistake and DrScheme crashes while running my
> type checking code, I get very little information about the crash. For
> instance, I just fixed the following mistake:
>   (define (fn-type? typ) 
>     (and (list typ)  ;;;;   <---  missing "?" !
>          (eq? (first typ) '->)))
> When running, it looks like :
>   # /home/gmarceau/collects/type-checker/ > drscheme ass2.ss
>      < The DrScheme's windows comes up, and I click on the button >
>   Begin traversal... 
>   first: expects argument of type <non-empty list>; given v1
> Without a line number for the crash, I had to binary search down my code
> using calls to display. Certainly less than optimal.
> I tried loading errortrace.ss :
>   (module unifier mzscheme
>     (require "base-gm.ss"
>              "hash-union.ss"
>              "env.ss"
>              "graph.ss"
>              (lib "errortrace.ss" "errortrace"))
>     ...)
> Yes that did not seem to work. I've read throught
> collects/errortrace/doc.txt, but I could not find what I am doing
> wrong (if anything). I'm using 'expand-program' to walk throught the ast
> of the text of the current the program window. Maybe that has something to
> do with the problem.
> I figured if I could start a DrScheme within DrScheme, and click on my
> Type Check button in the embeeded DrScheme, the first DrScheme would give
> me a clickable stack trace. Does anyone know how to do that?
> -- 
>   "In Google non est, ergo non est." 
> - Guillaume

Posted on the users mailing list.