    {-# LANGUAGE CPP #-}
    {-# LANGUAGE OverloadedStrings #-}
    {-# LANGUAGE MultiWayIf #-}
    {-# OPTIONS_GHC -fsimpl-tick-factor=150 #-}
    {-
     -   Parser functions for GHC RTS EventLog framework.
     -}

    module GHC.RTS.Events (
           -- * The event log types
           EventLog(..),
           Header(..),
           Data(..),
           EventType(..),
           Event(..),
           EventInfo(..),
           ThreadStopStatus(..),
           CapsetType(..),
           HeapProfBreakdown(..),
           HeapProfFlags(..),
           Timestamp,
           ThreadId,
           TaskId,
           KernelThreadId(..),
           EventTypeNum,
           EventTypeDesc,
           EventTypeSize,
           BlockSize,
           Capset,
           PID,
           StringId,
           -- some types for the parallel RTS
           ProcessId,
           MachineId,
           PortId,
           MessageSize,
           MessageTag(..),
           ParConjDynId,
           ParConjStaticId,
           SparkId,
           FutureId,
           PerfEventTypeNum,

           -- * Reading and writing event logs
           readEventLogFromFile,
           writeEventLogToFile,

           serialiseEventLog,

           -- * Utilities
           CapEvent(..), sortEvents,
           buildEventTypeMap,

           -- * Printing
           TimeFormat(..),
           printEventsIncremental,
           showEventInfo, buildEventInfo,
           showThreadStopStatus,
           ppEventLog, ppEventType,
           ppEvent, buildEvent, buildEvent',

           -- * Perf events
           nEVENT_PERF_NAME, nEVENT_PERF_COUNTER, nEVENT_PERF_TRACEPOINT,
           sz_perf_num, sz_kernel_tid,

           -- * For compatibility with old clients
           -- readEventLogFromFile, TODO
           spec,
           time,
      ) where

    {- Libraries. -}
    import Control.Applicative
    import Control.Concurrent hiding (ThreadId)
    import qualified Data.Binary.Put as P
    import qualified Data.ByteString as B
    import qualified Data.ByteString.Lazy as BL
    import Data.Char (isPrint)
    import Data.IntMap (IntMap)
    import qualified Data.IntMap as IM
    import Data.Function hiding (id)
    import Data.List
    import Data.String (IsString)
    import qualified Data.Text as T
    import qualified Data.Text.Encoding as TE
    import qualified Data.Text.Lazy as TL
    import qualified Data.Text.Lazy.Builder as TB
    import qualified Data.Text.Lazy.Builder.Int as TB
    import qualified Data.Text.Lazy.IO as TL
    import qualified Data.Vector.Unboxed as VU
    import Data.Word
    import System.IO
    import Prelude hiding (gcd, rem, id)

    import GHC.RTS.EventTypes
    import GHC.RTS.Events.Binary
    import GHC.RTS.Events.Incremental

    #if !MIN_VERSION_base(4, 11, 0)
    import Data.Monoid ((<>))
    #endif

    -- | Read an entire event log file. It returns an error message if it
    -- encounters an error while decoding.
    --
    -- Note that it doesn't fail if it consumes all input in the middle of decoding
    -- of an event.
    readEventLogFromFile :: FilePath -> IO (Either String EventLog)
    readEventLogFromFile :: [Char] -> IO (Either [Char] EventLog)
    readEventLogFromFile [Char]
    path = ((EventLog, Maybe [Char]) -> EventLog)
    -> Either [Char] (EventLog, Maybe [Char]) -> Either [Char] EventLog
    forall a b. (a -> b) -> Either [Char] a -> Either [Char] b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (EventLog, Maybe [Char]) -> EventLog
    forall a b. (a, b) -> a
    fst (Either [Char] (EventLog, Maybe [Char]) -> Either [Char] EventLog)
    -> (ByteString -> Either [Char] (EventLog, Maybe [Char]))
    -> ByteString
    -> Either [Char] EventLog
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ByteString -> Either [Char] (EventLog, Maybe [Char])
    readEventLog (ByteString -> Either [Char] EventLog)
    -> IO ByteString -> IO (Either [Char] EventLog)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Char] -> IO ByteString
    BL.readFile [Char]
    path

    -- | Read an event log file and pretty print it to stdout
    printEventsIncremental
      :: Bool -- ^ Follow the file or not
      -> FilePath
      -> IO ()
    printEventsIncremental :: Bool -> [Char] -> IO ()
    printEventsIncremental Bool
    follow [Char]
    path =
      [Char] -> IOMode -> (Handle -> IO ()) -> IO ()
    forall r. [Char] -> IOMode -> (Handle -> IO r) -> IO r
    withFile [Char]
    path IOMode
    ReadMode (Bool -> Handle -> IO ()
    hPrintEventsIncremental Bool
    follow)

    -- | Read an event log from the Handle and pretty print it to stdout
    hPrintEventsIncremental
      :: Bool -- ^ Follow the handle or not
      -> Handle
      -> IO ()
    hPrintEventsIncremental :: Bool -> Handle -> IO ()
    hPrintEventsIncremental Bool
    follow Handle
    hdl = Decoder Event -> IO ()
    go Decoder Event
    decodeEventLog
      where
        go :: Decoder Event -> IO ()
    go Decoder Event
    decoder = case Decoder Event
    decoder of
          Produce Event
    event Decoder Event
    decoder' -> do
            Handle -> Text -> IO ()
    TL.hPutStrLn Handle
    stdout (Text -> IO ()) -> Text -> IO ()
    forall a b. (a -> b) -> a -> b
    $ Builder -> Text
    TB.toLazyText (Builder -> Text) -> Builder -> Text
    forall a b. (a -> b) -> a -> b
    $ Event -> Builder
    buildEvent' Event
    event
            Decoder Event -> IO ()
    go Decoder Event
    decoder'
          Consume ByteString -> Decoder Event
    k -> do
            chunk <- Handle -> Int -> IO ByteString
    B.hGetSome Handle
    hdl Int
    4096
            if
              | not (B.null chunk) -> go $ k chunk
              | follow -> threadDelay 1000000 >> go decoder
              | otherwise -> return ()
          Done {} -> () -> IO ()
    forall a. a -> IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
          Error ByteString
    _ [Char]
    err -> [Char] -> IO ()
    forall a. [Char] -> IO a
    forall (m :: * -> *) a. MonadFail m => [Char] -> m a
    fail [Char]
    err

    -- | Writes the 'EventLog' to file. The log is expected to __NOT__ have 'EventBlock'
    -- markers/events - the parsers no longer emit them and they are handled behind
    -- the scenes.
    writeEventLogToFile :: FilePath -> EventLog -> IO ()
    writeEventLogToFile :: [Char] -> EventLog -> IO ()
    writeEventLogToFile [Char]
    fp = [Char] -> ByteString -> IO ()
    BL.writeFile [Char]
    fp (ByteString -> IO ())
    -> (EventLog -> ByteString) -> EventLog -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . EventLog -> ByteString
    serialiseEventLog

    -- | Serialises an 'EventLog' back to a 'ByteString', usually for writing it
    -- back to a file.
    serialiseEventLog :: EventLog -> BL.ByteString
    serialiseEventLog :: EventLog -> ByteString
    serialiseEventLog el :: EventLog
    el@(EventLog Header
    _ (Data [Event]
    events)) =
      Put -> ByteString
    P.runPut (Put -> ByteString) -> Put -> ByteString
    forall a b. (a -> b) -> a -> b
    $ EventLog -> Put
    putEventLog EventLog
    blockedEl
      where
        eventsMap :: IntMap [Event]
    eventsMap = [Event] -> IntMap [Event]
    capSplitEvents [Event]
    events
        blockedEventsMap :: IntMap [Event]
    blockedEventsMap = (Int -> [Event] -> [Event]) -> IntMap [Event] -> IntMap [Event]
    forall a b. (Int -> a -> b) -> IntMap a -> IntMap b
    IM.mapWithKey Int -> [Event] -> [Event]
    addBlockMarker IntMap [Event]
    eventsMap
        blockedEl :: EventLog
    blockedEl = EventLog
    el{dat = Data blockedEvents}
        blockedEvents :: [Event]
    blockedEvents = ([Event] -> [Event] -> [Event])
    -> [Event] -> IntMap [Event] -> [Event]
    forall a b. (a -> b -> b) -> b -> IntMap a -> b
    IM.foldr [Event] -> [Event] -> [Event]
    forall a. [a] -> [a] -> [a]
    (++) [] IntMap [Event]
    blockedEventsMap

    -- Gets the Capability of an event in numeric form
    getIntCap :: Event -> Int
    getIntCap :: Event -> Int
    getIntCap Event{evCap :: Event -> Maybe Int
    evCap = Maybe Int
    cap} =
      case Maybe Int
    cap of
      Just Int
    capNo -> Int
    capNo
      Maybe Int
    Nothing    -> -Int
    1

    -- Creates an IntMap of the events with capability number as the key.
    -- Key -1 indicates global (capless) event
    capSplitEvents :: [Event] -> IM.IntMap [Event]
    capSplitEvents :: [Event] -> IntMap [Event]
    capSplitEvents [Event]
    evts = [Event] -> IntMap [Event] -> IntMap [Event]
    capSplitEvents' [Event]
    evts IntMap [Event]
    forall a. IntMap a
    IM.empty

    capSplitEvents' :: [Event] -> IM.IntMap [Event] -> IM.IntMap [Event]
    capSplitEvents' :: [Event] -> IntMap [Event] -> IntMap [Event]
    capSplitEvents' [Event]
    evts IntMap [Event]
    imap =
      case [Event]
    evts of
      (Event
    x:[Event]
    xs) -> [Event] -> IntMap [Event] -> IntMap [Event]
    capSplitEvents' [Event]
    xs (([Event] -> [Event] -> [Event])
    -> Int -> [Event] -> IntMap [Event] -> IntMap [Event]
    forall a. (a -> a -> a) -> Int -> a -> IntMap a -> IntMap a
    IM.insertWith [Event] -> [Event] -> [Event]
    forall a. [a] -> [a] -> [a]
    (++) (Event -> Int
    getIntCap Event
    x) [Event
    x] IntMap [Event]
    imap)
      []     -> IntMap [Event]
    imap

    -- Adds a block marker to the beginning of a list of events, annotated with
    -- its capability. All events are expected to belong to the same cap.
    addBlockMarker :: Int -> [Event] -> [Event]
    addBlockMarker :: Int -> [Event] -> [Event]
    addBlockMarker Int
    cap [Event]
    evts =
      (Word64 -> EventInfo -> Maybe Int -> Event
    Event Word64
    startTime (Word64 -> Int -> ThreadId -> EventInfo
    EventBlock Word64
    endTime Int
    cap ThreadId
    sz) (Int -> Maybe Int
    mkCap Int
    cap)) Event -> [Event] -> [Event]
    forall a. a -> [a] -> [a]
    : [Event]
    sortedEvts
      where
        sz :: ThreadId
    sz = Int64 -> ThreadId
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (Int64 -> ThreadId)
    -> (ByteString -> Int64) -> ByteString -> ThreadId
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ByteString -> Int64
    BL.length (ByteString -> ThreadId) -> ByteString -> ThreadId
    forall a b. (a -> b) -> a -> b
    $ Put -> ByteString
    P.runPut (Put -> ByteString) -> Put -> ByteString
    forall a b. (a -> b) -> a -> b
    $ (Event -> Put) -> [Event] -> Put
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    (a -> m b) -> t a -> m ()
    mapM_ Event -> Put
    putEvent [Event]
    evts
        startTime :: Word64
    startTime = case [Event]
    sortedEvts of
          (Event
    x:[Event]
    _) -> Event -> Word64
    evTime Event
    x
          [] -> [Char] -> Word64
    forall a. HasCallStack => [Char] -> a
    error [Char]
    "Cannot add block marker to an empty list of events"
        sortedEvts :: [Event]
    sortedEvts = [Event] -> [Event]
    sortEvents [Event]
    evts
        endTime :: Word64
    endTime = Event -> Word64
    evTime (Event -> Word64) -> Event -> Word64
    forall a b. (a -> b) -> a -> b
    $ [Event] -> Event
    forall a. HasCallStack => [a] -> a
    last [Event]
    sortedEvts

    -- -----------------------------------------------------------------------------
    -- Utilities
    sortEvents :: [Event] -> [Event]
    sortEvents :: [Event] -> [Event]
    sortEvents = (Event -> Event -> Ordering) -> [Event] -> [Event]
    forall a. (a -> a -> Ordering) -> [a] -> [a]
    sortBy (Word64 -> Word64 -> Ordering
    forall a. Ord a => a -> a -> Ordering
    compare (Word64 -> Word64 -> Ordering)
    -> (Event -> Word64) -> Event -> Event -> Ordering
    forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
    `on` Event -> Word64
    evTime)

    buildEventTypeMap :: [EventType] -> IntMap EventType
    buildEventTypeMap :: [EventType] -> IntMap EventType
    buildEventTypeMap [EventType]
    etypes =
      [(Int, EventType)] -> IntMap EventType
    forall a. [(Int, a)] -> IntMap a
    IM.fromList [ (EventTypeNum -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (EventType -> EventTypeNum
    num EventType
    t),EventType
    t) | EventType
    t <- [EventType]
    etypes ]

    -----------------------------------------------------------------------------
    -- Some pretty-printing support

    showEventInfo :: EventInfo -> String
    showEventInfo :: EventInfo -> [Char]
    showEventInfo = Text -> [Char]
    TL.unpack (Text -> [Char]) -> (EventInfo -> Text) -> EventInfo -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Builder -> Text
    TB.toLazyText (Builder -> Text) -> (EventInfo -> Builder) -> EventInfo -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . EventInfo -> Builder
    buildEventInfo

    buildEventInfo :: EventInfo -> TB.Builder
    buildEventInfo :: EventInfo -> Builder
    buildEventInfo EventInfo
    spec' =
        case EventInfo
    spec' of
            EventBlock Word64
    end_time Int
    cap ThreadId
    _block_events ->
              Builder
    "event block: cap " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    cap
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", end time: " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    end_time Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "\n"
            Startup Int
    n_caps ->
              Builder
    "startup: " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    n_caps Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " capabilities"
            CreateThread ThreadId
    thread ->
              Builder
    "creating thread " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    thread
            RunThread ThreadId
    thread ->
              Builder
    "running thread " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    thread
            StopThread ThreadId
    thread ThreadStopStatus
    status ->
              Builder
    "stopping thread " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    thread
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " (" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Builder
    TB.fromString (ThreadStopStatus -> [Char]
    showThreadStopStatus ThreadStopStatus
    status) Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ")"
            ThreadRunnable ThreadId
    thread ->
              Builder
    "thread " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    thread Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " is runnable"
            MigrateThread ThreadId
    thread Int
    newCap  ->
              Builder
    "migrating thread " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    thread
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " to cap " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    newCap
            CreateSparkThread ThreadId
    sparkThread ->
              Builder
    "creating spark thread " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    sparkThread
            SparkCounters Word64
    crt Word64
    dud Word64
    ovf Word64
    cnv Word64
    fiz Word64
    gcd Word64
    rem ->
              Builder
    "spark stats: "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    crt Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " created, "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    cnv Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " converted, "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    rem Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " remaining ("
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    ovf Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " overflowed, "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    dud Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " dud, "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    gcd Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " GC'd, "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    fiz Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " fizzled)"
            EventInfo
    SparkCreate ->
              Builder
    "spark created"
            EventInfo
    SparkDud ->
              Builder
    "dud spark discarded"
            EventInfo
    SparkOverflow ->
              Builder
    "overflowed spark discarded"
            EventInfo
    SparkRun ->
              Builder
    "running a local spark"
            SparkSteal Int
    victimCap ->
              Builder
    "stealing a spark from cap " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    victimCap
            EventInfo
    SparkFizzle ->
              Builder
    "spark fizzled"
            EventInfo
    SparkGC ->
              Builder
    "spark GCed"
            TaskCreate Word64
    taskId Int
    cap KernelThreadId
    tid ->
              Builder
    "task 0x" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.hexadecimal Word64
    taskId
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " created on cap " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    cap
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <>Builder
    " with OS kernel thread " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal (KernelThreadId -> Word64
    kernelThreadId KernelThreadId
    tid)
            TaskMigrate Word64
    taskId Int
    cap Int
    new_cap ->
              Builder
    "task 0x" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.hexadecimal Word64
    taskId
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " migrated from cap " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    cap
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " to cap " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    new_cap
            TaskDelete Word64
    taskId ->
              Builder
    "task 0x" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.hexadecimal Word64
    taskId Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " deleted"
            EventInfo
    Shutdown ->
              Builder
    "shutting down"
            WakeupThread ThreadId
    thread Int
    otherCap ->
              Builder
    "waking up thread " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    thread
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " on cap " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    otherCap
            ThreadLabel ThreadId
    thread Text
    label ->
              Builder
    "thread " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    thread
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " has label \"" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Text -> Builder
    TB.fromText Text
    label Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "\""
            EventInfo
    RequestSeqGC ->
              Builder
    "requesting sequential GC"
            EventInfo
    RequestParGC ->
              Builder
    "requesting parallel GC"
            EventInfo
    StartGC ->
              Builder
    "starting GC"
            EventInfo
    EndGC ->
              Builder
    "finished GC"
            EventInfo
    GCWork ->
              Builder
    "GC working"
            EventInfo
    GCIdle ->
              Builder
    "GC idle"
            EventInfo
    GCDone ->
              Builder
    "GC done"
            EventInfo
    GlobalSyncGC ->
              Builder
    "all caps stopped for GC"
            GCStatsGHC{Int
    Maybe Word64
    ThreadId
    Word64
    heapCapset :: ThreadId
    gen :: Int
    copied :: Word64
    slop :: Word64
    frag :: Word64
    parNThreads :: Int
    parMaxCopied :: Word64
    parTotCopied :: Word64
    parBalancedCopied :: Maybe Word64
    parBalancedCopied :: EventInfo -> Maybe Word64
    parTotCopied :: EventInfo -> Word64
    parMaxCopied :: EventInfo -> Word64
    parNThreads :: EventInfo -> Int
    frag :: EventInfo -> Word64
    slop :: EventInfo -> Word64
    copied :: EventInfo -> Word64
    gen :: EventInfo -> Int
    heapCapset :: EventInfo -> ThreadId
    ..} ->
              Builder
    "GC stats for heap capset " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    heapCapset
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": generation " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    gen Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    copied Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " bytes copied, "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    slop Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " bytes slop, "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    frag Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " bytes fragmentation, "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    parNThreads Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " par threads, "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    parMaxCopied Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " bytes max par copied, "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    parTotCopied Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " bytes total par copied"
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder -> (Word64 -> Builder) -> Maybe Word64 -> Builder
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Builder
    forall a. Monoid a => a
    mempty (\Word64
    val -> Builder
    ", " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    val Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " bytes balanced par copied") Maybe Word64
    parBalancedCopied
            MemReturn{ThreadId
    heapCapset :: EventInfo -> ThreadId
    heapCapset :: ThreadId
    current :: ThreadId
    needed :: ThreadId
    returned :: ThreadId
    returned :: EventInfo -> ThreadId
    needed :: EventInfo -> ThreadId
    current :: EventInfo -> ThreadId
    ..} ->
              Builder
    "memory returned (mblocks): current(" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    current  Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <>
                                       Builder
    ") needed(" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    needed  Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <>
                                       Builder
    ") returned(" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    returned Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ")"
            HeapAllocated{ThreadId
    Word64
    heapCapset :: EventInfo -> ThreadId
    heapCapset :: ThreadId
    allocBytes :: Word64
    allocBytes :: EventInfo -> Word64
    ..} ->
              Builder
    "allocated on heap capset " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    heapCapset
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    allocBytes Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " total bytes till now"
            HeapSize{ThreadId
    Word64
    heapCapset :: EventInfo -> ThreadId
    heapCapset :: ThreadId
    sizeBytes :: Word64
    sizeBytes :: EventInfo -> Word64
    ..} ->
              Builder
    "size of heap capset " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    heapCapset
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    sizeBytes Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " bytes"
            BlocksSize{ThreadId
    Word64
    heapCapset :: EventInfo -> ThreadId
    heapCapset :: ThreadId
    blocksSize :: Word64
    blocksSize :: EventInfo -> Word64
    ..} ->
              Builder
    "blocks size of heap capset " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    heapCapset
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    blocksSize Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " bytes"
            HeapLive{ThreadId
    Word64
    heapCapset :: EventInfo -> ThreadId
    heapCapset :: ThreadId
    liveBytes :: Word64
    liveBytes :: EventInfo -> Word64
    ..} ->
              Builder
    "live data in heap capset " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    heapCapset
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    liveBytes Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " bytes"
            HeapInfoGHC{Int
    ThreadId
    Word64
    heapCapset :: EventInfo -> ThreadId
    heapCapset :: ThreadId
    gens :: Int
    maxHeapSize :: Word64
    allocAreaSize :: Word64
    mblockSize :: Word64
    blockSize :: Word64
    blockSize :: EventInfo -> Word64
    mblockSize :: EventInfo -> Word64
    allocAreaSize :: EventInfo -> Word64
    maxHeapSize :: EventInfo -> Word64
    gens :: EventInfo -> Int
    ..} ->
              Builder
    "heap stats for heap capset " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    heapCapset
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": generations " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    gens Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    maxHeapSize Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " bytes max heap size, "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    allocAreaSize Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " bytes alloc area size, "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    mblockSize Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " bytes mblock size, "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    blockSize Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " bytes block size"
            CapCreate{Int
    cap :: Int
    cap :: EventInfo -> Int
    cap} ->
              Builder
    "created cap " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    cap
            CapDelete{Int
    cap :: EventInfo -> Int
    cap :: Int
    cap} ->
              Builder
    "deleted cap " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    cap
            CapDisable{Int
    cap :: EventInfo -> Int
    cap :: Int
    cap} ->
              Builder
    "disabled cap " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    cap
            CapEnable{Int
    cap :: EventInfo -> Int
    cap :: Int
    cap} ->
              Builder
    "enabled cap " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    cap
            Message Text
    msg ->
              Text -> Builder
    TB.fromText Text
    msg
            UserMessage Text
    msg ->
              Text -> Builder
    TB.fromText Text
    msg
            UserMarker Text
    markername ->
              Builder
    "marker: " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Text -> Builder
    TB.fromText Text
    markername
            CapsetCreate ThreadId
    cs CapsetType
    ct ->
              Builder
    "created capset " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    cs
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " of type " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Builder
    TB.fromString (CapsetType -> [Char]
    forall a. Show a => a -> [Char]
    show CapsetType
    ct)
            CapsetDelete ThreadId
    cs ->
              Builder
    "deleted capset " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    cs
            CapsetAssignCap ThreadId
    cs Int
    cp ->
              Builder
    "assigned cap " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    cp Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " to capset " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    cs
            CapsetRemoveCap ThreadId
    cs Int
    cp ->
              Builder
    "removed cap " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    cp Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " from capset " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    cs
            OsProcessPid ThreadId
    cs ThreadId
    pid ->
              Builder
    "capset " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    cs Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": pid " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    pid
            OsProcessParentPid ThreadId
    cs ThreadId
    ppid ->
              Builder
    "capset " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    cs Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": parent pid " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    ppid
            WallClockTime ThreadId
    cs Word64
    sec ThreadId
    nsec ->
              Builder
    "capset " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    cs Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": wall clock time "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    sec Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "s "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    nsec Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "ns (unix epoch)"
            RtsIdentifier ThreadId
    cs Text
    i ->
              Builder
    "capset " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    cs
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": RTS version \"" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Text -> Builder
    TB.fromText Text
    i Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "\""
            ProgramArgs ThreadId
    cs [Text]
    args ->
              Builder
    "capset " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    cs
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": args: " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Builder
    TB.fromString ([Text] -> [Char]
    forall a. Show a => a -> [Char]
    show [Text]
    args)
            ProgramEnv ThreadId
    cs [Text]
    env ->
              Builder
    "capset " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    cs
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": env: " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Builder
    TB.fromString ([Text] -> [Char]
    forall a. Show a => a -> [Char]
    show [Text]
    env)
            UnknownEvent EventTypeNum
    n ->
              Builder
    "Unknown event type " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> EventTypeNum -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal EventTypeNum
    n
            InternString [Char]
    str ThreadId
    sId ->
              Builder
    "Interned string: \"" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Builder
    TB.fromString [Char]
    str
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "\" with id " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    sId
            -- events for the parallel RTS
            Version [Char]
    version ->
              Builder
    "compiler version is " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Builder
    TB.fromString [Char]
    version
            ProgramInvocation  [Char]
    commandline ->
              Builder
    "program invocation: " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Builder
    TB.fromString [Char]
    commandline
            EventInfo
    EdenStartReceive ->
              Builder
    "starting to receive"
            EventInfo
    EdenEndReceive ->
              Builder
    "stop receiving"
            CreateProcess  ThreadId
    process ->
              Builder
    "creating process " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    process
            KillProcess ThreadId
    process ->
              Builder
    "killing process " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    process
            AssignThreadToProcess ThreadId
    thread ThreadId
    process ->
              Builder
    "assigning thread " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    thread
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " to process " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    process
            CreateMachine EventTypeNum
    machine Word64
    realtime ->
              Builder
    "creating machine " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> EventTypeNum -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal EventTypeNum
    machine
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " at " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    realtime
            KillMachine EventTypeNum
    machine ->
              Builder
    "killing machine " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> EventTypeNum -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal EventTypeNum
    machine
            SendMessage MessageTag
    mesTag ThreadId
    senderProcess ThreadId
    senderThread
              EventTypeNum
    receiverMachine ThreadId
    receiverProcess ThreadId
    receiverInport ->
                Builder
    "sending message with tag " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Builder
    TB.fromString (MessageTag -> [Char]
    forall a. Show a => a -> [Char]
    show MessageTag
    mesTag)
                Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " from process " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    senderProcess
                Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", thread " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    senderThread
                Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " to machine " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> EventTypeNum -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal EventTypeNum
    receiverMachine
                Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", process " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    receiverProcess
                Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " on inport " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    receiverInport
            ReceiveMessage MessageTag
    mesTag ThreadId
    receiverProcess ThreadId
    receiverInport
              EventTypeNum
    senderMachine ThreadId
    senderProcess ThreadId
    senderThread ThreadId
    messageSize ->
                Builder
    "receiving message with tag " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Builder
    TB.fromString (MessageTag -> [Char]
    forall a. Show a => a -> [Char]
    show MessageTag
    mesTag)
                Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " at process " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    receiverProcess
                Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", inport " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    receiverInport
                Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " from machine " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> EventTypeNum -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal EventTypeNum
    senderMachine
                Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", process " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    senderProcess
                Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", thread " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    senderThread
                Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " with size " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    messageSize
            SendReceiveLocalMessage MessageTag
    mesTag ThreadId
    senderProcess ThreadId
    senderThread
              ThreadId
    receiverProcess ThreadId
    receiverInport ->
                Builder
    "sending/receiving message with tag " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> [Char] -> Builder
    TB.fromString (MessageTag -> [Char]
    forall a. Show a => a -> [Char]
    show MessageTag
    mesTag)
                Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " from process " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    senderProcess
                Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", thread " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    senderThread
                Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " to process " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    receiverProcess
                Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " on inport " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    receiverInport
            MerStartParConjunction Word64
    dyn_id ThreadId
    static_id ->
              Builder
    "Start a parallel conjunction 0x" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.hexadecimal Word64
    dyn_id
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", static_id: " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    static_id
            MerEndParConjunction Word64
    dyn_id ->
              Builder
    "End par conjunction: 0x" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.hexadecimal Word64
    dyn_id
            MerEndParConjunct Word64
    dyn_id ->
              Builder
    "End par conjunct: 0x" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.hexadecimal Word64
    dyn_id
            MerCreateSpark Word64
    dyn_id ThreadId
    spark_id ->
              Builder
    "Create spark for conjunction: 0x" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.hexadecimal Word64
    dyn_id
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " spark: 0x" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.hexadecimal ThreadId
    spark_id
            MerFutureCreate Word64
    future_id ThreadId
    name_id ->
              Builder
    "Create future 0x" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.hexadecimal Word64
    future_id
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " named " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    name_id
            MerFutureWaitNosuspend Word64
    future_id ->
              Builder
    "Wait didn't suspend for future: 0x" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.hexadecimal Word64
    future_id
            MerFutureWaitSuspended Word64
    future_id ->
              Builder
    "Wait suspended on future: 0x" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.hexadecimal Word64
    future_id
            MerFutureSignal Word64
    future_id ->
              Builder
    "Signaled future 0x" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.hexadecimal Word64
    future_id
            EventInfo
    MerLookingForGlobalThread ->
              Builder
    "Looking for global thread to resume"
            EventInfo
    MerWorkStealing ->
              Builder
    "Trying to steal a spark"
            EventInfo
    MerLookingForLocalSpark ->
              Builder
    "Looking for a local spark to execute"
            MerReleaseThread ThreadId
    thread_id ->
              Builder
    "Releasing thread " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    thread_id Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " to the free pool"
            EventInfo
    MerCapSleeping ->
              Builder
    "Capability going to sleep"
            EventInfo
    MerCallingMain ->
              Builder
    "About to call the program entry point"
            PerfName{ThreadId
    perfNum :: ThreadId
    perfNum :: EventInfo -> ThreadId
    perfNum, Text
    name :: Text
    name :: EventInfo -> Text
    name} ->
              Builder
    "perf event " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    perfNum
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " named \"" Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Text -> Builder
    TB.fromText Text
    name Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "\""
            PerfCounter{ThreadId
    perfNum :: EventInfo -> ThreadId
    perfNum :: ThreadId
    perfNum, KernelThreadId
    tid :: KernelThreadId
    tid :: EventInfo -> KernelThreadId
    tid, Word64
    period :: Word64
    period :: EventInfo -> Word64
    period} ->
              Builder
    "perf event counter " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    perfNum
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " incremented by " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal (Word64
    period Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    + Word64
    1)
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " in OS thread " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal (KernelThreadId -> Word64
    kernelThreadId KernelThreadId
    tid)
            PerfTracepoint{ThreadId
    perfNum :: EventInfo -> ThreadId
    perfNum :: ThreadId
    perfNum, KernelThreadId
    tid :: EventInfo -> KernelThreadId
    tid :: KernelThreadId
    tid} ->
              Builder
    "perf event tracepoint " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    perfNum
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " reached in OS thread " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal (KernelThreadId -> Word64
    kernelThreadId KernelThreadId
    tid)
            HeapProfBegin {Word8
    Word64
    Text
    HeapProfBreakdown
    heapProfId :: Word8
    heapProfSamplingPeriod :: Word64
    heapProfBreakdown :: HeapProfBreakdown
    heapProfModuleFilter :: Text
    heapProfClosureDescrFilter :: Text
    heapProfTypeDescrFilter :: Text
    heapProfCostCentreFilter :: Text
    heapProfCostCentreStackFilter :: Text
    heapProfRetainerFilter :: Text
    heapProfBiographyFilter :: Text
    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 -> Word64
    heapProfId :: EventInfo -> Word8
    ..} ->
              Builder
    "start heap profiling " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word8 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word8
    heapProfId
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " at sampling period " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    heapProfSamplingPeriod
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " broken down by " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> HeapProfBreakdown -> Builder
    forall s. IsString s => HeapProfBreakdown -> s
    showHeapProfBreakdown HeapProfBreakdown
    heapProfBreakdown
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder -> (Builder -> Builder) -> Maybe Builder -> Builder
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Builder
    "" (Builder
    " filtered by " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <>)
                ([Text] -> Maybe Builder
    buildFilters
                  [ Text
    heapProfModuleFilter
                  , Text
    heapProfClosureDescrFilter
                  , Text
    heapProfTypeDescrFilter
                  , Text
    heapProfCostCentreFilter
                  , Text
    heapProfCostCentreStackFilter
                  , Text
    heapProfRetainerFilter
                  , Text
    heapProfBiographyFilter
                  ])
            HeapProfCostCentre {ThreadId
    Text
    HeapProfFlags
    heapProfCostCentreId :: ThreadId
    heapProfLabel :: Text
    heapProfModule :: Text
    heapProfSrcLoc :: Text
    heapProfFlags :: HeapProfFlags
    heapProfFlags :: EventInfo -> HeapProfFlags
    heapProfSrcLoc :: EventInfo -> Text
    heapProfModule :: EventInfo -> Text
    heapProfLabel :: EventInfo -> Text
    heapProfCostCentreId :: EventInfo -> ThreadId
    ..} ->
              Builder
    "cost centre " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    heapProfCostCentreId
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Text -> Builder
    TB.fromText Text
    heapProfLabel
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " in " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Text -> Builder
    TB.fromText Text
    heapProfModule
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " at " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Text -> Builder
    TB.fromText Text
    heapProfSrcLoc
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> if HeapProfFlags -> Bool
    isCaf HeapProfFlags
    heapProfFlags then Builder
    " CAF" else Builder
    ""
            InfoTableProv{Int
    Word64
    Text
    itInfo :: Word64
    itTableName :: Text
    itClosureDesc :: Int
    itTyDesc :: Text
    itLabel :: Text
    itModule :: Text
    itSrcLoc :: Text
    itSrcLoc :: EventInfo -> Text
    itModule :: EventInfo -> Text
    itLabel :: EventInfo -> Text
    itTyDesc :: EventInfo -> Text
    itClosureDesc :: EventInfo -> Int
    itTableName :: EventInfo -> Text
    itInfo :: EventInfo -> Word64
    ..} ->
             Builder
    "Info Table: " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.hexadecimal Word64
    itInfo Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ":"
                            Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    itClosureDesc Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ":"
                            Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Text -> Builder
    TB.fromText Text
    itTableName
                            Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " - " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Text -> Builder
    TB.fromText Text
    itSrcLoc
            HeapProfSampleBegin {Word64
    heapProfSampleEra :: Word64
    heapProfSampleEra :: EventInfo -> Word64
    ..} ->
              Builder
    "start heap prof sample " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    heapProfSampleEra
            HeapProfSampleEnd {Word64
    heapProfSampleEra :: EventInfo -> Word64
    heapProfSampleEra :: Word64
    ..} ->
              Builder
    "end prof sample " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    heapProfSampleEra
            HeapBioProfSampleBegin {Word64
    heapProfSampleEra :: EventInfo -> Word64
    heapProfSampleEra :: Word64
    heapProfSampleTime :: Word64
    heapProfSampleTime :: EventInfo -> Word64
    ..} ->
              Builder
    "start heap prof sample " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    heapProfSampleEra
                Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " at time " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    heapProfSampleTime

            HeapProfSampleCostCentre {Word8
    Word64
    Vector ThreadId
    heapProfId :: EventInfo -> Word8
    heapProfId :: Word8
    heapProfResidency :: Word64
    heapProfStackDepth :: Word8
    heapProfStack :: Vector ThreadId
    heapProfStack :: EventInfo -> Vector ThreadId
    heapProfStackDepth :: EventInfo -> Word8
    heapProfResidency :: EventInfo -> Word64
    ..} ->
              Builder
    "heap prof sample " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word8 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word8
    heapProfId
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", residency " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    heapProfResidency
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", cost centre stack " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Vector ThreadId -> Builder
    buildCostCentreStack Vector ThreadId
    heapProfStack

            HeapProfSampleString {Word8
    Word64
    Text
    heapProfId :: EventInfo -> Word8
    heapProfLabel :: EventInfo -> Text
    heapProfResidency :: EventInfo -> Word64
    heapProfId :: Word8
    heapProfResidency :: Word64
    heapProfLabel :: Text
    ..} ->
              Builder
    "heap prof sample " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word8 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word8
    heapProfId
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", residency " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    heapProfResidency
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", label " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Text -> Builder
    TB.fromText Text
    heapProfLabel

            ProfSampleCostCentre {Word8
    EventTypeNum
    Word64
    Vector ThreadId
    profCap :: EventTypeNum
    profTicks :: Word64
    profStackDepth :: Word8
    profCcsStack :: Vector ThreadId
    profCcsStack :: EventInfo -> Vector ThreadId
    profStackDepth :: EventInfo -> Word8
    profTicks :: EventInfo -> Word64
    profCap :: EventInfo -> EventTypeNum
    ..} ->
              Builder
    "cap no " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> EventTypeNum -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal EventTypeNum
    profCap
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", prof sample " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    profTicks
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", cost centre stack " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Vector ThreadId -> Builder
    buildCostCentreStack Vector ThreadId
    profCcsStack

            ProfBegin {Word64
    profTickInterval :: Word64
    profTickInterval :: EventInfo -> Word64
    ..} ->
              Builder
    "start time profiling, tick interval " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    profTickInterval Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " (ns)"

            UserBinaryMessage {ByteString
    payload :: ByteString
    payload :: EventInfo -> ByteString
    ..} ->
              Builder
    "binary message " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Text -> Builder
    TB.fromText (Char -> ByteString -> Text
    replaceUnprintableWith Char
    '.' ByteString
    payload)

            EventInfo
    ConcMarkBegin    ->
              Builder
    "concurrent mark began"
            ConcMarkEnd {ThreadId
    concMarkedObjectCount :: ThreadId
    concMarkedObjectCount :: EventInfo -> ThreadId
    ..} ->
              Builder
    "concurrent mark ended: "
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "marked " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    concMarkedObjectCount Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " objects"
            EventInfo
    ConcSyncBegin ->
              Builder
    "post-mark synchronization began"
            EventInfo
    ConcSyncEnd ->
              Builder
    "post-mark synchronization ended"
            EventInfo
    ConcSweepBegin ->
              Builder
    "concurrent sweep began"
            EventInfo
    ConcSweepEnd ->
              Builder
    "concurrent sweep ended"
            ConcUpdRemSetFlush {Int
    cap :: EventInfo -> Int
    cap :: Int
    ..}  ->
              Builder
    "update remembered set flushed by " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    cap
            NonmovingHeapCensus {EventTypeNum
    ThreadId
    nonmovingCensusBlkSize :: EventTypeNum
    nonmovingCensusActiveSegs :: ThreadId
    nonmovingCensusFilledSegs :: ThreadId
    nonmovingCensusLiveBlocks :: ThreadId
    nonmovingCensusLiveBlocks :: EventInfo -> ThreadId
    nonmovingCensusFilledSegs :: EventInfo -> ThreadId
    nonmovingCensusActiveSegs :: EventInfo -> ThreadId
    nonmovingCensusBlkSize :: EventInfo -> EventTypeNum
    ..}  ->
              Builder
    "nonmoving heap census " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> EventTypeNum -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal EventTypeNum
    nonmovingCensusBlkSize
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    nonmovingCensusActiveSegs Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " active segments"
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    nonmovingCensusFilledSegs Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " filled segments"
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    nonmovingCensusLiveBlocks Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " live blocks"
            NonmovingPrunedSegments {ThreadId
    nonmovingPrunedSegments :: ThreadId
    nonmovingFreeSegments :: ThreadId
    nonmovingFreeSegments :: EventInfo -> ThreadId
    nonmovingPrunedSegments :: EventInfo -> ThreadId
    ..} ->
              Builder
    "nonmoving segments pruned: "
               Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    nonmovingPrunedSegments Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " pruned segments, "
               Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> ThreadId -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal ThreadId
    nonmovingFreeSegments Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " free segments retained"
            TickyCounterDef {Maybe Text
    EventTypeNum
    Word64
    Text
    tickyCtrDefId :: Word64
    tickyCtrDefArity :: EventTypeNum
    tickyCtrDefKinds :: Text
    tickyCtrDefName :: Text
    tickyCtrInfoTbl :: Word64
    tickyCtrJsonDesc :: Maybe Text
    tickyCtrJsonDesc :: EventInfo -> Maybe Text
    tickyCtrInfoTbl :: EventInfo -> Word64
    tickyCtrDefName :: EventInfo -> Text
    tickyCtrDefKinds :: EventInfo -> Text
    tickyCtrDefArity :: EventInfo -> EventTypeNum
    tickyCtrDefId :: EventInfo -> Word64
    ..}  ->
              Builder
    "ticky counter definition " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    tickyCtrDefId
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <>  Builder
    "arity: " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> EventTypeNum -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal EventTypeNum
    tickyCtrDefArity
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "def kinds: " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Text -> Builder
    TB.fromText Text
    tickyCtrDefKinds
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "name: " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Text -> Builder
    TB.fromText Text
    tickyCtrDefName
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "itbl: " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.hexadecimal Word64
    tickyCtrInfoTbl
            TickyCounterSample {Word64
    tickyCtrSampleId :: Word64
    tickyCtrSampleEntryCount :: Word64
    tickyCtrSampleAllocs :: Word64
    tickyCtrSampleAllocd :: Word64
    tickyCtrSampleAllocd :: EventInfo -> Word64
    tickyCtrSampleAllocs :: EventInfo -> Word64
    tickyCtrSampleEntryCount :: EventInfo -> Word64
    tickyCtrSampleId :: EventInfo -> Word64
    ..}  ->
              Builder
    "ticky counter sample " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    tickyCtrSampleId
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "entry count: " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    tickyCtrSampleEntryCount
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    tickyCtrSampleAllocs Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " allocs"
              Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    tickyCtrSampleAllocd Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " allocd"
            EventInfo
    TickyBeginSample ->
              Builder
    "ticky begin counter sample"

    -- | Replace unprintable bytes in the message with the replacement character
    replaceUnprintableWith
      :: Char -- ^ Replacement character
      -> B.ByteString -- ^ Binary message which may contain unprintable bytes
      -> T.Text
    replaceUnprintableWith :: Char -> ByteString -> Text
    replaceUnprintableWith Char
    replacement = (Char -> Char) -> Text -> Text
    T.map Char -> Char
    replace (Text -> Text) -> (ByteString -> Text) -> ByteString -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . OnDecodeError -> ByteString -> Text
    TE.decodeUtf8With (\[Char]
    _ Maybe Word8
    _ -> Char -> Maybe Char
    forall a. a -> Maybe a
    Just Char
    replacement)
      where
        replace :: Char -> Char
    replace Char
    c
          | Char -> Bool
    isPrint Char
    c = Char
    c
          | Bool
    otherwise = Char
    replacement

    buildFilters :: [T.Text] -> Maybe TB.Builder
    buildFilters :: [Text] -> Maybe Builder
    buildFilters = (Text -> Maybe Builder -> Maybe Builder)
    -> Maybe Builder -> [Text] -> Maybe Builder
    forall a b. (a -> b -> b) -> b -> [a] -> b
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr Text -> Maybe Builder -> Maybe Builder
    g Maybe Builder
    forall a. Maybe a
    Nothing
      where
        g :: Text -> Maybe Builder -> Maybe Builder
    g Text
    f Maybe Builder
    b
          | Text -> Bool
    T.null Text
    f = Maybe Builder
    b
          | Bool
    otherwise = Builder -> Maybe Builder
    forall a. a -> Maybe a
    Just (Text -> Builder
    TB.fromText Text
    f Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", ") Maybe Builder -> Maybe Builder -> Maybe Builder
    forall a. Semigroup a => a -> a -> a
    <> Maybe Builder
    b

    buildCostCentreStack :: VU.Vector Word32 -> TB.Builder
    buildCostCentreStack :: Vector ThreadId -> Builder
    buildCostCentreStack = (Builder -> Int -> ThreadId -> Builder)
    -> Builder -> Vector ThreadId -> Builder
    forall b a. Unbox b => (a -> Int -> b -> a) -> a -> Vector b -> a
    VU.ifoldl' Builder -> Int -> ThreadId -> Builder
    forall {a} {a}.
    (Integral a, Num a, Eq a) =>
    Builder -> a -> a -> Builder
    go Builder
    ""
      where
        go :: Builder -> a -> a -> Builder
    go Builder
    b a
    i a
    cc
          | a
    i a -> a -> Bool
    forall a. Eq a => a -> a -> Bool
    == a
    0 = a -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal a
    cc
          | Bool
    otherwise = Builder
    b Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ", " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> a -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal a
    cc

    showThreadStopStatus :: ThreadStopStatus -> String
    showThreadStopStatus :: ThreadStopStatus -> [Char]
    showThreadStopStatus ThreadStopStatus
    HeapOverflow   = [Char]
    "heap overflow"
    showThreadStopStatus ThreadStopStatus
    StackOverflow  = [Char]
    "stack overflow"
    showThreadStopStatus ThreadStopStatus
    ThreadYielding = [Char]
    "thread yielding"
    showThreadStopStatus ThreadStopStatus
    ThreadBlocked  = [Char]
    "thread blocked"
    showThreadStopStatus ThreadStopStatus
    ThreadFinished = [Char]
    "thread finished"
    showThreadStopStatus ThreadStopStatus
    ForeignCall    = [Char]
    "making a foreign call"
    showThreadStopStatus ThreadStopStatus
    BlockedOnMVar  = [Char]
    "blocked on an MVar"
    showThreadStopStatus ThreadStopStatus
    BlockedOnMVarRead = [Char]
    "blocked reading an MVar"
    showThreadStopStatus ThreadStopStatus
    BlockedOnBlackHole = [Char]
    "blocked on a black hole"
    showThreadStopStatus ThreadStopStatus
    BlockedOnRead = [Char]
    "blocked on I/O read"
    showThreadStopStatus ThreadStopStatus
    BlockedOnWrite = [Char]
    "blocked on I/O write"
    showThreadStopStatus ThreadStopStatus
    BlockedOnDelay = [Char]
    "blocked on threadDelay"
    showThreadStopStatus ThreadStopStatus
    BlockedOnSTM = [Char]
    "blocked in STM retry"
    showThreadStopStatus ThreadStopStatus
    BlockedOnDoProc = [Char]
    "blocked on asyncDoProc"
    showThreadStopStatus ThreadStopStatus
    BlockedOnCCall = [Char]
    "blocked in a foreign call"
    showThreadStopStatus ThreadStopStatus
    BlockedOnCCall_NoUnblockExc = [Char]
    "blocked in a foreign call"
    showThreadStopStatus ThreadStopStatus
    BlockedOnMsgThrowTo = [Char]
    "blocked in throwTo"
    showThreadStopStatus ThreadStopStatus
    ThreadMigrating = [Char]
    "thread migrating"
    showThreadStopStatus ThreadStopStatus
    BlockedOnMsgGlobalise = [Char]
    "waiting for data to be globalised"
    showThreadStopStatus (BlockedOnBlackHoleOwnedBy ThreadId
    target) =
              [Char]
    "blocked on black hole owned by thread " [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ ThreadId -> [Char]
    forall a. Show a => a -> [Char]
    show ThreadId
    target
    showThreadStopStatus ThreadStopStatus
    NoStatus = [Char]
    "No stop thread status"

    showHeapProfBreakdown :: IsString s => HeapProfBreakdown -> s
    showHeapProfBreakdown :: forall s. IsString s => HeapProfBreakdown -> s
    showHeapProfBreakdown HeapProfBreakdown
    breakdown = case HeapProfBreakdown
    breakdown of
      HeapProfBreakdown
    HeapProfBreakdownCostCentre -> s
    "cost centre"
      HeapProfBreakdown
    HeapProfBreakdownModule -> s
    "module"
      HeapProfBreakdown
    HeapProfBreakdownClosureDescr -> s
    "closure description"
      HeapProfBreakdown
    HeapProfBreakdownTypeDescr -> s
    "type description"
      HeapProfBreakdown
    HeapProfBreakdownRetainer -> s
    "retainer"
      HeapProfBreakdown
    HeapProfBreakdownBiography -> s
    "biography"
      HeapProfBreakdown
    HeapProfBreakdownClosureType -> s
    "closure type"
      HeapProfBreakdown
    HeapProfBreakdownInfoTable -> s
    "info table"
      HeapProfBreakdown
    HeapProfBreakdownEra -> s
    "era"

    -- | How to format event timestamps
    data TimeFormat = RawTime | PrettyTime

    ppEventLog :: TimeFormat -> EventLog -> String
    ppEventLog :: TimeFormat -> EventLog -> [Char]
    ppEventLog TimeFormat
    time_fmt = Text -> [Char]
    TL.unpack (Text -> [Char]) -> (EventLog -> Text) -> EventLog -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Builder -> Text
    TB.toLazyText (Builder -> Text) -> (EventLog -> Builder) -> EventLog -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . TimeFormat -> EventLog -> Builder
    buildEventLog TimeFormat
    time_fmt

    buildEventLog :: TimeFormat -> EventLog -> TB.Builder
    buildEventLog :: TimeFormat -> EventLog -> Builder
    buildEventLog TimeFormat
    time_fmt (EventLog (Header [EventType]
    ets) (Data [Event]
    es)) =
      Builder
    "Event Types:\n"
      Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> (EventType -> Builder) -> [EventType] -> Builder
    forall m a. Monoid m => (a -> m) -> [a] -> m
    forall (t :: * -> *) m a.
    (Foldable t, Monoid m) =>
    (a -> m) -> t a -> m
    foldMap (\EventType
    evType -> EventType -> Builder
    buildEventType EventType
    evType Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "\n") [EventType]
    ets
      Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "\n"
      Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "Events:\n"
      Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> (Event -> Builder) -> [Event] -> Builder
    forall m a. Monoid m => (a -> m) -> [a] -> m
    forall (t :: * -> *) m a.
    (Foldable t, Monoid m) =>
    (a -> m) -> t a -> m
    foldMap (\Event
    ev -> TimeFormat -> IntMap EventType -> Event -> Builder
    buildEvent TimeFormat
    time_fmt IntMap EventType
    imap Event
    ev Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "\n") [Event]
    sorted
      where
        imap :: IntMap EventType
    imap = [EventType] -> IntMap EventType
    buildEventTypeMap [EventType]
    ets
        sorted :: [Event]
    sorted = [Event] -> [Event]
    sortEvents [Event]
    es

    ppEventType :: EventType -> String
    ppEventType :: EventType -> [Char]
    ppEventType = Text -> [Char]
    TL.unpack (Text -> [Char]) -> (EventType -> Text) -> EventType -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Builder -> Text
    TB.toLazyText (Builder -> Text) -> (EventType -> Builder) -> EventType -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . EventType -> Builder
    buildEventType

    buildEventType :: EventType -> TB.Builder
    buildEventType :: EventType -> Builder
    buildEventType (EventType EventTypeNum
    num Text
    dsc Maybe EventTypeNum
    msz) =
      EventTypeNum -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal EventTypeNum
    num Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": "
      Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Text -> Builder
    TB.fromText Text
    dsc Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    " (size "
      Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    -> (EventTypeNum -> Builder) -> Maybe EventTypeNum -> Builder
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Builder
    "variable" EventTypeNum -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Maybe EventTypeNum
    msz Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ")"

    -- | Pretty prints an 'Event', with clean handling for 'UnknownEvent'
    ppEvent
      :: TimeFormat
      -> IntMap EventType -- ^ Look up @'UnknownEvent'.'ref'@ to find a suitable description.
      -> Event
      -> String
    ppEvent :: TimeFormat -> IntMap EventType -> Event -> [Char]
    ppEvent TimeFormat
    time_fmt IntMap EventType
    imap =
      Text -> [Char]
    TL.unpack (Text -> [Char]) -> (Event -> Text) -> Event -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Builder -> Text
    TB.toLazyText (Builder -> Text) -> (Event -> Builder) -> Event -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . TimeFormat -> IntMap EventType -> Event -> Builder
    buildEvent TimeFormat
    time_fmt IntMap EventType
    imap

    buildEvent :: TimeFormat -> IntMap EventType -> Event -> TB.Builder
    buildEvent :: TimeFormat -> IntMap EventType -> Event -> Builder
    buildEvent TimeFormat
    time_fmt IntMap EventType
    imap Event {Maybe Int
    Word64
    EventInfo
    evCap :: Event -> Maybe Int
    evTime :: Event -> Word64
    evTime :: Word64
    evSpec :: EventInfo
    evCap :: Maybe Int
    evSpec :: Event -> EventInfo
    ..} =
      TimeFormat -> Word64 -> Builder
    buildTime TimeFormat
    time_fmt Word64
    evTime
      Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": "
      Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder -> (Int -> Builder) -> Maybe Int -> Builder
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Builder
    "" (\Int
    c -> Builder
    "cap " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    c Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": ") Maybe Int
    evCap
      Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> case EventInfo
    evSpec of
        UnknownEvent{ ref :: EventInfo -> EventTypeNum
    ref=EventTypeNum
    ref } ->
          Builder -> (EventType -> Builder) -> Maybe EventType -> Builder
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Builder
    "" (Text -> Builder
    TB.fromText (Text -> Builder) -> (EventType -> Text) -> EventType -> Builder
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . EventType -> Text
    desc) (Maybe EventType -> Builder) -> Maybe EventType -> Builder
    forall a b. (a -> b) -> a -> b
    $ Int -> IntMap EventType -> Maybe EventType
    forall a. Int -> IntMap a -> Maybe a
    IM.lookup (EventTypeNum -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral EventTypeNum
    ref) IntMap EventType
    imap
        EventInfo
    _ -> EventInfo -> Builder
    buildEventInfo EventInfo
    evSpec

    buildTime :: TimeFormat -> Word64 -> TB.Builder
    buildTime :: TimeFormat -> Word64 -> Builder
    buildTime TimeFormat
    RawTime Word64
    t = Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    t
    buildTime TimeFormat
    PrettyTime Word64
    t =
         Word64 -> Builder
    rJustDecimal Word64
    secs  Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "s "
      Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    rJustDecimal Word64
    msecs Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "ms "
      Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    rJustDecimal Word64
    usecs
      Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "."
      Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    lJustDecimal Word64
    nsecs''  Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    "us"
      where
        (Word64
    secs, Word64
    nsecs) = Word64
    t Word64 -> Word64 -> (Word64, Word64)
    forall a. Integral a => a -> a -> (a, a)
    `divMod` (Word64
    1000Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    *Word64
    1000Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    *Word64
    1000)
        (Word64
    msecs, Word64
    nsecs') = Word64
    nsecs Word64 -> Word64 -> (Word64, Word64)
    forall a. Integral a => a -> a -> (a, a)
    `divMod` (Word64
    1000Word64 -> Word64 -> Word64
    forall a. Num a => a -> a -> a
    *Word64
    1000)
        (Word64
    usecs, Word64
    nsecs'') = Word64
    nsecs' Word64 -> Word64 -> (Word64, Word64)
    forall a. Integral a => a -> a -> (a, a)
    `divMod` Word64
    1000

        padSpaces :: Word64 -> TB.Builder
        padSpaces :: Word64 -> Builder
    padSpaces Word64
    n
          | Word64
    n Word64 -> Word64 -> Bool
    forall a. Ord a => a -> a -> Bool
    < Word64
    10    = Builder
    "  "
          | Word64
    n Word64 -> Word64 -> Bool
    forall a. Ord a => a -> a -> Bool
    < Word64
    100   = Builder
    " "
          | Bool
    otherwise = Builder
    forall a. Monoid a => a
    mempty

        -- decimal numbers justified to three columns
        rJustDecimal :: Word64 -> Builder
    rJustDecimal Word64
    n = Word64 -> Builder
    padSpaces Word64
    n Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    n
        lJustDecimal :: Word64 -> Builder
    lJustDecimal Word64
    n = Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    n Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Word64 -> Builder
    padSpaces Word64
    n

    buildEvent' :: Event -> TB.Builder
    buildEvent' :: Event -> Builder
    buildEvent' Event {Maybe Int
    Word64
    EventInfo
    evCap :: Event -> Maybe Int
    evTime :: Event -> Word64
    evSpec :: Event -> EventInfo
    evTime :: Word64
    evSpec :: EventInfo
    evCap :: Maybe Int
    ..} =
       Word64 -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Word64
    evTime
       Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": "
       Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder -> (Int -> Builder) -> Maybe Int -> Builder
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Builder
    "" (\Int
    c -> Builder
    "cap " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Int -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal Int
    c Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ": ") Maybe Int
    evCap
       Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> case EventInfo
    evSpec of
         UnknownEvent{ ref :: EventInfo -> EventTypeNum
    ref=EventTypeNum
    ref } ->
          Builder
    "Unknown Event (ref: " Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> EventTypeNum -> Builder
    forall a. Integral a => a -> Builder
    TB.decimal EventTypeNum
    ref Builder -> Builder -> Builder
    forall a. Semigroup a => a -> a -> a
    <> Builder
    ")"
         EventInfo
    _ -> EventInfo -> Builder
    buildEventInfo EventInfo
    evSpec