@hackage / ghc-heap-view

Extract the heap representation of Haskell values and thunks

Latest0.6.4.1

About

Metadata

  • Last updated , by JoachimBreitner
  • License BSD-3-Clause
  • Categories Debugging
  • Maintained by: Joachim Breitner <mail@joachim-breitner.de>

  • Lottery factor: 0

Links

Installation

This package uses the Custom cabal build type

Tested Compilers

  1. 9.8.1
  2. 9.6.3
  3. 9.4.8
  4. 9.2.8
  5. 9.2.1
  6. 9.0.1
  7. 8.10.1
  8. 8.8.1
  9. 8.6.5
  10. 8.6.4
  11. 8.6.3
  12. 8.6.2
  13. 8.6.1

Package Flags

Use the -f option with cabal commands to enable flags

    prim-supports-any (off by default)

    The used GHC supports Any as an argument to foreign prim functions (GHC ticket #5931)

Readme

This library provides functions to introspect the Haskell heap, for example to investigate sharing and lazy evaluation. As this is tied to the internals of the compiler, it only works with specific versions. This version supports, GHC 8.8. For GHC 8.6 use version 0.6.0. For older GHC versions see ghc-heap-view-0.5.10.

It has been inspired by (and taken code from) the vacuum package and the GHCi debugger, but also allows to investigate thunks and other closures.

This package also provides a new GHCi-command, :printHeap, which allows you to inspect the current heap representation of a value, including sharing and cyclic references. To enable the command, you need to load the included ghci script or add it to ~/.ghci, as explained by cabal install. Once it is set up, you can do this:

> let value = "A Value"
> let x = (value, if head value == 'A' then value else "", cycle [True, False])
> :printHeap x
let x1 = _bco
    x21 = []
in (x1,_bco,_bco)
> length (take 100 (show x)) `seq` return () -- evaluate everything
> :printHeap x
let x1 = "A Value"
    x16 = True : False : x16
in (x1,x1,x16)

You can change the maximum recursion depth using :setPrintHeapDepth:

> :setPrintHeapDepth 3
> :printHeap x
let x1 = C# 'A' : ... : ...
in (x1,x1,True : ... : ...)

If the view is impaired by blackholes (written _bh), running System.Mem.performGC usually helps.

The work on this package has been supported by the Deutsche Telekom Stiftung (http://telekom-stiftung.de).