Debugging the RTS
Simon Peyton Jones
simonpj at microsoft.com
Fri May 15 11:17:50 UTC 2015
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.
thanks!
Simon
From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of Lennart Kolmodin
Sent: 15 May 2015 11:31
To: Jost Berthold
Cc: ghc-devs at haskell.org
Subject: Re: Debugging the RTS
Searching for online resources brought me to
https://ghc.haskell.org/trac/ghc/wiki/Debugging and
https://ghc.haskell.org/trac/ghc/wiki/Debugging/RuntimeSystem
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<https://ghc.haskell.org/trac/ghc/wiki/Debugging/RuntimeSystem> page?
2015-05-14 16:21 GMT+02:00 Jost Berthold <berthold at mathematik.uni-marburg.de<mailto:berthold at mathematik.uni-marburg.de>>:
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/ways.mk<http://ways.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 build.mk<http://build.mk> (also see mk/config.mk<http://config.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 haskell.org<mailto:ghc-devs-request at haskell.org> wrote:
Date: Thu, 14 May 2015 18:36:04 +1000
From: Erik de Castro Lopo <mle+hs at mega-nerd.com<mailto:mle%2Bhs at mega-nerd.com>>
To: ghc-devs at haskell.org<mailto:ghc-devs at haskell.org>
Subject: Debugging the RTS
Message-ID: <20150514183604.2476baaaacd6a85ef1430b37 at mega-nerd.com<mailto:20150514183604.2476baaaacd6a85ef1430b37 at mega-nerd.com>>
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/build.mk<http://build.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/ghc.mk<http://ghc.mk> as follows:
-STANDARD_OPTS += -DCOMPILING_RTS
+STANDARD_OPTS += -DCOMPILING_RTS -DDEBUG
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 haskell.org<mailto:ghc-devs at haskell.org>
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20150515/55ae3728/attachment.html>
More information about the ghc-devs
mailing list