ghc-heap-view 0.1 → 0.2
raw patch · 4 files changed
+41/−8 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ GHC.HeapView: MVarClosure :: StgInfoTable -> Box -> Box -> Box -> Closure
+ GHC.HeapView: MutVarClosure :: StgInfoTable -> Box -> Closure
+ GHC.HeapView: instance Eq Box
+ GHC.HeapView: queueHead :: Closure -> Box
+ GHC.HeapView: queueTail :: Closure -> Box
+ GHC.HeapView: value :: Closure -> Box
+ GHC.HeapView: var :: Closure -> Box
Files
- Demo.hs +1/−1
- cbits/HeapView.c +9/−0
- ghc-heap-view.cabal +5/−5
- src/GHC/HeapView.hs +26/−2
Demo.hs view
@@ -45,7 +45,7 @@ let !(I# m') = length args + 23 let f = \x n -> take (I# m + I# x) n ++ args t = f m' l2- putStrLn $ "So here is (" ++ show (asBox f) ++ "), referncing its free variables args and 42:"+ putStrLn $ "So here is (" ++ show (asBox f) ++ "), referencing its free variables args and 42:" getClosureData f >>= printInd putStrLn "And t is a thunk that applies f (also referenced here) to an unboxed value (23) and l2:" getClosureData t >>= printInd
cbits/HeapView.c view
@@ -234,9 +234,18 @@ case MUT_ARR_PTRS_CLEAN: case MUT_ARR_PTRS_DIRTY: case MUT_ARR_PTRS_FROZEN:+ case MUT_ARR_PTRS_FROZEN0: for (i = 0; i < ((StgMutArrPtrs *)closure)->ptrs; ++i) { ptrs[nptrs++] = ((StgMutArrPtrs *)closure)->payload[i]; }+ break;+ case MUT_VAR_CLEAN:+ ptrs[nptrs++] = ((StgMutVar *)closure)->var;+ break;+ case MVAR_CLEAN:+ ptrs[nptrs++] = (StgClosure *)((StgMVar *)closure)->head;+ ptrs[nptrs++] = (StgClosure *)((StgMVar *)closure)->tail;+ ptrs[nptrs++] = ((StgMVar *)closure)->value; break; default:
ghc-heap-view.cabal view
@@ -1,5 +1,5 @@ Name: ghc-heap-view-Version: 0.1+Version: 0.2 Synopsis: Extract the heap representation of Haskell values and thunks Description: This library provides functions to introspect the Haskell heap, for example@@ -9,7 +9,7 @@ debugger, but also allows to investiage thunks and other closures. . The work on this package has been supported by the Deutsche Telekom Stiftung- <http://telekom-stiftung.de>.+ (<http://telekom-stiftung.de>). License: BSD3 License-file: LICENSE Author: Joachim Breitner@@ -17,7 +17,7 @@ Copyright: 2012 Joachim Breitner Category: Debug, GHC Build-type: Simple-Cabal-version: >=1.6+Cabal-version: >=1.14 Extra-source-files: Demo.hs Flag prim-supports-any@@ -26,6 +26,7 @@ Library Exposed-modules: GHC.HeapView + Default-Language: Haskell2010 Build-depends: base == 4.5.*, ghc@@ -38,5 +39,4 @@ source-repository head type: darcs- location: http://darcs.nomeata.de/darcswatch/-+ location: http://darcs.nomeata.de/ghc-heap-view/
src/GHC/HeapView.hs view
@@ -57,6 +57,11 @@ pad_out ls = '0':'x':(replicate (2*wORD_SIZE - length ls) '0') ++ ls +instance Eq Box where+ Box a == Box b = case reallyUnsafePtrEquality# a b of+ 1# -> True+ _ -> False+ {-| This takes an arbitrary value and puts it into a box. Note that calls like @@ -289,6 +294,16 @@ , mccPayload :: [Box] -- Card table ignored } |+ MutVarClosure {+ info :: StgInfoTable + , var :: Box+ } |+ MVarClosure {+ info :: StgInfoTable + , queueHead :: Box+ , queueTail :: Box+ , value :: Box+ } | FunClosure { info :: StgInfoTable , ptrArgs :: [Box]@@ -319,6 +334,8 @@ allPtrs (BCOClosure {..}) = [instrs,literals,bcoptrs] allPtrs (ArrWordsClosure {..}) = [] allPtrs (MutArrClosure {..}) = mccPayload+allPtrs (MutVarClosure {..}) = [var]+allPtrs (MVarClosure {..}) = [queueHead,queueTail,value] allPtrs (FunClosure {..}) = ptrArgs allPtrs (BlockingQueueClosure {..}) = [link, blackHole, owner, queue] allPtrs (OtherClosure {..}) = hvalues@@ -459,8 +476,15 @@ ARR_WORDS -> return $ ArrWordsClosure itbl (wds !! 1) (drop 2 wds)- MUT_ARR_PTRS_FROZEN ->- return $ MutArrClosure itbl (wds !! 2) (wds !! 3) ptrs++ t | t == MUT_ARR_PTRS_FROZEN || t == MUT_ARR_PTRS_FROZEN0 ->+ return $ MutArrClosure itbl (wds !! 1) (wds !! 2) ptrs++ t | t == MUT_VAR_CLEAN || t == MUT_VAR_DIRTY ->+ return $ MutVarClosure itbl (head ptrs)++ t | t == MVAR_CLEAN || t == MVAR_DIRTY ->+ return $ MVarClosure itbl (ptrs !! 0) (ptrs !! 1) (ptrs !! 2) BLOCKING_QUEUE -> return $ OtherClosure itbl ptrs wds