Skip to content

Commit d521e9e

Browse files
committed
io-sim-por: backport logging of MaskingState
Backport aa0fb5b11 to `IOSimPOR`.
1 parent 742f4de commit d521e9e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

io-sim/src/Control/Monad/IOSimPOR/Internal.hs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,22 +301,24 @@ schedule thread@Thread{
301301
let thread' = thread { threadControl = ThreadControl (k x) ctl'
302302
, threadMasking = maskst' }
303303
-- but if we're now unmasked, check for any pending async exceptions
304-
deschedule Interruptable thread' simstate
304+
trace <- deschedule Interruptable thread' simstate
305+
return (SimTrace time tid tlbl (EventMask maskst') trace)
305306

306307
CatchFrame _handler k ctl' -> do
307308
-- pop the control stack and continue
308309
let thread' = thread { threadControl = ThreadControl (k x) ctl' }
309310
schedule thread' simstate
310311

311312
Throw e -> case unwindControlStack e thread of
312-
Right thread0 -> do
313+
Right thread0@Thread { threadMasking = maskst' } -> do
313314
-- We found a suitable exception handler, continue with that
314315
-- We record a step, in case there is no exception handler on replay.
315316
let thread' = stepThread thread0
316317
control' = advanceControl (threadStepId thread0) control
317318
races' = updateRacesInSimState thread0 simstate
318319
trace <- schedule thread' simstate{ races = races', control = control' }
319-
return (SimTrace time tid tlbl (EventThrow e) trace)
320+
return (SimTrace time tid tlbl (EventThrow e) $
321+
SimTrace time tid tlbl (EventMask maskst') trace)
320322

321323
Left isMain
322324
-- We unwound and did not find any suitable exception handler, so we
@@ -583,10 +585,12 @@ schedule thread@Thread{
583585
(runIOSim action')
584586
(MaskFrame k maskst ctl)
585587
, threadMasking = maskst' }
586-
case maskst' of
587-
-- If we're now unmasked then check for any pending async exceptions
588-
Unmasked -> deschedule Interruptable thread' simstate
589-
_ -> schedule thread' simstate
588+
trace <-
589+
case maskst' of
590+
-- If we're now unmasked then check for any pending async exceptions
591+
Unmasked -> deschedule Interruptable thread' simstate
592+
_ -> schedule thread' simstate
593+
return (SimTrace time tid tlbl (EventMask maskst') trace)
590594

591595
ThrowTo e tid' _ | tid' == tid -> do
592596
-- Throw to ourself is equivalent to a synchronous throw,

0 commit comments

Comments
 (0)