diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-02-24 10:45:58 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-03-03 08:12:42 -0500 |
commit | 3f9af89128988652f024b142e3feb6216fa88b30 (patch) | |
tree | e7caced4f4e450442c3a2caab6b8cd33a09a11ff | |
parent | 3630b9baa3887a5bf5cb3ba12e48301fe6cce173 (diff) | |
download | haskell-3f9af89128988652f024b142e3feb6216fa88b30.tar.gz |
Add a flag to dump the FastString table
-rw-r--r-- | compiler/GHC/Driver/Flags.hs | 1 | ||||
-rw-r--r-- | compiler/GHC/Driver/Session.hs | 3 | ||||
-rw-r--r-- | docs/users_guide/debugging.rst | 7 | ||||
-rw-r--r-- | ghc/Main.hs | 9 |
4 files changed, 19 insertions, 1 deletions
diff --git a/compiler/GHC/Driver/Flags.hs b/compiler/GHC/Driver/Flags.hs index 7867d4bd04..728b6159a6 100644 --- a/compiler/GHC/Driver/Flags.hs +++ b/compiler/GHC/Driver/Flags.hs @@ -112,6 +112,7 @@ data DumpFlag | Opt_D_dump_json | Opt_D_ppr_debug | Opt_D_no_debug_output + | Opt_D_dump_faststrings deriving (Eq, Show, Enum) -- | Enumerates the simple on-or-off dynamic flags diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs index a0a6153b0b..f7424f5003 100644 --- a/compiler/GHC/Driver/Session.hs +++ b/compiler/GHC/Driver/Session.hs @@ -2522,6 +2522,9 @@ dynamic_flags_deps = [ , make_ord_flag defGhcFlag "dno-debug-output" (setDumpFlag Opt_D_no_debug_output) + , make_ord_flag defGhcFlag "ddump-faststrings" + (setDumpFlag Opt_D_dump_faststrings) + ------ Machine dependent (-m<blah>) stuff --------------------------- , make_ord_flag defGhcFlag "msse" (noArg (\d -> diff --git a/docs/users_guide/debugging.rst b/docs/users_guide/debugging.rst index b1612f4536..d8a024dde4 100644 --- a/docs/users_guide/debugging.rst +++ b/docs/users_guide/debugging.rst @@ -68,6 +68,13 @@ Dumping out compiler intermediate structures Show statistics on the usage of fast strings by the compiler. +.. ghc-flag:: -ddump-faststrings + :shortdesc: Dump the whole FastString table when finished + :type: dynamic + + Dump the whole FastString table when finished. Consider using + :ghc-flag:`-ddump-file-prefix=⟨str⟩` to dump it into a file. + .. ghc-flag:: -dppr-debug :shortdesc: Turn on debug printing (more verbose) :type: dynamic diff --git a/ghc/Main.hs b/ghc/Main.hs index 2626d78924..e09242b5ad 100644 --- a/ghc/Main.hs +++ b/ghc/Main.hs @@ -757,9 +757,16 @@ showUsage ghci dflags = do dump (c:s) = putChar c >> dump s dumpFinalStats :: Logger -> DynFlags -> IO () -dumpFinalStats logger dflags = +dumpFinalStats logger dflags = do when (gopt Opt_D_faststring_stats dflags) $ dumpFastStringStats logger dflags + when (dopt Opt_D_dump_faststrings dflags) $ do + fss <- getFastStringTable + let ppr_table = fmap ppr_segment (fss `zip` [0..]) + ppr_segment (s,n) = hang (text "Segment" <+> int n) 2 (vcat (fmap ppr_bucket (s `zip` [0..]))) + ppr_bucket (b,n) = hang (text "Bucket" <+> int n) 2 (vcat (fmap ftext b)) + dumpIfSet_dyn logger dflags Opt_D_dump_faststrings "FastStrings" FormatText (vcat ppr_table) + dumpFastStringStats :: Logger -> DynFlags -> IO () dumpFastStringStats logger dflags = do segments <- getFastStringTable |