stack traces when debugging GHC
marlowsd at gmail.com
Sat Apr 11 20:26:48 UTC 2015
On 09/02/2015 02:51, Richard Eisenberg wrote:
> Hi devs,
> I've just made a miraculous discovery and I want to share!
> It has happened many times that I create some bizarre error in GHC and have no clue where it comes from. In the past, I've ended up using pprTrace to label all calls of the failing function, sometimes recursively, until I get an idea of what's going on. This is terribly painful. And then, I noticed that the function Debug.Trace.traceStack (just in the `base` package, not part of GHC) will print out a stack trace, when profiling is enabled. So, I tried building a profiled build of GHC, with -DDEBUG and -fprof-auto (just by editing the "prof" section of build.mk).
> And then, voila, ASSERTs now print stack traces! And, with a small change in Outputable, I can get pprTrace to print stack traces, too! Hooray!
I should have advertised this more widely, thanks for pointing it out.
> I'd love to put this on the wiki. Any clue where this might be found?
I see you've added a reference buried in Debugging/Compiler. Why don't
we just make traceStack the default? Perhaps with a flag to disable (or
enable) the stack trace.
More information about the ghc-devs