From 3654951ca31b225c84c1b1fa8eafe34b701c91e6 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Thu, 21 Apr 2022 12:37:29 +0200 Subject: Get entire log instead of only a prefix --- src/GHC/GC_Hook.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/GHC/GC_Hook.hs b/src/GHC/GC_Hook.hs index 44826c9..35fbbc5 100644 --- a/src/GHC/GC_Hook.hs +++ b/src/GHC/GC_Hook.hs @@ -1,4 +1,5 @@ {-# LANGUAGE ForeignFunctionInterface #-} +{-# LANGUAGE LambdaCase #-} {-# LANGUAGE TypeApplications #-} module GHC.GC_Hook ( setGCHook, @@ -97,6 +98,12 @@ setGCHook = do -- will never get the same structure twice. getGCLog :: IO [Details] getGCLog = + getLogBatch >>= \case + [] -> return [] + batch -> (batch ++) <$> getGCLog + +getLogBatch :: IO [Details] +getLogBatch = let bufferCapacity = 2048 in allocaBytes bufferCapacity $ \pbuffer -> alloca $ \punitsize -> -- cgit v1.2.3-54-g00ecf