<div dir="ltr"><div>Searching for online resources brought me to </div><div><a href="https://ghc.haskell.org/trac/ghc/wiki/Debugging">https://ghc.haskell.org/trac/ghc/wiki/Debugging</a> and</div><div><div><a href="https://ghc.haskell.org/trac/ghc/wiki/Debugging/RuntimeSystem">https://ghc.haskell.org/trac/ghc/wiki/Debugging/RuntimeSystem</a></div></div><div><br></div>This mail seems to be a more detailed description than available on the wiki. That page refers to GHC 6.12.<div>Would it make sense to add some info to the <a href="https://ghc.haskell.org/trac/ghc/wiki/Debugging/RuntimeSystem">RuntimeSystem</a> page?</div><div><div class="gmail_extra"><br><div class="gmail_quote">2015-05-14 16:21 GMT+02:00 Jost Berthold <span dir="ltr"><<a href="mailto:berthold@mathematik.uni-marburg.de" target="_blank">berthold@mathematik.uni-marburg.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Eric,<br>
<br>
definitely not bit-rotted - the #if DEBUG code is what you get when you compile with -debug.<br>
<br>
Short roadmap:<br>
<br>
In general, GHC is built in many "ways", the -debug way is one.<br>
Some ways (like -threaded, -eventlog, -debug) are RTS-only, others (like -prof) lead to different library code.<br>
<br>
Ways are defined in compiler/main/DynFlags.hs as a Haskell data structure.<br>
In _dynamic_flags_, the actual flag strings for the ghc invocation are defined (like -prof, -threaded), they will activate the respective _Way_.<br>
_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.<br>
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!<br>
<br>
In mk/<a href="http://ways.mk" target="_blank">ways.mk</a> 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).<br>
Here we find<br>
WAY_debug_HC_OPTS= -static -optc-DDEBUG -ticky -DTICKY_TICKY<br>
which is what you were looking for<br>
<br>
To build a GHC with debug-way RTS, you need to add GhcRtsWays += debug to your <a href="http://build.mk" target="_blank">build.mk</a> (also see mk/<a href="http://config.mk" target="_blank">config.mk</a>{.in}, which gathers the default ways to build depending on platform and build configuration).<br>
I guess this might produce quite a number of new warnings and errors if you do it on a new platform...<br>
<br>
Once you have built this, you can compile with -debug and pass RTS options to get debug traces and activate sanity checks, like so:<br>
ghc -debug -myprogram.hs -o myprogramDebug<br>
./myprogramDebug +RTS -Ds -DS<br>
(-DS = sanity checks on, -Ds = scheduler tracing)<br>
The usage message (see /rts/RtsFlags.c) tells you more options you can use.<br>
<br>
Happy debugging!<br>
/ Jost<br>
<br>
<br>
On 05/14/2015 10:00 PM, <a href="mailto:ghc-devs-request@haskell.org" target="_blank">ghc-devs-request@haskell.org</a> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Date: Thu, 14 May 2015 18:36:04 +1000<br>
From: Erik de Castro Lopo <<a href="mailto:mle%2Bhs@mega-nerd.com" target="_blank">mle+hs@mega-nerd.com</a>><br>
To: <a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
Subject: Debugging the RTS<br>
Message-ID: <<a href="mailto:20150514183604.2476baaaacd6a85ef1430b37@mega-nerd.com" target="_blank">20150514183604.2476baaaacd6a85ef1430b37@mega-nerd.com</a>><br>
Content-Type: text/plain; charset=US-ASCII<span class=""><br>
<br>
Hi all,<br>
<br>
I'm trying to debug a AArch64/Linux specific RTS issue and digging<br>
around in the rts C code, I see a large amount of code wrapped in<br>
"#if DEBUG" type statements, but no way to enable in either<br>
mk/<a href="http://build.mk" target="_blank">build.mk</a> or it seems in any of the other build related settings<br>
files in the mk/ directory.<br>
<br>
The only way I have found to enable this debug code that actually<br>
works is to enable this DEBUG code is to edit mk/<a href="http://ghc.mk" target="_blank">ghc.mk</a> as follows:<br>
<br>
-STANDARD_OPTS += -DCOMPILING_RTS<br>
+STANDARD_OPTS += -DCOMPILING_RTS -DDEBUG<br>
<br>
However, once I do that I get a bunch of C synatx errors.<br>
<br>
I am doing this wrong or has the DEBUG code bit rotted?<br>
<br>
Cheers,<br>
Erik<br>
<br>
</span></blockquote><div class=""><div class="h5">
<br>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</div></div></blockquote></div><br></div></div></div>