Skip to content

Commit d17af5f

Browse files
committed
fix: Look for active breaks in right ModBreaks
In `getActiveBreakpoints`, we were incorrectly looking up the occurence module of an internal breakpoint id (`getBreakSourceMod`) on the `InternalModBreaks` of a different module (`readIModBreaksMaybe` of the argument module, not the internal breakpoint id one)! That is just plain incorrect... The `activeBreakpoints` map stores the active internal-breakpoint-ids. To get the active breakpoints at module A, we find the *occurrence module* for every internal breakpoint id in `activeBreakpoints` and keep the ones whose occurrence module matches the argument module (recall: a breakpoint defined in B may be inlined in A, which means `getBreakSourceMod` will return `A` -- and that's what we want to match against the argument module) (See also Note [ModBreaks vs InternalModBreaks] and Note [Breakpoint identifiers] in GHC) Fixes #297
1 parent 5fdce54 commit d17af5f

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

haskell-debugger/GHC/Debugger/Breakpoint.hs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import GHC.Debugger.Session
3333
import GHC.Debugger.Utils
3434
import GHC.Debugger.Interface.Messages
3535
import qualified GHC.Debugger.Breakpoint.Map as BM
36+
import Data.Function
3637

3738
--------------------------------------------------------------------------------
3839
-- * Breakpoints
@@ -192,14 +193,14 @@ getActiveBreakpoints mfile = do
192193
mms <- getModuleByPath file
193194
case mms of
194195
Right ms -> do
195-
hsc_env <- getSession
196-
imodBreaks <- liftIO $ expectJust <$> readIModBreaksMaybe (hsc_HUG hsc_env) (ms_mod ms)
197-
return
198-
[ ibi
199-
| ibi <- BM.keys bm
200-
, getBreakSourceMod ibi imodBreaks == ms_mod ms
201-
-- assert: status is always > disabled
202-
]
196+
hug <- hsc_HUG <$> getSession
197+
-- Return all active IBIs whose occurrence (source) module
198+
-- matches the argument source module.
199+
map fst <$> filterM (\(ibi, info) -> do
200+
ibi_occ_mod <- getBreakSourceMod ibi <$> readIModBreaks hug ibi & liftIO
201+
assert (bpInfoStatus info /= BreakpointDisabled) $
202+
return (ibi_occ_mod == ms_mod ms)
203+
) (BM.toList bm)
203204
Left e -> do
204205
logSDoc Logger.Warning e
205206
return []

0 commit comments

Comments
 (0)