]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Move dwarf_edit::compile_unit into dwarf_data.
authorRoland McGrath <roland@redhat.com>
Sat, 4 Jul 2009 09:25:23 +0000 (02:25 -0700)
committerRoland McGrath <roland@redhat.com>
Sat, 4 Jul 2009 09:25:23 +0000 (02:25 -0700)
libdw/c++/dwarf
libdw/c++/dwarf_data
libdw/c++/dwarf_edit

index d31d0107f1f68103f6384d0f0288ce9bcfe0c7f1..103dc08dfd372a0e585f26b4b078d953a459a34f 100644 (file)
@@ -1007,11 +1007,11 @@ namespace elfutils
       {
        return line_info ().include_directories ();
       }
-      const file_table files () const
+      inline const file_table files () const
       {
        return line_info ().files ();
       }
-      const line_table lines () const
+      inline const line_table lines () const
       {
        return line_info ().lines ();
       }
index 76a44e014c1816a74c990185310f769bdd096b4a..5b2945e9501d26a05bd97a8ae6fe9f2653789dbb 100644 (file)
@@ -68,6 +68,64 @@ namespace elfutils
   {
   public:
 
+    template<class impl>
+    class compile_unit : public impl::debug_info_entry
+    {
+      friend class subr::create_container;
+      friend class impl::compile_units;
+    private:
+      inline compile_unit () :
+       impl::debug_info_entry (::DW_TAG_compile_unit)
+      {}
+
+      template<typename die_type>
+      static inline const die_type &require_cu (const die_type &die)
+      {
+       if (die.tag () != ::DW_TAG_compile_unit)
+         throw std::invalid_argument ("not a compile_unit entry");
+       return die;
+      }
+
+      template<typename die_type, typename tracker>
+      inline compile_unit (const die_type &die, tracker &t)
+       : impl::debug_info_entry (require_cu (die), t)
+      {}
+
+    public:
+
+      // Fetch the CU's DW_AT_stmt_list.
+      inline const typename impl::line_info_table &line_info () const
+      {
+       return this->attributes ()[::DW_AT_stmt_list].line_info ();
+      }
+
+      inline typename impl::line_info_table &line_info ()
+      {
+       return this->attributes ()[::DW_AT_stmt_list].line_info ();
+      }
+
+      // Convenience methods for line_info_table sub-containers.
+      inline const typename impl::directory_table &include_directories () const
+      {
+       return line_info ().include_directories ();
+      }
+
+      inline typename impl::directory_table &include_directories ()
+      {
+       return line_info ().include_directories ();
+      }
+
+      inline const typename impl::line_table &lines () const
+      {
+       return line_info ().lines ();
+      }
+
+      inline typename impl::line_table &lines ()
+      {
+       return line_info ().lines ();
+      }
+    };
+
     class source_file
     {
     private:
index 40873e4b29da14a65f048eeee45994f6ac812cda..ef4ebec7c762f81dbf094587888cf968423509cb 100644 (file)
@@ -268,28 +268,7 @@ namespace elfutils
 
     typedef debug_info_entry::attributes_type::value_type attribute;
 
-    class compile_unit : public debug_info_entry
-    {
-      friend class subr::create_container;
-      friend class compile_units;
-    private:
-      inline compile_unit () : debug_info_entry (::DW_TAG_compile_unit) {}
-
-      // XXX should be private
-    public:
-      template<typename die_type, typename tracker>
-      inline compile_unit (const die_type &die, tracker &t)
-       : debug_info_entry (die, t)
-      {
-       if (die.tag () != ::DW_TAG_compile_unit)
-         throw std::invalid_argument ("not a compile_unit entry");
-      }
-
-      /* XXX doesn't help
-       public:
-       compile_unit (const compile_unit &u) : debug_info_entry (u) {}
-      */
-    };
+    typedef dwarf_data::compile_unit<dwarf_edit> compile_unit;
 
     // Main container anchoring all the output.
     class compile_units : public std::list<compile_unit>