On Mon, Mar 19, 2012 at 11:54:12AM -0600, Tom Tromey wrote:
Subject: [PATCH] Fix bug using dwarf_next_unit to iterate over
* libdw_findcu.c (findcu_cb): Move earlier.
(__libdw_intern_next_unit): Add new CU to search tree here...
(__libdw_findcu): ... not here.
If you call dwarf_next_unit to iterate over .debug_types, then call
dwarf_offdie_types, you can see a failure if some earlier call
happened to call __libdw_intern_next_unit via dwarf_formref_die.
What happens is that __libdw_intern_next_unit updates the Dwarf's
next_tu_offset, but does not add the TU to the TU search tree. So,
the call to dwarf_offdie_types does not find the TU in the tree, and
will not search any more, causing a failure.
This fix changes __libdw_intern_next_unit to add the TU to the search
tree, rather than relying on __libdw_findcu to do it.
This looks correct to me. And I saw your systemtap patch that adds a
testcase for it. But I would like Roland to take a look too, because
he wrote the original dwarf_next_unit () support.
P.S. Your message was base64 encoded and had some extra lines (saying
just "Tom") in from of the actual patch, which made git am apply your
commit funny. So if you could resend it (with the copyright year update
for libdw/libdw_findcu.c) that would be great.