Copyright | (c) The University of Glasgow 2011 |
---|---|
License | see libraries/base/LICENSE |
Maintainer | cvs-ghc@haskell.org |
Stability | internal |
Portability | non-portable (GHC Extensions) |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Access to GHC's call-stack simulation
Since: base-4.5.0.0
Synopsis
- currentCallStack :: IO [String]
- whoCreated :: a -> IO [String]
- whereFrom :: a -> IO (Maybe InfoProv)
- data CostCentreStack
- data CostCentre
- getCurrentCCS :: dummy -> IO (Ptr CostCentreStack)
- getCCSOf :: a -> IO (Ptr CostCentreStack)
- clearCCS :: IO a -> IO a
- ccsCC :: Ptr CostCentreStack -> IO (Ptr CostCentre)
- ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack)
- ccLabel :: Ptr CostCentre -> IO CString
- ccModule :: Ptr CostCentre -> IO CString
- ccSrcSpan :: Ptr CostCentre -> IO CString
- ccsToStrings :: Ptr CostCentreStack -> IO [String]
- renderStack :: [String] -> String
- ipeProv :: Ptr InfoProvEnt -> Ptr InfoProv
- peekInfoProv :: Ptr InfoProv -> IO InfoProv
- data InfoProv = InfoProv {}
- data InfoProvEnt
Call stacks
currentCallStack :: IO [String] Source #
Returns a [String]
representing the current call stack. This
can be useful for debugging.
The implementation uses the call-stack simulation maintained by the
profiler, so it only works if the program was compiled with -prof
and contains suitable SCC annotations (e.g. by using -fprof-auto
).
Otherwise, the list returned is likely to be empty or
uninformative.
Since: base-4.5.0.0
whoCreated :: a -> IO [String] Source #
Get the stack trace attached to an object.
Since: base-4.5.0.0
whereFrom :: a -> IO (Maybe InfoProv) Source #
Get information about where a value originated from. This information is stored statically in a binary when `-finfo-table-map` is enabled. The source positions will be greatly improved by also enabled debug information with `-g3`. Finally you can enable `-fdistinct-constructor-tables` to get more precise information about data constructor allocations.
The information is collect by looking at the info table address of a specific closure and then consulting a specially generated map (by `-finfo-table-map`) to find out where we think the best source position to describe that info table arose from.
Internals
data CostCentreStack Source #
A cost-centre stack from GHC's cost-center profiler.
data CostCentre Source #
A cost-centre from GHC's cost-center profiler.
getCurrentCCS :: dummy -> IO (Ptr CostCentreStack) Source #
Returns the current CostCentreStack
(value is nullPtr
if the current
program was not compiled with profiling support). Takes a dummy argument
which can be used to avoid the call to getCurrentCCS
being floated out by
the simplifier, which would result in an uninformative stack (CAF).
getCCSOf :: a -> IO (Ptr CostCentreStack) Source #
Get the CostCentreStack
associated with the given value.
clearCCS :: IO a -> IO a Source #
Run a computation with an empty cost-center stack. For example, this is used by the interpreter to run an interpreted computation without the call stack showing that it was invoked from GHC.
ccsCC :: Ptr CostCentreStack -> IO (Ptr CostCentre) Source #
Get the CostCentre
at the head of a CostCentreStack
.
ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack) Source #
Get the tail of a CostCentreStack
.
ccLabel :: Ptr CostCentre -> IO CString Source #
Get the label of a CostCentre
.
ccModule :: Ptr CostCentre -> IO CString Source #
Get the module of a CostCentre
.
ccSrcSpan :: Ptr CostCentre -> IO CString Source #
Get the source span of a CostCentre
.
ccsToStrings :: Ptr CostCentreStack -> IO [String] Source #
Format a CostCentreStack
as a list of lines.
renderStack :: [String] -> String Source #
data InfoProvEnt Source #