@@ -27,7 +27,7 @@ module Control.Monad.IOSim
27
27
, unshareClock
28
28
-- * Simulation trace
29
29
, type SimTrace
30
- , Trace (Cons , Nil , Trace , SimTrace , TraceDeadlock , TraceLoop ,
30
+ , Trace (Cons , Nil , Trace , SimTrace , SimPORTrace , TraceDeadlock , TraceLoop ,
31
31
TraceMainReturn , TraceMainException , TraceRacesFound )
32
32
, SimResult (.. )
33
33
, SimEvent (.. )
@@ -59,7 +59,7 @@ module Control.Monad.IOSim
59
59
, printTraceEventsSay
60
60
-- * Exploration options
61
61
, ExplorationSpec
62
- , ExplorationOptions
62
+ , ExplorationOptions ( .. )
63
63
, stdExplorationOptions
64
64
, withScheduleBound
65
65
, withBranching
@@ -135,6 +135,7 @@ selectTraceRaces :: SimTrace a -> [ScheduleControl]
135
135
selectTraceRaces = go
136
136
where
137
137
go (SimTrace _ _ _ _ trace) = go trace
138
+ go (SimPORTrace _ _ _ _ _ trace) = go trace
138
139
go (TraceRacesFound races trace) =
139
140
races ++ go trace
140
141
go _ = []
@@ -160,9 +161,10 @@ detachTraceRaces trace = unsafePerformIO $ do
160
161
saveRaces r t = unsafePerformIO $ do
161
162
modifyIORef races (r: )
162
163
return t
163
- let go (SimTrace a b c d trace) = SimTrace a b c d $ go trace
164
- go (TraceRacesFound r trace) = saveRaces r $ go trace
165
- go t = t
164
+ let go (SimTrace a b c d trace) = SimTrace a b c d $ go trace
165
+ go (SimPORTrace a b c d e trace) = SimPORTrace a b c d e $ go trace
166
+ go (TraceRacesFound r trace) = saveRaces r $ go trace
167
+ go t = t
166
168
return (readRaces,go trace)
167
169
168
170
-- | Select all the traced values matching the expected type. This relies on
@@ -230,6 +232,10 @@ traceSelectTraceEvents fn = bifoldr ( \ v _acc -> Nil v )
230
232
case fn (seType eventCtx) of
231
233
Nothing -> acc
232
234
Just b -> Cons b acc
235
+ SimPOREvent {} ->
236
+ case fn (seType eventCtx) of
237
+ Nothing -> acc
238
+ Just b -> Cons b acc
233
239
)
234
240
undefined -- it is ignored
235
241
@@ -306,6 +312,7 @@ traceResult :: Bool -> SimTrace a -> Either Failure a
306
312
traceResult strict = go
307
313
where
308
314
go (SimTrace _ _ _ _ t) = go t
315
+ go (SimPORTrace _ _ _ _ _ t) = go t
309
316
go (TraceRacesFound _ t) = go t
310
317
go (TraceMainReturn _ _ tids@ (_: _))
311
318
| strict = Left (FailureSloppyShutdown tids)
@@ -315,9 +322,11 @@ traceResult strict = go
315
322
go TraceLoop {} = error " Impossible: traceResult TraceLoop{}"
316
323
317
324
traceEvents :: SimTrace a -> [(Time , ThreadId , Maybe ThreadLabel , SimEventType )]
318
- traceEvents (SimTrace time tid tlbl event t) = (time, tid, tlbl, event)
319
- : traceEvents t
320
- traceEvents _ = []
325
+ traceEvents (SimTrace time tid tlbl event t) = (time, tid, tlbl, event)
326
+ : traceEvents t
327
+ traceEvents (SimPORTrace time tid _ tlbl event t) = (time, tid, tlbl, event)
328
+ : traceEvents t
329
+ traceEvents _ = []
321
330
322
331
323
332
ppEvents :: [(Time , ThreadId , Maybe ThreadLabel , SimEventType )]
@@ -462,23 +471,28 @@ compareTraces (Just passing) trace = unsafePerformIO $ do
462
471
sleeper <- newIORef Nothing
463
472
return (unsafePerformIO $ readIORef sleeper,
464
473
go sleeper passing trace)
465
- where go sleeper (SimTrace tpass tidpass _ _ pass')
466
- ( SimTrace tfail tidfail tlfail evfail fail')
474
+ where go sleeper (SimPORTrace tpass tidpass _ _ _ pass')
475
+ ( SimPORTrace tfail tidfail tstepfail tlfail evfail fail')
467
476
| (tpass,tidpass) == (tfail,tidfail) =
468
- SimTrace tfail tidfail tlfail evfail $
469
- go sleeper pass' fail'
470
- go sleeper (SimTrace tpass tidpass tlpass _ _) fail =
477
+ SimPORTrace tfail tidfail tstepfail tlfail evfail
478
+ $ go sleeper pass' fail'
479
+ go sleeper (SimPORTrace tpass tidpass tsteppass tlpass _ _) fail =
471
480
unsafePerformIO $ do
472
481
writeIORef sleeper $ Just ((tpass, tidpass, tlpass),Set. empty)
473
- return $ SimTrace tpass tidpass tlpass EventThreadSleep $
474
- wakeup sleeper tidpass fail
482
+ return $ SimPORTrace tpass tidpass tsteppass tlpass EventThreadSleep
483
+ $ wakeup sleeper tidpass fail
484
+ go _ SimTrace {} _ = error " compareTraces: invariant violation"
485
+ go _ _ SimTrace {} = error " compareTraces: invariant violation"
475
486
go _ _ fail = fail
476
- wakeup sleeper tidpass fail @ (SimTrace tfail tidfail tlfail evfail fail')
487
+
488
+ wakeup sleeper tidpass
489
+ fail @ (SimPORTrace tfail tidfail tstepfail tlfail evfail fail')
477
490
| tidpass == tidfail =
478
- SimTrace tfail tidfail tlfail EventThreadWake fail
491
+ SimPORTrace tfail tidfail tstepfail tlfail EventThreadWake fail
479
492
| otherwise = unsafePerformIO $ do
480
493
Just (slp,racing) <- readIORef sleeper
481
494
writeIORef sleeper $ Just (slp,Set. insert (tidfail,tlfail) racing)
482
- return $ SimTrace tfail tidfail tlfail evfail
495
+ return $ SimPORTrace tfail tidfail tstepfail tlfail evfail
483
496
$ wakeup sleeper tidpass fail'
497
+ wakeup _ _ SimTrace {} = error " compareTraces: invariant violation"
484
498
wakeup _ _ fail = fail
0 commit comments