I’m trying to get stack traces from a live running GHC (version 9.2.2) compiled Haskell program.
I understand I need to send SIGQUIT to the process to get the stacktraces of the currently running threads.
But everytime I do this I just get the message: “This build does not support backtraces.”
This is what I have done:
- Our build is using nix, so I’ve added the following to the overrides for the GHC build:
ghc =
old.ghc.overrideAttrs (oldAttrs: {
configureFlags = oldAttrs.configureFlags ++ ["--enable-dwarf-unwind"];
buildInputs = oldAttrs.buildInputs ++ [pkgs.elfutils];
});
- I’ve added the following flags to all the builds of our packages:
-ticky
-g
-fprof-auto
-fprof-auto-calls
- I added the flag
--enable-debug-infoto the cabal build command.
I don’t know what else to do. The docs say:
On POSIX-compatible platforms GHC’s runtime system (when built with
libdwsupport) will produce a stack trace onstderrwhen aSIGQUITsignal is received
It doesn’t say here how to build with libdw support, but I read somewhere elsewhere that one needed to add --enable-dwarf-unwind, and indeed when I did that the GHC build initially complained about not being about to find the libdw library until I added elfutils to the buildInputs.
The error message also doesn’t make it clear whether the build of GHC doesn’t support backtraces or the build of my executable doesn’t support backtraces. Which makes hunting this down even more difficult.
What am I missing? Is there anyway to ask GHC whether it’s compiled with libdw support so I can at least work out whether the problem is with the GHC build or the build of my executable?