From 7bd518ddd4113c3cdc2497c6383f3b02f609486f Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Tue, 13 Nov 2007 17:45:39 +0000 Subject: [PATCH] GHCi debugger: added a new flag, -fno-print-binding-contents The contents of bindings show at breakpoints and by :show bindings is rendered using the same printer that :print uses. But sometimes the output it gives spans over too many lines and the user may want to be able to disable it. --- compiler/ghci/InteractiveUI.hs | 19 ++++++++++++------- compiler/main/DynFlags.hs | 5 ++++- docs/users_guide/flags.xml | 7 +++++++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs index dd75a09..c0346fb 100644 --- a/compiler/ghci/InteractiveUI.hs +++ b/compiler/ghci/InteractiveUI.hs @@ -681,13 +681,18 @@ printTypeOfName session n printTypeAndContents :: Session -> [Id] -> GHCi () printTypeAndContents session ids = do - terms <- mapM (io . GHC.obtainTermB session 10 False) ids - docs_terms <- mapM (io . showTerm session) terms - dflags <- getDynFlags - let pefas = dopt Opt_PrintExplicitForalls dflags - printForUser $ vcat $ zipWith (\ty cts -> ty <+> equals <+> cts) - (map (pprTyThing pefas . AnId) ids) - docs_terms + dflags <- getDynFlags + let pefas = dopt Opt_PrintExplicitForalls dflags + pcontents = dopt Opt_PrintBindContents dflags + if pcontents + then do + let depthBound = 100 + terms <- mapM (io . GHC.obtainTermB session depthBound False) ids + docs_terms <- mapM (io . showTerm session) terms + printForUser $ vcat $ zipWith (\ty cts -> ty <+> equals <+> cts) + (map (pprTyThing pefas . AnId) ids) + docs_terms + else printForUser $ vcat $ map (pprTyThing pefas . AnId) ids specialCommand :: String -> GHCi Bool diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 9becbb4..f8e9408 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -272,6 +272,7 @@ data DynFlag | Opt_BreakOnException | Opt_BreakOnError | Opt_PrintEvldWithShow + | Opt_PrintBindContents | Opt_GenManifest | Opt_EmbedManifest | Opt_RunCPSZ @@ -536,7 +537,8 @@ defaultDynFlags = Opt_DoAsmMangling, Opt_GenManifest, - Opt_EmbedManifest + Opt_EmbedManifest, + Opt_PrintBindContents ] ++ [f | (ns,f) <- optLevelFlags, 0 `elem` ns] -- The default -O0 options @@ -1210,6 +1212,7 @@ fFlags = [ ( "break-on-exception", Opt_BreakOnException ), ( "break-on-error", Opt_BreakOnError ), ( "print-evld-with-show", Opt_PrintEvldWithShow ), + ( "print-bind-contents", Opt_PrintBindContents ), ( "run-cps", Opt_RunCPSZ ), ( "convert-to-zipper-and-back", Opt_ConvertToZipCfgAndBack), ( "vectorise", Opt_Vectorise ), diff --git a/docs/users_guide/flags.xml b/docs/users_guide/flags.xml index 4a900b6..51f917f 100644 --- a/docs/users_guide/flags.xml +++ b/docs/users_guide/flags.xml @@ -522,6 +522,13 @@ dynamic + + + Turn off printing of binding contents in GHCi + dynamic + - + + -- 1.7.10.4