GHC already support DWARF, and there are articles telling that we can use DWARF to get a stace trace when error occurs, but no one telling how, and just add -g
when compiling doesn't make the generated program print out stack trace directly.
I also read the article about DWARF from the ghc wiki and from the ghc users guide, but both of them is telling about how to get stack trace by adding a breakpoint on gdb
or by SIGINT, but tells nothing about how to get stack trace when error occurs.
So what is the exact step to get the stack trace use DWARF when error occurs?
Are we expected to use the GHC.ExecutionStack
API to get the stack trace by manually adding code which calls showStackTrace
wrapped by unsafePerformIO
?