I've been poking at it again a bit lately, and, oddly enough, I think the roland/unwind branch might be more or less ready to merge on the trunk (perhaps as soon as 0.142). I'd appreciate some review of the branch code.
The branch is really a misnomer, of course. It's not the "unwinder" branch, it's the CFI support branch. Like everything else in libdw, it is meant to be the right granular interface at the right level of abstraction for what the data is really about. So it does not do any "unwinding" at all. What this piece exposes is the "PC => {register #, location} map" mapping. That is, the static semantics view of CFI, using DWARF location expressions (or value expressions) in Dwarf_Op[] form.
The "show me a backtrace in the core file/process" level of "unwinding" that everyone thinks about is in fact a composition of CFI interpretation, location expression evaluation, and register/memory gathering. What we have here is the first of those.
This is the only piece we need for static DWARF tools like dwarfcmp and writer/compression support. I think the new libdw interfaces here are decent enough in C for simple support, and a sufficient foundation for the C++ interfaces to read and write this data.
This is work I originally did a couple of years ago; I have updated it along the way, and cleaned up a bit more lately around the edges. But I haven't done a thorough review of all the code from scratch myself lately. So anything XXX-commented or unfinished-looking or otherwise questionable merits some fresh hashing out.
Thanks, Roland
$ git diff --stat origin/master..roland/unwind backends/ChangeLog | 10 + backends/Makefile.am | 4 +- backends/i386_cfi.c | 65 +++++ backends/i386_init.c | 1 + backends/x86_64_cfi.c | 60 +++++ backends/x86_64_init.c | 1 + libdw/ChangeLog | 54 +++++ libdw/Makefile.am | 10 +- libdw/cfi.c | 498 +++++++++++++++++++++++++++++++++++++++ libdw/cfi.h | 249 +++++++++++++++++++ libdw/cie.c | 193 +++++++++++++++ libdw/dwarf_begin_elf.c | 3 +- libdw/dwarf_cfi_addrframe.c | 78 ++++++ libdw/dwarf_cfi_end.c | 70 ++++++ libdw/dwarf_end.c | 8 +- libdw/dwarf_error.c | 1 + libdw/dwarf_frame_cfa.c | 100 ++++++++ libdw/dwarf_frame_info.c | 74 ++++++ libdw/dwarf_frame_register.c | 143 +++++++++++ libdw/dwarf_getcfi.c | 92 +++++++ libdw/dwarf_getcfi_elf.c | 331 ++++++++++++++++++++++++++ libdw/dwarf_getlocation.c | 75 +++++-- libdw/dwarf_next_cfi.c | 234 ++++++++++++++++++ libdw/encoded-value.h | 174 ++++++++++++++ libdw/fde.c | 297 +++++++++++++++++++++++ libdw/frame-cache.c | 87 +++++++ libdw/libdw.h | 158 ++++++++++++- libdw/libdw.map | 16 ++ libdw/libdwP.h | 15 +- libdw/memory-access.h | 37 ++- libdwfl/ChangeLog | 11 +- libdwfl/Makefile.am | 2 + libdwfl/dwfl_addrframe.c | 93 ++++++++ libdwfl/dwfl_module_dwarf_cfi.c | 89 +++++++ libdwfl/dwfl_module_eh_cfi.c | 75 ++++++ libdwfl/libdwfl.h | 23 ++ libdwfl/libdwflP.h | 10 + libebl/ChangeLog | 9 + libebl/Makefile.am | 2 +- libebl/ebl-hooks.h | 2 + libebl/eblabicfi.c | 63 +++++ libebl/eblopenbackend.c | 9 + libebl/libebl.h | 34 +++- libebl/libeblP.h | 6 + tests/ChangeLog | 6 + tests/Makefile.am | 3 +- tests/addrcfi.c | 191 +++++++++++++++ 47 files changed, 3720 insertions(+), 46 deletions(-)
elfutils-devel@lists.fedorahosted.org