diff options
author | Ben Gamari <ben@smart-cactus.org> | 2020-05-20 15:37:03 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-05-27 22:47:11 -0400 |
commit | 53b6bdee6374dfd283abe2b39418fa03fac56a25 (patch) | |
tree | a5946252d5742427475a76b0c1e96e349e0e6b87 | |
parent | 37c0dd8f875faf3c960b9e2b5e116351646d14f7 (diff) | |
download | haskell-53b6bdee6374dfd283abe2b39418fa03fac56a25.tar.gz |
Coverage: Don't produce ModBreaks if not HscInterpreted
emptyModBreaks contains a bottom and consequently it's important that we
don't use it unless necessary.
(cherry picked from commit f684a7d505f19bd78f178e01bbd8e4467aaa00ea)
-rw-r--r-- | compiler/deSugar/Coverage.hs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/compiler/deSugar/Coverage.hs b/compiler/deSugar/Coverage.hs index bea0172a69..afb0809479 100644 --- a/compiler/deSugar/Coverage.hs +++ b/compiler/deSugar/Coverage.hs @@ -111,7 +111,7 @@ addTicksToBinds hsc_env mod mod_loc exports tyCons binds dumpIfSet_dyn dflags Opt_D_dump_ticked "HPC" (pprLHsBinds binds1) - return (binds1, HpcInfo tickCount hashNo, Just modBreaks) + return (binds1, HpcInfo tickCount hashNo, modBreaks) | otherwise = return (binds, emptyHpcInfo False, Nothing) @@ -128,23 +128,23 @@ guessSourceFile binds orig_file = _ -> orig_file -mkModBreaks :: HscEnv -> Module -> Int -> [MixEntry_] -> IO ModBreaks +mkModBreaks :: HscEnv -> Module -> Int -> [MixEntry_] -> IO (Maybe ModBreaks) mkModBreaks hsc_env mod count entries - | HscInterpreted <- hscTarget (hsc_dflags hsc_env) = do + | breakpointsEnabled (hsc_dflags hsc_env) = do breakArray <- GHCi.newBreakArray hsc_env (length entries) ccs <- mkCCSArray hsc_env mod count entries let locsTicks = listArray (0,count-1) [ span | (span,_,_,_) <- entries ] varsTicks = listArray (0,count-1) [ vars | (_,_,vars,_) <- entries ] declsTicks = listArray (0,count-1) [ decls | (_,decls,_,_) <- entries ] - return emptyModBreaks + return $ Just $ emptyModBreaks { modBreaks_flags = breakArray , modBreaks_locs = locsTicks , modBreaks_vars = varsTicks , modBreaks_decls = declsTicks , modBreaks_ccs = ccs } - | otherwise = return emptyModBreaks + | otherwise = return Nothing mkCCSArray :: HscEnv -> Module -> Int -> [MixEntry_] @@ -1038,7 +1038,7 @@ data TickishType = ProfNotes | HpcTicks | Breakpoints | SourceNotes coveragePasses :: DynFlags -> [TickishType] coveragePasses dflags = - ifa (hscTarget dflags == HscInterpreted) Breakpoints $ + ifa (breakpointsEnabled dflags) Breakpoints $ ifa (gopt Opt_Hpc dflags) HpcTicks $ ifa (gopt Opt_SccProfilingOn dflags && profAuto dflags /= NoProfAuto) ProfNotes $ @@ -1046,6 +1046,10 @@ coveragePasses dflags = where ifa f x xs | f = x:xs | otherwise = xs +-- | Should we produce 'Breakpoint' ticks? +breakpointsEnabled :: DynFlags -> Bool +breakpointsEnabled dflags = hscTarget dflags == HscInterpreted + -- | Tickishs that only make sense when their source code location -- refers to the current file. This might not always be true due to -- LINE pragmas in the code - which would confuse at least HPC. |