I am adding full DWARF unwinding-based backtrace support to the Glasgow
Haskell Compiler's (GHC) runtime system. GHC now emits DWARF information
in the object files it produces [1] and we would like to be able to
record full backtraces on both runtime system events and the user's
request.
The goal here is to expose a function to the runtime system and user
programs allowing them to get a snapshot of the calling thread's current
call-stack. It seems that elfutils' current dwfl interfaces only allow
for extraction of frames from Core dumps (with dwfl_core_file_attach)
and ptrace'd processes (with dwfl_linux_proc_attach).
In principle, however, I can't see any reason why frames couldn't be
extracted from the current thread. Besides taking care to preserve the
registers at the out-set, it doesn't even seem that this should be
terribly difficult. Am I missing something? Does the interface for this
exist and I have simply overlooked it? Does it not yet exist but is
merely waiting for someone to implement it?
Thanks,
- Ben