Debugging the RTS

Jost Berthold berthold at
Fri May 15 12:12:20 UTC 2015

On 05/15/2015 09:17 PM, Simon Peyton Jones wrote:
> Good idea.  I think it’d great if Jost (or someone else) felt able to
> update those wiki pages with the info in his email.

Sure, will do that.
I am not sure whether either of those pages is the best place for 
information about the GHC ways. Maybe there is already a page about them 
in the commentary - I will take a look tomorrow and add the information 
about ways from the mail. If no page exists I'll add a page, and link to 
it from the Debugging/RuntimeSystem page.

A few years ago, I wrote one page specifically about the parallel ways,
but the information is outdated.

/ Jost

> thanks!
> Simon
> *From:*ghc-devs [mailto:ghc-devs-bounces at] *On Behalf Of
> *Lennart Kolmodin
> *Sent:* 15 May 2015 11:31
> *To:* Jost Berthold
> *Cc:* ghc-devs at
> *Subject:* Re: Debugging the RTS
> Searching for online resources brought me to
> and
> This mail seems to be a more detailed description than available on the
> wiki. That page refers to GHC 6.12.
> Would it make sense to add some info to the RuntimeSystem
> <> page?
> 2015-05-14 16:21 GMT+02:00 Jost Berthold
> <berthold at
> <mailto:berthold at>>:
>     Hi Eric,
>     definitely not bit-rotted - the #if DEBUG code is what you get when
>     you compile with -debug.
>     Short roadmap:
>     In general, GHC is built in many "ways", the -debug way is one.
>     Some ways (like -threaded, -eventlog, -debug) are RTS-only, others
>     (like -prof) lead to different library code.
>     Ways are defined in compiler/main/DynFlags.hs as a Haskell data
>     structure.
>     In _dynamic_flags_, the actual flag strings for the ghc invocation
>     are defined (like -prof, -threaded), they will activate the
>     respective _Way_.
>     _wayTag_, in turn, defines short names used as a suffix for *.o and
>     *.a files, for instance *.p_o for profiling, *.l_o for eventlog.
>     A number of other functions in there customise behaviour depending
>     on the ways. Note _wayOptc_ which sets some options for the C
>     compiler, like -DTRACING for the -eventlog way. However, it does not
>     define DEBUG for the debug way!
>     In mk/ <> you will find all the short names,
>     and some more options are defined (WAY_*_HC_OPTS). These definitions
>     are for the driver script, and pass on the right (long-name) options
>     to the Haskell compiler to activate what is inside DynFlags (like
>     -prof for WAY_p_HC_OPTS).
>     Here we find
>     WAY_debug_HC_OPTS= -static -optc-DDEBUG -ticky -DTICKY_TICKY
>     which is what you were looking for
>     To build a GHC with debug-way RTS, you need to add GhcRtsWays +=
>     debug to your <> (also see mk/
>     <>{.in}, which gathers the default ways to build
>     depending on platform and build configuration).
>     I guess this might produce quite a number of new warnings and errors
>     if you do it on a new platform...
>     Once you have built this, you can compile with -debug and pass RTS
>     options to get debug traces and activate sanity checks, like so:
>     ghc -debug -myprogram.hs -o myprogramDebug
>     ./myprogramDebug +RTS -Ds -DS
>     (-DS = sanity checks on, -Ds = scheduler tracing)
>     The usage message (see /rts/RtsFlags.c) tells you more options you
>     can use.
>     Happy debugging!
>     / Jost
>     On 05/14/2015 10:00 PM, ghc-devs-request at
>     <mailto:ghc-devs-request at> wrote:
>         Date: Thu, 14 May 2015 18:36:04 +1000
>         From: Erik de Castro Lopo <mle+hs at
>         <mailto:mle%2Bhs at>>
>         To: ghc-devs at <mailto:ghc-devs at>
>         Subject: Debugging the RTS
>         Message-ID:
>         <20150514183604.2476baaaacd6a85ef1430b37 at
>         <mailto:20150514183604.2476baaaacd6a85ef1430b37 at>>
>         Content-Type: text/plain; charset=US-ASCII
>         Hi all,
>         I'm trying to debug a AArch64/Linux specific RTS issue and digging
>         around in the rts C code, I see a large amount of code wrapped in
>         "#if DEBUG" type statements, but no way to enable in either
>         mk/ <> or it seems in any of the other
>         build related settings
>         files in the mk/ directory.
>         The only way I have found to enable this debug code that actually
>         works is to enable this DEBUG code is to edit mk/
>         <> as follows:
>         However, once I do that I get a bunch of C synatx errors.
>         I am doing this wrong or has the DEBUG code bit rotted?
>         Cheers,
>         Erik
>     _______________________________________________
>     ghc-devs mailing list
>     ghc-devs at <mailto:ghc-devs at>

More information about the ghc-devs mailing list