haskell-debugger
Safe HaskellNone
LanguageGHC2021

GHC.Debugger.Monad

Synopsis

Documentation

newtype Debugger a Source #

A debugger action.

Constructors

Debugger 

Instances

Instances details
MonadCatch Debugger Source # 
Instance details

Defined in GHC.Debugger.Monad

MonadMask Debugger Source # 
Instance details

Defined in GHC.Debugger.Monad

Methods

mask :: HasCallStack => ((forall a. Debugger a -> Debugger a) -> Debugger b) -> Debugger b #

uninterruptibleMask :: HasCallStack => ((forall a. Debugger a -> Debugger a) -> Debugger b) -> Debugger b #

generalBracket :: HasCallStack => Debugger a -> (a -> ExitCase b -> Debugger c) -> (a -> Debugger b) -> Debugger (b, c) #

MonadThrow Debugger Source # 
Instance details

Defined in GHC.Debugger.Monad

HasDynFlags Debugger Source # 
Instance details

Defined in GHC.Debugger.Monad

GhcMonad Debugger Source # 
Instance details

Defined in GHC.Debugger.Monad

HasLogger Debugger Source # 
Instance details

Defined in GHC.Debugger.Monad

Applicative Debugger Source # 
Instance details

Defined in GHC.Debugger.Monad

Methods

pure :: a -> Debugger a #

(<*>) :: Debugger (a -> b) -> Debugger a -> Debugger b #

liftA2 :: (a -> b -> c) -> Debugger a -> Debugger b -> Debugger c #

(*>) :: Debugger a -> Debugger b -> Debugger b #

(<*) :: Debugger a -> Debugger b -> Debugger a #

Functor Debugger Source # 
Instance details

Defined in GHC.Debugger.Monad

Methods

fmap :: (a -> b) -> Debugger a -> Debugger b #

(<$) :: a -> Debugger b -> Debugger a #

Monad Debugger Source # 
Instance details

Defined in GHC.Debugger.Monad

Methods

(>>=) :: Debugger a -> (a -> Debugger b) -> Debugger b #

(>>) :: Debugger a -> Debugger b -> Debugger b #

return :: a -> Debugger a #

MonadIO Debugger Source # 
Instance details

Defined in GHC.Debugger.Monad

Methods

liftIO :: IO a -> Debugger a #

MonadReader DebuggerState Debugger Source # 
Instance details

Defined in GHC.Debugger.Monad

data DebuggerState Source #

State required to run the debugger.

  • Keep track of active breakpoints to easily unset them all.

Constructors

DebuggerState 

Fields

  • activeBreakpoints :: IORef (BreakpointMap BreakpointInfo)

    Maps a InternalBreakpointId in Trie representation (map of Module to map of Int) to the BreakpointStatus it was activated with.

  • rtinstancesCache :: IORef RuntimeInstancesCache

    RuntimeInstancesCache

  • threadMap :: IORef ThreadMap

    ThreadMap for threads spawned by the debuggee

  • compCache :: IORef CompCache

    Cache loaded and compiled expressions.

  • hsDbgViewUnitId :: Maybe UnitId

    The unit-id of the companion haskell-debugger-view unit, used for user-defined and built-in custom debug visualisations of values (e.g. for Strings or IntMap).

    If the user depends on haskell-debugger-view in its transitive closure, then we should use that exact unit which was solved by Cabal. The built-in instances and additional instances be available for the DebugView class found in that unit. We can find the exact unit of the module by looking for haskell-debugger-view in the module graph.

    If the user does not depend on haskell-debugger-view in any way, then we create our own unit and try to load the haskell-debugger-view modules directly into it. As long as loading succeeds, the DebugView class from this custom unit can be used to find the built-in instances for types like String

    If the user explicitly disabled custom views, use Nothing.

  • dbgLogger :: LogAction Debugger DebuggerLog

    See Note [Debugger, debuggee, and DAP logs]

Instances

Instances details
MonadReader DebuggerState Debugger Source # 
Instance details

Defined in GHC.Debugger.Monad

data BreakpointStatus Source #

Enabling/Disabling a breakpoint

Constructors

BreakpointDisabled

Breakpoint is disabled

Note: this must be the first constructor s.t. BreakpointDisabled < {BreakpointEnabled, BreakpointAfterCount}

BreakpointEnabled

Breakpoint is enabled

BreakpointAfterCount Int

Breakpoint is disabled the first N times and enabled afterwards

BreakpointWhenCond String

Breakpoint is enabled when condition evaluates to true

BreakpointAfterCountCond Int String

Breakpoint is disabled the first N times the condition evaluates to true and enabled in the next time it is true

data BreakpointAction Source #

What to do when a breakpoint is enabled

Constructors

BreakpointStop

Evaluation is stopped, typical behaviour

BreakpointLogAndResume String

A log message is printed and then evaluation resumes. The String is an expression that takes care of interpolation and printing the log message.

data RunDebuggerSettings Source #

Additional settings configuring the debugger

runDebugger :: LogAction IO DebuggerLog -> DebugRunner Ghc a -> RunDebuggerSettings -> Debugger a -> IO a Source #

Run a Debugger action on a session constructed by a DebugRunner

INVARIANT: The initUniqSupply has already been initialized.

Users of hdb-as-a-library will have to call initUniqSupply at their leisure, special care needed if they supply any loaded units/modules to us via the DebugRunner, as those will contain Uniques.

See Note [UniqueSupply is process global].

type DebugSession (m :: Type -> Type) a Source #

Arguments

 = FilePath

project root dir

-> [String]

extra ghc args

-> m ()

action to load debugee home units

-> Ghc a 

type DebugRunner (m :: Type -> Type) a = DebugSession m a -> IO a Source #

data ProjectDebugSpec Source #

Constructors

ProjectDebugSpec 

Fields

withProjectDebugSession :: GhcMonad m => ProjectDebugSpec -> DebugRunner m a Source #

Construct a session from paths and flags inferred from the debugee's project.

runDebuggerAction Source #

Arguments

:: LogAction IO DebuggerLog 
-> FilePath

rootDir

-> [String]

extraGhcArgs

-> RunDebuggerSettings 
-> Ghc ()

load home units action

-> Debugger a 
-> Ghc a 

loadInternal :: LogAction IO DebuggerLog -> Ways -> Ghc () Source #

Throws exception when module fails to load.

loadFFIInspect :: LogAction IO DebuggerLog -> Ways -> Ghc () Source #

Throws exception when module fails to load. Needed for GHC.Debugger.Runtime.Interpreter.Legacy

cleanupInterp :: Ghc () Source #

See Note [Shutting down the external interpreter]

parseDynamicFlagsWithRootDir :: MonadIO m => FilePath -> Logger -> DynFlags -> [Located String] -> m (DynFlags, [Located String], Messages DriverMessage) Source #

Variant of GHC's parseDynamicFlags which interprets paths relative to first arg.

doDownsweep Source #

Arguments

:: GhcMonad m 
=> Maybe ModuleGraph

Re-use existing module graph which was already summarised

-> m ModuleGraph

Module graph constructed from current set targets

Run downsweep on the currently set targets (see hsc_targets)

Finding Debugger View

getHsDebuggerViewUid :: Debugger (Maybe UnitId) Source #

Fetch the haskell-debugger-view unit-id from the environment. Nothing means custom debugger views are disabled.

findHsDebuggerViewUnitId :: Ghc (Maybe UnitId) Source #

Try to find the haskell-debugger-view unit-id in the transitive closure, or, otherwise, return the a custom unit for which we'll load the haskell-debugger-view modules in it (essentially preparing an in-memory version of the library to find the built-in instances in).

See also comment on the hsDbgViewUnitId field of DebuggerState

liftGhc :: Ghc a -> Debugger a Source #

Lift a Ghc action into a Debugger one.

Modules

getAllLoadedModules :: GhcMonad m => m [ModuleNodeInfo] Source #

List all loaded modules ModSummarys

Forcing laziness

defaultDepth :: Int Source #

The depth determines how much of the runtime structure is traversed. obtainTerm and friends handle fetching arbitrarily nested data structures so we only depth enough to get to the next level of subterms.

seqTerm :: HscEnv -> Term -> IO Term Source #

Evaluate a suspended Term to WHNF.

Used in getVariables to reply to a variable introspection request.

deepseqTerm :: HscEnv -> Term -> IO Term Source #

Evaluate a Term to NF