Describe how to use GHC.ExecutionStack
I was recently inspired to give DWARF-powered stack traces a try. But I don't know how to proceed.
The manual page is very helpful, describing how to use -g
to get debugging information put into binaries. Good. It even tells me about the extra step to take on macOS.
But the section on stack traces using GHC.ExecutionStack
tells me that we need to satisfy "libdw
library from the elfutils
package is available". I don't quite know what "is available" means here. But on the NixOS system I'm working on, I do see that there exists a libdw.a.
Looking further, I see this in the Haddocks for GHC.ExecutionStack
:
Your GHC must have been built with
libdw
support for this to work.user@host:~$ ghc --info | grep libdw ,("RTS expects libdw",YES)
Indeed, running ghc --info | grep libdw
tells be NO
, so I'm hosed.
Question 1: how can I make that into YES?
Question 2: The manual page suggests that there is hope for success on macOS. But elfutils
is not available for macOS. I did find dwarfutils
in Homebrew, which installs libdwarf.a
. Poking around online suggests that libdwarf.a
and libdw.a
basically accomplish the same goal, and may even be somewhat easily exchanged. Would it make sense to switch GHC to use libdwarf instead of libdw to gain more platform compatibility? (Maybe not: my brief searching suggests that libdw is generally the better option when it is available.) In any case, I'll settle for an answer to Question 1 for now, waiting to push on Question 2 until after I can experience the glory of DWARF stack traces for myself.
Thanks!