Trying to get some of the algorithm ideas going on the mjw/dwarf_output
branch. Although I started out trying to change te way the copier marked
entries final and put them into the collector I ended up not immediately
needing that. Because when the entries are marked final both their
children and reference attributes are resolved already.
So what the code does at the moment is add a local_hash function to both
dwarf_output::debug_info_die and copier::pending_entry. These hash
functions should be in sync because a not fully resolved attribute
reference could be pointing to a pending_entry. Both calculate the local
hash based on the local hash of the attributes_type and the
children_type. Then the hash of a value_reference is the local hash of
the debug_info_die hash it is pointing at.
For now the really tricky case inside the local hash function of the
attribute_types containing a reference attribute is side stepped by just
using the tag of the reference attribute. This is enough to get the
small testcases in dwarf_edit_output working that failed before. Because
this makes the hashes of similar structures always the same (before they
would have hash slightly differently based on where a attribute
reference cycle was detected).
So what is missing is "chaining" the reference attribute local hashes
(if we don't chain them, we end up with very "flat" hashes where lots
dies get the same hash just because they have a reference attribute).
Ideally this would just be ref_attr.reference()->local_hash (), but
since we calculate the hash of the attributes_type just before it is
inserted into the collector this doesn't work (the way this aborts is
somewhat obscure though - it ends up in in the dwarf_data::variant
constructor that throws a "can't happen!"). I am a little confused atm
about how the instantiation of the attributes_type gets triggered
precisely. It is probably necessary to do this in two phases by lifting
parts of pending_entry::final () method out in a second initialization
Please do poke holes in the code or the whole story.