{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}
module GHC.RTS.Events.Binary
  ( -- * Readers
    getHeader
  , getEvent
  , standardParsers
  , mercuryParsers
  , perfParsers
  , heapProfParsers
  , timeProfParsers
  , parRTSParsers
  , binaryEventParsers
  , tickyParsers

  -- * Writers
  , putEventLog
  , putHeader
  , putEvent

  -- * Perf events
  , nEVENT_PERF_NAME
  , nEVENT_PERF_COUNTER
  , nEVENT_PERF_TRACEPOINT

  ) where
import Control.Exception (assert)
import Control.Monad
import Data.List (intersperse)
import Data.Maybe
import Prelude hiding (gcd, rem, id)

import Data.Array
import Data.Binary
import Data.Binary.Put
import qualified Data.Binary.Get as G
import qualified Data.ByteString as B
import qualified Data.Text as T
import qualified Data.Text.Read as TR
import qualified Data.Text.Encoding as TE
import qualified Data.Vector.Unboxed as VU

import GHC.RTS.EventTypes
import GHC.RTS.EventParserUtils

#define EVENTLOG_CONSTANTS_ONLY
#include "EventLogFormat.h"

getEventType :: Get EventType
getEventType :: Get EventType
getEventType = do
           EventTypeNum
etNum <- forall t. Binary t => Get t
get
           EventTypeNum
size <- forall t. Binary t => Get t
get :: Get EventTypeSize
           let etSize :: Maybe EventTypeNum
etSize = if EventTypeNum
size forall a. Eq a => a -> a -> Bool
== EventTypeNum
0xffff then forall a. Maybe a
Nothing else forall a. a -> Maybe a
Just EventTypeNum
size
           -- 0xffff indicates variable-sized event
           Word32
etDescLen <- forall t. Binary t => Get t
get :: Get EventTypeDescLen
           Text
etDesc <- forall a. Integral a => a -> Get Text
getText Word32
etDescLen
           Word32
etExtraLen <- forall t. Binary t => Get t
get :: Get Word32
           Int -> Get ()
G.skip (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
etExtraLen)
           Word32
ete <- forall t. Binary t => Get t
get :: Get Marker
           forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Word32
ete forall a. Eq a => a -> a -> Bool
/= EVENT_ET_ENDforall a b. (a -> b) -> a -> b
) $
              forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Event Type end marker not found."
           forall (m :: * -> *) a. Monad m => a -> m a
return (EventTypeNum -> Text -> Maybe EventTypeNum -> EventType
EventType EventTypeNum
etNum Text
etDesc Maybe EventTypeNum
etSize)

getHeader :: Get Header
getHeader :: Get Header
getHeader = do
            Word32
hdrb <- forall t. Binary t => Get t
get :: Get Marker
            forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Word32
hdrb forall a. Eq a => a -> a -> Bool
/= EVENT_HEADER_BEGIN) $
                 forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Header begin marker not found"
            Word32
hetm <- forall t. Binary t => Get t
get :: Get Marker
            forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Word32
hetm forall a. Eq a => a -> a -> Bool
/= EVENT_HET_BEGIN) $
                 forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Header Event Type begin marker not found"
            [EventType]
ets <- Get [EventType]
getEventTypes
            Word32
emark <- forall t. Binary t => Get t
get :: Get Marker
            forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Word32
emark forall a. Eq a => a -> a -> Bool
/= EVENT_HEADER_END) $
                 forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Header end marker not found"
            Word32
db <- forall t. Binary t => Get t
get :: Get Marker
            forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Word32
db forall a. Eq a => a -> a -> Bool
/= EVENT_DATA_BEGIN) $
                  forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"My Data begin marker not found"
            forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ [EventType] -> Header
Header [EventType]
ets
     where
      getEventTypes :: Get [EventType]
      getEventTypes :: Get [EventType]
getEventTypes = do
          Word32
m <- forall t. Binary t => Get t
get :: Get Marker
          case Word32
m of
             EVENT_ET_BEGIN -> do
                  et <- getEventType
                  nextET <- getEventTypes
                  return (et : nextET)
             EVENT_HET_END ->
                  return []
             Word32
_ ->
                  forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Malformed list of Event Types in header"

getEvent :: EventParsers -> Get (Maybe Event)
getEvent :: EventParsers -> Get (Maybe Event)
getEvent (EventParsers Array Int (Get EventInfo)
parsers) = do
  EventTypeNum
etRef <- forall t. Binary t => Get t
get :: Get EventTypeNum
  if EventTypeNum
etRef forall a. Eq a => a -> a -> Bool
== EVENT_DATA_END
     then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
     else do !Timestamp
evTime   <- forall t. Binary t => Get t
get
             EventInfo
evSpec <- Array Int (Get EventInfo)
parsers forall i e. Ix i => Array i e -> i -> e
! forall a b. (Integral a, Num b) => a -> b
fromIntegral EventTypeNum
etRef
             forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just Event { evCap :: Maybe Int
evCap = forall a. HasCallStack => a
undefined, Timestamp
EventInfo
evSpec :: EventInfo
evTime :: Timestamp
evSpec :: EventInfo
evTime :: Timestamp
.. }

--
-- standardEventParsers.
--
standardParsers :: [EventParser EventInfo]
standardParsers :: [EventParser EventInfo]
standardParsers = [
 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_STARTUP sz_cap (do -- (n_caps)
      c <- get :: Get CapNo
      return Startup{ n_caps = fromIntegral c }
   )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_BLOCK_MARKER (sz_block_size + sz_time + sz_cap) (do -- (size, end_time, cap)
      block_size <- get :: Get BlockSize
      end_time <- get :: Get Timestamp
      c <- get :: Get CapNo
      return EventBlock { end_time   = end_time,
                          cap        = fromIntegral c,
                          block_size = ((fromIntegral block_size) -
                                        (fromIntegral sz_block_event))
                        }
   )),

 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_REQUEST_SEQ_GC RequestSeqGC),

 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_REQUEST_PAR_GC RequestParGC),

 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_GC_START StartGC),

 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_GC_WORK GCWork),

 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_GC_IDLE GCIdle),

 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_GC_DONE GCDone),

 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_GC_END EndGC),

 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_GC_GLOBAL_SYNC GlobalSyncGC),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_GC_STATS_GHC (sz_capset + 2 + 5*8 + 4) (do  -- (heap_capset, generation, copied_bytes, slop_bytes, frag_bytes, par_n_threads, par_max_copied, par_tot_copied)
      Word32
heapCapset   <- forall t. Binary t => Get t
get
      EventTypeNum
gen          <- forall t. Binary t => Get t
get :: Get Word16
      Timestamp
copied       <- forall t. Binary t => Get t
get :: Get Word64
      Timestamp
slop         <- forall t. Binary t => Get t
get :: Get Word64
      Timestamp
frag         <- forall t. Binary t => Get t
get :: Get Word64
      Word32
parNThreads  <- forall t. Binary t => Get t
get :: Get Word32
      Timestamp
parMaxCopied <- forall t. Binary t => Get t
get :: Get Word64
      Timestamp
parTotCopied <- forall t. Binary t => Get t
get :: Get Word64
      forall (m :: * -> *) a. Monad m => a -> m a
return GCStatsGHC{ gen :: Int
gen = forall a b. (Integral a, Num b) => a -> b
fromIntegral EventTypeNum
gen
                       , parNThreads :: Int
parNThreads = forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
parNThreads
                       , parBalancedCopied :: Maybe Timestamp
parBalancedCopied = forall a. Maybe a
Nothing
                       , Word32
Timestamp
parTotCopied :: Timestamp
parMaxCopied :: Timestamp
frag :: Timestamp
slop :: Timestamp
copied :: Timestamp
heapCapset :: Word32
parTotCopied :: Timestamp
parMaxCopied :: Timestamp
frag :: Timestamp
slop :: Timestamp
copied :: Timestamp
heapCapset :: Word32
..}
 )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_GC_STATS_GHC (sz_capset + 2 + 5*8 + 4 + 8) (do  -- (heap_capset, generation, copied_bytes, slop_bytes, frag_bytes, par_n_threads, par_max_copied, par_tot_copied, par_balanced_copied)
      Word32
heapCapset   <- forall t. Binary t => Get t
get
      EventTypeNum
gen          <- forall t. Binary t => Get t
get :: Get Word16
      Timestamp
copied       <- forall t. Binary t => Get t
get :: Get Word64
      Timestamp
slop         <- forall t. Binary t => Get t
get :: Get Word64
      Timestamp
frag         <- forall t. Binary t => Get t
get :: Get Word64
      Word32
parNThreads  <- forall t. Binary t => Get t
get :: Get Word32
      Timestamp
parMaxCopied <- forall t. Binary t => Get t
get :: Get Word64
      Timestamp
parTotCopied <- forall t. Binary t => Get t
get :: Get Word64
      Timestamp
parBalancedCopied <- forall t. Binary t => Get t
get :: Get Word64
      forall (m :: * -> *) a. Monad m => a -> m a
return GCStatsGHC{ gen :: Int
gen = forall a b. (Integral a, Num b) => a -> b
fromIntegral EventTypeNum
gen
                       , parNThreads :: Int
parNThreads = forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
parNThreads
                       , parBalancedCopied :: Maybe Timestamp
parBalancedCopied = forall a. a -> Maybe a
Just Timestamp
parBalancedCopied
                       , Word32
Timestamp
parTotCopied :: Timestamp
parMaxCopied :: Timestamp
frag :: Timestamp
slop :: Timestamp
copied :: Timestamp
heapCapset :: Word32
parTotCopied :: Timestamp
parMaxCopied :: Timestamp
frag :: Timestamp
slop :: Timestamp
copied :: Timestamp
heapCapset :: Word32
..}
 )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_MEM_RETURN (sz_capset + 3*4) (do
      heapCapset   <- get
      current      <- get :: Get Word32
      needed       <- get :: Get Word32
      returned     <- get :: Get Word32
      return $! MemReturn{ current = current
                       , needed = needed
                       , returned = returned
                       , ..}
 )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_HEAP_ALLOCATED (sz_capset + 8) (do  -- (heap_capset, alloc_bytes)
      heapCapset <- get
      allocBytes <- get
      return HeapAllocated{..}
 )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_HEAP_SIZE (sz_capset + 8) (do  -- (heap_capset, size_bytes)
      heapCapset <- get
      sizeBytes  <- get
      return HeapSize{..}
 )),
 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_BLOCKS_SIZE (sz_capset + 8) (do  -- (heap_capset, blocks_size)
      heapCapset <- get
      blocksSize  <- get
      return $! BlocksSize{..}
 )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_HEAP_LIVE (sz_capset + 8) (do  -- (heap_capset, live_bytes)
      heapCapset <- get
      liveBytes  <- get
      return HeapLive{..}
 )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_HEAP_INFO_GHC (sz_capset + 2 + 4*8) (do  -- (heap_capset, n_generations, max_heap_size, alloc_area_size, mblock_size, block_size)
      heapCapset    <- get
      gens          <- get :: Get Word16
      maxHeapSize   <- get :: Get Word64
      allocAreaSize <- get :: Get Word64
      mblockSize    <- get :: Get Word64
      blockSize     <- get :: Get Word64
      return HeapInfoGHC{gens = fromIntegral gens, ..}
 )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_CAP_CREATE (sz_cap) (do  -- (cap)
      cap <- get :: Get CapNo
      return CapCreate{cap = fromIntegral cap}
 )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_CAP_DELETE (sz_cap) (do  -- (cap)
      cap <- get :: Get CapNo
      return CapDelete{cap = fromIntegral cap}
 )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_CAP_DISABLE (sz_cap) (do  -- (cap)
      cap <- get :: Get CapNo
      return CapDisable{cap = fromIntegral cap}
 )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_CAP_ENABLE (sz_cap) (do  -- (cap)
      cap <- get :: Get CapNo
      return CapEnable{cap = fromIntegral cap}
 )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_CAPSET_CREATE (sz_capset + sz_capset_type) (do -- (capset, capset_type)
      Word32
cs <- forall t. Binary t => Get t
get
      CapsetType
ct <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap EventTypeNum -> CapsetType
mkCapsetType forall t. Binary t => Get t
get
      forall (m :: * -> *) a. Monad m => a -> m a
return CapsetCreate{capset :: Word32
capset=Word32
cs,capsetType :: CapsetType
capsetType=CapsetType
ct}
   )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_CAPSET_DELETE sz_capset (do -- (capset)
      cs <- get
      return CapsetDelete{capset=cs}
   )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_CAPSET_ASSIGN_CAP (sz_capset + sz_cap) (do -- (capset, cap)
      Word32
cs <- forall t. Binary t => Get t
get
      EventTypeNum
cp <- forall t. Binary t => Get t
get :: Get CapNo
      forall (m :: * -> *) a. Monad m => a -> m a
return CapsetAssignCap{capset :: Word32
capset=Word32
cs,cap :: Int
cap=forall a b. (Integral a, Num b) => a -> b
fromIntegral EventTypeNum
cp}
   )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_CAPSET_REMOVE_CAP (sz_capset + sz_cap) (do -- (capset, cap)
      Word32
cs <- forall t. Binary t => Get t
get
      EventTypeNum
cp <- forall t. Binary t => Get t
get :: Get CapNo
      forall (m :: * -> *) a. Monad m => a -> m a
return CapsetRemoveCap{capset :: Word32
capset=Word32
cs,cap :: Int
cap=forall a b. (Integral a, Num b) => a -> b
fromIntegral EventTypeNum
cp}
   )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_OSPROCESS_PID (sz_capset + sz_pid) (do -- (capset, pid)
      cs <- get
      pd <- get
      return OsProcessPid{capset=cs,pid=pd}
   )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_OSPROCESS_PPID (sz_capset + sz_pid) (do -- (capset, ppid)
      cs <- get
      pd <- get
      return OsProcessParentPid{capset=cs,ppid=pd}
  )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_WALL_CLOCK_TIME (sz_capset + 8 + 4) (do -- (capset, unix_epoch_seconds, nanoseconds)
      cs <- get
      s  <- get
      ns <- get
      return WallClockTime{capset=cs,sec=s,nsec=ns}
  )),

 (forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_LOG_MSG (do -- (msg)
      num <- get :: Get Word16
      string <- getText num
      return Message{ msg = string }
   )),
 (forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_USER_MSG (do -- (msg)
      num <- get :: Get Word16
      string <- getText num
      return UserMessage{ msg = string }
   )),
    (forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_USER_MARKER (do -- (markername)
      num <- get :: Get Word16
      string <- getText num
      return UserMarker{ markername = string }
   )),
 (forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_PROGRAM_ARGS (do -- (capset, [arg])
      num <- get :: Get Word16
      cs <- get
      string <- getText (num - sz_capset)
      return ProgramArgs
        { capset = cs
        , args = T.splitOn "\0" $ T.dropWhileEnd (== '\0') string }
   )),
 (forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_PROGRAM_ENV (do -- (capset, [arg])
      num <- get :: Get Word16
      cs <- get
      string <- getText (num - sz_capset)
      return ProgramEnv
        { capset = cs
        , env = T.splitOn "\0" $ T.dropWhileEnd (== '\0') string }
   )),
 (forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_RTS_IDENTIFIER (do -- (capset, str)
      num <- get :: Get Word16
      cs <- get
      string <- getText (num - sz_capset)
      return RtsIdentifier{ capset = cs
                          , rtsident = string }
   )),

 (forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_INTERN_STRING (do -- (str, id)
      num <- get :: Get Word16
      string <- getString (num - sz_string_id)
      sId <- get :: Get StringId
      return (InternString string sId)
    )),

 (forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_THREAD_LABEL (do -- (thread, str)
      num <- get :: Get Word16
      tid <- get
      str <- getText (num - sz_tid)
      return ThreadLabel{ thread      = tid
                        , threadlabel = str }
    )),

 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_CONC_MARK_BEGIN ConcMarkBegin),
 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_CONC_MARK_END 4 (do -- (marked_object_count)
      num <- get :: Get Word32
      return ConcMarkEnd{ concMarkedObjectCount = num }
    )),
 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_CONC_SYNC_BEGIN ConcSyncBegin),
 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_CONC_SYNC_END ConcSyncEnd),
 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_CONC_SWEEP_BEGIN ConcSweepBegin),
 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_CONC_SWEEP_END ConcSweepEnd),
 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_CONC_UPD_REM_SET_FLUSH sz_cap (do -- (cap)
      cap <- get :: Get CapNo
      return ConcUpdRemSetFlush{ cap = fromIntegral cap }
    )),
 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_NONMOVING_HEAP_CENSUS 13 (do -- (blk_size, active_segs, filled_segs, live_blks)
      nonmovingCensusBlkSize <- get :: Get Word8
      nonmovingCensusActiveSegs <- get :: Get Word32
      nonmovingCensusFilledSegs <- get :: Get Word32
      nonmovingCensusLiveBlocks <- get :: Get Word32
      return NonmovingHeapCensus{..}
    )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_CREATE_THREAD sz_tid (do  -- (thread)
      t <- get
      return CreateThread{thread=t}
   )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_RUN_THREAD sz_tid (do  --  (thread)
      t <- get
      return RunThread{thread=t}
   )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_THREAD_RUNNABLE sz_tid (do  -- (thread)
      t <- get
      return ThreadRunnable{thread=t}
   )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_MIGRATE_THREAD (sz_tid + sz_cap) (do  --  (thread, newCap)
      Word32
t  <- forall t. Binary t => Get t
get
      EventTypeNum
nc <- forall t. Binary t => Get t
get :: Get CapNo
      forall (m :: * -> *) a. Monad m => a -> m a
return MigrateThread{thread :: Word32
thread=Word32
t,newCap :: Int
newCap=forall a b. (Integral a, Num b) => a -> b
fromIntegral EventTypeNum
nc}
   )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_CREATE_SPARK_THREAD sz_tid (do  -- (sparkThread)
      st <- get :: Get ThreadId
      return CreateSparkThread{sparkThread=st}
   )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_SPARK_COUNTERS (7*8) (do -- (crt,dud,ovf,cnv,gcd,fiz,rem)
      crt <- get :: Get Word64
      dud <- get :: Get Word64
      ovf <- get :: Get Word64
      cnv <- get :: Get Word64
      gcd <- get :: Get Word64
      fiz <- get :: Get Word64
      rem <- get :: Get Word64
      return SparkCounters{sparksCreated    = crt, sparksDud       = dud,
                           sparksOverflowed = ovf, sparksConverted = cnv,
                           -- Warning: order of fiz and gcd reversed!
                           sparksFizzled    = fiz, sparksGCd       = gcd,
                           sparksRemaining  = rem}
   )),

 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_SPARK_CREATE   SparkCreate),
 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_SPARK_DUD      SparkDud),
 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_SPARK_OVERFLOW SparkOverflow),
 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_SPARK_RUN      SparkRun),
 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_SPARK_STEAL sz_cap (do  -- (victimCap)
      vc <- get :: Get CapNo
      return SparkSteal{victimCap=fromIntegral vc}
   )),
 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_SPARK_FIZZLE   SparkFizzle),
 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_SPARK_GC       SparkGC),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_TASK_CREATE (sz_taskid + sz_cap + sz_kernel_tid) (do  -- (taskID, cap, tid)
      taskId <- get :: Get TaskId
      cap    <- get :: Get CapNo
      tid    <- get :: Get KernelThreadId
      return TaskCreate{ taskId, cap = fromIntegral cap, tid }
   )),
 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_TASK_MIGRATE (sz_taskid + sz_cap*2) (do  -- (taskID, cap, new_cap)
      taskId  <- get :: Get TaskId
      cap     <- get :: Get CapNo
      new_cap <- get :: Get CapNo
      return TaskMigrate{ taskId, cap = fromIntegral cap
                                , new_cap = fromIntegral new_cap
                        }
   )),
 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_TASK_DELETE (sz_taskid) (do  -- (taskID)
      taskId <- get :: Get TaskId
      return TaskDelete{ taskId }
   )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_THREAD_WAKEUP (sz_tid + sz_cap) (do  -- (thread, other_cap)
      Word32
t <- forall t. Binary t => Get t
get
      EventTypeNum
oc <- forall t. Binary t => Get t
get :: Get CapNo
      forall (m :: * -> *) a. Monad m => a -> m a
return WakeupThread{thread :: Word32
thread=Word32
t,otherCap :: Int
otherCap=forall a b. (Integral a, Num b) => a -> b
fromIntegral EventTypeNum
oc}
   )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_STOP_THREAD (sz_tid + sz_th_stop_status + sz_tid)
    (do
      -- (thread, status, info)
      Word32
t <- forall t. Binary t => Get t
get
      EventTypeNum
s <- forall t. Binary t => Get t
get :: Get RawThreadStopStatus
      Word32
i <- forall t. Binary t => Get t
get :: Get ThreadId
      forall (m :: * -> *) a. Monad m => a -> m a
return StopThread{thread :: Word32
thread = Word32
t,
                        status :: ThreadStopStatus
status = case () of
                                  ()
_ | EventTypeNum
s forall a. Ord a => a -> a -> Bool
> EventTypeNum
maxThreadStopStatus
                                    -> ThreadStopStatus
NoStatus
                                    | EventTypeNum
s forall a. Eq a => a -> a -> Bool
== EventTypeNum
8 {- XXX yeuch -}
                                      -- post-7.8.2: 8==BlockedOnBlackhole
                                    -> Word32 -> ThreadStopStatus
BlockedOnBlackHoleOwnedBy Word32
i
                                    | Bool
otherwise
                                    -> EventTypeNum -> ThreadStopStatus
mkStopStatus EventTypeNum
s}
    ))
 ]


-- Parsers for parallel events. Parameter is the thread_id size, to create
-- ghc6-parsers (using the wrong size) where necessary.
parRTSParsers :: EventTypeSize -> [EventParser EventInfo]
parRTSParsers :: EventTypeNum -> [EventParser EventInfo]
parRTSParsers EventTypeNum
sz_tid' = [
 (forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_VERSION (do -- (version)
      num <- get :: Get Word16
      string <- getString num
      return Version{ version = string }
   )),

 (forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_PROGRAM_INVOCATION (do -- (cmd. line)
      num <- get :: Get Word16
      string <- getString num
      return ProgramInvocation{ commandline = string }
   )),

 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_EDEN_START_RECEIVE EdenStartReceive),
 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_EDEN_END_RECEIVE   EdenEndReceive),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_CREATE_PROCESS sz_procid
    (do Word32
p <- forall t. Binary t => Get t
get
        forall (m :: * -> *) a. Monad m => a -> m a
return CreateProcess{ process :: Word32
process = Word32
p })
 ),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_KILL_PROCESS sz_procid
    (do Word32
p <- forall t. Binary t => Get t
get
        forall (m :: * -> *) a. Monad m => a -> m a
return KillProcess{ process :: Word32
process = Word32
p })
 ),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_ASSIGN_THREAD_TO_PROCESS (sz_tid' + sz_procid)
    (do Word32
t <- forall t. Binary t => Get t
get
        Word32
p <- forall t. Binary t => Get t
get
        forall (m :: * -> *) a. Monad m => a -> m a
return AssignThreadToProcess { thread :: Word32
thread = Word32
t, process :: Word32
process = Word32
p })
 ),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_CREATE_MACHINE (sz_mid + sz_realtime)
    (do EventTypeNum
m <- forall t. Binary t => Get t
get
        Timestamp
t <- forall t. Binary t => Get t
get
        forall (m :: * -> *) a. Monad m => a -> m a
return CreateMachine { machine :: EventTypeNum
machine = EventTypeNum
m, realtime :: Timestamp
realtime = Timestamp
t })
 ),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_KILL_MACHINE sz_mid
    (do EventTypeNum
m <- forall t. Binary t => Get t
get :: Get MachineId
        forall (m :: * -> *) a. Monad m => a -> m a
return KillMachine { machine :: EventTypeNum
machine = EventTypeNum
m })
 ),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_SEND_MESSAGE
    (EventTypeNum
sz_msgtag forall a. Num a => a -> a -> a
+ EventTypeNum
2forall a. Num a => a -> a -> a
*EventTypeNum
sz_procid forall a. Num a => a -> a -> a
+ EventTypeNum
2forall a. Num a => a -> a -> a
*EventTypeNum
sz_tid' forall a. Num a => a -> a -> a
+ EventTypeNum
sz_mid)
    (do RawMsgTag
tag <- forall t. Binary t => Get t
get :: Get RawMsgTag
        Word32
sP  <- forall t. Binary t => Get t
get :: Get ProcessId
        Word32
sT  <- forall t. Binary t => Get t
get :: Get ThreadId
        EventTypeNum
rM  <- forall t. Binary t => Get t
get :: Get MachineId
        Word32
rP  <- forall t. Binary t => Get t
get :: Get ProcessId
        Word32
rIP <- forall t. Binary t => Get t
get :: Get PortId
        forall (m :: * -> *) a. Monad m => a -> m a
return SendMessage { mesTag :: MessageTag
mesTag = RawMsgTag -> MessageTag
toMsgTag RawMsgTag
tag,
                             senderProcess :: Word32
senderProcess = Word32
sP,
                             senderThread :: Word32
senderThread = Word32
sT,
                             receiverMachine :: EventTypeNum
receiverMachine = EventTypeNum
rM,
                             receiverProcess :: Word32
receiverProcess = Word32
rP,
                             receiverInport :: Word32
receiverInport = Word32
rIP
                           })
 ),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_RECEIVE_MESSAGE
    (EventTypeNum
sz_msgtag forall a. Num a => a -> a -> a
+ EventTypeNum
2forall a. Num a => a -> a -> a
*EventTypeNum
sz_procid forall a. Num a => a -> a -> a
+ EventTypeNum
2forall a. Num a => a -> a -> a
*EventTypeNum
sz_tid' forall a. Num a => a -> a -> a
+ EventTypeNum
sz_mid forall a. Num a => a -> a -> a
+ EventTypeNum
sz_mes)
    (do RawMsgTag
tag <- forall t. Binary t => Get t
get :: Get Word8
        Word32
rP  <- forall t. Binary t => Get t
get :: Get ProcessId
        Word32
rIP <- forall t. Binary t => Get t
get :: Get PortId
        EventTypeNum
sM  <- forall t. Binary t => Get t
get :: Get MachineId
        Word32
sP  <- forall t. Binary t => Get t
get :: Get ProcessId
        Word32
sT  <- forall t. Binary t => Get t
get :: Get ThreadId
        Word32
mS  <- forall t. Binary t => Get t
get :: Get MessageSize
        forall (m :: * -> *) a. Monad m => a -> m a
return  ReceiveMessage { mesTag :: MessageTag
mesTag = RawMsgTag -> MessageTag
toMsgTag RawMsgTag
tag,
                                 receiverProcess :: Word32
receiverProcess = Word32
rP,
                                 receiverInport :: Word32
receiverInport = Word32
rIP,
                                 senderMachine :: EventTypeNum
senderMachine = EventTypeNum
sM,
                                 senderProcess :: Word32
senderProcess = Word32
sP,
                                 senderThread :: Word32
senderThread= Word32
sT,
                                 messageSize :: Word32
messageSize = Word32
mS
                               })
 ),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_SEND_RECEIVE_LOCAL_MESSAGE
    (EventTypeNum
sz_msgtag forall a. Num a => a -> a -> a
+ EventTypeNum
2forall a. Num a => a -> a -> a
*EventTypeNum
sz_procid forall a. Num a => a -> a -> a
+ EventTypeNum
2forall a. Num a => a -> a -> a
*EventTypeNum
sz_tid')
    (do RawMsgTag
tag <- forall t. Binary t => Get t
get :: Get Word8
        Word32
sP  <- forall t. Binary t => Get t
get :: Get ProcessId
        Word32
sT  <- forall t. Binary t => Get t
get :: Get ThreadId
        Word32
rP  <- forall t. Binary t => Get t
get :: Get ProcessId
        Word32
rIP <- forall t. Binary t => Get t
get :: Get PortId
        forall (m :: * -> *) a. Monad m => a -> m a
return SendReceiveLocalMessage { mesTag :: MessageTag
mesTag = RawMsgTag -> MessageTag
toMsgTag RawMsgTag
tag,
                                         senderProcess :: Word32
senderProcess = Word32
sP,
                                         senderThread :: Word32
senderThread = Word32
sT,
                                         receiverProcess :: Word32
receiverProcess = Word32
rP,
                                         receiverInport :: Word32
receiverInport = Word32
rIP
                                       })
 )]

mercuryParsers :: [EventParser EventInfo]
mercuryParsers :: [EventParser EventInfo]
mercuryParsers = [
 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_MER_START_PAR_CONJUNCTION
    (EventTypeNum
sz_par_conj_dyn_id forall a. Num a => a -> a -> a
+ EventTypeNum
sz_par_conj_static_id)
    (do Timestamp
dyn_id <- forall t. Binary t => Get t
get
        Word32
static_id <- forall t. Binary t => Get t
get
        forall (m :: * -> *) a. Monad m => a -> m a
return (Timestamp -> Word32 -> EventInfo
MerStartParConjunction Timestamp
dyn_id Word32
static_id))
 ),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_MER_STOP_PAR_CONJUNCTION sz_par_conj_dyn_id
    (do Timestamp
dyn_id <- forall t. Binary t => Get t
get
        forall (m :: * -> *) a. Monad m => a -> m a
return (Timestamp -> EventInfo
MerEndParConjunction Timestamp
dyn_id))
 ),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_MER_STOP_PAR_CONJUNCT sz_par_conj_dyn_id
    (do Timestamp
dyn_id <- forall t. Binary t => Get t
get
        forall (m :: * -> *) a. Monad m => a -> m a
return (Timestamp -> EventInfo
MerEndParConjunct Timestamp
dyn_id))
 ),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_MER_CREATE_SPARK (sz_par_conj_dyn_id + sz_spark_id)
    (do Timestamp
dyn_id <- forall t. Binary t => Get t
get
        Word32
spark_id <- forall t. Binary t => Get t
get
        forall (m :: * -> *) a. Monad m => a -> m a
return (Timestamp -> Word32 -> EventInfo
MerCreateSpark Timestamp
dyn_id Word32
spark_id))
 ),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_MER_FUT_CREATE (sz_future_id + sz_string_id)
    (do Timestamp
future_id <- forall t. Binary t => Get t
get
        Word32
name_id <- forall t. Binary t => Get t
get
        forall (m :: * -> *) a. Monad m => a -> m a
return (Timestamp -> Word32 -> EventInfo
MerFutureCreate Timestamp
future_id Word32
name_id))
 ),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_MER_FUT_WAIT_NOSUSPEND (sz_future_id)
    (do Timestamp
future_id <- forall t. Binary t => Get t
get
        forall (m :: * -> *) a. Monad m => a -> m a
return (Timestamp -> EventInfo
MerFutureWaitNosuspend Timestamp
future_id))
 ),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_MER_FUT_WAIT_SUSPENDED (sz_future_id)
    (do Timestamp
future_id <- forall t. Binary t => Get t
get
        forall (m :: * -> *) a. Monad m => a -> m a
return (Timestamp -> EventInfo
MerFutureWaitSuspended Timestamp
future_id))
 ),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_MER_FUT_SIGNAL (sz_future_id)
    (do Timestamp
future_id <- forall t. Binary t => Get t
get
        forall (m :: * -> *) a. Monad m => a -> m a
return (Timestamp -> EventInfo
MerFutureSignal Timestamp
future_id))
 ),

 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_MER_LOOKING_FOR_GLOBAL_CONTEXT MerLookingForGlobalThread),
 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_MER_WORK_STEALING MerWorkStealing),
 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_MER_LOOKING_FOR_LOCAL_SPARK MerLookingForLocalSpark),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_MER_RELEASE_CONTEXT sz_tid
    (do Word32
thread_id <- forall t. Binary t => Get t
get
        forall (m :: * -> *) a. Monad m => a -> m a
return (Word32 -> EventInfo
MerReleaseThread Word32
thread_id))
 ),

 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_MER_ENGINE_SLEEPING MerCapSleeping),
 (forall a. Int -> a -> EventParser a
simpleEvent EVENT_MER_CALLING_MAIN MerCallingMain)

 ]

perfParsers :: [EventParser EventInfo]
perfParsers :: [EventParser EventInfo]
perfParsers = [
 (forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_PERF_NAME (do -- (perf_num, name)
      num     <- get :: Get Word16
      perfNum <- get
      name    <- getText (num - sz_perf_num)
      return PerfName{perfNum, name}
   )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_PERF_COUNTER (sz_perf_num + sz_kernel_tid + 8) (do -- (perf_num, tid, period)
      perfNum <- get
      tid     <- get
      period  <- get
      return PerfCounter{perfNum, tid, period}
  )),

 (forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_PERF_TRACEPOINT (sz_perf_num + sz_kernel_tid) (do -- (perf_num, tid)
      Word32
perfNum <- forall t. Binary t => Get t
get
      KernelThreadId
tid     <- forall t. Binary t => Get t
get
      forall (m :: * -> *) a. Monad m => a -> m a
return PerfTracepoint{Word32
perfNum :: Word32
perfNum :: Word32
perfNum, KernelThreadId
tid :: KernelThreadId
tid :: KernelThreadId
tid}
  ))
 ]

heapProfParsers :: [EventParser EventInfo]
heapProfParsers :: [EventParser EventInfo]
heapProfParsers =
  [ forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_HEAP_PROF_BEGIN $ do
    payloadLen <- get :: Get Word16
    heapProfId <- get
    heapProfSamplingPeriod <- get
    heapProfBreakdown <- get
    heapProfModuleFilter <- getTextNul
    heapProfClosureDescrFilter <- getTextNul
    heapProfTypeDescrFilter <- getTextNul
    heapProfCostCentreFilter <- getTextNul
    heapProfCostCentreStackFilter <- getTextNul
    heapProfRetainerFilter <- getTextNul
    heapProfBiographyFilter <- getTextNul
    assert
      (fromIntegral payloadLen == sum
        [ 1 -- heapProfId
        , 8 -- heapProfSamplingPeriod
        , 4 -- heapProfBreakdown
        , textByteLen heapProfModuleFilter
        , textByteLen heapProfClosureDescrFilter
        , textByteLen heapProfTypeDescrFilter
        , textByteLen heapProfCostCentreFilter
        , textByteLen heapProfCostCentreStackFilter
        , textByteLen heapProfRetainerFilter
        , textByteLen heapProfBiographyFilter
        ])
      (return ())
    return $! HeapProfBegin {..}
  , forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_HEAP_PROF_COST_CENTRE $ do
    payloadLen <- get :: Get Word16
    heapProfCostCentreId <- get
    heapProfLabel <- getTextNul
    heapProfModule <- getTextNul
    heapProfSrcLoc <- getTextNul
    heapProfFlags <- get
    assert
      (fromIntegral payloadLen == sum
        [ 4 -- heapProfCostCentreId
        , textByteLen heapProfLabel
        , textByteLen heapProfModule
        , textByteLen heapProfSrcLoc
        , 1 -- heapProfFlags
        ])
      (return ())
    return $! HeapProfCostCentre {..}
  , forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_IPE $ do
    payloadLen <- get :: Get Word16
    itInfo <- get
    itTableName <- getTextNul
    itClosureDescText <- getTextNul
    itClosureDesc <- either fail (return . fst) (TR.decimal itClosureDescText)
    itTyDesc <- getTextNul
    itLabel <- getTextNul
    itModule <- getTextNul
    itSrcLoc <- getTextNul
    assert
      (fromIntegral payloadLen == sum
        [ 8 -- itInfo
        , textByteLen itTableName
        , textByteLen itClosureDescText
        , textByteLen itTyDesc
        , textByteLen itLabel
        , textByteLen itModule
        , textByteLen itSrcLoc
        ])
      (return ())
    return $! InfoTableProv {..}
  , forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_HEAP_PROF_SAMPLE_BEGIN 8 $ do
    heapProfSampleEra <- get
    return $! HeapProfSampleBegin {..}
  , forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_HEAP_PROF_SAMPLE_END 8 $ do
    heapProfSampleEra <- get
    return $! HeapProfSampleEnd {..}
  , forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_HEAP_BIO_PROF_SAMPLE_BEGIN 16 $ do
    heapProfSampleEra <- get
    heapProfSampleTime <- get
    return $! HeapBioProfSampleBegin {..}
  , forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_HEAP_PROF_SAMPLE_COST_CENTRE $ do
    payloadLen <- get :: Get Word16
    heapProfId <- get
    heapProfResidency <- get
    heapProfStackDepth <- get
    heapProfStack <- VU.replicateM (fromIntegral heapProfStackDepth) get
    assert
      ((fromIntegral payloadLen :: Int) == sum
        [ 1 -- heapProfId
        , 8 -- heapProfResidency
        , 1 -- heapProfStackDepth
        , fromIntegral heapProfStackDepth * 4
        ])
      (return ())
    return $! HeapProfSampleCostCentre {..}
  , forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_HEAP_PROF_SAMPLE_STRING $ do
    payloadLen <- get :: Get Word16
    heapProfId <- get
    heapProfResidency <- get
    heapProfLabel <- getTextNul
    assert
      (fromIntegral payloadLen == sum
        [ 1 -- heapProfId
        , 8 -- heapProfResidency
        , textByteLen heapProfLabel
        ])
      (return ())
    return $! HeapProfSampleString {..}
  ]

timeProfParsers :: [EventParser EventInfo]
timeProfParsers :: [EventParser EventInfo]
timeProfParsers = [
  forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_PROF_BEGIN 8 $ do
    profTickInterval <- get
    return $! ProfBegin{..}
  , forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_PROF_SAMPLE_COST_CENTRE $ do
    payloadLen <- get :: Get Word16
    profCapset <- get
    profTicks <- get
    profStackDepth <- get
    profCcsStack <- VU.replicateM (fromIntegral profStackDepth) get
    assert
      ((fromIntegral payloadLen :: Int) == sum
        [ 4
        , 8 -- ticks
        , 1 -- stack depth
        , fromIntegral profStackDepth * 4
        ])
      (return ())
    return $! ProfSampleCostCentre {..} ]

binaryEventParsers :: [EventParser EventInfo]
binaryEventParsers :: [EventParser EventInfo]
binaryEventParsers =
  [ forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_USER_BINARY_MSG $ do
    payloadLen <- get :: Get Word16
    payload <- G.getByteString $ fromIntegral payloadLen
    return $! UserBinaryMessage { payload }
  ]

tickyParsers :: [EventParser EventInfo]
tickyParsers :: [EventParser EventInfo]
tickyParsers =
  [ forall a. Int -> Get a -> EventParser a
VariableSizeParser EVENT_TICKY_COUNTER_DEF $ do
    payloadLen         <- get :: Get Word16
    tickyCtrDefId      <- get
    tickyCtrDefArity   <- get
    tickyCtrDefKinds   <- getTextNul
    tickyCtrDefName    <- getTextNul
    assert
      (fromIntegral payloadLen == sum
        [ 8 -- tickyCtrDefId
        , 2 -- tickyCtrDefArity
        , textByteLen tickyCtrDefKinds
        , textByteLen tickyCtrDefName
        ])
      (return ())
    return $! TickyCounterDef{..}
  , forall a. Int -> EventTypeNum -> Get a -> EventParser a
FixedSizeParser EVENT_TICKY_COUNTER_SAMPLE (8*4) $ do
    tickyCtrSampleId         <- get
    tickyCtrSampleEntryCount <- get
    tickyCtrSampleAllocs     <- get
    tickyCtrSampleAllocd     <- get
    return $! TickyCounterSample{..}
  , forall a. Int -> a -> EventParser a
simpleEvent EVENT_TICKY_BEGIN_SAMPLE TickyBeginSample
  ]

-- | String byte length in the event log format. It includes
-- 1 byte for NUL.
textByteLen :: T.Text -> Int
textByteLen :: Text -> Int
textByteLen = (forall a. Num a => a -> a -> a
+Int
1) forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Int
B.length forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ByteString
TE.encodeUtf8

-----------------------------------------------------------

putE :: Binary a => a -> PutM ()
putE :: forall a. Binary a => a -> PutM ()
putE = forall a. Binary a => a -> PutM ()
put

putType :: EventTypeNum -> PutM ()
putType :: EventTypeNum -> PutM ()
putType = forall a. Binary a => a -> PutM ()
putE

putCap :: Int -> PutM ()
putCap :: Int -> PutM ()
putCap Int
c = forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
c :: CapNo)

putMarker :: Word32 -> PutM ()
putMarker :: Word32 -> PutM ()
putMarker = forall a. Binary a => a -> PutM ()
putE

putEventLog :: EventLog -> PutM ()
putEventLog :: EventLog -> PutM ()
putEventLog (EventLog Header
hdr Data
es) = do
    Header -> PutM ()
putHeader Header
hdr
    Data -> PutM ()
putData Data
es

putHeader :: Header -> PutM ()
putHeader :: Header -> PutM ()
putHeader (Header [EventType]
ets) = do
    Word32 -> PutM ()
putMarker EVENT_HEADER_BEGIN
    Word32 -> PutM ()
putMarker EVENT_HET_BEGIN
    forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ EventType -> PutM ()
putEventType [EventType]
ets
    Word32 -> PutM ()
putMarker EVENT_HET_END
    Word32 -> PutM ()
putMarker EVENT_HEADER_END
 where
    putEventType :: EventType -> PutM ()
putEventType (EventType EventTypeNum
n (Text -> ByteString
TE.encodeUtf8 -> ByteString
d) Maybe EventTypeNum
msz) = do
        Word32 -> PutM ()
putMarker EVENT_ET_BEGIN
        EventTypeNum -> PutM ()
putType EventTypeNum
n
        forall a. Binary a => a -> PutM ()
putE forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a -> a
fromMaybe EventTypeNum
0xffff Maybe EventTypeNum
msz
        forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
d :: EventTypeDescLen)
        ByteString -> PutM ()
putByteString ByteString
d
        -- the event type header allows for extra data, which we don't use:
        forall a. Binary a => a -> PutM ()
putE (Word32
0 :: Word32)
        Word32 -> PutM ()
putMarker EVENT_ET_END

putData :: Data -> PutM ()
putData :: Data -> PutM ()
putData (Data [Event]
es) = do
    Word32 -> PutM ()
putMarker EVENT_DATA_BEGIN -- Word32
    forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Event -> PutM ()
putEvent [Event]
es
    EventTypeNum -> PutM ()
putType EVENT_DATA_END -- Word16

eventTypeNum :: EventInfo -> EventTypeNum
eventTypeNum :: EventInfo -> EventTypeNum
eventTypeNum EventInfo
e = case EventInfo
e of
    CreateThread {} -> EVENT_CREATE_THREAD
    RunThread {} -> EVENT_RUN_THREAD
    StopThread {} -> EVENT_STOP_THREAD
    ThreadRunnable {} -> EVENT_THREAD_RUNNABLE
    MigrateThread {} -> EVENT_MIGRATE_THREAD
    Shutdown {} -> EVENT_SHUTDOWN
    WakeupThread {} -> EVENT_THREAD_WAKEUP
    ThreadLabel {}  -> EVENT_THREAD_LABEL
    StartGC {} -> EVENT_GC_START
    EndGC {} -> EVENT_GC_END
    GlobalSyncGC {} -> EVENT_GC_GLOBAL_SYNC
    RequestSeqGC {} -> EVENT_REQUEST_SEQ_GC
    RequestParGC {} -> EVENT_REQUEST_PAR_GC
    CreateSparkThread {} -> EVENT_CREATE_SPARK_THREAD
    SparkCounters {} -> EVENT_SPARK_COUNTERS
    SparkCreate   {} -> EVENT_SPARK_CREATE
    SparkDud      {} -> EVENT_SPARK_DUD
    SparkOverflow {} -> EVENT_SPARK_OVERFLOW
    SparkRun      {} -> EVENT_SPARK_RUN
    SparkSteal    {} -> EVENT_SPARK_STEAL
    SparkFizzle   {} -> EVENT_SPARK_FIZZLE
    SparkGC       {} -> EVENT_SPARK_GC
    TaskCreate  {} -> EVENT_TASK_CREATE
    TaskMigrate {} -> EVENT_TASK_MIGRATE
    TaskDelete  {} -> EVENT_TASK_DELETE
    Message {} -> EVENT_LOG_MSG
    Startup {} -> EVENT_STARTUP
    EventBlock {} -> EVENT_BLOCK_MARKER
    UserMessage {} -> EVENT_USER_MSG
    UserMarker  {} -> EVENT_USER_MARKER
    GCIdle {} -> EVENT_GC_IDLE
    GCWork {} -> EVENT_GC_WORK
    GCDone {} -> EVENT_GC_DONE
    GCStatsGHC{} -> EVENT_GC_STATS_GHC
    HeapAllocated{} -> EVENT_HEAP_ALLOCATED
    HeapSize{} -> EVENT_HEAP_SIZE
    BlocksSize{} -> EVENT_BLOCKS_SIZE
    HeapLive{} -> EVENT_HEAP_LIVE
    HeapInfoGHC{} -> EVENT_HEAP_INFO_GHC
    CapCreate{} -> EVENT_CAP_CREATE
    CapDelete{} -> EVENT_CAP_DELETE
    CapDisable{} -> EVENT_CAP_DISABLE
    CapEnable{} -> EVENT_CAP_ENABLE
    CapsetCreate {} -> EVENT_CAPSET_CREATE
    CapsetDelete {} -> EVENT_CAPSET_DELETE
    CapsetAssignCap {} -> EVENT_CAPSET_ASSIGN_CAP
    CapsetRemoveCap {} -> EVENT_CAPSET_REMOVE_CAP
    RtsIdentifier {} -> EVENT_RTS_IDENTIFIER
    ProgramArgs {} -> EVENT_PROGRAM_ARGS
    ProgramEnv {} -> EVENT_PROGRAM_ENV
    OsProcessPid {} -> EVENT_OSPROCESS_PID
    OsProcessParentPid{} -> EVENT_OSPROCESS_PPID
    WallClockTime{} -> EVENT_WALL_CLOCK_TIME
    UnknownEvent {} -> forall a. HasCallStack => String -> a
error String
"eventTypeNum UnknownEvent"
    InternString {} -> EVENT_INTERN_STRING
    Version {} -> EVENT_VERSION
    ProgramInvocation {} -> EVENT_PROGRAM_INVOCATION
    EdenStartReceive {} -> EVENT_EDEN_START_RECEIVE
    EdenEndReceive {} -> EVENT_EDEN_END_RECEIVE
    CreateProcess {} -> EVENT_CREATE_PROCESS
    KillProcess {} -> EVENT_KILL_PROCESS
    AssignThreadToProcess {} -> EVENT_ASSIGN_THREAD_TO_PROCESS
    CreateMachine {} -> EVENT_CREATE_MACHINE
    KillMachine {} -> EVENT_KILL_MACHINE
    SendMessage {} -> EVENT_SEND_MESSAGE
    ReceiveMessage {} -> EVENT_RECEIVE_MESSAGE
    SendReceiveLocalMessage {} -> EVENT_SEND_RECEIVE_LOCAL_MESSAGE
    MerStartParConjunction {} -> EVENT_MER_START_PAR_CONJUNCTION
    MerEndParConjunction Timestamp
_ -> EVENT_MER_STOP_PAR_CONJUNCTION
    MerEndParConjunct Timestamp
_ -> EVENT_MER_STOP_PAR_CONJUNCT
    MerCreateSpark {} -> EVENT_MER_CREATE_SPARK
    MerFutureCreate {} -> EVENT_MER_FUT_CREATE
    MerFutureWaitNosuspend Timestamp
_ -> EVENT_MER_FUT_WAIT_NOSUSPEND
    MerFutureWaitSuspended Timestamp
_ -> EVENT_MER_FUT_WAIT_SUSPENDED
    MerFutureSignal Timestamp
_ -> EVENT_MER_FUT_SIGNAL
    EventInfo
MerLookingForGlobalThread -> EVENT_MER_LOOKING_FOR_GLOBAL_CONTEXT
    EventInfo
MerWorkStealing -> EVENT_MER_WORK_STEALING
    EventInfo
MerLookingForLocalSpark -> EVENT_MER_LOOKING_FOR_LOCAL_SPARK
    MerReleaseThread Word32
_ -> EVENT_MER_RELEASE_CONTEXT
    EventInfo
MerCapSleeping -> EVENT_MER_ENGINE_SLEEPING
    EventInfo
MerCallingMain -> EVENT_MER_CALLING_MAIN
    PerfName       {} -> EventTypeNum
nEVENT_PERF_NAME
    PerfCounter    {} -> EventTypeNum
nEVENT_PERF_COUNTER
    PerfTracepoint {} -> EventTypeNum
nEVENT_PERF_TRACEPOINT
    HeapProfBegin {} -> EVENT_HEAP_PROF_BEGIN
    HeapProfCostCentre {} -> EVENT_HEAP_PROF_COST_CENTRE
    HeapProfSampleBegin {} -> EVENT_HEAP_PROF_SAMPLE_BEGIN
    HeapProfSampleEnd {} -> EVENT_HEAP_PROF_SAMPLE_END
    HeapBioProfSampleBegin {} -> EVENT_HEAP_BIO_PROF_SAMPLE_BEGIN
    HeapProfSampleCostCentre {} -> EVENT_HEAP_PROF_SAMPLE_COST_CENTRE
    HeapProfSampleString {} -> EVENT_HEAP_PROF_SAMPLE_STRING
    ProfSampleCostCentre {} -> EVENT_PROF_SAMPLE_COST_CENTRE
    ProfBegin {}            -> EVENT_PROF_BEGIN
    UserBinaryMessage {} -> EVENT_USER_BINARY_MSG
    ConcMarkBegin {} -> EVENT_CONC_MARK_BEGIN
    ConcMarkEnd {} -> EVENT_CONC_MARK_END
    ConcSyncBegin {} -> EVENT_CONC_SYNC_BEGIN
    ConcSyncEnd {} -> EVENT_CONC_SYNC_END
    ConcSweepBegin {} -> EVENT_CONC_SWEEP_BEGIN
    ConcSweepEnd {} -> EVENT_CONC_SWEEP_END
    ConcUpdRemSetFlush {} -> EVENT_CONC_UPD_REM_SET_FLUSH
    NonmovingHeapCensus {} -> EVENT_NONMOVING_HEAP_CENSUS
    TickyCounterDef {} -> EVENT_TICKY_COUNTER_DEF
    TickyCounterSample {} -> EVENT_TICKY_COUNTER_SAMPLE
    InfoTableProv {} -> EVENT_IPE
    MemReturn {} -> EVENT_MEM_RETURN
    TickyBeginSample {} -> EVENT_TICKY_BEGIN_SAMPLE

nEVENT_PERF_NAME, nEVENT_PERF_COUNTER, nEVENT_PERF_TRACEPOINT :: EventTypeNum
nEVENT_PERF_NAME :: EventTypeNum
nEVENT_PERF_NAME = EVENT_PERF_NAME
nEVENT_PERF_COUNTER :: EventTypeNum
nEVENT_PERF_COUNTER = EVENT_PERF_COUNTER
nEVENT_PERF_TRACEPOINT :: EventTypeNum
nEVENT_PERF_TRACEPOINT = EVENT_PERF_TRACEPOINT

putEvent :: Event -> PutM ()
putEvent :: Event -> PutM ()
putEvent Event {Maybe Int
Timestamp
EventInfo
evCap :: Maybe Int
evSpec :: EventInfo
evTime :: Timestamp
evSpec :: Event -> EventInfo
evTime :: Event -> Timestamp
evCap :: Event -> Maybe Int
..} = do
    EventTypeNum -> PutM ()
putType (EventInfo -> EventTypeNum
eventTypeNum EventInfo
evSpec)
    forall a. Binary a => a -> PutM ()
put Timestamp
evTime
    EventInfo -> PutM ()
putEventSpec EventInfo
evSpec

putEventSpec :: EventInfo -> PutM ()
putEventSpec :: EventInfo -> PutM ()
putEventSpec (Startup Int
caps) = do
    Int -> PutM ()
putCap (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
caps)

putEventSpec (EventBlock Timestamp
end Int
cap Word32
sz) = do
    forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word32
szforall a. Num a => a -> a -> a
+Word32
24) :: BlockSize)
    forall a. Binary a => a -> PutM ()
putE Timestamp
end
    forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
cap :: CapNo)

putEventSpec (CreateThread Word32
t) =
    forall a. Binary a => a -> PutM ()
putE Word32
t

putEventSpec (RunThread Word32
t) =
    forall a. Binary a => a -> PutM ()
putE Word32
t

-- here we assume that ThreadStopStatus fromEnum matches the definitions in
-- EventLogFormat.h
-- The standard encoding is used here, which is wrong for event logs
-- produced by GHC-7.8.2 ([Stop status in GHC-7.8.2] in EventTypes.hs
putEventSpec (StopThread Word32
t ThreadStopStatus
s) = do
    forall a. Binary a => a -> PutM ()
putE Word32
t
    forall a. Binary a => a -> PutM ()
putE forall a b. (a -> b) -> a -> b
$ case ThreadStopStatus
s of
            ThreadStopStatus
NoStatus -> EventTypeNum
0 :: Word16
            ThreadStopStatus
HeapOverflow -> EventTypeNum
1
            ThreadStopStatus
StackOverflow -> EventTypeNum
2
            ThreadStopStatus
ThreadYielding -> EventTypeNum
3
            ThreadStopStatus
ThreadBlocked -> EventTypeNum
4
            ThreadStopStatus
ThreadFinished -> EventTypeNum
5
            ThreadStopStatus
ForeignCall -> EventTypeNum
6
            ThreadStopStatus
BlockedOnMVar -> EventTypeNum
7
            ThreadStopStatus
BlockedOnMVarRead -> EventTypeNum
20 -- since GHC-7.8.3
            ThreadStopStatus
BlockedOnBlackHole -> EventTypeNum
8
            BlockedOnBlackHoleOwnedBy Word32
_ -> EventTypeNum
8
            ThreadStopStatus
BlockedOnRead -> EventTypeNum
9
            ThreadStopStatus
BlockedOnWrite -> EventTypeNum
10
            ThreadStopStatus
BlockedOnDelay -> EventTypeNum
11
            ThreadStopStatus
BlockedOnSTM -> EventTypeNum
12
            ThreadStopStatus
BlockedOnDoProc -> EventTypeNum
13
            ThreadStopStatus
BlockedOnCCall -> EventTypeNum
14
            ThreadStopStatus
BlockedOnCCall_NoUnblockExc -> EventTypeNum
15
            ThreadStopStatus
BlockedOnMsgThrowTo -> EventTypeNum
16
            ThreadStopStatus
ThreadMigrating -> EventTypeNum
17
            ThreadStopStatus
BlockedOnMsgGlobalise -> EventTypeNum
18
    forall a. Binary a => a -> PutM ()
putE forall a b. (a -> b) -> a -> b
$ case ThreadStopStatus
s of
            BlockedOnBlackHoleOwnedBy Word32
i -> Word32
i
            ThreadStopStatus
_                           -> Word32
0

putEventSpec (ThreadRunnable Word32
t) =
    forall a. Binary a => a -> PutM ()
putE Word32
t

putEventSpec (MigrateThread Word32
t Int
c) = do
    forall a. Binary a => a -> PutM ()
putE Word32
t
    Int -> PutM ()
putCap Int
c

putEventSpec (CreateSparkThread Word32
t) =
    forall a. Binary a => a -> PutM ()
putE Word32
t

putEventSpec (SparkCounters Timestamp
crt Timestamp
dud Timestamp
ovf Timestamp
cnv Timestamp
fiz Timestamp
gcd Timestamp
rem) = do
    forall a. Binary a => a -> PutM ()
putE Timestamp
crt
    forall a. Binary a => a -> PutM ()
putE Timestamp
dud
    forall a. Binary a => a -> PutM ()
putE Timestamp
ovf
    forall a. Binary a => a -> PutM ()
putE Timestamp
cnv
    -- Warning: order of fiz and gcd reversed!
    forall a. Binary a => a -> PutM ()
putE Timestamp
gcd
    forall a. Binary a => a -> PutM ()
putE Timestamp
fiz
    forall a. Binary a => a -> PutM ()
putE Timestamp
rem

putEventSpec EventInfo
SparkCreate =
    forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec EventInfo
SparkDud =
    forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec EventInfo
SparkOverflow =
    forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec EventInfo
SparkRun =
    forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec (SparkSteal Int
c) =
    Int -> PutM ()
putCap Int
c

putEventSpec EventInfo
SparkFizzle =
    forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec EventInfo
SparkGC =
    forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec (WakeupThread Word32
t Int
c) = do
    forall a. Binary a => a -> PutM ()
putE Word32
t
    Int -> PutM ()
putCap Int
c

putEventSpec (ThreadLabel Word32
t (Text -> ByteString
TE.encodeUtf8 -> ByteString
l)) = do
    forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString -> Int
B.length ByteString
l) forall a. Num a => a -> a -> a
+ EventTypeNum
sz_tid :: Word16)
    forall a. Binary a => a -> PutM ()
putE Word32
t
    ByteString -> PutM ()
putByteString ByteString
l

putEventSpec EventInfo
Shutdown =
    forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec EventInfo
RequestSeqGC =
    forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec EventInfo
RequestParGC =
    forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec EventInfo
StartGC =
    forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec EventInfo
GCWork =
    forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec EventInfo
GCIdle =
    forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec EventInfo
GCDone =
    forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec EventInfo
EndGC =
    forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec EventInfo
GlobalSyncGC =
    forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec (TaskCreate Timestamp
taskId Int
cap KernelThreadId
tid) = do
    forall a. Binary a => a -> PutM ()
putE Timestamp
taskId
    Int -> PutM ()
putCap Int
cap
    forall a. Binary a => a -> PutM ()
putE KernelThreadId
tid

putEventSpec (TaskMigrate Timestamp
taskId Int
cap Int
new_cap) = do
    forall a. Binary a => a -> PutM ()
putE Timestamp
taskId
    Int -> PutM ()
putCap Int
cap
    Int -> PutM ()
putCap Int
new_cap

putEventSpec (TaskDelete Timestamp
taskId) =
    forall a. Binary a => a -> PutM ()
putE Timestamp
taskId

putEventSpec GCStatsGHC{Int
Maybe Timestamp
Word32
Timestamp
parBalancedCopied :: Maybe Timestamp
parTotCopied :: Timestamp
parMaxCopied :: Timestamp
parNThreads :: Int
frag :: Timestamp
slop :: Timestamp
copied :: Timestamp
gen :: Int
heapCapset :: Word32
parTotCopied :: EventInfo -> Timestamp
parMaxCopied :: EventInfo -> Timestamp
frag :: EventInfo -> Timestamp
slop :: EventInfo -> Timestamp
copied :: EventInfo -> Timestamp
heapCapset :: EventInfo -> Word32
parBalancedCopied :: EventInfo -> Maybe Timestamp
parNThreads :: EventInfo -> Int
gen :: EventInfo -> Int
..} = do
    forall a. Binary a => a -> PutM ()
putE Word32
heapCapset
    forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
gen :: Word16)
    forall a. Binary a => a -> PutM ()
putE Timestamp
copied
    forall a. Binary a => a -> PutM ()
putE Timestamp
slop
    forall a. Binary a => a -> PutM ()
putE Timestamp
frag
    forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
parNThreads :: Word32)
    forall a. Binary a => a -> PutM ()
putE Timestamp
parMaxCopied
    forall a. Binary a => a -> PutM ()
putE Timestamp
parTotCopied
    case Maybe Timestamp
parBalancedCopied of
      Maybe Timestamp
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
      Just Timestamp
v  -> forall a. Binary a => a -> PutM ()
putE Timestamp
v

putEventSpec MemReturn{Word32
returned :: Word32
needed :: Word32
current :: Word32
heapCapset :: Word32
returned :: EventInfo -> Word32
needed :: EventInfo -> Word32
current :: EventInfo -> Word32
heapCapset :: EventInfo -> Word32
..} = do
    forall a. Binary a => a -> PutM ()
putE Word32
heapCapset
    forall a. Binary a => a -> PutM ()
putE Word32
current
    forall a. Binary a => a -> PutM ()
putE Word32
needed
    forall a. Binary a => a -> PutM ()
putE Word32
returned

putEventSpec HeapAllocated{Word32
Timestamp
allocBytes :: Timestamp
heapCapset :: Word32
allocBytes :: EventInfo -> Timestamp
heapCapset :: EventInfo -> Word32
..} = do
    forall a. Binary a => a -> PutM ()
putE Word32
heapCapset
    forall a. Binary a => a -> PutM ()
putE Timestamp
allocBytes

putEventSpec HeapSize{Word32
Timestamp
sizeBytes :: Timestamp
heapCapset :: Word32
sizeBytes :: EventInfo -> Timestamp
heapCapset :: EventInfo -> Word32
..} = do
    forall a. Binary a => a -> PutM ()
putE Word32
heapCapset
    forall a. Binary a => a -> PutM ()
putE Timestamp
sizeBytes

putEventSpec BlocksSize{Word32
Timestamp
blocksSize :: Timestamp
heapCapset :: Word32
blocksSize :: EventInfo -> Timestamp
heapCapset :: EventInfo -> Word32
..} = do
    forall a. Binary a => a -> PutM ()
putE Word32
heapCapset
    forall a. Binary a => a -> PutM ()
putE Timestamp
blocksSize

putEventSpec HeapLive{Word32
Timestamp
liveBytes :: Timestamp
heapCapset :: Word32
liveBytes :: EventInfo -> Timestamp
heapCapset :: EventInfo -> Word32
..} = do
    forall a. Binary a => a -> PutM ()
putE Word32
heapCapset
    forall a. Binary a => a -> PutM ()
putE Timestamp
liveBytes

putEventSpec HeapInfoGHC{Int
Word32
Timestamp
blockSize :: Timestamp
mblockSize :: Timestamp
allocAreaSize :: Timestamp
maxHeapSize :: Timestamp
gens :: Int
heapCapset :: Word32
blockSize :: EventInfo -> Timestamp
mblockSize :: EventInfo -> Timestamp
allocAreaSize :: EventInfo -> Timestamp
maxHeapSize :: EventInfo -> Timestamp
gens :: EventInfo -> Int
heapCapset :: EventInfo -> Word32
..} = do
    forall a. Binary a => a -> PutM ()
putE Word32
heapCapset
    forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
gens :: Word16)
    forall a. Binary a => a -> PutM ()
putE Timestamp
maxHeapSize
    forall a. Binary a => a -> PutM ()
putE Timestamp
allocAreaSize
    forall a. Binary a => a -> PutM ()
putE Timestamp
mblockSize
    forall a. Binary a => a -> PutM ()
putE Timestamp
blockSize

putEventSpec CapCreate{Int
cap :: Int
cap :: EventInfo -> Int
cap} =
    Int -> PutM ()
putCap Int
cap

putEventSpec CapDelete{Int
cap :: Int
cap :: EventInfo -> Int
cap} =
    Int -> PutM ()
putCap Int
cap

putEventSpec CapDisable{Int
cap :: Int
cap :: EventInfo -> Int
cap} =
    Int -> PutM ()
putCap Int
cap

putEventSpec CapEnable{Int
cap :: Int
cap :: EventInfo -> Int
cap} =
    Int -> PutM ()
putCap Int
cap

putEventSpec (CapsetCreate Word32
cs CapsetType
ct) = do
    forall a. Binary a => a -> PutM ()
putE Word32
cs
    forall a. Binary a => a -> PutM ()
putE forall a b. (a -> b) -> a -> b
$ case CapsetType
ct of
            CapsetType
CapsetCustom -> EventTypeNum
1 :: Word16
            CapsetType
CapsetOsProcess -> EventTypeNum
2
            CapsetType
CapsetClockDomain -> EventTypeNum
3
            CapsetType
CapsetUnknown -> EventTypeNum
0

putEventSpec (CapsetDelete Word32
cs) =
    forall a. Binary a => a -> PutM ()
putE Word32
cs

putEventSpec (CapsetAssignCap Word32
cs Int
cp) = do
    forall a. Binary a => a -> PutM ()
putE Word32
cs
    Int -> PutM ()
putCap Int
cp

putEventSpec (CapsetRemoveCap Word32
cs Int
cp) = do
    forall a. Binary a => a -> PutM ()
putE Word32
cs
    Int -> PutM ()
putCap Int
cp

putEventSpec (RtsIdentifier Word32
cs (Text -> ByteString
TE.encodeUtf8 -> ByteString
rts)) = do
    forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString -> Int
B.length ByteString
rts) forall a. Num a => a -> a -> a
+ EventTypeNum
sz_capset :: Word16)
    forall a. Binary a => a -> PutM ()
putE Word32
cs
    ByteString -> PutM ()
putByteString ByteString
rts

putEventSpec (ProgramArgs Word32
cs (forall a b. (a -> b) -> [a] -> [b]
map Text -> ByteString
TE.encodeUtf8 -> [ByteString]
as)) = do
    let sz_args :: Int
sz_args = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum (forall a b. (a -> b) -> [a] -> [b]
map ((forall a. Num a => a -> a -> a
+ Int
1) {- for \0 -} forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Int
B.length) [ByteString]
as) forall a. Num a => a -> a -> a
- Int
1
    forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
sz_args forall a. Num a => a -> a -> a
+ EventTypeNum
sz_capset :: Word16)
    forall a. Binary a => a -> PutM ()
putE Word32
cs
    forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ByteString -> PutM ()
putByteString (forall a. a -> [a] -> [a]
intersperse ByteString
"\0" [ByteString]
as)

putEventSpec (ProgramEnv Word32
cs (forall a b. (a -> b) -> [a] -> [b]
map Text -> ByteString
TE.encodeUtf8 -> [ByteString]
es)) = do
    let sz_env :: Int
sz_env = forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum (forall a b. (a -> b) -> [a] -> [b]
map ((forall a. Num a => a -> a -> a
+ Int
1) {- for \0 -} forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Int
B.length) [ByteString]
es) forall a. Num a => a -> a -> a
- Int
1
    forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
sz_env forall a. Num a => a -> a -> a
+ EventTypeNum
sz_capset :: Word16)
    forall a. Binary a => a -> PutM ()
putE Word32
cs
    forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ByteString -> PutM ()
putByteString forall a b. (a -> b) -> a -> b
$ forall a. a -> [a] -> [a]
intersperse ByteString
"\0" [ByteString]
es

putEventSpec (OsProcessPid Word32
cs Word32
pid) = do
    forall a. Binary a => a -> PutM ()
putE Word32
cs
    forall a. Binary a => a -> PutM ()
putE Word32
pid

putEventSpec (OsProcessParentPid Word32
cs Word32
ppid) = do
    forall a. Binary a => a -> PutM ()
putE Word32
cs
    forall a. Binary a => a -> PutM ()
putE Word32
ppid

putEventSpec (WallClockTime Word32
cs Timestamp
sec Word32
nsec) = do
    forall a. Binary a => a -> PutM ()
putE Word32
cs
    forall a. Binary a => a -> PutM ()
putE Timestamp
sec
    forall a. Binary a => a -> PutM ()
putE Word32
nsec

putEventSpec (Message (Text -> ByteString
TE.encodeUtf8 -> ByteString
s)) = do
    forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString -> Int
B.length ByteString
s) :: Word16)
    ByteString -> PutM ()
putByteString ByteString
s

putEventSpec (UserMessage (Text -> ByteString
TE.encodeUtf8 -> ByteString
s)) = do
    forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString -> Int
B.length ByteString
s) :: Word16)
    ByteString -> PutM ()
putByteString ByteString
s

putEventSpec (UserMarker (Text -> ByteString
TE.encodeUtf8 -> ByteString
s)) = do
    forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString -> Int
B.length ByteString
s) :: Word16)
    ByteString -> PutM ()
putByteString ByteString
s

putEventSpec (UnknownEvent {}) = forall a. HasCallStack => String -> a
error String
"putEventSpec UnknownEvent"

putEventSpec (InternString String
str Word32
id) = do
    forall a. Binary a => a -> PutM ()
putE EventTypeNum
len
    forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ forall a. Binary a => a -> PutM ()
putE String
str
    forall a. Binary a => a -> PutM ()
putE Word32
id
  where len :: EventTypeNum
len = (forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (t :: * -> *) a. Foldable t => t a -> Int
length String
str) :: Word16) forall a. Num a => a -> a -> a
+ EventTypeNum
sz_string_id

putEventSpec (Version String
s) = do
    forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (t :: * -> *) a. Foldable t => t a -> Int
length String
s) :: Word16)
    forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ forall a. Binary a => a -> PutM ()
putE String
s

putEventSpec (ProgramInvocation String
s) = do
    forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (t :: * -> *) a. Foldable t => t a -> Int
length String
s) :: Word16)
    forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ forall a. Binary a => a -> PutM ()
putE String
s

putEventSpec ( EventInfo
EdenStartReceive ) = forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec ( EventInfo
EdenEndReceive ) = forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec ( CreateProcess  Word32
process ) = do
    forall a. Binary a => a -> PutM ()
putE Word32
process

putEventSpec ( KillProcess Word32
process ) = do
    forall a. Binary a => a -> PutM ()
putE Word32
process

putEventSpec ( AssignThreadToProcess Word32
thread Word32
process ) = do
    forall a. Binary a => a -> PutM ()
putE Word32
thread
    forall a. Binary a => a -> PutM ()
putE Word32
process

putEventSpec ( CreateMachine EventTypeNum
machine Timestamp
realtime ) = do
    forall a. Binary a => a -> PutM ()
putE EventTypeNum
machine
    forall a. Binary a => a -> PutM ()
putE Timestamp
realtime

putEventSpec ( KillMachine EventTypeNum
machine ) = do
    forall a. Binary a => a -> PutM ()
putE EventTypeNum
machine

putEventSpec ( SendMessage MessageTag
mesTag Word32
senderProcess Word32
senderThread
                 EventTypeNum
receiverMachine Word32
receiverProcess Word32
receiverInport ) = do
    forall a. Binary a => a -> PutM ()
putE (MessageTag -> RawMsgTag
fromMsgTag MessageTag
mesTag)
    forall a. Binary a => a -> PutM ()
putE Word32
senderProcess
    forall a. Binary a => a -> PutM ()
putE Word32
senderThread
    forall a. Binary a => a -> PutM ()
putE EventTypeNum
receiverMachine
    forall a. Binary a => a -> PutM ()
putE Word32
receiverProcess
    forall a. Binary a => a -> PutM ()
putE Word32
receiverInport

putEventSpec ( ReceiveMessage MessageTag
mesTag Word32
receiverProcess Word32
receiverInport
                 EventTypeNum
senderMachine Word32
senderProcess Word32
senderThread Word32
messageSize ) = do
    forall a. Binary a => a -> PutM ()
putE (MessageTag -> RawMsgTag
fromMsgTag MessageTag
mesTag)
    forall a. Binary a => a -> PutM ()
putE Word32
receiverProcess
    forall a. Binary a => a -> PutM ()
putE Word32
receiverInport
    forall a. Binary a => a -> PutM ()
putE EventTypeNum
senderMachine
    forall a. Binary a => a -> PutM ()
putE Word32
senderProcess
    forall a. Binary a => a -> PutM ()
putE Word32
senderThread
    forall a. Binary a => a -> PutM ()
putE Word32
messageSize

putEventSpec ( SendReceiveLocalMessage MessageTag
mesTag Word32
senderProcess Word32
senderThread
                 Word32
receiverProcess Word32
receiverInport ) = do
    forall a. Binary a => a -> PutM ()
putE (MessageTag -> RawMsgTag
fromMsgTag MessageTag
mesTag)
    forall a. Binary a => a -> PutM ()
putE Word32
senderProcess
    forall a. Binary a => a -> PutM ()
putE Word32
senderThread
    forall a. Binary a => a -> PutM ()
putE Word32
receiverProcess
    forall a. Binary a => a -> PutM ()
putE Word32
receiverInport

putEventSpec (MerStartParConjunction Timestamp
dyn_id Word32
static_id) = do
    forall a. Binary a => a -> PutM ()
putE Timestamp
dyn_id
    forall a. Binary a => a -> PutM ()
putE Word32
static_id

putEventSpec (MerEndParConjunction Timestamp
dyn_id) =
    forall a. Binary a => a -> PutM ()
putE Timestamp
dyn_id

putEventSpec (MerEndParConjunct Timestamp
dyn_id) =
    forall a. Binary a => a -> PutM ()
putE Timestamp
dyn_id

putEventSpec (MerCreateSpark Timestamp
dyn_id Word32
spark_id) = do
    forall a. Binary a => a -> PutM ()
putE Timestamp
dyn_id
    forall a. Binary a => a -> PutM ()
putE Word32
spark_id

putEventSpec (MerFutureCreate Timestamp
future_id Word32
name_id) = do
    forall a. Binary a => a -> PutM ()
putE Timestamp
future_id
    forall a. Binary a => a -> PutM ()
putE Word32
name_id

putEventSpec (MerFutureWaitNosuspend Timestamp
future_id) =
    forall a. Binary a => a -> PutM ()
putE Timestamp
future_id

putEventSpec (MerFutureWaitSuspended Timestamp
future_id) =
    forall a. Binary a => a -> PutM ()
putE Timestamp
future_id

putEventSpec (MerFutureSignal Timestamp
future_id) =
    forall a. Binary a => a -> PutM ()
putE Timestamp
future_id

putEventSpec EventInfo
MerLookingForGlobalThread = forall (m :: * -> *) a. Monad m => a -> m a
return ()
putEventSpec EventInfo
MerWorkStealing = forall (m :: * -> *) a. Monad m => a -> m a
return ()
putEventSpec EventInfo
MerLookingForLocalSpark = forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec (MerReleaseThread Word32
thread_id) =
    forall a. Binary a => a -> PutM ()
putE Word32
thread_id

putEventSpec EventInfo
MerCapSleeping = forall (m :: * -> *) a. Monad m => a -> m a
return ()
putEventSpec EventInfo
MerCallingMain = forall (m :: * -> *) a. Monad m => a -> m a
return ()

putEventSpec PerfName{name :: EventInfo -> Text
name = (Text -> ByteString
TE.encodeUtf8 -> ByteString
name), Word32
perfNum :: Word32
perfNum :: EventInfo -> Word32
..} = do
    forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString -> Int
B.length ByteString
name) forall a. Num a => a -> a -> a
+ EventTypeNum
sz_perf_num :: Word16)
    forall a. Binary a => a -> PutM ()
putE Word32
perfNum
    ByteString -> PutM ()
putByteString ByteString
name

putEventSpec PerfCounter{Word32
Timestamp
KernelThreadId
period :: Timestamp
tid :: KernelThreadId
perfNum :: Word32
period :: EventInfo -> Timestamp
perfNum :: EventInfo -> Word32
tid :: EventInfo -> KernelThreadId
..} = do
    forall a. Binary a => a -> PutM ()
putE Word32
perfNum
    forall a. Binary a => a -> PutM ()
putE KernelThreadId
tid
    forall a. Binary a => a -> PutM ()
putE Timestamp
period

putEventSpec PerfTracepoint{Word32
KernelThreadId
tid :: KernelThreadId
perfNum :: Word32
perfNum :: EventInfo -> Word32
tid :: EventInfo -> KernelThreadId
..} = do
    forall a. Binary a => a -> PutM ()
putE Word32
perfNum
    forall a. Binary a => a -> PutM ()
putE KernelThreadId
tid

putEventSpec HeapProfBegin {RawMsgTag
Timestamp
Text
HeapProfBreakdown
heapProfBiographyFilter :: Text
heapProfRetainerFilter :: Text
heapProfCostCentreStackFilter :: Text
heapProfCostCentreFilter :: Text
heapProfTypeDescrFilter :: Text
heapProfClosureDescrFilter :: Text
heapProfModuleFilter :: Text
heapProfBreakdown :: HeapProfBreakdown
heapProfSamplingPeriod :: Timestamp
heapProfId :: RawMsgTag
heapProfBiographyFilter :: EventInfo -> Text
heapProfRetainerFilter :: EventInfo -> Text
heapProfCostCentreStackFilter :: EventInfo -> Text
heapProfCostCentreFilter :: EventInfo -> Text
heapProfTypeDescrFilter :: EventInfo -> Text
heapProfClosureDescrFilter :: EventInfo -> Text
heapProfModuleFilter :: EventInfo -> Text
heapProfBreakdown :: EventInfo -> HeapProfBreakdown
heapProfSamplingPeriod :: EventInfo -> Timestamp
heapProfId :: EventInfo -> RawMsgTag
..} = do
    forall a. Binary a => a -> PutM ()
putE RawMsgTag
heapProfId
    forall a. Binary a => a -> PutM ()
putE Timestamp
heapProfSamplingPeriod
    forall a. Binary a => a -> PutM ()
putE HeapProfBreakdown
heapProfBreakdown
    forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (forall a. Binary a => a -> PutM ()
putE forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
T.unpack)
      [ Text
heapProfModuleFilter
      , Text
heapProfClosureDescrFilter
      , Text
heapProfTypeDescrFilter
      , Text
heapProfCostCentreFilter
      , Text
heapProfCostCentreStackFilter
      , Text
heapProfRetainerFilter
      , Text
heapProfBiographyFilter
      ]

putEventSpec HeapProfCostCentre {Word32
Text
HeapProfFlags
heapProfFlags :: HeapProfFlags
heapProfSrcLoc :: Text
heapProfModule :: Text
heapProfLabel :: Text
heapProfCostCentreId :: Word32
heapProfFlags :: EventInfo -> HeapProfFlags
heapProfSrcLoc :: EventInfo -> Text
heapProfModule :: EventInfo -> Text
heapProfLabel :: EventInfo -> Text
heapProfCostCentreId :: EventInfo -> Word32
..} = do
    forall a. Binary a => a -> PutM ()
putE Word32
heapProfCostCentreId
    forall a. Binary a => a -> PutM ()
putE forall a b. (a -> b) -> a -> b
$ Text -> String
T.unpack Text
heapProfLabel
    forall a. Binary a => a -> PutM ()
putE forall a b. (a -> b) -> a -> b
$ Text -> String
T.unpack Text
heapProfModule
    forall a. Binary a => a -> PutM ()
putE forall a b. (a -> b) -> a -> b
$ Text -> String
T.unpack Text
heapProfSrcLoc
    forall a. Binary a => a -> PutM ()
putE HeapProfFlags
heapProfFlags

putEventSpec HeapProfSampleBegin {Timestamp
heapProfSampleEra :: Timestamp
heapProfSampleEra :: EventInfo -> Timestamp
..} =
    forall a. Binary a => a -> PutM ()
putE Timestamp
heapProfSampleEra

putEventSpec HeapProfSampleEnd {Timestamp
heapProfSampleEra :: Timestamp
heapProfSampleEra :: EventInfo -> Timestamp
..} =
    forall a. Binary a => a -> PutM ()
putE Timestamp
heapProfSampleEra

putEventSpec HeapBioProfSampleBegin {Timestamp
heapProfSampleTime :: Timestamp
heapProfSampleEra :: Timestamp
heapProfSampleTime :: EventInfo -> Timestamp
heapProfSampleEra :: EventInfo -> Timestamp
..} = do
    forall a. Binary a => a -> PutM ()
putE Timestamp
heapProfSampleEra
    forall a. Binary a => a -> PutM ()
putE Timestamp
heapProfSampleTime


putEventSpec HeapProfSampleCostCentre {RawMsgTag
Timestamp
Vector Word32
heapProfStack :: Vector Word32
heapProfStackDepth :: RawMsgTag
heapProfResidency :: Timestamp
heapProfId :: RawMsgTag
heapProfStack :: EventInfo -> Vector Word32
heapProfStackDepth :: EventInfo -> RawMsgTag
heapProfResidency :: EventInfo -> Timestamp
heapProfId :: EventInfo -> RawMsgTag
..} = do
    forall a. Binary a => a -> PutM ()
putE RawMsgTag
heapProfId
    forall a. Binary a => a -> PutM ()
putE Timestamp
heapProfResidency
    forall a. Binary a => a -> PutM ()
putE RawMsgTag
heapProfStackDepth
    forall (m :: * -> *) a b.
(Monad m, Unbox a) =>
(a -> m b) -> Vector a -> m ()
VU.mapM_ forall a. Binary a => a -> PutM ()
putE Vector Word32
heapProfStack

putEventSpec HeapProfSampleString {RawMsgTag
Timestamp
Text
heapProfLabel :: Text
heapProfResidency :: Timestamp
heapProfId :: RawMsgTag
heapProfResidency :: EventInfo -> Timestamp
heapProfLabel :: EventInfo -> Text
heapProfId :: EventInfo -> RawMsgTag
..} = do
    forall a. Binary a => a -> PutM ()
putE RawMsgTag
heapProfId
    forall a. Binary a => a -> PutM ()
putE Timestamp
heapProfResidency
    forall a. Binary a => a -> PutM ()
putE forall a b. (a -> b) -> a -> b
$ Text -> String
T.unpack Text
heapProfLabel

putEventSpec ProfSampleCostCentre {RawMsgTag
Word32
Timestamp
Vector Word32
profCcsStack :: Vector Word32
profStackDepth :: RawMsgTag
profTicks :: Timestamp
profCapset :: Word32
profCcsStack :: EventInfo -> Vector Word32
profStackDepth :: EventInfo -> RawMsgTag
profTicks :: EventInfo -> Timestamp
profCapset :: EventInfo -> Word32
..} = do
    forall a. Binary a => a -> PutM ()
putE Word32
profCapset
    forall a. Binary a => a -> PutM ()
putE Timestamp
profTicks
    forall a. Binary a => a -> PutM ()
putE RawMsgTag
profStackDepth
    forall (m :: * -> *) a b.
(Monad m, Unbox a) =>
(a -> m b) -> Vector a -> m ()
VU.mapM_ forall a. Binary a => a -> PutM ()
putE Vector Word32
profCcsStack

putEventSpec ProfBegin {Timestamp
profTickInterval :: Timestamp
profTickInterval :: EventInfo -> Timestamp
..} = do
    forall a. Binary a => a -> PutM ()
putE Timestamp
profTickInterval

putEventSpec UserBinaryMessage {ByteString
payload :: ByteString
payload :: EventInfo -> ByteString
..} = do
    forall a. Binary a => a -> PutM ()
putE (forall a b. (Integral a, Num b) => a -> b
fromIntegral (ByteString -> Int
B.length ByteString
payload) :: Word16)
    ByteString -> PutM ()
putByteString ByteString
payload

putEventSpec EventInfo
ConcMarkBegin = forall (m :: * -> *) a. Monad m => a -> m a
return ()
putEventSpec ConcMarkEnd {Word32
concMarkedObjectCount :: Word32
concMarkedObjectCount :: EventInfo -> Word32
..} = do
    forall a. Binary a => a -> PutM ()
putE Word32
concMarkedObjectCount
putEventSpec EventInfo
ConcSyncBegin = forall (m :: * -> *) a. Monad m => a -> m a
return ()
putEventSpec EventInfo
ConcSyncEnd = forall (m :: * -> *) a. Monad m => a -> m a
return ()
putEventSpec EventInfo
ConcSweepBegin = forall (m :: * -> *) a. Monad m => a -> m a
return ()
putEventSpec EventInfo
ConcSweepEnd = forall (m :: * -> *) a. Monad m => a -> m a
return ()
putEventSpec ConcUpdRemSetFlush {Int
cap :: Int
cap :: EventInfo -> Int
..} = do
    Int -> PutM ()
putCap Int
cap
putEventSpec NonmovingHeapCensus {RawMsgTag
Word32
nonmovingCensusLiveBlocks :: Word32
nonmovingCensusFilledSegs :: Word32
nonmovingCensusActiveSegs :: Word32
nonmovingCensusBlkSize :: RawMsgTag
nonmovingCensusLiveBlocks :: EventInfo -> Word32
nonmovingCensusFilledSegs :: EventInfo -> Word32
nonmovingCensusActiveSegs :: EventInfo -> Word32
nonmovingCensusBlkSize :: EventInfo -> RawMsgTag
..} = do
    forall a. Binary a => a -> PutM ()
putE RawMsgTag
nonmovingCensusBlkSize
    forall a. Binary a => a -> PutM ()
putE Word32
nonmovingCensusActiveSegs
    forall a. Binary a => a -> PutM ()
putE Word32
nonmovingCensusFilledSegs
    forall a. Binary a => a -> PutM ()
putE Word32
nonmovingCensusLiveBlocks
putEventSpec TickyCounterDef {EventTypeNum
Timestamp
Text
tickyCtrDefName :: Text
tickyCtrDefKinds :: Text
tickyCtrDefArity :: EventTypeNum
tickyCtrDefId :: Timestamp
tickyCtrDefName :: EventInfo -> Text
tickyCtrDefKinds :: EventInfo -> Text
tickyCtrDefArity :: EventInfo -> EventTypeNum
tickyCtrDefId :: EventInfo -> Timestamp
..} = do
    forall a. Binary a => a -> PutM ()
putE Timestamp
tickyCtrDefId
    forall a. Binary a => a -> PutM ()
putE EventTypeNum
tickyCtrDefArity
    forall a. Binary a => a -> PutM ()
putE (Text -> String
T.unpack Text
tickyCtrDefKinds)
    forall a. Binary a => a -> PutM ()
putE (Text -> String
T.unpack Text
tickyCtrDefName)
putEventSpec TickyCounterSample {Timestamp
tickyCtrSampleAllocd :: Timestamp
tickyCtrSampleAllocs :: Timestamp
tickyCtrSampleEntryCount :: Timestamp
tickyCtrSampleId :: Timestamp
tickyCtrSampleAllocd :: EventInfo -> Timestamp
tickyCtrSampleAllocs :: EventInfo -> Timestamp
tickyCtrSampleEntryCount :: EventInfo -> Timestamp
tickyCtrSampleId :: EventInfo -> Timestamp
..} = do
    forall a. Binary a => a -> PutM ()
putE Timestamp
tickyCtrSampleId
    forall a. Binary a => a -> PutM ()
putE Timestamp
tickyCtrSampleEntryCount
    forall a. Binary a => a -> PutM ()
putE Timestamp
tickyCtrSampleAllocs
    forall a. Binary a => a -> PutM ()
putE Timestamp
tickyCtrSampleAllocd
putEventSpec InfoTableProv{Int
Timestamp
Text
itSrcLoc :: Text
itModule :: Text
itLabel :: Text
itTyDesc :: Text
itClosureDesc :: Int
itTableName :: Text
itInfo :: Timestamp
itSrcLoc :: EventInfo -> Text
itModule :: EventInfo -> Text
itLabel :: EventInfo -> Text
itTyDesc :: EventInfo -> Text
itClosureDesc :: EventInfo -> Int
itTableName :: EventInfo -> Text
itInfo :: EventInfo -> Timestamp
..} = do
    forall a. Binary a => a -> PutM ()
putE Timestamp
itInfo
    forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (forall a. Binary a => a -> PutM ()
putE forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
T.unpack)
      [ Text
itTableName
      , String -> Text
T.pack (forall a. Show a => a -> String
show Int
itClosureDesc)
      , Text
itTyDesc
      , Text
itLabel
      , Text
itModule
      , Text
itSrcLoc
      ]
putEventSpec EventInfo
TickyBeginSample = forall (m :: * -> *) a. Monad m => a -> m a
return ()