[MLton] debugging

Daniel C. Wang danwang@CS.Princeton.EDU
Tue, 15 Nov 2005 08:01:03 -0800


Matthew Fluet wrote:
{stuff deleted}

> 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?
i.e. given

fun f(x) = let
 val x = 1
 val y = 2
in
x + y
end

Can be translated to as early as possible


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.