]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Fiddle dwarf_edit interfaces, let refs work a little.
authorRoland McGrath <roland@redhat.com>
Thu, 2 Jul 2009 10:45:58 +0000 (03:45 -0700)
committerRoland McGrath <roland@redhat.com>
Thu, 2 Jul 2009 10:45:58 +0000 (03:45 -0700)
libdw/c++/dwarf_data
libdw/c++/dwarf_edit
libdw/c++/dwarf_output

index d2355bb7b36b228ef7e87e8dcf11506d2943a2e4..dff1bd3ec26528e842d953d39dd97498bc8a4a32 100644 (file)
@@ -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<typename arg_type>
-       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<typename iter, typename arg_type>      // XXX dummy
-       inline value_reference (const iter &i, const arg_type &arg)
-         : ref () {}
+       template<typename iter, typename tracker>
+       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<flavor *> (_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<typename vw::value_flag> ().flag;
       }
 
+      inline bool &flag ()
+      {
+       return variant<typename vw::value_flag> ().flag;
+      }
+
       // XXX dwfl, reloc
       inline ::Dwarf_Addr &address () const
       {
        return variant<typename vw::value_address> ().addr;
       }
 
-      inline typename impl::debug_info_entry::children_type::iterator
-      reference () const
+      // XXX dwfl, reloc
+      inline ::Dwarf_Addr &address ()
+      {
+       return variant<typename vw::value_address> ().addr;
+      }
+
+      inline typename impl::debug_info_entry::pointer &reference () const
+      {
+       return variant<typename vw::value_reference> ().ref;
+      }
+
+      inline typename impl::debug_info_entry::pointer &reference ()
       {
        return variant<typename vw::value_reference> ().ref;
       }
@@ -1009,25 +1033,34 @@ namespace elfutils
          (variant<typename vw::value_location> ());
       }
 
-      inline std::string &string ()
+      inline location_attr &location ()
       {
-       return static_cast<std::string &>
-         (variant<typename vw::value_string> ());
+       return static_cast<location_attr &>
+         (variant<typename vw::value_location> ());
       }
+
       inline const std::string &string () const
       {
        return static_cast<const std::string &>
          (variant<typename vw::value_string> ());
       }
-      inline std::string &identifier ()
+
+      inline std::string &string ()
       {
-       return string ();
+       return static_cast<std::string &>
+         (variant<typename vw::value_string> ());
       }
+
       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<typename impl::source_file &>
index 8e12c5da76a96ec300109f3e93f6b3dd26b1c481..3139aa604b550776eea904c0c64a630973a3be72 100644 (file)
@@ -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<dwarf_edit>
       {
@@ -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);
       }
index ff2621ba5ef6db7bc428f1a12c417b48aac48a8f..e13a15f2ae0ca293790b1e1dc58dd21b129d1864 100644 (file)
@@ -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<dwarf_output,
                                             dwarf_output_collector *,