Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
4396a6f2
by Andrea Vezzosi at 2026-07-10T11:09:25-04:00
20 changed files:
- compiler/GHC/ByteCode/Breakpoints.hs
- compiler/GHC/ByteCode/Types.hs
- compiler/GHC/Driver/Main/Compile.hs
- compiler/GHC/Driver/Main/Hsc.hs
- compiler/GHC/Driver/Main/Passes.hs
- compiler/GHC/HsToCore/Breakpoints.hs
- + compiler/GHC/HsToCore/Breakpoints/Types.hs
- compiler/GHC/Iface/Load.hs
- compiler/GHC/Iface/Make.hs
- compiler/GHC/Iface/Recomp.hs
- compiler/GHC/Unit/Module/ModGuts.hs
- compiler/GHC/Unit/Module/ModIface.hs
- compiler/GHC/Unit/Module/WholeCoreBindings.hs
- compiler/GHC/Utils/Binary.hs
- compiler/ghc.cabal.in
- testsuite/tests/count-deps/CountDepsParser.stdout
- testsuite/tests/ghci/should_run/Makefile
- + testsuite/tests/ghci/should_run/T27287.hs
- + testsuite/tests/ghci/should_run/T27287.stdout
- testsuite/tests/ghci/should_run/all.T
Changes:
| ... | ... | @@ -41,7 +41,7 @@ import qualified Data.ByteString.Short as SBS |
| 41 | 41 | import Data.IntMap.Strict (IntMap)
|
| 42 | 42 | import qualified Data.IntMap.Strict as IM
|
| 43 | 43 | |
| 44 | -import GHC.HsToCore.Breakpoints
|
|
| 44 | +import GHC.HsToCore.Breakpoints.Types
|
|
| 45 | 45 | import GHC.Iface.Syntax
|
| 46 | 46 | |
| 47 | 47 | import GHC.Unit.Module (Module)
|
| ... | ... | @@ -46,7 +46,7 @@ import GHC.Utils.Binary |
| 46 | 46 | import GHC.Utils.Outputable
|
| 47 | 47 | import GHC.Builtin.PrimOps
|
| 48 | 48 | import GHC.Types.SptEntry
|
| 49 | -import GHC.HsToCore.Breakpoints
|
|
| 49 | +import GHC.HsToCore.Breakpoints.Types
|
|
| 50 | 50 | import GHC.ByteCode.Breakpoints
|
| 51 | 51 | import GHCi.Message
|
| 52 | 52 | import GHCi.RemoteTypes
|
| ... | ... | @@ -376,4 +376,3 @@ instance Binary FFIInfo where |
| 376 | 376 | get bh = FFIInfo <$> get bh <*> get bh
|
| 377 | 377 | |
| 378 | 378 | put_ bh FFIInfo {..} = put_ bh ffiInfoArgs *> put_ bh ffiInfoRet |
| 379 | - |
| ... | ... | @@ -331,11 +331,11 @@ compileWholeCoreBindings hsc_env type_env wcb = do |
| 331 | 331 | gen_bytecode core_binds stubs foreign_files = do
|
| 332 | 332 | let cgi_guts = CgInteractiveGuts wcb_module core_binds
|
| 333 | 333 | (typeEnvTyCons type_env) stubs foreign_files
|
| 334 | - Nothing [] NoHpcInfo
|
|
| 334 | + wcb_modBreaks [] NoHpcInfo
|
|
| 335 | 335 | trace_if logger (text "Generating ByteCode for" <+> ppr wcb_module)
|
| 336 | 336 | mkModuleByteCode hsc_env wcb_module wcb_mod_location cgi_guts
|
| 337 | 337 | |
| 338 | - WholeCoreBindings {wcb_module, wcb_mod_location, wcb_foreign} = wcb
|
|
| 338 | + WholeCoreBindings {wcb_module, wcb_mod_location, wcb_foreign, wcb_modBreaks} = wcb
|
|
| 339 | 339 | |
| 340 | 340 | logger = hsc_logger hsc_env
|
| 341 | 341 |
| ... | ... | @@ -61,6 +61,8 @@ import GHC.Iface.Load ( ifaceStats ) |
| 61 | 61 | import GHC.Iface.Make
|
| 62 | 62 | import GHC.Iface.Tidy
|
| 63 | 63 | |
| 64 | +import GHC.HsToCore.Breakpoints.Types (ModBreaks)
|
|
| 65 | + |
|
| 64 | 66 | import GHC.Core
|
| 65 | 67 | |
| 66 | 68 | import GHC.Parser.Errors.Types
|
| ... | ... | @@ -191,9 +193,10 @@ initModDetails hsc_env iface = |
| 191 | 193 | -- | Assemble 'WholeCoreBindings' if the interface contains Core bindings.
|
| 192 | 194 | iface_core_bindings :: ModIface -> ModLocation -> Maybe WholeCoreBindings
|
| 193 | 195 | iface_core_bindings iface wcb_mod_location =
|
| 194 | - mi_simplified_core <&> \(IfaceSimplifiedCore bindings foreign') ->
|
|
| 196 | + mi_simplified_core <&> \(IfaceSimplifiedCore bindings mbreaks foreign') ->
|
|
| 195 | 197 | WholeCoreBindings {
|
| 196 | 198 | wcb_bindings = bindings,
|
| 199 | + wcb_modBreaks = mbreaks,
|
|
| 197 | 200 | wcb_module = mi_module,
|
| 198 | 201 | wcb_mod_location,
|
| 199 | 202 | wcb_foreign = foreign'
|
| ... | ... | @@ -311,17 +314,19 @@ genModDetails hsc_env old_iface |
| 311 | 314 | -- generates interface files. See Note [hscSimpleIface - mkBootModDetailsTc]
|
| 312 | 315 | hscSimpleIface :: HscEnv
|
| 313 | 316 | -> Maybe CoreProgram
|
| 317 | + -> Maybe ModBreaks
|
|
| 314 | 318 | -> TcGblEnv
|
| 315 | 319 | -> ModSummary
|
| 316 | 320 | -> IO (ModIface, ModDetails)
|
| 317 | -hscSimpleIface hsc_env mb_core_program tc_result summary
|
|
| 318 | - = runHsc hsc_env $ hscSimpleIface' mb_core_program tc_result summary
|
|
| 321 | +hscSimpleIface hsc_env mb_core_program mb_modBreaks tc_result summary
|
|
| 322 | + = runHsc hsc_env $ hscSimpleIface' mb_core_program mb_modBreaks tc_result summary
|
|
| 319 | 323 | |
| 320 | 324 | hscSimpleIface' :: Maybe CoreProgram
|
| 325 | + -> Maybe ModBreaks
|
|
| 321 | 326 | -> TcGblEnv
|
| 322 | 327 | -> ModSummary
|
| 323 | 328 | -> Hsc (ModIface, ModDetails)
|
| 324 | -hscSimpleIface' mb_core_program tc_result summary = do
|
|
| 329 | +hscSimpleIface' mb_core_program mb_modBreaks tc_result summary = do
|
|
| 325 | 330 | hsc_env <- getHscEnv
|
| 326 | 331 | logger <- getLogger
|
| 327 | 332 | details <- liftIO $ mkBootModDetailsTc logger tc_result
|
| ... | ... | @@ -329,7 +334,7 @@ hscSimpleIface' mb_core_program tc_result summary = do |
| 329 | 334 | new_iface
|
| 330 | 335 | <- {-# SCC "MkFinalIface" #-}
|
| 331 | 336 | liftIO $
|
| 332 | - mkIfaceTc hsc_env safe_mode details summary mb_core_program tc_result
|
|
| 337 | + mkIfaceTc hsc_env safe_mode details summary mb_core_program mb_modBreaks tc_result
|
|
| 333 | 338 | -- And the answer is ...
|
| 334 | 339 | liftIO $ dumpIfaceStats hsc_env
|
| 335 | 340 | return (new_iface, details)
|
| ... | ... | @@ -424,7 +424,7 @@ hsc_typecheck tc_rn_opts mod_summary mb_rdr_module = do |
| 424 | 424 | Nothing -> hscParse' mod_summary
|
| 425 | 425 | tc_result0 <- tcRnModule' mod_summary tc_rn_opts' hpm
|
| 426 | 426 | if hsc_src == HsigFile
|
| 427 | - then do (iface, _) <- liftIO $ hscSimpleIface hsc_env Nothing tc_result0 mod_summary
|
|
| 427 | + then do (iface, _) <- liftIO $ hscSimpleIface hsc_env Nothing Nothing tc_result0 mod_summary
|
|
| 428 | 428 | ioMsgMaybe $ hoistTcRnMessage $
|
| 429 | 429 | tcRnMergeSignatures hsc_env hpm tc_result0 iface
|
| 430 | 430 | else return tc_result0
|
| ... | ... | @@ -895,7 +895,7 @@ hscDesugarAndSimplify summary (FrontendTypecheck tc_result) tc_warnings mb_old_h |
| 895 | 895 | liftIO $ hscTidy hsc_env simplified_guts
|
| 896 | 896 | |
| 897 | 897 | (iface, _details) <- liftIO $
|
| 898 | - hscSimpleIface hsc_env (Just $ cg_binds cg_guts) tc_result summary
|
|
| 898 | + hscSimpleIface hsc_env (Just $ cg_binds cg_guts) (cg_modBreaks cg_guts) tc_result summary
|
|
| 899 | 899 | |
| 900 | 900 | liftIO $ hscMaybeWriteIface logger dflags True iface mb_old_hash (ms_location summary)
|
| 901 | 901 | |
| ... | ... | @@ -910,7 +910,7 @@ hscDesugarAndSimplify summary (FrontendTypecheck tc_result) tc_warnings mb_old_h |
| 910 | 910 | -- and generate a simple interface.
|
| 911 | 911 | _ -> do
|
| 912 | 912 | (iface, _details) <- liftIO $
|
| 913 | - hscSimpleIface hsc_env Nothing tc_result summary
|
|
| 913 | + hscSimpleIface hsc_env Nothing Nothing tc_result summary
|
|
| 914 | 914 | |
| 915 | 915 | liftIO $ hscMaybeWriteIface logger dflags True iface mb_old_hash (ms_location summary)
|
| 916 | 916 | |
| ... | ... | @@ -1715,4 +1715,3 @@ jsCodeGen hsc_env srcspan i this_mod stg_binds_with_deps binding_id = do |
| 1715 | 1715 | mkForeignRef href (freeReallyRemoteRef inst href)
|
| 1716 | 1716 | |
| 1717 | 1717 | return (castForeignRef binding_fref, dep_linkables, this_pkgs_loaded) |
| 1718 | - |
| ... | ... | @@ -23,54 +23,15 @@ module GHC.HsToCore.Breakpoints |
| 23 | 23 | |
| 24 | 24 | import GHC.Prelude
|
| 25 | 25 | import Data.Array
|
| 26 | -import qualified Data.ByteString.Short as SBS
|
|
| 27 | 26 | |
| 28 | 27 | import GHC.HsToCore.Ticks (Tick (..))
|
| 28 | +import GHC.HsToCore.Breakpoints.Types
|
|
| 29 | 29 | import GHC.Data.SizedSeq
|
| 30 | -import GHC.Types.SrcLoc (SrcSpan)
|
|
| 31 | -import GHC.Types.Name (OccName)
|
|
| 32 | -import GHC.Types.Tickish (BreakTickIndex, BreakpointId(..))
|
|
| 33 | 30 | import GHC.Unit.Module (Module)
|
| 34 | 31 | import GHC.Utils.Binary
|
| 35 | 32 | import GHC.Utils.Encoding (utf8EncodeShortByteString)
|
| 36 | 33 | import GHC.Utils.Outputable
|
| 37 | 34 | import Data.List (intersperse)
|
| 38 | -import Data.Coerce
|
|
| 39 | - |
|
| 40 | ---------------------------------------------------------------------------------
|
|
| 41 | --- ModBreaks
|
|
| 42 | ---------------------------------------------------------------------------------
|
|
| 43 | - |
|
| 44 | --- | All the information about the source-relevant breakpoints for a module
|
|
| 45 | ---
|
|
| 46 | --- This information is constructed once during desugaring (with `mkModBreaks`)
|
|
| 47 | --- from breakpoint ticks and fixed/unchanged from there on forward. It could be
|
|
| 48 | --- exported as an abstract datatype because it should never be updated after
|
|
| 49 | --- construction, only queried.
|
|
| 50 | ---
|
|
| 51 | --- The arrays can be indexed using the int in the corresponding 'BreakpointId'
|
|
| 52 | --- (i.e. the 'BreakpointId' whose 'Module' matches the 'Module' corresponding
|
|
| 53 | --- to these 'ModBreaks') with the accessors 'modBreaks_locs', 'modBreaks_vars',
|
|
| 54 | --- and 'modBreaks_decls'.
|
|
| 55 | -data ModBreaks
|
|
| 56 | - = ModBreaks
|
|
| 57 | - { modBreaks_locs_ :: !(Array BreakTickIndex BinSrcSpan)
|
|
| 58 | - -- ^ An array giving the source span of each breakpoint.
|
|
| 59 | - , modBreaks_vars :: !(Array BreakTickIndex [OccName])
|
|
| 60 | - -- ^ An array giving the names of the free variables at each breakpoint.
|
|
| 61 | - , modBreaks_decls :: !(Array BreakTickIndex [String])
|
|
| 62 | - -- ^ An array giving the names of the declarations enclosing each breakpoint.
|
|
| 63 | - -- See Note [Field modBreaks_decls]
|
|
| 64 | - , modBreaks_ccs :: !(Array BreakTickIndex (SBS.ShortByteString, SBS.ShortByteString))
|
|
| 65 | - -- ^ Array pointing to cost centre info for each breakpoint;
|
|
| 66 | - -- actual 'CostCentre' allocation is done at link-time.
|
|
| 67 | - , modBreaks_module :: !Module
|
|
| 68 | - -- ^ The module to which this ModBreaks is associated.
|
|
| 69 | - -- We also cache this here for internal sanity checks.
|
|
| 70 | - }
|
|
| 71 | - |
|
| 72 | -modBreaks_locs :: ModBreaks -> Array BreakTickIndex SrcSpan
|
|
| 73 | -modBreaks_locs = coerce . modBreaks_locs_
|
|
| 74 | 35 | |
| 75 | 36 | -- | Initialize memory for breakpoint data that is shared between the bytecode
|
| 76 | 37 | -- generator and the interpreter.
|
| ... | ... | @@ -113,13 +74,3 @@ The breakpoint is in the function called "baz" that is declared in a `let` |
| 113 | 74 | or `where` clause of a declaration called "bar", which itself is declared
|
| 114 | 75 | in a `let` or `where` clause of the top-level function called "foo".
|
| 115 | 76 | -} |
| 116 | - |
|
| 117 | -instance Binary ModBreaks where
|
|
| 118 | - get bh = ModBreaks <$> get bh <*> get bh <*> get bh <*> get bh <*> get bh
|
|
| 119 | - |
|
| 120 | - put_ bh ModBreaks {..} =
|
|
| 121 | - put_ bh modBreaks_locs_
|
|
| 122 | - *> put_ bh modBreaks_vars
|
|
| 123 | - *> put_ bh modBreaks_decls
|
|
| 124 | - *> put_ bh modBreaks_ccs
|
|
| 125 | - *> put_ bh modBreaks_module |
| 1 | +{-# LANGUAGE RecordWildCards #-}
|
|
| 2 | + |
|
| 3 | +-- | Information attached to Breakpoints generated from Ticks
|
|
| 4 | +--
|
|
| 5 | +-- The breakpoint information stored in 'ModBreaks' is generated during
|
|
| 6 | +-- desugaring from the ticks annotating the source expressions.
|
|
| 7 | +--
|
|
| 8 | +-- This information can be queried per-breakpoint using the 'BreakpointId'
|
|
| 9 | +-- datatype, which indexes tick-level breakpoint information.
|
|
| 10 | +--
|
|
| 11 | +-- 'ModBreaks' and 'BreakpointId's are not to be confused with
|
|
| 12 | +-- 'InternalModBreaks' and 'InternalBreakId's. The latter are constructed
|
|
| 13 | +-- during bytecode generation and can be found in 'GHC.ByteCode.Breakpoints'.
|
|
| 14 | +--
|
|
| 15 | +-- See Note [ModBreaks vs InternalModBreaks] and Note [Breakpoint identifiers]
|
|
| 16 | +module GHC.HsToCore.Breakpoints.Types
|
|
| 17 | + ( -- * ModBreaks
|
|
| 18 | + ModBreaks(..), modBreaks_locs
|
|
| 19 | + |
|
| 20 | + -- ** Re-exports BreakpointId
|
|
| 21 | + , BreakpointId(..), BreakTickIndex
|
|
| 22 | + ) where
|
|
| 23 | + |
|
| 24 | +import GHC.Prelude
|
|
| 25 | +import Data.Array
|
|
| 26 | +import qualified Data.ByteString.Short as SBS
|
|
| 27 | + |
|
| 28 | +import GHC.Types.SrcLoc (SrcSpan)
|
|
| 29 | +import GHC.Types.Name (OccName)
|
|
| 30 | +import GHC.Types.Tickish (BreakTickIndex, BreakpointId(..))
|
|
| 31 | +import GHC.Unit.Module (Module)
|
|
| 32 | +import Data.Coerce
|
|
| 33 | +import GHC.Utils.Binary (BinSrcSpan(..), Binary(..))
|
|
| 34 | +import Control.DeepSeq
|
|
| 35 | + |
|
| 36 | +--------------------------------------------------------------------------------
|
|
| 37 | +-- ModBreaks
|
|
| 38 | +--------------------------------------------------------------------------------
|
|
| 39 | + |
|
| 40 | +-- | All the information about the source-relevant breakpoints for a module
|
|
| 41 | +--
|
|
| 42 | +-- This information is constructed once during desugaring (with `mkModBreaks`)
|
|
| 43 | +-- from breakpoint ticks and fixed/unchanged from there on forward. It could be
|
|
| 44 | +-- exported as an abstract datatype because it should never be updated after
|
|
| 45 | +-- construction, only queried.
|
|
| 46 | +--
|
|
| 47 | +-- The arrays can be indexed using the int in the corresponding 'BreakpointId'
|
|
| 48 | +-- (i.e. the 'BreakpointId' whose 'Module' matches the 'Module' corresponding
|
|
| 49 | +-- to these 'ModBreaks') with the accessors 'modBreaks_locs', 'modBreaks_vars',
|
|
| 50 | +-- and 'modBreaks_decls'.
|
|
| 51 | +data ModBreaks
|
|
| 52 | + = ModBreaks
|
|
| 53 | + { modBreaks_locs_ :: !(Array BreakTickIndex BinSrcSpan)
|
|
| 54 | + -- ^ An array giving the source span of each breakpoint.
|
|
| 55 | + , modBreaks_vars :: !(Array BreakTickIndex [OccName])
|
|
| 56 | + -- ^ An array giving the names of the free variables at each breakpoint.
|
|
| 57 | + , modBreaks_decls :: !(Array BreakTickIndex [String])
|
|
| 58 | + -- ^ An array giving the names of the declarations enclosing each breakpoint.
|
|
| 59 | + -- See Note [Field modBreaks_decls]
|
|
| 60 | + , modBreaks_ccs :: !(Array BreakTickIndex (SBS.ShortByteString, SBS.ShortByteString))
|
|
| 61 | + -- ^ Array pointing to cost centre info for each breakpoint;
|
|
| 62 | + -- actual 'CostCentre' allocation is done at link-time.
|
|
| 63 | + , modBreaks_module :: !Module
|
|
| 64 | + -- ^ The module to which this ModBreaks is associated.
|
|
| 65 | + -- We also cache this here for internal sanity checks.
|
|
| 66 | + }
|
|
| 67 | + |
|
| 68 | +modBreaks_locs :: ModBreaks -> Array BreakTickIndex SrcSpan
|
|
| 69 | +modBreaks_locs = coerce . modBreaks_locs_
|
|
| 70 | + |
|
| 71 | +instance Binary ModBreaks where
|
|
| 72 | + get bh = ModBreaks <$> get bh <*> get bh <*> get bh <*> get bh <*> get bh
|
|
| 73 | + |
|
| 74 | + put_ bh ModBreaks {..} =
|
|
| 75 | + put_ bh modBreaks_locs_
|
|
| 76 | + *> put_ bh modBreaks_vars
|
|
| 77 | + *> put_ bh modBreaks_decls
|
|
| 78 | + *> put_ bh modBreaks_ccs
|
|
| 79 | + *> put_ bh modBreaks_module
|
|
| 80 | + |
|
| 81 | +instance NFData ModBreaks where
|
|
| 82 | + rnf (ModBreaks a b c d e) = rnf a `seq` rnf b `seq` rnf c `seq` rnf d `seq` rnf e |
|
| \ No newline at end of file |
| ... | ... | @@ -61,6 +61,8 @@ import GHC.Iface.Rename |
| 61 | 61 | import GHC.Iface.Env
|
| 62 | 62 | import GHC.Iface.Errors as Iface_Errors
|
| 63 | 63 | |
| 64 | +import GHC.HsToCore.Breakpoints.Types (modBreaks_locs)
|
|
| 65 | + |
|
| 64 | 66 | import GHC.Tc.Errors.Types
|
| 65 | 67 | import GHC.Tc.Utils.Monad
|
| 66 | 68 | |
| ... | ... | @@ -111,6 +113,7 @@ import GHC.Unit.Env |
| 111 | 113 | import GHC.Data.Maybe
|
| 112 | 114 | |
| 113 | 115 | import Control.Monad
|
| 116 | +import qualified Data.Foldable as Foldable
|
|
| 114 | 117 | import Data.Map ( toList )
|
| 115 | 118 | import System.FilePath
|
| 116 | 119 | import System.Directory
|
| ... | ... | @@ -1158,9 +1161,11 @@ pprModIface unit_state iface |
| 1158 | 1161 | , vcat [ppr ver $$ nest 2 (ppr decl) | (ver,decl) <- mi_decls iface]
|
| 1159 | 1162 | , case mi_simplified_core iface of
|
| 1160 | 1163 | Nothing -> empty
|
| 1161 | - Just (IfaceSimplifiedCore eds fs) ->
|
|
| 1164 | + Just (IfaceSimplifiedCore eds mbs fs) ->
|
|
| 1162 | 1165 | vcat [ text "extra decls:"
|
| 1163 | 1166 | $$ nest 2 (vcat ([ppr bs | bs <- eds]))
|
| 1167 | + , text "mod breaks:"
|
|
| 1168 | + $$ nest 2 (ppr $ Foldable.toList . modBreaks_locs <$> mbs)
|
|
| 1164 | 1169 | , text "foreign stubs:"
|
| 1165 | 1170 | $$ nest 2 (ppr fs)
|
| 1166 | 1171 | ]
|
| ... | ... | @@ -34,6 +34,7 @@ import GHC.Iface.Syntax |
| 34 | 34 | import GHC.Iface.Recomp
|
| 35 | 35 | import GHC.Iface.Load
|
| 36 | 36 | import GHC.Iface.Ext.Fields
|
| 37 | +import GHC.HsToCore.Breakpoints.Types (ModBreaks)
|
|
| 37 | 38 | |
| 38 | 39 | import GHC.CoreToIface
|
| 39 | 40 | |
| ... | ... | @@ -121,11 +122,12 @@ mkPartialIface hsc_env core_prog mod_details mod_summary import_decls |
| 121 | 122 | , mg_safe_haskell = safe_mode
|
| 122 | 123 | , mg_trust_pkg = self_trust
|
| 123 | 124 | , mg_docs = docs
|
| 125 | + , mg_modBreaks = modBreaks
|
|
| 124 | 126 | }
|
| 125 | 127 | = do
|
| 126 | 128 | self_recomp <- traverse (mkSelfRecomp hsc_env this_mod (ms_hs_hash mod_summary)) usages
|
| 127 | 129 | return $ mkIface_ hsc_env this_mod core_prog hsc_src deps rdr_env import_decls fix_env warns self_trust
|
| 128 | - safe_mode self_recomp docs mod_details
|
|
| 130 | + safe_mode self_recomp docs mod_details modBreaks
|
|
| 129 | 131 | |
| 130 | 132 | -- | Fully instantiate an interface. Adds fingerprints and potentially code
|
| 131 | 133 | -- generator produced information.
|
| ... | ... | @@ -227,9 +229,10 @@ mkIfaceTc :: HscEnv |
| 227 | 229 | -> ModDetails -- gotten from mkBootModDetails, probably
|
| 228 | 230 | -> ModSummary
|
| 229 | 231 | -> Maybe CoreProgram
|
| 232 | + -> Maybe ModBreaks
|
|
| 230 | 233 | -> TcGblEnv -- Usages, deprecations, etc
|
| 231 | 234 | -> IO ModIface
|
| 232 | -mkIfaceTc hsc_env safe_mode mod_details mod_summary mb_program
|
|
| 235 | +mkIfaceTc hsc_env safe_mode mod_details mod_summary mb_program mb_modBreaks
|
|
| 233 | 236 | tc_result@TcGblEnv{ tcg_mod = this_mod,
|
| 234 | 237 | tcg_src = hsc_src,
|
| 235 | 238 | tcg_imports = imports,
|
| ... | ... | @@ -257,6 +260,7 @@ mkIfaceTc hsc_env safe_mode mod_details mod_summary mb_program |
| 257 | 260 | (imp_trust_own_pkg imports) safe_mode self_recomp
|
| 258 | 261 | docs
|
| 259 | 262 | mod_details
|
| 263 | + mb_modBreaks
|
|
| 260 | 264 | |
| 261 | 265 | mkFullIface hsc_env partial_iface Nothing Nothing NoStubs []
|
| 262 | 266 | |
| ... | ... | @@ -303,6 +307,7 @@ mkIface_ :: HscEnv -> Module -> CoreProgram -> HscSource |
| 303 | 307 | -> Maybe IfaceSelfRecomp
|
| 304 | 308 | -> Maybe Docs
|
| 305 | 309 | -> ModDetails
|
| 310 | + -> Maybe ModBreaks
|
|
| 306 | 311 | -> PartialModIface
|
| 307 | 312 | mkIface_ hsc_env
|
| 308 | 313 | this_mod core_prog hsc_src deps rdr_env import_decls fix_env src_warns
|
| ... | ... | @@ -320,7 +325,7 @@ mkIface_ hsc_env |
| 320 | 325 | -- only at the TypeEnv. The previous Tidy phase has
|
| 321 | 326 | -- put exactly the info into the TypeEnv that we want
|
| 322 | 327 | -- to expose in the interface
|
| 323 | - |
|
| 328 | + modBreaks
|
|
| 324 | 329 | = do
|
| 325 | 330 | let home_unit = hsc_home_unit hsc_env
|
| 326 | 331 | semantic_mod = homeModuleNameInstantiation home_unit (moduleName this_mod)
|
| ... | ... | @@ -328,7 +333,7 @@ mkIface_ hsc_env |
| 328 | 333 | |
| 329 | 334 | simplified_core =
|
| 330 | 335 | if gopt Opt_WriteIfSimplifiedCore dflags
|
| 331 | - then Just (IfaceSimplifiedCore [ toIfaceTopBind b | b <- core_prog ] emptyIfaceForeign)
|
|
| 336 | + then Just (IfaceSimplifiedCore [ toIfaceTopBind b | b <- core_prog ] modBreaks emptyIfaceForeign)
|
|
| 332 | 337 | else Nothing
|
| 333 | 338 | decls = [ tyThingToIfaceDecl entity
|
| 334 | 339 | | entity <- entities,
|
| ... | ... | @@ -1256,7 +1256,7 @@ addFingerprints hsc_env iface0 = do |
| 1256 | 1256 | |
| 1257 | 1257 | sorted_extra_decls :: Maybe IfaceSimplifiedCore
|
| 1258 | 1258 | sorted_extra_decls = mi_simplified_core iface0 <&> \simpl_core ->
|
| 1259 | - IfaceSimplifiedCore (sortOn binding_key (mi_sc_extra_decls simpl_core)) (mi_sc_foreign simpl_core)
|
|
| 1259 | + IfaceSimplifiedCore (sortOn binding_key (mi_sc_extra_decls simpl_core)) (mi_sc_modBreaks simpl_core) (mi_sc_foreign simpl_core)
|
|
| 1260 | 1260 | |
| 1261 | 1261 | -- The interface hash depends on:
|
| 1262 | 1262 | -- - the ABI hash, plus
|
| ... | ... | @@ -7,7 +7,7 @@ where |
| 7 | 7 | |
| 8 | 8 | import GHC.Prelude
|
| 9 | 9 | |
| 10 | -import GHC.HsToCore.Breakpoints
|
|
| 10 | +import GHC.HsToCore.Breakpoints.Types
|
|
| 11 | 11 | import GHC.ForeignSrcLang
|
| 12 | 12 | |
| 13 | 13 | import GHC.Hs
|
| ... | ... | @@ -122,6 +122,8 @@ import GHC.Iface.Flags |
| 122 | 122 | import GHC.Iface.Ext.Fields
|
| 123 | 123 | import GHC.Iface.Recomp.Types
|
| 124 | 124 | |
| 125 | +import GHC.HsToCore.Breakpoints.Types
|
|
| 126 | + |
|
| 125 | 127 | import GHC.Unit
|
| 126 | 128 | import GHC.Unit.Module.Deps
|
| 127 | 129 | import GHC.Unit.Module.Warnings
|
| ... | ... | @@ -420,6 +422,8 @@ data IfaceSimplifiedCore = IfaceSimplifiedCore { |
| 420 | 422 | -- ^ Extra variable definitions which are **NOT** exposed but when
|
| 421 | 423 | -- combined with mi_decls allows us to restart code generation.
|
| 422 | 424 | -- See Note [Interface Files with Core Definitions] and Note [Interface File with Core: Sharing RHSs]
|
| 425 | + , mi_sc_modBreaks :: Maybe ModBreaks
|
|
| 426 | + -- ^ If breakpoints are present in @mi_sc_extra_decls@ this field provides this field provides the metadata required by the bytecode debugger.
|
|
| 423 | 427 | , mi_sc_foreign :: IfaceForeign
|
| 424 | 428 | -- ^ Foreign stubs and files to supplement 'mi_extra_decls_'.
|
| 425 | 429 | -- See Note [Foreign stubs and TH bytecode linking]
|
| ... | ... | @@ -749,14 +753,16 @@ instance Binary IfaceAbiHashes where |
| 749 | 753 | }
|
| 750 | 754 | |
| 751 | 755 | instance Binary IfaceSimplifiedCore where
|
| 752 | - put_ bh (IfaceSimplifiedCore eds fs) = do
|
|
| 756 | + put_ bh (IfaceSimplifiedCore eds mbs fs) = do
|
|
| 753 | 757 | put_ bh eds
|
| 758 | + put_ bh mbs
|
|
| 754 | 759 | put_ bh fs
|
| 755 | 760 | |
| 756 | 761 | get bh = do
|
| 757 | 762 | eds <- get bh
|
| 763 | + mbs <- get bh
|
|
| 758 | 764 | fs <- get bh
|
| 759 | - return (IfaceSimplifiedCore eds fs)
|
|
| 765 | + return (IfaceSimplifiedCore eds mbs fs)
|
|
| 760 | 766 | |
| 761 | 767 | emptyPartialModIface :: Module -> PartialModIface
|
| 762 | 768 | emptyPartialModIface mod
|
| ... | ... | @@ -865,7 +871,7 @@ instance NFData IfaceModInfo where |
| 865 | 871 | |
| 866 | 872 | |
| 867 | 873 | instance NFData IfaceSimplifiedCore where
|
| 868 | - rnf (IfaceSimplifiedCore eds fs) = rnf eds `seq` rnf fs
|
|
| 874 | + rnf (IfaceSimplifiedCore eds mbs fs) = rnf eds `seq` rnf mbs `seq` rnf fs
|
|
| 869 | 875 | |
| 870 | 876 | instance NFData IfaceAbiHashes where
|
| 871 | 877 | rnf (IfaceAbiHashes a1 a2 a3 a4 a5 a6)
|
| ... | ... | @@ -8,6 +8,7 @@ import GHC.Cmm.CLabel |
| 8 | 8 | import GHC.Driver.DynFlags (DynFlags (targetPlatform), initSDocContext)
|
| 9 | 9 | import GHC.ForeignSrcLang (ForeignSrcLang (..))
|
| 10 | 10 | import GHC.Iface.Syntax
|
| 11 | +import GHC.HsToCore.Breakpoints.Types (ModBreaks)
|
|
| 11 | 12 | import GHC.Prelude
|
| 12 | 13 | import GHC.Types.ForeignStubs
|
| 13 | 14 | import GHC.Unit.Module.Location
|
| ... | ... | @@ -122,6 +123,7 @@ the object files. |
| 122 | 123 | |
| 123 | 124 | data WholeCoreBindings = WholeCoreBindings
|
| 124 | 125 | { wcb_bindings :: [IfaceBindingX IfaceMaybeRhs IfaceTopBndrInfo] -- ^ serialised tidied core bindings.
|
| 126 | + , wcb_modBreaks :: Maybe ModBreaks -- ^ if @wcb_bindings@ contains breakpoints, this field provides the metadata required by the bytecode debugger.
|
|
| 125 | 127 | , wcb_module :: Module -- ^ The module which the bindings are for
|
| 126 | 128 | , wcb_mod_location :: ModLocation -- ^ The location where the sources reside.
|
| 127 | 129 | -- | Stubs for foreign declarations and files added via
|
| ... | ... | @@ -1974,6 +1974,7 @@ instance Binary UnhelpfulSpanReason where |
| 1974 | 1974 | _ -> UnhelpfulOther <$> get bh
|
| 1975 | 1975 | |
| 1976 | 1976 | newtype BinSrcSpan = BinSrcSpan { unBinSrcSpan :: SrcSpan }
|
| 1977 | + deriving newtype NFData
|
|
| 1977 | 1978 | |
| 1978 | 1979 | instance Binary GeneratedSrcSpanDetails where
|
| 1979 | 1980 | put_ bh (OrigSpan ss) = do
|
| ... | ... | @@ -572,6 +572,7 @@ Library |
| 572 | 572 | GHC.HsToCore.Arrows
|
| 573 | 573 | GHC.HsToCore.Binds
|
| 574 | 574 | GHC.HsToCore.Breakpoints
|
| 575 | + GHC.HsToCore.Breakpoints.Types
|
|
| 575 | 576 | GHC.HsToCore.Coverage
|
| 576 | 577 | GHC.HsToCore.Docs
|
| 577 | 578 | GHC.HsToCore.Errors.Ppr
|
| ... | ... | @@ -116,6 +116,7 @@ GHC.Hs.Pat |
| 116 | 116 | GHC.Hs.Specificity
|
| 117 | 117 | GHC.Hs.Type
|
| 118 | 118 | GHC.Hs.Utils
|
| 119 | +GHC.HsToCore.Breakpoints.Types
|
|
| 119 | 120 | GHC.HsToCore.Errors.Types
|
| 120 | 121 | GHC.HsToCore.Pmc.Solver.Types
|
| 121 | 122 | GHC.Iface.Errors.Types
|
| ... | ... | @@ -13,3 +13,7 @@ TopEnvIface: |
| 13 | 13 | # Second compilation starts from interface files, but still can print "a"
|
| 14 | 14 | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) TopEnvIface -v1 -fno-hide-source-paths -e "a" -e ":q" -fwrite-if-simplified-core -fwrite-interface
|
| 15 | 15 | |
| 16 | +T27287:
|
|
| 17 | + "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) T27287.hs -v1 -fno-hide-source-paths -e ":q" -fwrite-if-simplified-core -fwrite-interface
|
|
| 18 | + # Second compilation starts from interface files, but still can print "a"
|
|
| 19 | + "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) T27287.hs -v1 -fno-hide-source-paths -e ":break T27287 5" -e ":q" -fwrite-if-simplified-core -fwrite-interface |
| 1 | +module T27287 where
|
|
| 2 | + |
|
| 3 | +myfun :: String -> String
|
|
| 4 | +myfun xs = case reverse xs of
|
|
| 5 | + [] -> "empty"
|
|
| 6 | + xy -> xy |
| 1 | +[1 of 1] Compiling T27287 ( T27287.hs, interpreted )[main]
|
|
| 2 | +Ok, one module loaded.
|
|
| 3 | +Leaving GHCi.
|
|
| 4 | +Ok, one module loaded.
|
|
| 5 | +Breakpoint 0 activated at T27287.hs:5:9-15
|
|
| 6 | +Leaving GHCi. |
| ... | ... | @@ -8,6 +8,7 @@ test('ghcirun002', just_ghci, compile_and_run, ['']) |
| 8 | 8 | test('ghcirun003', just_ghci, compile_and_run, [''])
|
| 9 | 9 | test('T2589', just_ghci, compile_and_run, [''])
|
| 10 | 10 | test('T2881', just_ghci, compile_and_run, [''])
|
| 11 | +test('T27287', [just_ghci, combined_output], makefile_test, [])
|
|
| 11 | 12 | |
| 12 | 13 | test('T3171',
|
| 13 | 14 | [when(opsys('mingw32'),skip),
|