haskell / ghc-events

Library and tool for parsing .eventlog files from GHC
http://www.haskell.org/haskellwiki/ThreadScope
Other
33 stars 34 forks source link

Add support for EVENT_USER_BINARY_MSG #54

Closed maoe closed 4 years ago

maoe commented 4 years ago

This PR adds support for the EVENT_USER_BINARY_MSG event implemented in https://gitlab.haskell.org/ghc/ghc/commit/21f0f56164f50844c2150c62f950983b2376f8b6, which was included in GHC 8.8.1.

Since it's binary logging, ghc-events show/inc need to deal with unprintable characters. Currently those characters are replaced with .s, which may be arguable (i.e. binary logging tends to emit long messages so ghc-events probably shouldn't print the whole message etc).

The test eventlog was generated by the following source code

{-# LANGUAGE OverloadedStrings #-}
module Main where
import Debug.Trace.Binary (traceBinaryEventIO)

main :: IO ()
main = traceBinaryEventIO $ "Hello, " <> "\NUL"

and the output contains this line:

2871512: cap 0: binary message Hello, .
maoe commented 4 years ago

It might be useful to make the binary printer user configurable.

buildEventInfo :: EventInfo -> TB.Builder
buildEventInfo = buildEventInfoWith $ \payload ->
  "binary message " <> TB.fromText (replaceUnprintableWith '.' payload)

buildEventInfoWith :: (B.ByteString -> TB.Builder) -> EventInfo -> TB.Builder
buildEventInfoWith = ...
maoe commented 4 years ago

Is anyone available to review this PR? If no one is available in a week or so I'll just merge it and release.

maoe commented 4 years ago

It's been a week since the last comment. I'll go ahead.