[MLton] debugging
Matthew Fluet
fluet@cs.cornell.edu
Tue, 15 Nov 2005 11:55:34 -0500 (EST)
>> Oh, there was never an issue with emitting .stabs data, its rather that we
>> don't have any reasonable data to emit. We don't carry source variable
>> location beyond type-checking, and it isn't clear how to carry such info
>> though all the optimization passes.
>
> Can't you just add a new intrinsic?
Sure, but it is orders of magnitude more work to decide _how_ to handle
this new primitive in each and every pass of the compiler.
> fun f(x) = let
> val x = 1
> val y = 2
> in
> Debug.info(<file name>,line,[I x,I y]);
> x + y
> end
>
> just treat Debug.info pesmisticlly as a effectful function (yeah, I know that
> disables optimizations). So long as your compler is semantics preserving
> (i.e. it's not buggy) you can just reverse engineer the stack by looking at
> what is passed to the intrinsic functions.
Fine for integers, but what info are you going to generate for:
datatype 'a t = T of 'a state ref
and 'a state =
Unevaluated of unit -> 'a
| Evaluating
| Evaluated of 'a
fun delay th =
let
val state = Unevaluated th
val promise = T (ref state)
in
Debug.info(<file name>,line,[??? state,??? promise]);
promise
end