summaryrefslogtreecommitdiff
path: root/utils/hpc/HpcShowTix.hs
diff options
context:
space:
mode:
authorandy@galois.com <unknown>2007-07-12 19:42:00 +0000
committerandy@galois.com <unknown>2007-07-12 19:42:00 +0000
commita966047ca5c407f336a633d716d3d7b5ed29d231 (patch)
tree2022e1d3b41e70d664efc1fd93b7f39590502464 /utils/hpc/HpcShowTix.hs
parent41ac7eb30ff99535c24c39efd33e2b65ea458707 (diff)
downloadhaskell-a966047ca5c407f336a633d716d3d7b5ed29d231.tar.gz
Adding draft and show to hpc
we now have hpc draft <TIX_FILE> This drafts up a candidate overlay for 100% coverage. and hpc show <TIX_FILE> This show verbose details about a tix file; mainly for debugging.
Diffstat (limited to 'utils/hpc/HpcShowTix.hs')
-rw-r--r--utils/hpc/HpcShowTix.hs60
1 files changed, 60 insertions, 0 deletions
diff --git a/utils/hpc/HpcShowTix.hs b/utils/hpc/HpcShowTix.hs
new file mode 100644
index 0000000000..79c9fa3428
--- /dev/null
+++ b/utils/hpc/HpcShowTix.hs
@@ -0,0 +1,60 @@
+module HpcShowTix (showtix_plugin) where
+
+import Trace.Hpc.Mix
+import Trace.Hpc.Tix
+import Trace.Hpc.Util
+
+import HpcFlags
+
+import qualified Data.Set as Set
+
+showtix_options =
+ [ excludeOpt,includeOpt,hpcDirOpt
+ , outputOpt
+ ]
+
+showtix_plugin = Plugin { name = "show"
+ , usage = "[OPTION] .. <TIX_FILE> [<MODULE> [<MODULE> ..]]"
+ , options = showtix_options
+ , summary = "Show .tix file in readable, verbose format"
+ , implementation = showtix_main
+ , init_flags = default_flags
+ , final_flags = default_final_flags
+ }
+
+
+
+showtix_main flags [] = hpcError showtix_plugin $ "no .tix file or executable name specified"
+showtix_main flags (prog:modNames) = do
+ let hpcflags1 = flags
+ { includeMods = Set.fromList modNames
+ `Set.union`
+ includeMods flags }
+
+ optTixs <- readTix (getTixFileName prog)
+ case optTixs of
+ Nothing -> hpcError showtix_plugin $ "could not read .tix file : " ++ prog
+ Just (Tix tixs) -> do
+ let modules = map tixModuleName tixs
+
+ mixs <- sequence
+ [ readMix (hpcDirs hpcflags1) modName -- hard wired to .hpc for now
+ | modName <- modules
+ , allowModule hpcflags1 modName
+ ]
+
+ let rjust n str = take (n - length str) (repeat ' ') ++ str
+ let ljust n str = str ++ take (n - length str) (repeat ' ')
+
+ sequence_ [ sequence_ [ putStrLn (rjust 5 (show ix) ++ " " ++
+ rjust 10 (show count) ++ " " ++
+ ljust 20 modName ++ " " ++ rjust 20 (show pos) ++ " " ++ show lab)
+ | (count,ix,(pos,lab)) <- zip3 tixs [(0::Int)..] entries
+ ]
+ | ( TixModule modName hash _ tixs
+ , Mix _file _timestamp _hash _tab entries
+ ) <- zip tixs mixs
+ ]
+
+ return ()
+ \ No newline at end of file