runThreadToEventWorker :: Worker -> History -> ThreadId -> Topped AccessNr -> IO (Maybe TraceRecord, History, ReplayState)
runThreadToEventWorker worker start tid limit =
    do setThreadWorker worker tid
       trc <- traceCmd worker $ runToEventPacket limit
       rs <- replayStateWorker worker
       let newHist = appendHistory start $ HistoryRun tid $ Finite $ rs_access_nr rs
       return (case trc of
                 [] -> Nothing
                 [x] -> Just x
                 _ -> error $ "runToEvent gave long trace " ++ (show trc), newHist, rs)
runThreadToEventWorker :: Worker -> History -> ThreadId -> Topped AccessNr -> IO (Maybe TraceRecord, History, ReplayState)
runThreadToEventWorker worker start tid limit =
    do setThreadWorker worker tid
       trc <- traceCmd worker $ runToEventPacket limit
       rs <- replayStateWorker worker
       let newHist = appendHistory start $ HistoryRun tid $ Finite $ rs_access_nr rs
       return (case trc of
                 [] -> Nothing
                 [x] -> Just x
                 _ -> error $ "runToEvent gave long trace " ++ (show trc), newHist, rs)
runThreadToEventWorker worker start tid limit =
    do setThreadWorker worker tid
       trc <- traceCmd worker $ runToEventPacket limit
       rs <- replayStateWorker worker
       let newHist = appendHistory start $ HistoryRun tid $ Finite $ rs_access_nr rs
       return (case trc of
                 [] -> Nothing
                 [x] -> Just x
                 _ -> error $ "runToEvent gave long trace " ++ (show trc), newHist, rs)