Changes between Version 3 and Version 4 of Building/DebuggingGHC


Ignore:
Timestamp:
Aug 27, 2009 11:03:40 AM (6 years ago)
Author:
simonmar
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Building/DebuggingGHC

    v3 v4  
    1 = Debugging GHC =
    2 
    3 This page is about strategies that may help you find a bug in GHC or its runtime system.
    4 
    5 == At compile time ==
    6 
    7 At compile time (see also the [http://www.haskell.org/ghc/docs/latest/html/users_guide/options-debugging.html relevant User Manual section]):
    8 
    9  * Add `-dcore-lint` the GHC command line when compiling each Haskell module.  This makes GHC type-check the intermediate program after every optimisation pass, which often nails a fault.
    10 
    11  * Add `-ddump-simpl` to see the optimised Core output.  There are a number of other `-ddump-x` flags; see the user manual.
    12 
    13  * The flag `-dppr-debug` makes the `-ddump-x` flags print much more verbose output.  Use this if you are getting desperate!
    14 
    15 == At link time ==
    16 
    17  * Add `-debug` to the GHC command line when linking. This links the program against a special version of the runtime system that does lots of extra internal consistency checking.  Overall performance is significantly reduced.  '''Simon: any flags?'''
    18 
    19 == At run time ==
    20 
    21 At run time (see also the [http://www.haskell.org/ghc/docs/latest/html/users_guide/runtime-control.html#rts-options-debugging  relevant User Manual section]):
    22   * Use `+RTS -sstderr` or `+RTS -Sstderr` to watch garbage collection activity.
    23 
    24 == At crash time ==
    25 
    26 If your GHC-compiled program actually crashes, you may have to roll up your sleeves and wake up gdb.  There's a [wiki:DebuggingGhcCrashes whole Wiki page describing what to do].
    27 
    28 ---------------
    29 == Ticky-ticky profiling ==
    30 
    31 Ticky-ticky profiling adds counters to every STG function.  It's very low-level, but it really tells you what is going on:
    32 
    33  * Add the `-ticky` flag when compiling a Haskell module to enable "ticky-ticky" profiling of that module.  This makes GHC emit performance-counting instructions in every STG function. 
    34 
    35  * Add `-ticky` to the command line when linking, so that you link against a version of the runtime system that allows you to display the results.
    36 
    37  * Add `+RTS -rfoo.ticky` to the run-time command line, to put the ticky-ticky profile in the file `foo.ticky`.
    38 
    39 It's very low level stuff.  You need to use `-ddump-simpl -ddump-prep` when compiling the source files to see the functions that correspond to the performance counter report.
    40 
    41 You can mix modules compiled with `-ticky` and modules compiled without.
    42 
    43 To really see everything you need to compile all the libraries with `-ticky`.  To do that in a standard build tree, here are some flag settings in `build.mk` that work:
    44 {{{
    45 # Build all libraries with -ticky
    46 GhcLibOpts += -ticky
    47 
    48 # Build the RTS in the ticky way
    49 GhcRTSWays += t
    50 
    51 # Currently ticky is incompatible with threading
    52 GhcThreaded = NO
    53 
    54 # When linking stage2 you need -ticky, else you get unresolved symols
    55 GhcStage2HcOpts += -ticky
    56 
    57 # Ditto Haddock
    58 utils/haddock_dist_EXTRA_HC_OPTS += -ticky
    59 }}}
    60 But see #3439, which would allow you to drop the last two.
     1[[redirect(wiki:Debugging)]]