[Haskell-cafe] Re: HPC for debugging (Was Re: GHCi Debugger

Don Stewart dons at galois.com
Fri Jul 11 00:38:15 EDT 2008


thomas.dubuisson:
> > I could try GHC's new debugger. But my experiences with it so far have 
> > shown that for all but the most trivial programs possible, it becomes 
> > intractably difficult to figure out what the debugger is actually 
> > showing you. 
> 
> At times I think of ghcid as the anti-gdb.  If there's a series of let
> bindings, each mutating the predecessor, its enjoyable to see the
> debugger start at the bottom and crawl its way back up.

I'd like to relate a debugging effort this week. A colleague had an
exception thrown from deep within a large body of code, we knew not where. 
A few trace statements didn't yield much information. The debugger was
fired up on this >50 module program, and we got a few interesting hints
and pieces, but it seemed as if the exception was floating away from its
call site, to the point it was being demanded. Hmm. A puzzle.

So instead we compiled the application with -fhpc, ran it till the
exception occured, and then ran hpc markup on the result. (This marks up
the program source in colours showing what code was actually executed
during a given program run).

Loading the colourised trace into firefox, we saw at a glance all the
code that had been executed up to the point of the exception, and then
there was the exception itself, staring at us amongst a chunk of bright
yellow code, a lone streak of uncoloured code where it shouldn't have
been.

It took all of 5 seconds to find the bug with HPC.    

-- Don


More information about the Haskell-Cafe mailing list