This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

dwarf_data value


These are mostly just notes to myself. But hints to the ideas behind the
abstracts always appreciated (I might just not be up to c++ design
patterns, so please feel free to just tell me to lookup some
foo-creator-bar if things are just standard). Hoping to make the
dwarf_output copier less abstract I am trying to better understand the
ideas behind dwarf_data values which seem the base of every value (in
dwarf_edit and dwarf_output). Where attr_values template classes use
specific implementations as template<class impl, typename vw =
value<impl> >.

A elfutils::dwarf_data::value is defined as a
template<typename impl, bool alloc_values = true>

It has a const bool delete_value equal to alloc_values.

It defines a struct value_dispatch with just a virtual destructor and a
typedef value_dispatch value_cell_type;

It has two template variant functions:

      template<typename flavor>
      static inline flavor &
      variant (flavor *&, const value_dispatch *&)

      template<typename flavor>
      static inline flavor &
      variant (flavor *&result, value_dispatch *&value)

The first just throws because it "can't happen!" (because the . The
second will either create a new flavor and return a pointer to it when
the given value is NULL. Or it will dynamic_cast the value to flavor and
return a pointer to that. The result argument reference will be used in
both cases to store the return value.

A maker struct template and a make template function are provided that
returns a maker struct instantiated for the arg_type. The maker struct
just provides a templated function make that will create a new flavor
from input x and arg_type arg to be assigned to a value dispatch pointer
and flavor result pointer.

All the above seems plumbing for casting stuff around, although I am not
really sure why and what it is to achieve. The values seem designed to
be used as is for dwarf_edit (default alloc_values = true). dwarf_output
overrides maker and make.

The rest of the structs defined by dwarf_data::value are much simpler
representations of various dwarf entities. All extend value_dispatch.

value_dispatch
  value_string (also extends std::string)
    value_identifier
  value_reference
  value_flag
  value_address
  value_rangelistptr (also extends range_list == dwarf::arange_list)
  value_lineptr (also extends impl::line_info_table)
  value_constant
  value_constant_block (also extends std::vector<uint8_t>)
  value_dwarf_constant (also extends dwarf_enum)
  value_source_file (also extends source_file)
  value_source_line
  value_source_column
    (currently empty)
  value_macptr
    (currently empty)
  value_location (also extends location_attr)

All constructors are templated on arg_type, but I don't understand
how/why this is used.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]