On Wed, 2011-01-26 at 22:14 +0100, Mark Wielaard wrote:
> 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.

Just to clear this up for my self. The way this works is through the
following call in copier<input>::pending_entry::final ():

const debug_info_entry::attributes_type *attrs
  = &co->add_attributes (_m_tag, _m_attributes, equalator)->first;

Where _m_attributes is defined as:

typedef dwarf_data::attributes_type<dwarf_output, value> attr_map;
attr_map _m_attributes;

while add_attributes () in elfutils::dwarf_output_collector is defined
as:

template<typename match_type>
const attrs_pair *
add_attributes (int tag, const attrs_type &candidate, match_type &matcher)
{
  return _m_attr_sets.add (std::make_pair (candidate, tag), matcher);
}

Where attrs_type is defined as:

typedef dwarf_output::debug_info_entry die_type;
typedef die_type::attributes_type attrs_type;

So what happens is that before the actual call to add_attributes (), the
dwarf_data::debug_info_entry::attributes_type is converted to a
dwarf_output::debug_info_entry::attributes_type through some magic c++
type conversion, which somehow knows it has to call the right conversion
operator:

      template<typename attrs>
      inline operator attrs () const
      {
        return attrs (base_type::begin (), base_type::end ());
      }

Which will end up in the dwarf_output::debug_info_entry::attributes_type
constructor with the input attr_values.

Cheers,

Mark

_______________________________________________
elfutils-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/elfutils-devel

Reply via email to