module GHC.Debug.Client
(
Debuggee
, DebugM
, debuggeeRun
, debuggeeConnect
, debuggeeClose
, withDebuggeeRun
, withDebuggeeConnect
, socketDirectory
, snapshotRun
, run
, runTrace
, runAnalysis
, pause
, fork
, pauseThen
, resume
, pausePoll
, withPause
, version
, gcRoots
, allBlocks
, getSourceInfo
, savedObjects
, precacheBlocks
, dereferenceClosure
, dereferenceToClosurePtr
, addConstrDesc
, requestCCSMain
, dereferenceClosures
, dereferenceStack
, dereferencePapPayload
, dereferenceConDesc
, dereferenceInfoTable
, dereferenceIndexTable
, dereferenceSRT
, dereferenceCCS
, dereferenceCC
, Hextraversable(..)
, buildHeapGraph
, multiBuildHeapGraph
, HG.HeapGraph(..)
, HG.HeapGraphEntry(..)
, HG.ppHeapGraph
, traceWrite
, traceMsg
, saveCache
, loadCache
, module GHC.Debug.Types.Closures
, SourceInformation(..)
, RawBlock(..)
, BlockPtr
, StackPtr
, ClosurePtr
, InfoTablePtr
, CCPtr
, CCSPtr
, IndexTablePtr
, HG.StackHI
, HG.PapHI
, HG.HeapGraphIndex
) where
import GHC.Debug.Types
import GHC.Debug.Types.Closures
import GHC.Debug.Convention (socketDirectory)
import GHC.Debug.Client.Monad
import GHC.Debug.Client.Query
import qualified GHC.Debug.Types.Graph as HG
import Data.List.NonEmpty (NonEmpty)
import Data.Bitraversable
import Control.Monad
derefFuncM :: HG.DerefFunction DebugM Size
derefFuncM :: DerefFunction DebugM Size
derefFuncM ClosurePtr
c = do
SizedClosure
c' <- ClosurePtr -> DebugM SizedClosure
dereferenceClosure ClosurePtr
c
(CCSPtr -> DebugM CCSPtr)
-> (InfoTablePtr -> DebugM SrtPayload)
-> (PayloadCont -> DebugM PapPayload)
-> (InfoTablePtr -> DebugM ConstrDesc)
-> (StackCont -> DebugM (GenStackFrames SrtPayload ClosurePtr))
-> (ClosurePtr -> DebugM ClosurePtr)
-> SizedClosure
-> DebugM
(DebugClosureWithExtra
Size
CCSPtr
SrtPayload
PapPayload
ConstrDesc
(GenStackFrames SrtPayload ClosurePtr)
ClosurePtr)
forall (f :: * -> *) a b c d e g h i j k l n.
Applicative f =>
(a -> f b)
-> (c -> f d)
-> (e -> f g)
-> (h -> f i)
-> (j -> f k)
-> (l -> f n)
-> DebugClosureWithExtra Size a c e h j l
-> f (DebugClosureWithExtra Size b d g i k n)
forall (m :: * -> * -> * -> * -> * -> * -> *) (f :: * -> *) a b c d
e g h i j k l n.
(Hextraversable m, Applicative f) =>
(a -> f b)
-> (c -> f d)
-> (e -> f g)
-> (h -> f i)
-> (j -> f k)
-> (l -> f n)
-> m a c e h j l
-> f (m b d g i k n)
hextraverse CCSPtr -> DebugM CCSPtr
forall a. a -> DebugM a
forall (f :: * -> *) a. Applicative f => a -> f a
pure InfoTablePtr -> DebugM SrtPayload
dereferenceSRT PayloadCont -> DebugM PapPayload
dereferencePapPayload InfoTablePtr -> DebugM ConstrDesc
dereferenceConDesc ((InfoTablePtr -> DebugM SrtPayload)
-> (ClosurePtr -> DebugM ClosurePtr)
-> GenStackFrames InfoTablePtr ClosurePtr
-> DebugM (GenStackFrames SrtPayload ClosurePtr)
forall (f :: * -> *) a c b d.
Applicative f =>
(a -> f c)
-> (b -> f d) -> GenStackFrames a b -> f (GenStackFrames c d)
forall (t :: * -> * -> *) (f :: * -> *) a c b d.
(Bitraversable t, Applicative f) =>
(a -> f c) -> (b -> f d) -> t a b -> f (t c d)
bitraverse InfoTablePtr -> DebugM SrtPayload
dereferenceSRT ClosurePtr -> DebugM ClosurePtr
forall a. a -> DebugM a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (GenStackFrames InfoTablePtr ClosurePtr
-> DebugM (GenStackFrames SrtPayload ClosurePtr))
-> (StackCont -> DebugM (GenStackFrames InfoTablePtr ClosurePtr))
-> StackCont
-> DebugM (GenStackFrames SrtPayload ClosurePtr)
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< StackCont -> DebugM (GenStackFrames InfoTablePtr ClosurePtr)
dereferenceStack) ClosurePtr -> DebugM ClosurePtr
forall a. a -> DebugM a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SizedClosure
c'
buildHeapGraph :: Maybe Int -> ClosurePtr -> DebugM (HG.HeapGraph Size)
buildHeapGraph :: Maybe Int -> ClosurePtr -> DebugM (HeapGraph Size)
buildHeapGraph = DerefFunction DebugM Size
-> Maybe Int -> ClosurePtr -> DebugM (HeapGraph Size)
forall (m :: * -> *) a.
MonadFix m =>
DerefFunction m a -> Maybe Int -> ClosurePtr -> m (HeapGraph a)
HG.buildHeapGraph DerefFunction DebugM Size
derefFuncM
multiBuildHeapGraph :: Maybe Int -> NonEmpty ClosurePtr -> DebugM (HG.HeapGraph Size)
multiBuildHeapGraph :: Maybe Int -> NonEmpty ClosurePtr -> DebugM (HeapGraph Size)
multiBuildHeapGraph = DerefFunction DebugM Size
-> Maybe Int -> NonEmpty ClosurePtr -> DebugM (HeapGraph Size)
forall (m :: * -> *) a.
MonadFix m =>
DerefFunction m a
-> Maybe Int -> NonEmpty ClosurePtr -> m (HeapGraph a)
HG.multiBuildHeapGraph DerefFunction DebugM Size
derefFuncM
runAnalysis :: DebugM a -> (a -> IO r) -> Debuggee -> IO r
runAnalysis :: forall a r. DebugM a -> (a -> IO r) -> Debuggee -> IO r
runAnalysis DebugM a
a a -> IO r
k Debuggee
e = do
Debuggee -> IO ()
pause Debuggee
e
a
r <- Debuggee -> DebugM a -> IO a
forall a. Debuggee -> DebugM a -> IO a
run Debuggee
e DebugM a
a
Debuggee -> IO ()
resume Debuggee
e
a -> IO r
k a
r