From: Roland McGrath Date: Thu, 2 Jul 2009 10:45:58 +0000 (-0700) Subject: Fiddle dwarf_edit interfaces, let refs work a little. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=18610f8148170420dfe8e88efee4a6207723dcf3;p=thirdparty%2Felfutils.git Fiddle dwarf_edit interfaces, let refs work a little. --- diff --git a/libdw/c++/dwarf_data b/libdw/c++/dwarf_data index d2355bb7b..dff1bd3ec 100644 --- a/libdw/c++/dwarf_data +++ b/libdw/c++/dwarf_data @@ -716,18 +716,26 @@ namespace elfutils struct value_reference : public value_dispatch { - typename impl::debug_info_entry::children_type::iterator ref; + typedef typename impl::debug_info_entry::pointer value_type; + value_type ref; - template - inline value_reference - (const typename impl::debug_info_entry::children_type::iterator &i, - const arg_type &arg) + // Default constructor: reference to nowhere, invalid. + inline value_reference () + : ref () + {} + + /* This is only kosher for a pointer into the same dwarf_edit + object. This is what plain assignment does. This just uses + this pointer, rather than translating it from another file + into this one (which requires a tracker). */ + inline value_reference (const value_type &i, const nothing &) : ref (i) {} - template // XXX dummy - inline value_reference (const iter &i, const arg_type &arg) - : ref () {} + template + inline value_reference (const iter &i, tracker *t) + : ref () + {} }; struct value_flag : public value_dispatch @@ -918,7 +926,8 @@ namespace elfutils { flavor *p = dynamic_cast (_m_value); if (p == NULL) - throw std::runtime_error ("wrong value type"); + throw std::runtime_error (_m_value != NULL ? "wrong value type" + : "uninitialized attr_value (const?)"); return *p; } @@ -991,14 +1000,29 @@ namespace elfutils return variant ().flag; } + inline bool &flag () + { + return variant ().flag; + } + // XXX dwfl, reloc inline ::Dwarf_Addr &address () const { return variant ().addr; } - inline typename impl::debug_info_entry::children_type::iterator - reference () const + // XXX dwfl, reloc + inline ::Dwarf_Addr &address () + { + return variant ().addr; + } + + inline typename impl::debug_info_entry::pointer &reference () const + { + return variant ().ref; + } + + inline typename impl::debug_info_entry::pointer &reference () { return variant ().ref; } @@ -1009,25 +1033,34 @@ namespace elfutils (variant ()); } - inline std::string &string () + inline location_attr &location () { - return static_cast - (variant ()); + return static_cast + (variant ()); } + inline const std::string &string () const { return static_cast (variant ()); } - inline std::string &identifier () + + inline std::string &string () { - return string (); + return static_cast + (variant ()); } + inline const std::string &identifier () const { return string (); } + inline std::string &identifier () + { + return string (); + } + inline const typename impl::source_file &source_file () const { return static_cast diff --git a/libdw/c++/dwarf_edit b/libdw/c++/dwarf_edit index 8e12c5da7..3139aa604 100644 --- a/libdw/c++/dwarf_edit +++ b/libdw/c++/dwarf_edit @@ -120,13 +120,20 @@ namespace elfutils public: typedef debug_info_entry value_type; - inline debug_info_entry &add_entry (int tag) + inline iterator add_entry (int tag, const iterator &pos) { - push_back (debug_info_entry (tag)); - return back (); + return insert (pos, debug_info_entry (tag)); + } + + inline iterator add_entry (int tag) + { + return add_entry (tag, end ()); } }; + typedef children_type::iterator pointer; + typedef children_type::const_iterator const_pointer; + class attributes_type : public dwarf_data::attributes_type { @@ -214,8 +221,8 @@ namespace elfutils return identity (); } - // Convenience entry points. - inline debug_info_entry &add_entry (int child_tag) + // Convenience entry point. + inline pointer add_entry (int child_tag) { return children ().add_entry (child_tag); } diff --git a/libdw/c++/dwarf_output b/libdw/c++/dwarf_output index ff2621ba5..e13a15f2a 100644 --- a/libdw/c++/dwarf_output +++ b/libdw/c++/dwarf_output @@ -379,6 +379,9 @@ namespace elfutils typedef debug_info_entry value_type; }; + typedef children_type::const_iterator const_pointer; + typedef children_type::const_iterator pointer; + class attributes_type : public dwarf_data::attributes_type