[Haskell-cafe] How to debug GHC
Donn Cave
donn at drizzle.com
Fri Sep 2 13:28:58 EDT 2005
On Fri, 2 Sep 2005 dagit at eecs.oregonstate.edu wrote:
...
> I was trying to debug a smallish program where I was getting this exact error
> and the trick with profiling did "work" on my system, but I remember it being
> almost useless for me. What what did end up working for me was:
> myhead :: [a] -> String -> a
> myhead [] s = error s
> myhead xs _ = head xs
>
> And then I did a M-x occur head <RET>, replaced all the calls to head with
> |myhead xs "myhead callsite n"| and incremented n appropriately.
>
> This technique is pedestrian, but it generalizes quite well and it will work in
> any situation given enough time to do all the search/replace. There are
> certainly better methods and it's not a replacement for a real debugger, but
> this one is easy for a beginner to come up with and it does work.
Just more or less as an aside, at its origin in April (!) this thread
didn't mention any debugger - the question was just how to build ghc
so that a stack trace would come out. A real debugger is no replacement
for that (because you have to be on hand and know how to repeat the problem
to get anywhere with a debugger), but that's just my opinion.
Donn Cave, donn at drizzle.com
More information about the Haskell-Cafe
mailing list