Running ghc-debug on ghc

Matthew Pickering matthewtpickering at
Tue Mar 9 15:22:41 UTC 2021


I now have some simple instructions for running ghc-debug on GHC.

1. Cherry-pick 4be70967f1f1ab70cbe31aad8ae69aea87c6f4c4

commit 4be70967f1f1ab70cbe31aad8ae69aea87c6f4c4 (HEAD -> wip/ghc-with-debug)
Author: Matthew Pickering <matthewtpickering at>
Date:   Fri Jan 8 11:26:17 2021 +0000

    Add support for ghc-debug to ghc executable

2. Build GHC
* Add the following to _build/hadrian.settings

stage1.*.ghc.hs.opts += -finfo-table-map -fdistinct-constructor-tables

* Build GHC as normal

./hadrian/build -j8

* The result is a ghc-debug enabled compiler

# Building a debugger

* Use the compiler you just built to build ghc-debug

cd ghc-debug
cabal update
cabal new-build debugger -w ../_build/stage1/bin/ghc

# Running the debugger

Modify `test/Test.hs` to implement the debugging thing you want to do. Perhaps
start with `p30`, which is a program to generate a profile.

* Start the process you want to debug
GHC_DEBUG_SOCKET=/tmp/ghc-debug build-cabal

* Start the debugger
cabal new-run debugger -w ...

* Open a ticket about the memory issue you find.

There is the start of some more documentation here -

These instructions are also in the file in the commit.



More information about the ghc-devs mailing list