diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2019-01-03 18:31:08 +0100 |
---|---|---|
committer | Sylvain Henry <sylvain@haskus.fr> | 2019-12-18 13:43:37 +0100 |
commit | 58655b9da7599135395417a042f53cfa13b2151d (patch) | |
tree | cceacdd2c9848e49d5ebc6ba19d209cc823349a2 /compiler/deSugar | |
parent | a8f7ecd54821493dc061c55ceebb7e271b17056e (diff) | |
download | haskell-58655b9da7599135395417a042f53cfa13b2151d.tar.gz |
Add GHC-API logging hooks
* Add 'dumpAction' hook to DynFlags.
It allows GHC API users to catch dumped intermediate codes and
information. The format of the dump (Core, Stg, raw text, etc.) is now
reported allowing easier automatic handling.
* Add 'traceAction' hook to DynFlags.
Some dumps go through the trace mechanism (for instance unfoldings that
have been considered for inlining). This is problematic because:
1) dumps aren't written into files even with -ddump-to-file on
2) dumps are written on stdout even with GHC API
3) in this specific case, dumping depends on unsafe globally stored
DynFlags which is bad for GHC API users
We introduce 'traceAction' hook which allows GHC API to catch those
traces and to avoid using globally stored DynFlags.
* Avoid dumping empty logs via dumpAction/traceAction (but still write
empty files to keep the existing behavior)
Diffstat (limited to 'compiler/deSugar')
-rw-r--r-- | compiler/deSugar/Coverage.hs | 3 | ||||
-rw-r--r-- | compiler/deSugar/Desugar.hs | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/compiler/deSugar/Coverage.hs b/compiler/deSugar/Coverage.hs index 8a823906af..6930af6e0b 100644 --- a/compiler/deSugar/Coverage.hs +++ b/compiler/deSugar/Coverage.hs @@ -111,7 +111,8 @@ addTicksToBinds hsc_env mod mod_loc exports tyCons binds hashNo <- writeMixEntries dflags mod tickCount entries orig_file2 modBreaks <- mkModBreaks hsc_env mod tickCount entries - dumpIfSet_dyn dflags Opt_D_dump_ticked "HPC" (pprLHsBinds binds1) + dumpIfSet_dyn dflags Opt_D_dump_ticked "HPC" FormatHaskell + (pprLHsBinds binds1) return (binds1, HpcInfo tickCount hashNo, Just modBreaks) diff --git a/compiler/deSugar/Desugar.hs b/compiler/deSugar/Desugar.hs index f5aa6f0785..48edd61b1b 100644 --- a/compiler/deSugar/Desugar.hs +++ b/compiler/deSugar/Desugar.hs @@ -270,7 +270,7 @@ deSugarExpr hsc_env tc_expr = do { ; case mb_core_expr of Nothing -> return () Just expr -> dumpIfSet_dyn dflags Opt_D_dump_ds "Desugared" - (pprCoreExpr expr) + FormatCore (pprCoreExpr expr) ; return (msgs, mb_core_expr) } |