Support for -finfo-table-map in GHCi
Motivation
GHCi has good support for heap inspection. Profiling can collect statistics, GHCi's :print
and the VS-Code debugging plugin use GHC.Runtime.Heap.Inspect to inspect heap values, some tools like ghc-vis use ghc-heap-view, and ghc-debug does its own thing.
GHC 9.2 added a powerful tool to aid this kind of analysis - -finfo-table-map
lets us investigate thunks and function pointers! Unfortunately, it is not available in GHCi.
But imagine if it was! The GHCi debugger could visualize expressions, including thunks. Space leaks become obvious. We could replace step debugging with graph reduction, so users see expression trees and step into or over sub-nodes, reducing the friction of debugging laziness. Tools like ghc-vis could visualize CPS heavy code in a reasonably intuitive way.
Proposal
In short, making GHC.Stack.CCS.whereFrom work with interpreted bytecode in GHCi.
Notably loading object code in GHCi, if it was compiled with-finfo-table-map
, does work already.
I do not know enough about GHC to accurately estimate implementation or maintenance burden. From glancing at the code it seems that new entries could be written into the global ipeBufferList and that InfoTableProvMap is available when byteCodeGen is called, though, so I'm hoping the changes wouldn't be huge. If the feature seems worthwhile and nobody more qualified can find the time I could try to tackle this, but I have no idea whether this is anywhere near a reasonable first issue.