Improvements to the ghc-debug terminal interface

submited by
Style Pass
2024-04-25 09:00:07

ghc-debug is a debugging tool for performing precise heap analysis of Haskell programs (check out our previous post introducing it). While working on Eras Profiling, we took the opportunity to make some much needed improvements and quality of life fixes to both the ghc-debug library and the ghc-debug-brick terminal user interface.

This post explores the changes and the new possibilities for inspecting the heap of Haskell processes that they enable. These changes are available by using the 0.6.0.0 version of ghc-debug-stub and ghc-debug-brick.

There are typically two processes involved when using ghc-debug on a live program. The first is the debuggee process, which is the process whose heap you want to inspect. The debuggee process is linked against the ghc-debug-stub package. The ghc-debug-stub package provides a wrapper function

that you wrap around your main function to enable the use of ghc-debug. This wrapper opens a unix socket and answers queries about the debuggee process’ heap, including transmitting various metadata about the debuggee, like the ghc version it was compiled with, and the actual bits that make up various objects on the heap.

Leave a Comment