stack traces when debugging GHC

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'd love to put this on the wiki. Any clue where this might be found? Richard

Looks like you want
https://ghc.haskell.org/trac/ghc/wiki/Debugging/Compiler - the first
section mentions -DDEBUG, but not -fprof-auto. Probably worth adding a
few sentences about what you've found to the top of the page.
Thanks!
On Sun, Feb 8, 2015 at 8:51 PM, Richard Eisenberg
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'd love to put this on the wiki. Any clue where this might be found?
Richard
_______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://www.haskell.org/mailman/listinfo/ghc-devs
-- Regards, Austin Seipp, Haskell Consultant Well-Typed LLP, http://www.well-typed.com/

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. Cheers, Simon

On 12 Apr 2015, at 04:26, Simon Marlow
wrote: 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.
I think this is a great idea and would really like to see this being the default.
Cheers, Simon _______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

| 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. Sounds desirable to me. It'll only work with profiling, though, of course. Would someone like to do this? At least make a ticket? Simon | -----Original Message----- | From: ghc-devs [mailto:ghc-devs-bounces@haskell.org] On Behalf Of Simon | Marlow | Sent: 11 April 2015 21:27 | To: Richard Eisenberg; ghc-devs@haskell.org Devs | Subject: Re: stack traces when debugging GHC | | 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. | | Cheers, | Simon | _______________________________________________ | ghc-devs mailing list | ghc-devs@haskell.org | http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

Posted as #10303. Comments welcome.
On Apr 13, 2015, at 7:57 AM, Simon Peyton Jones
| 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.
Sounds desirable to me. It'll only work with profiling, though, of course.
Would someone like to do this? At least make a ticket?
Simon
| -----Original Message----- | From: ghc-devs [mailto:ghc-devs-bounces@haskell.org] On Behalf Of Simon | Marlow | Sent: 11 April 2015 21:27 | To: Richard Eisenberg; ghc-devs@haskell.org Devs | Subject: Re: stack traces when debugging GHC | | 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. | | Cheers, | Simon | _______________________________________________ | ghc-devs mailing list | ghc-devs@haskell.org | http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
participants (5)
-
Austin Seipp
-
Moritz Angermann
-
Richard Eisenberg
-
Simon Marlow
-
Simon Peyton Jones