{-# LANGUAGE CPP #-}
module GHC.Stack.Profiler.Internal.Stack.Compat (
lookupIpeIdForStackFrame,
) where
import Data.Binary
import GHC.Internal.InfoProv.Types.Compat
import GHC.Internal.Stack.Decode.Compat
#if !MIN_VERSION_ghc_internal(9,1500,0)
import GHC.Stack.Profiler.Internal.Util (castPtrToWord64)
#endif
lookupIpeIdForStackFrame :: StackInfoTable -> IO (Maybe Word64)
lookupIpeIdForStackFrame :: StackInfoTable -> IO (Maybe Word64)
lookupIpeIdForStackFrame StackInfoTable
itbl = do
mId <- Ptr StgInfoTable -> IO (Maybe Word64)
lookupIpeId (StackInfoTable -> Ptr StgInfoTable
infoTablePtr StackInfoTable
itbl)
#if MIN_VERSION_ghc_internal(9,1500,0)
pure mId
#else
pure $! castPtrToWord64 (infoTableStructPtr itbl) <$ mId
#endif