[Haskell-cafe] How to debug GHC

Nils Anders Danielsson nad at cs.chalmers.se
Fri Sep 2 02:47:05 EDT 2005


On Thu, 01 Sep 2005, Frederik Eaton <frederik at a5.repetae.net> wrote:

> But getting a stack backtrace when there is an error should be a
> pretty basic feature. It's very hard to debug a large program when you
> can randomly get messages like "*** Exception: Prelude.head: empty
> list" and have no idea where they came from.

>From the GHC FAQ:

My program is failing with head [], or an array bounds error, or some
other random error, and I have no idea how to find the bug. Can you
help?

    Compile your program with -prof -auto-all (make sure you have the
    profiling libraries installed), and run it with +RTS -xc -RTS to
    get a “stack trace” at the point at which the exception was
    raised. See Section 4.14.4, “RTS options for hackers, debuggers,
    and over-interested souls” for more details.

I tried this out under GHC 6.4/Linux and got a segmentation fault
instead of a stack trace. Under GHC 6.2.2 it seemed to work, though.

-- 
/NAD



More information about the Haskell-Cafe mailing list