Rodrigo Mesquita pushed to branch wip/romes/step-out-11 at Glasgow Haskell Compiler / GHC
Commits:
-
ef667857
by Rodrigo Mesquita at 2025-07-11T19:46:30+01:00
7 changed files:
- compiler/GHC/ByteCode/Breakpoints.hs
- compiler/GHC/CoreToIface.hs
- compiler/GHC/Linker/Loader.hs
- compiler/GHC/Runtime/Debugger/Breakpoints.hs
- compiler/GHC/Runtime/Eval.hs
- compiler/GHC/StgToByteCode.hs
- ghc/GHCi/UI.hs
Changes:
1 | 1 | {-# LANGUAGE RecordWildCards #-}
|
2 | +{-# LANGUAGE DerivingStrategies #-}
|
|
2 | 3 | |
3 | 4 | -- | Breakpoint information constructed during ByteCode generation.
|
4 | 5 | --
|
... | ... | @@ -15,6 +16,7 @@ module GHC.ByteCode.Breakpoints |
15 | 16 | |
16 | 17 | -- ** Internal breakpoint identifier
|
17 | 18 | , InternalBreakpointId(..), BreakInfoIndex
|
19 | + , InternalBreakLoc(..)
|
|
18 | 20 | |
19 | 21 | -- * Operations
|
20 | 22 | |
... | ... | @@ -23,7 +25,7 @@ module GHC.ByteCode.Breakpoints |
23 | 25 | |
24 | 26 | -- ** Source-level information operations
|
25 | 27 | , getBreakLoc, getBreakVars, getBreakDecls, getBreakCCS
|
26 | - , getBreakSourceId
|
|
28 | + , getBreakSourceId, getBreakSourceMod
|
|
27 | 29 | |
28 | 30 | -- * Utils
|
29 | 31 | , seqInternalModBreaks
|
... | ... | @@ -165,7 +167,7 @@ data CgBreakInfo |
165 | 167 | { cgb_tyvars :: ![IfaceTvBndr] -- ^ Type variables in scope at the breakpoint
|
166 | 168 | , cgb_vars :: ![Maybe (IfaceIdBndr, Word)]
|
167 | 169 | , cgb_resty :: !IfaceType
|
168 | - , cgb_tick_id :: !BreakpointId
|
|
170 | + , cgb_tick_id :: !(Either InternalBreakLoc BreakpointId)
|
|
169 | 171 | -- ^ This field records the original breakpoint tick identifier for this
|
170 | 172 | -- internal breakpoint info. It is used to convert a breakpoint
|
171 | 173 | -- *occurrence* index ('InternalBreakpointId') into a *definition* index
|
... | ... | @@ -173,9 +175,19 @@ data CgBreakInfo |
173 | 175 | --
|
174 | 176 | -- The modules of breakpoint occurrence and breakpoint definition are not
|
175 | 177 | -- necessarily the same: See Note [Breakpoint identifiers].
|
178 | + --
|
|
179 | + -- If there is no original tick identifier (that is, the breakpoint was
|
|
180 | + -- created during code generation), instead refer directly to the SrcSpan
|
|
181 | + -- we want to use for it. See Note [Internal Breakpoint Locations]
|
|
176 | 182 | }
|
177 | 183 | -- See Note [Syncing breakpoint info] in GHC.Runtime.Eval
|
178 | 184 | |
185 | +-- | Breakpoints created during code generation don't have a source-level tick
|
|
186 | +-- location. Instead, we come up with one ourselves.
|
|
187 | +-- See Note [Internal Breakpoint Locations]
|
|
188 | +newtype InternalBreakLoc = InternalBreakLoc SrcSpan
|
|
189 | + deriving newtype (Eq, Show, NFData, Outputable)
|
|
190 | + |
|
179 | 191 | -- | Get an internal breakpoint info by 'InternalBreakpointId'
|
180 | 192 | getInternalBreak :: InternalBreakpointId -> InternalModBreaks -> CgBreakInfo
|
181 | 193 | getInternalBreak (InternalBreakpointId mod ix) imbs =
|
... | ... | @@ -196,27 +208,36 @@ assert_modules_match ibi_mod imbs_mod = |
196 | 208 | |
197 | 209 | -- | Get the source module and tick index for this breakpoint
|
198 | 210 | -- (as opposed to the module where this breakpoint occurs, which is in 'InternalBreakpointId')
|
199 | -getBreakSourceId :: InternalBreakpointId -> InternalModBreaks -> BreakpointId
|
|
211 | +getBreakSourceId :: InternalBreakpointId -> InternalModBreaks -> Either InternalBreakLoc BreakpointId
|
|
200 | 212 | getBreakSourceId (InternalBreakpointId ibi_mod ibi_ix) imbs =
|
201 | 213 | assert_modules_match ibi_mod (imodBreaks_module imbs) $
|
202 | 214 | let cgb = imodBreaks_breakInfo imbs IM.! ibi_ix
|
203 | 215 | in cgb_tick_id cgb
|
204 | 216 | |
217 | +-- | Get the source module for this breakpoint (where the breakpoint is defined)
|
|
218 | +getBreakSourceMod :: InternalBreakpointId -> InternalModBreaks -> Module
|
|
219 | +getBreakSourceMod (InternalBreakpointId ibi_mod ibi_ix) imbs =
|
|
220 | + assert_modules_match ibi_mod (imodBreaks_module imbs) $
|
|
221 | + let cgb = imodBreaks_breakInfo imbs IM.! ibi_ix
|
|
222 | + in case cgb_tick_id cgb of
|
|
223 | + Left InternalBreakLoc{} -> imodBreaks_module imbs
|
|
224 | + Right BreakpointId{bi_tick_mod} -> bi_tick_mod
|
|
225 | + |
|
205 | 226 | -- | Get the source span for this breakpoint
|
206 | 227 | getBreakLoc :: (Module -> IO ModBreaks) -> InternalBreakpointId -> InternalModBreaks -> IO SrcSpan
|
207 | -getBreakLoc = getBreakXXX modBreaks_locs
|
|
228 | +getBreakLoc = getBreakXXX modBreaks_locs (\(InternalBreakLoc x) -> x)
|
|
208 | 229 | |
209 | 230 | -- | Get the vars for this breakpoint
|
210 | 231 | getBreakVars :: (Module -> IO ModBreaks) -> InternalBreakpointId -> InternalModBreaks -> IO [OccName]
|
211 | -getBreakVars = getBreakXXX modBreaks_vars
|
|
232 | +getBreakVars = getBreakXXX modBreaks_vars (const [])
|
|
212 | 233 | |
213 | 234 | -- | Get the decls for this breakpoint
|
214 | 235 | getBreakDecls :: (Module -> IO ModBreaks) -> InternalBreakpointId -> InternalModBreaks -> IO [String]
|
215 | -getBreakDecls = getBreakXXX modBreaks_decls
|
|
236 | +getBreakDecls = getBreakXXX modBreaks_decls (const [])
|
|
216 | 237 | |
217 | 238 | -- | Get the decls for this breakpoint
|
218 | -getBreakCCS :: (Module -> IO ModBreaks) -> InternalBreakpointId -> InternalModBreaks -> IO (String, String)
|
|
219 | -getBreakCCS = getBreakXXX modBreaks_ccs
|
|
239 | +getBreakCCS :: (Module -> IO ModBreaks) -> InternalBreakpointId -> InternalModBreaks -> IO (Maybe (String, String))
|
|
240 | +getBreakCCS = getBreakXXX (fmap Just . modBreaks_ccs) (const Nothing)
|
|
220 | 241 | |
221 | 242 | -- | Internal utility to access a ModBreaks field at a particular breakpoint index
|
222 | 243 | --
|
... | ... | @@ -228,14 +249,17 @@ getBreakCCS = getBreakXXX modBreaks_ccs |
228 | 249 | -- 'ModBreaks'. When the tick module is different, we need to look up the
|
229 | 250 | -- 'ModBreaks' in the HUG for that other module.
|
230 | 251 | --
|
252 | +-- When there is no tick module (the breakpoint was generated at codegen), use
|
|
253 | +-- the function on internal mod breaks.
|
|
254 | +--
|
|
231 | 255 | -- To avoid cyclic dependencies, we instead receive a function that looks up
|
232 | 256 | -- the 'ModBreaks' given a 'Module'
|
233 | -getBreakXXX :: (ModBreaks -> Array BreakTickIndex a) -> (Module -> IO ModBreaks) -> InternalBreakpointId -> InternalModBreaks -> IO a
|
|
234 | -getBreakXXX view lookupModule (InternalBreakpointId ibi_mod ibi_ix) imbs =
|
|
257 | +getBreakXXX :: (ModBreaks -> Array BreakTickIndex a) -> (InternalBreakLoc -> a) -> (Module -> IO ModBreaks) -> InternalBreakpointId -> InternalModBreaks -> IO a
|
|
258 | +getBreakXXX view viewInternal lookupModule (InternalBreakpointId ibi_mod ibi_ix) imbs =
|
|
235 | 259 | assert_modules_match ibi_mod (imodBreaks_module imbs) $ do
|
236 | 260 | let cgb = imodBreaks_breakInfo imbs IM.! ibi_ix
|
237 | 261 | case cgb_tick_id cgb of
|
238 | - BreakpointId{bi_tick_mod, bi_tick_index}
|
|
262 | + Right BreakpointId{bi_tick_mod, bi_tick_index}
|
|
239 | 263 | | bi_tick_mod == ibi_mod
|
240 | 264 | -> do
|
241 | 265 | let these_mbs = imodBreaks_modBreaks imbs
|
... | ... | @@ -244,6 +268,8 @@ getBreakXXX view lookupModule (InternalBreakpointId ibi_mod ibi_ix) imbs = |
244 | 268 | -> do
|
245 | 269 | other_mbs <- lookupModule bi_tick_mod
|
246 | 270 | return $ view other_mbs ! bi_tick_index
|
271 | + Left l ->
|
|
272 | + return $ viewInternal l
|
|
247 | 273 | |
248 | 274 | --------------------------------------------------------------------------------
|
249 | 275 | -- Instances
|
... | ... | @@ -50,8 +50,6 @@ import GHC.Prelude |
50 | 50 | |
51 | 51 | import GHC.StgToCmm.Types
|
52 | 52 | |
53 | -import GHC.ByteCode.Types
|
|
54 | - |
|
55 | 53 | import GHC.Core
|
56 | 54 | import GHC.Core.TyCon hiding ( pprPromotionQuote )
|
57 | 55 | import GHC.Core.Coercion.Axiom
|
... | ... | @@ -58,6 +58,7 @@ import GHCi.RemoteTypes |
58 | 58 | import GHC.Iface.Load
|
59 | 59 | import GHCi.Message (ConInfoTable(..), LoadedDLL)
|
60 | 60 | |
61 | +import GHC.ByteCode.Breakpoints
|
|
61 | 62 | import GHC.ByteCode.Linker
|
62 | 63 | import GHC.ByteCode.Asm
|
63 | 64 | import GHC.ByteCode.Types
|
... | ... | @@ -1711,8 +1712,10 @@ allocateCCS interp ce mbss |
1711 | 1712 | let count = 1 + (maybe 0 fst $ IM.lookupMax imodBreaks_breakInfo)
|
1712 | 1713 | let ccs = IM.map
|
1713 | 1714 | (\info ->
|
1714 | - fromMaybe (toRemotePtr nullPtr)
|
|
1715 | - (M.lookup (cgb_tick_id info) ccss)
|
|
1715 | + case cgb_tick_id info of
|
|
1716 | + Right bi -> fromMaybe (toRemotePtr nullPtr)
|
|
1717 | + (M.lookup bi ccss)
|
|
1718 | + Left InternalBreakLoc{} -> toRemotePtr nullPtr
|
|
1716 | 1719 | )
|
1717 | 1720 | imodBreaks_breakInfo
|
1718 | 1721 | assertPpr (count == length ccs)
|
... | ... | @@ -253,8 +253,11 @@ mkBreakpointOccurrences = do |
253 | 253 | let imod = modBreaks_module $ imodBreaks_modBreaks ibrks
|
254 | 254 | IntMap.foldrWithKey (\info_ix cgi bmp -> do
|
255 | 255 | let ibi = InternalBreakpointId imod info_ix
|
256 | - let BreakpointId tick_mod tick_ix = cgb_tick_id cgi
|
|
257 | - extendModuleEnvWith (IntMap.unionWith (S.<>)) bmp tick_mod (IntMap.singleton tick_ix [ibi])
|
|
256 | + case cgb_tick_id cgi of
|
|
257 | + Right (BreakpointId tick_mod tick_ix)
|
|
258 | + -> extendModuleEnvWith (IntMap.unionWith (S.<>)) bmp tick_mod (IntMap.singleton tick_ix [ibi])
|
|
259 | + Left _
|
|
260 | + -> bmp
|
|
258 | 261 | ) bmp0 (imodBreaks_breakInfo ibrks)
|
259 | 262 | |
260 | 263 | --------------------------------------------------------------------------------
|
... | ... | @@ -287,7 +290,7 @@ getCurrentBreakModule = do |
287 | 290 | Nothing -> pure Nothing
|
288 | 291 | Just ibi -> do
|
289 | 292 | brks <- readIModBreaks hug ibi
|
290 | - return $ Just $ bi_tick_mod $ getBreakSourceId ibi brks
|
|
293 | + return $ Just $ getBreakSourceMod ibi brks
|
|
291 | 294 | ix ->
|
292 | 295 | Just <$> getHistoryModule hug (resumeHistory r !! (ix-1))
|
293 | 296 |
... | ... | @@ -151,7 +151,7 @@ getHistoryModule :: HUG.HomeUnitGraph -> History -> IO Module |
151 | 151 | getHistoryModule hug hist = do
|
152 | 152 | let ibi = historyBreakpointId hist
|
153 | 153 | brks <- readIModBreaks hug ibi
|
154 | - return $ bi_tick_mod $ getBreakSourceId ibi brks
|
|
154 | + return $ getBreakSourceMod ibi brks
|
|
155 | 155 | |
156 | 156 | getHistorySpan :: HUG.HomeUnitGraph -> History -> IO SrcSpan
|
157 | 157 | getHistorySpan hug hist = do
|
... | ... | @@ -63,7 +63,7 @@ import GHC.StgToCmm.Closure ( NonVoid(..), fromNonVoid, idPrimRepU, |
63 | 63 | assertNonVoidIds, assertNonVoidStgArgs )
|
64 | 64 | import GHC.StgToCmm.Layout
|
65 | 65 | import GHC.Runtime.Heap.Layout hiding (WordOff, ByteOff, wordsToBytes)
|
66 | -import GHC.Runtime.Interpreter ( interpreterProfiled )
|
|
66 | +import GHC.Runtime.Interpreter ( interpreterProfiled, readIModModBreaks )
|
|
67 | 67 | import GHC.Data.Bitmap
|
68 | 68 | import GHC.Data.FlatBag as FlatBag
|
69 | 69 | import GHC.Data.OrdList
|
... | ... | @@ -99,6 +99,7 @@ import GHC.CoreToIface |
99 | 99 | import Control.Monad.IO.Class
|
100 | 100 | import Control.Monad.Trans.Reader (ReaderT(..))
|
101 | 101 | import Control.Monad.Trans.State (StateT(..))
|
102 | +import Data.Array ((!))
|
|
102 | 103 | |
103 | 104 | -- -----------------------------------------------------------------------------
|
104 | 105 | -- Generating byte code for a complete module
|
... | ... | @@ -393,26 +394,30 @@ schemeR_wrk fvs nm original_body (args, body) |
393 | 394 | -- | Introduce break instructions for ticked expressions.
|
394 | 395 | -- If no breakpoint information is available, the instruction is omitted.
|
395 | 396 | schemeER_wrk :: StackDepth -> BCEnv -> CgStgExpr -> BcM BCInstrList
|
396 | -schemeER_wrk d p (StgTick (Breakpoint tick_ty tick_id fvs) rhs) = do
|
|
397 | - code <- schemeE d 0 p rhs
|
|
398 | - mb_current_mod_breaks <- getCurrentModBreaks
|
|
399 | - case mb_current_mod_breaks of
|
|
400 | - -- if we're not generating ModBreaks for this module for some reason, we
|
|
401 | - -- can't store breakpoint occurrence information.
|
|
402 | - Nothing -> pure code
|
|
403 | - Just current_mod_breaks -> do
|
|
404 | - platform <- profilePlatform <$> getProfile
|
|
405 | - let idOffSets = getVarOffSets platform d p fvs
|
|
406 | - ty_vars = tyCoVarsOfTypesWellScoped (tick_ty:map idType fvs)
|
|
407 | - toWord :: Maybe (Id, WordOff) -> Maybe (Id, Word)
|
|
408 | - toWord = fmap (\(i, wo) -> (i, fromIntegral wo))
|
|
409 | - breakInfo = dehydrateCgBreakInfo ty_vars (map toWord idOffSets) tick_ty tick_id
|
|
410 | - |
|
411 | - let info_mod = modBreaks_module current_mod_breaks
|
|
412 | - infox <- newBreakInfo breakInfo
|
|
397 | +schemeER_wrk d p (StgTick bp@(Breakpoint tick_ty tick_id fvs) rhs) = do
|
|
398 | + platform <- profilePlatform <$> getProfile
|
|
399 | + |
|
400 | + -- When we find a tick surrounding a case expression we introduce a new BRK_FUN
|
|
401 | + -- instruction at the start of the case *continuation*, in addition to the
|
|
402 | + -- usual BRK_FUN surrounding the StgCase)
|
|
403 | + -- See Note [TODO]
|
|
404 | + code <- case rhs of
|
|
405 | + StgCase scrut bndr _ alts
|
|
406 | + -> doCase d 0 p (Just bp) scrut bndr alts
|
|
407 | + _ -> schemeE d 0 p rhs
|
|
408 | + |
|
409 | + let idOffSets = getVarOffSets platform d p fvs
|
|
410 | + ty_vars = tyCoVarsOfTypesWellScoped (tick_ty:map idType fvs)
|
|
411 | + toWord :: Maybe (Id, WordOff) -> Maybe (Id, Word)
|
|
412 | + toWord = fmap (\(i, wo) -> (i, fromIntegral wo))
|
|
413 | + breakInfo = dehydrateCgBreakInfo ty_vars (map toWord idOffSets) tick_ty (Right tick_id)
|
|
414 | + |
|
415 | + mibi <- newBreakInfo breakInfo
|
|
416 | + |
|
417 | + return $ case mibi of
|
|
418 | + Nothing -> code
|
|
419 | + Just ibi -> BRK_FUN ibi `consOL` code
|
|
413 | 420 | |
414 | - let breakInstr = BRK_FUN (InternalBreakpointId info_mod infox)
|
|
415 | - return $ breakInstr `consOL` code
|
|
416 | 421 | schemeER_wrk d p rhs = schemeE d 0 p rhs
|
417 | 422 | |
418 | 423 | getVarOffSets :: Platform -> StackDepth -> BCEnv -> [Id] -> [Maybe (Id, WordOff)]
|
... | ... | @@ -614,7 +619,7 @@ schemeE d s p (StgTick _ rhs) = schemeE d s p rhs |
614 | 619 | schemeE d s p (StgCase scrut _ _ []) = schemeE d s p scrut
|
615 | 620 | |
616 | 621 | schemeE d s p (StgCase scrut bndr _ alts)
|
617 | - = doCase d s p scrut bndr alts
|
|
622 | + = doCase d s p Nothing scrut bndr alts
|
|
618 | 623 | |
619 | 624 | |
620 | 625 | {-
|
... | ... | @@ -1106,11 +1111,15 @@ doCase |
1106 | 1111 | :: StackDepth
|
1107 | 1112 | -> Sequel
|
1108 | 1113 | -> BCEnv
|
1114 | + -> Maybe StgTickish
|
|
1115 | + -- ^ The breakpoint surrounding the full case expression, if any (only
|
|
1116 | + -- source-level cases get breakpoint ticks, and those are the only we care
|
|
1117 | + -- about). See Note [TODO]
|
|
1109 | 1118 | -> CgStgExpr
|
1110 | 1119 | -> Id
|
1111 | 1120 | -> [CgStgAlt]
|
1112 | 1121 | -> BcM BCInstrList
|
1113 | -doCase d s p scrut bndr alts
|
|
1122 | +doCase d s p m_bid scrut bndr alts
|
|
1114 | 1123 | = do
|
1115 | 1124 | profile <- getProfile
|
1116 | 1125 | hsc_env <- getHscEnv
|
... | ... | @@ -1327,11 +1336,28 @@ doCase d s p scrut bndr alts |
1327 | 1336 | let alt_final1
|
1328 | 1337 | | ubx_tuple_frame = SLIDE 0 2 `consOL` alt_final0
|
1329 | 1338 | | otherwise = alt_final0
|
1330 | - alt_final
|
|
1331 | - | gopt Opt_InsertBreakpoints (hsc_dflags hsc_env)
|
|
1332 | - -- See Note [Debugger: BRK_ALTS]
|
|
1333 | - = BRK_ALTS False `consOL` alt_final1
|
|
1334 | - | otherwise = alt_final1
|
|
1339 | + |
|
1340 | + alt_final <- case m_bid of
|
|
1341 | + Just (Breakpoint tick_ty tick_id fvs)
|
|
1342 | + | gopt Opt_InsertBreakpoints (hsc_dflags hsc_env)
|
|
1343 | + -- Construct an internal breakpoint to put at the start of this case
|
|
1344 | + -- continuation BCO.
|
|
1345 | + -- See Note [TODO]
|
|
1346 | + -> do
|
|
1347 | + internal_tick_loc <- makeCaseInternalBreakLoc tick_id
|
|
1348 | + |
|
1349 | + -- same fvs available in the case expression are available in the case continuation
|
|
1350 | + let idOffSets = getVarOffSets platform d p fvs
|
|
1351 | + ty_vars = tyCoVarsOfTypesWellScoped (tick_ty:map idType fvs)
|
|
1352 | + toWord :: Maybe (Id, WordOff) -> Maybe (Id, Word)
|
|
1353 | + toWord = fmap (\(i, wo) -> (i, fromIntegral wo))
|
|
1354 | + breakInfo = dehydrateCgBreakInfo ty_vars (map toWord idOffSets) tick_ty (Left internal_tick_loc)
|
|
1355 | + |
|
1356 | + mibi <- newBreakInfo breakInfo
|
|
1357 | + return $ case mibi of
|
|
1358 | + Nothing -> alt_final1
|
|
1359 | + Just ibi -> BRK_FUN ibi `consOL` alt_final1
|
|
1360 | + _ -> pure alt_final1
|
|
1335 | 1361 | |
1336 | 1362 | add_bco_name <- shouldAddBcoName
|
1337 | 1363 | let
|
... | ... | @@ -1351,6 +1377,24 @@ doCase d s p scrut bndr alts |
1351 | 1377 | _ -> panic "schemeE(StgCase).push_alts"
|
1352 | 1378 | in return (PUSH_ALTS alt_bco scrut_rep `consOL` scrut_code)
|
1353 | 1379 | |
1380 | +makeCaseInternalBreakLoc :: BreakpointId -> BcM InternalBreakLoc
|
|
1381 | +makeCaseInternalBreakLoc bid = do
|
|
1382 | + hug <- hsc_HUG <$> getHscEnv
|
|
1383 | + curr_mod <- getCurrentModule
|
|
1384 | + mb_mod_brks <- getCurrentModBreaks
|
|
1385 | + |
|
1386 | + -- TODO: Subtract the scrutinee loc from the case loc to get continuation loc
|
|
1387 | + InternalBreakLoc <$> case bid of
|
|
1388 | + BreakpointId{bi_tick_mod, bi_tick_index}
|
|
1389 | + | bi_tick_mod == curr_mod
|
|
1390 | + , Just these_mbs <- mb_mod_brks
|
|
1391 | + -> do
|
|
1392 | + return $ modBreaks_locs these_mbs ! bi_tick_index
|
|
1393 | + | otherwise
|
|
1394 | + -> do
|
|
1395 | + other_mbs <- liftIO $ readIModModBreaks hug bi_tick_mod
|
|
1396 | + return $ modBreaks_locs other_mbs ! bi_tick_index
|
|
1397 | + |
|
1354 | 1398 | {-
|
1355 | 1399 | Note [Debugger: BRK_ALTS]
|
1356 | 1400 | ~~~~~~~~~~~~~~~~~~~~~~~~~
|
... | ... | @@ -2667,14 +2711,19 @@ getLabelsBc n = BcM $ \_ st -> |
2667 | 2711 | let ctr = nextlabel st
|
2668 | 2712 | in return (coerce [ctr .. ctr+n-1], st{nextlabel = ctr+n})
|
2669 | 2713 | |
2670 | -newBreakInfo :: CgBreakInfo -> BcM Int
|
|
2671 | -newBreakInfo info = BcM $ \_ st ->
|
|
2672 | - let ix = breakInfoIdx st
|
|
2673 | - st' = st
|
|
2674 | - { breakInfo = IntMap.insert ix info (breakInfo st)
|
|
2675 | - , breakInfoIdx = ix + 1
|
|
2676 | - }
|
|
2677 | - in return (ix, st')
|
|
2714 | +newBreakInfo :: CgBreakInfo -> BcM (Maybe InternalBreakpointId)
|
|
2715 | +newBreakInfo info = BcM $ \env st -> do
|
|
2716 | + -- if we're not generating ModBreaks for this module for some reason, we
|
|
2717 | + -- can't store breakpoint occurrence information.
|
|
2718 | + case modBreaks env of
|
|
2719 | + Nothing -> pure (Nothing, st)
|
|
2720 | + Just modBreaks -> do
|
|
2721 | + let ix = breakInfoIdx st
|
|
2722 | + st' = st
|
|
2723 | + { breakInfo = IntMap.insert ix info (breakInfo st)
|
|
2724 | + , breakInfoIdx = ix + 1
|
|
2725 | + }
|
|
2726 | + return (Just $ InternalBreakpointId (modBreaks_module modBreaks) ix, st')
|
|
2678 | 2727 | |
2679 | 2728 | getCurrentModule :: BcM Module
|
2680 | 2729 | getCurrentModule = BcM $ \env st -> return (bcm_module env, st)
|
... | ... | @@ -2687,7 +2736,7 @@ tickFS = fsLit "ticked" |
2687 | 2736 | |
2688 | 2737 | -- Dehydrating CgBreakInfo
|
2689 | 2738 | |
2690 | -dehydrateCgBreakInfo :: [TyVar] -> [Maybe (Id, Word)] -> Type -> BreakpointId -> CgBreakInfo
|
|
2739 | +dehydrateCgBreakInfo :: [TyVar] -> [Maybe (Id, Word)] -> Type -> Either InternalBreakLoc BreakpointId -> CgBreakInfo
|
|
2691 | 2740 | dehydrateCgBreakInfo ty_vars idOffSets tick_ty bid =
|
2692 | 2741 | CgBreakInfo
|
2693 | 2742 | { cgb_tyvars = map toIfaceTvBndr ty_vars
|
... | ... | @@ -45,7 +45,7 @@ import GHC.Runtime.Eval (mkTopLevEnv) |
45 | 45 | import GHC.Runtime.Eval.Utils
|
46 | 46 | |
47 | 47 | -- The GHC interface
|
48 | -import GHC.ByteCode.Breakpoints (imodBreaks_modBreaks, InternalBreakpointId(..), getBreakSourceId)
|
|
48 | +import GHC.ByteCode.Breakpoints (imodBreaks_modBreaks, InternalBreakpointId(..), getBreakSourceId, getBreakSourceMod)
|
|
49 | 49 | import GHC.Runtime.Interpreter
|
50 | 50 | import GHCi.RemoteTypes
|
51 | 51 | import GHCi.BreakArray( breakOn, breakOff )
|
... | ... | @@ -1621,7 +1621,7 @@ toBreakIdAndLocation (Just inf) = do |
1621 | 1621 | brks <- liftIO $ readIModBreaks hug inf
|
1622 | 1622 | let bi = getBreakSourceId inf brks
|
1623 | 1623 | return $ listToMaybe [ id_loc | id_loc@(_,loc) <- IntMap.assocs (breaks st),
|
1624 | - breakId loc == bi ]
|
|
1624 | + Right (breakId loc) == bi ]
|
|
1625 | 1625 | |
1626 | 1626 | printStoppedAtBreakInfo :: GHC.GhcMonad m => Resume -> [Name] -> m ()
|
1627 | 1627 | printStoppedAtBreakInfo res names = do
|
... | ... | @@ -3825,7 +3825,7 @@ pprStopped res = do |
3825 | 3825 | hug <- hsc_HUG <$> GHC.getSession
|
3826 | 3826 | brks <- liftIO $ readIModBreaks hug ibi
|
3827 | 3827 | return $ Just $ moduleName $
|
3828 | - bi_tick_mod $ getBreakSourceId ibi brks
|
|
3828 | + getBreakSourceMod ibi brks
|
|
3829 | 3829 | return $
|
3830 | 3830 | text "Stopped in"
|
3831 | 3831 | <+> ((case mb_mod_name of
|