specifing user RTS options to GHCi

Simon Marlow simonmar@microsoft.com
Thu, 7 Nov 2002 17:24:38 -0000


> I would like to be able to use the -xc option in ghci, since=20
> this is where
> I do most of my debugging anyway.  I can put
>=20
>   :set -prof -auto-all
>   :set -osuf prof.sun4.o -hisuf prof.sun4.hi
>=20
> in my .ghci file, but I can't get ghci to run my code with -xc
> enabled.  If I try to ":set +RTS -xc", ghci doesn't know this=20
> options; if
> I pass then to ghci on the commandline (i.e., "% ghci +RTS -xc") it
> (rightfully) tells me that ghci wasn't built for profiling.
>=20
> Is there any way to do this and, if not, might it find its way in?

I'm afraid there isn't a way to do this.

The long answer:  GHCi runs the interpreted code on top of the same RTS
as it is running itself, and for -xc to work, that means the RTS has to
be a profiling version.  The profiled version of the RTS differs from
the normal version in several ways: heap objects have an extra field,
info tables have extra fields, and so on.  The bytecode compiler and
interpreter don't have the necessary knowledge to generate and run
bytecode in this different environment.

> p.s., I think the -xc option is seriously undervalued -- I know that I
> didn't know about it for about a year of using ghc even after=20
> asking if
> such a thing could be done in various places (clf, mostly).=20

Yes, we should probably advertise it more.  Please feel free to send us
documentation patches...

> Perhaps it should go in the option list for +RTS?

It is in the option list for +RTS - but only when the binary is compiled
for profiling.

Cheers,
	Simon