summaryrefslogtreecommitdiff
path: root/compiler/ghci
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2019-01-03 18:31:08 +0100
committerSylvain Henry <sylvain@haskus.fr>2019-12-18 13:43:37 +0100
commit58655b9da7599135395417a042f53cfa13b2151d (patch)
treecceacdd2c9848e49d5ebc6ba19d209cc823349a2 /compiler/ghci
parenta8f7ecd54821493dc061c55ceebb7e271b17056e (diff)
downloadhaskell-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/ghci')
-rw-r--r--compiler/ghci/ByteCodeGen.hs6
-rw-r--r--compiler/ghci/Debugger.hs1
2 files changed, 5 insertions, 2 deletions
diff --git a/compiler/ghci/ByteCodeGen.hs b/compiler/ghci/ByteCodeGen.hs
index ece728a288..4a8e138daf 100644
--- a/compiler/ghci/ByteCodeGen.hs
+++ b/compiler/ghci/ByteCodeGen.hs
@@ -107,7 +107,8 @@ byteCodeGen hsc_env this_mod binds tycs mb_modBreaks
(panic "ByteCodeGen.byteCodeGen: missing final emitBc?")
dumpIfSet_dyn dflags Opt_D_dump_BCOs
- "Proto-BCOs" (vcat (intersperse (char ' ') (map ppr proto_bcos)))
+ "Proto-BCOs" FormatByteCode
+ (vcat (intersperse (char ' ') (map ppr proto_bcos)))
cbc <- assembleBCOs hsc_env proto_bcos tycs (map snd stringPtrs)
(case modBreaks of
@@ -175,7 +176,8 @@ coreExprToBCOs hsc_env this_mod expr
when (notNull mallocd)
(panic "ByteCodeGen.coreExprToBCOs: missing final emitBc?")
- dumpIfSet_dyn dflags Opt_D_dump_BCOs "Proto-BCOs" (ppr proto_bco)
+ dumpIfSet_dyn dflags Opt_D_dump_BCOs "Proto-BCOs" FormatByteCode
+ (ppr proto_bco)
assembleOneBCO hsc_env proto_bco
where dflags = hsc_dflags hsc_env
diff --git a/compiler/ghci/Debugger.hs b/compiler/ghci/Debugger.hs
index a9bf9a87e9..373369e733 100644
--- a/compiler/ghci/Debugger.hs
+++ b/compiler/ghci/Debugger.hs
@@ -91,6 +91,7 @@ pprintClosureCommand bindThings force str = do
Just subst' -> do { dflags <- GHC.getSessionDynFlags
; liftIO $
dumpIfSet_dyn dflags Opt_D_dump_rtti "RTTI"
+ FormatText
(fsep $ [text "RTTI Improvement for", ppr id,
text "old substitution:" , ppr subst,
text "new substitution:" , ppr subst'])