yet more -v stuff

Matthew Fluet Matthew Fluet <fluet@CS.Cornell.EDU>
Fri, 5 Jan 2001 10:19:46 -0500 (EST)


> + mlton -v -g /tmp/z.sml
> Compile SML starting
>       gcc -DMLton_safe=TRUE -DMLton_detectOverflow=TRUE \
>           -I/home/sweeks/mlton/include -o /tmp/file2OFIne /tmp/file9cOrmH.c \
>           -L/home/sweeks/mlton/lib -lmlton-gdb -lm -lgmp
>       /tmp/file2OFIne /tmp/filed2Xfg4
> Compile SML finished in 2.740
> Compile C starting
>    gcc -S -g -DMLton_safe=TRUE -DMLton_detectOverflow=TRUE \
>        -I/home/sweeks/mlton/include -o /tmp/fileXT1a8i.s /tmp/fileq3na53.c
> Compile C finished in 0.190
> Assemble starting
>    gcc -c -g -o /tmp/filehr2MTK.o /tmp/fileXT1a8i.s
>    gcc -Wa,--gstabs -c -g -o /tmp/fileffLS2e.o /tmp/fileZx94k5.0.S
> Assemble finished in 0.060
> Link starting
>    gcc -g -o /tmp/z /tmp/filehr2MTK.o /tmp/fileffLS2e.o \
>        -L/home/sweeks/mlton/lib -lmlton-gdb -lm -lgmp
> Link finished in 0.140

This looks fine, although I think that the -g in
gcc -Wa,--gstabs -c -g -o /tmp/fileffLS2e.o /tmp/fileZx94k5.0.S
is redundant; but it's probably more trouble than it's worth to remove it
(and it shouldn't hurt).

I discovered yesterday an unfortunate side effect of using .S and -g: all
of the debugging information is relative to the pre-processed temporary
file that gcc creates, which is trashed at the end of the gcc invocation.
This makes debugging assembly files almost useless -- there isn't much to
step through in the .c file, and we can't really get through the assembly
files.

I see two sorts of solutions:
 1. remove the dependence on the preprocessor and emit .s files
    It's only the __LINE__ directive for calls to GC_gc; but when
    I create a call to GC_gc, I haven't a clue where it will end up
    in a file
    One possibility would be to give each invocation of GC_gc a unique
    integer to pass in as the line number; to find the GC_gc corresponding
    to unique number NNN, look for code like:
    
        pushl $NNN
        pushl $fileName
        pushl $0
        pushl %eax
        pushl $gcState
        movl %edi,(gcState+40)
        movl %esi,(gcState+12)
        call GC_gc

 2. add a Preprocess S phase, like

gcc -S -g -DMLton_safe=TRUE -DMLton_detectOverflow=TRUE \
    -I/home/sweeks/mlton/include -o /tmp/z.0.s /tmp/z.0.S