]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
C++ warning fiddles. Let dwarf-print/dwarf_edit test copy constructors.
authorRoland McGrath <roland@redhat.com>
Fri, 3 Jul 2009 20:31:24 +0000 (13:31 -0700)
committerRoland McGrath <roland@redhat.com>
Fri, 3 Jul 2009 20:31:24 +0000 (13:31 -0700)
14 files changed:
libdw/ChangeLog
libdw/Makefile.am
libdw/c++/dwarf
libdw/c++/dwarf_comparator
libdw/c++/dwarf_data
libdw/c++/dwarf_edit
libdw/c++/dwarf_tracker
libdw/c++/exception.cc
src/ChangeLog
src/Makefile.am
src/dwarfcmp.cc
tests/ChangeLog
tests/Makefile.am
tests/print-die.hh

index ce933bc4a649a912230f39429eb284678753f838..a8e54a22cba3df663af1abdaa7b0317e9940f66a 100644 (file)
@@ -1,5 +1,7 @@
 2009-07-03  Roland McGrath  <roland@redhat.com>
 
+       * Makefile.am (AM_CXXFLAGS): New variable (from ../src/Makefile.am).
+
        * c++/dwarf: Fix range_list canonicalizing comparisons.
 
        * c++/dwarf_edit: Fix copy construction using a ref-maker.
index 7fb3171c8db378924f694d52edba5898a88bdc61..0d3e636bb275519833fce4bb0e262fbdf8fba476 100644 (file)
@@ -37,6 +37,8 @@ AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 -Wextra -std=gnu99
 INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I.. -I$(srcdir)/../lib
 VERSION = 1
 
+AM_CXXFLAGS = $(AM_CFLAGS:gnu99=gnu++0x)
+
 COMPILE.os = $(filter-out -fprofile-arcs, $(filter-out -ftest-coverage, \
                                                       $(COMPILE)))
 
index 4ed0c796c1769c4d6d594db4b9bd798479248b95..7f7757dca90a1fbe61ad6012a49e2d8f30d97aef 100644 (file)
@@ -1265,7 +1265,7 @@ namespace elfutils
       template<typename pair>
       struct any : public std::unary_function<pair, bool>
       {
-       inline bool operator () (const pair &x)
+       inline bool operator () (const pair &)
        {
          return true;
        }
index 62556596baba657d7c2530d6c9d9bc3b603d7289..7465dab52ab20cb3e5120343fe97b8b7d221d835 100644 (file)
@@ -72,7 +72,7 @@ namespace elfutils
     // This object is created to start a walk and destroyed to finish one.
     struct walk
     {
-      inline walk (dwarf_tracker_base *, const cu1 &a, const cu2 &b)
+      inline walk (dwarf_tracker_base *, const cu1 &, const cu2 &)
       {
       }
       inline ~walk ()
@@ -83,7 +83,7 @@ namespace elfutils
     // This object is created in pre-order and destroyed in post-order.
     struct step
     {
-      inline step (dwarf_tracker_base *, const die1 &a, const die2 &b)
+      inline step (dwarf_tracker_base *, const die1 &, const die2 &)
       {
       }
       inline ~step ()
@@ -91,23 +91,23 @@ namespace elfutils
       }
     };
 
-    inline void visit (const typename dwarf1::debug_info_entry &a,
-                      const typename dwarf2::debug_info_entry &b)
+    inline void visit (const typename dwarf1::debug_info_entry &,
+                      const typename dwarf2::debug_info_entry &)
     {
     }
 
-    inline void mismatch (const cu1 &it1, const cu1 &end1,
-                         const cu2 &it2, const cu2 &end2)
+    inline void mismatch (const cu1 &, const cu1 &, // at, end
+                         const cu2 &, const cu2 &)
     {
     }
 
-    inline void mismatch (const die1 &it1, const die1 &end1,
-                         const die2 &it2, const die2 &end2)
+    inline void mismatch (const die1 &, const die1 &, // at, end
+                         const die2 &, const die2 &)
     {
     }
 
-    inline void mismatch (const attr1 &it1, const attr1 &end1,
-                         const attr2 &it2, const attr2 &end2)
+    inline void mismatch (const attr1 &, const attr1 &, // at, end
+                         const attr2 &, const attr2 &)
     {
     }
 
@@ -115,26 +115,26 @@ namespace elfutils
     struct right_context_type {};
 
     // Return the lhs context of an arbitrary DIE.
-    inline const left_context_type left_context (const die1 &die)
+    inline const left_context_type left_context (const die1 &)
     {
       return left_context_type ();
     }
 
     // Return the rhs context of an arbitrary DIE.
-    inline const right_context_type right_context (const die2 &die)
+    inline const right_context_type right_context (const die2 &)
     {
       return right_context_type ();
     }
 
-    inline bool context_quick_mismatch (const left_context_type &a,
-                                       const right_context_type &b)
+    inline bool context_quick_mismatch (const left_context_type &,
+                                       const right_context_type &)
 
     {
       return true;
     }
 
-    inline bool context_match (const left_context_type &a,
-                              const right_context_type &b)
+    inline bool context_match (const left_context_type &,
+                              const right_context_type &)
     {
       return false;
     }
index 5598e945e58a31c53efa82be5dc8328bdf4b28f8..28eeef0be3c94a47bf61133968321ae7732f82f4 100644 (file)
@@ -51,8 +51,8 @@
 #define _ELFUTILS_DWARF_DATA   1
 
 #include "dwarf"
+#include <cassert>
 #include <bitset>
-#include <typeinfo>
 
 /* This contains common classes/templates used by dwarf_output and dwarf_edit.
 
@@ -685,7 +685,7 @@ namespace elfutils
        inline value_string () {}
 
        template<typename string, typename arg_type>
-       inline value_string (const string &s, arg_type &arg)
+       inline value_string (const string &s, arg_type &)
          : std::string (s)
        {}
 
@@ -741,7 +741,7 @@ namespace elfutils
        {}
 
        template<typename arg_type>
-       inline value_flag (bool t, arg_type &arg)
+       inline value_flag (bool t, arg_type &)
          : flag (t)
        {}
       };
@@ -756,7 +756,7 @@ namespace elfutils
        {}
 
        template<typename arg_type>
-       inline value_address (::Dwarf_Addr x, arg_type &arg)
+       inline value_address (::Dwarf_Addr x, arg_type &)
          : addr (x)
        {}
       };
@@ -766,7 +766,7 @@ namespace elfutils
        inline value_rangelistptr () {}
 
        template<typename list, typename arg_type>
-       inline value_rangelistptr (const list &other, arg_type &arg)
+       inline value_rangelistptr (const list &other, arg_type &)
          : range_list (other)
        {}
       };
@@ -776,7 +776,7 @@ namespace elfutils
        inline value_lineptr () {}
 
        template<typename table, typename arg_type>
-       inline value_lineptr (const table &other, arg_type &arg)
+       inline value_lineptr (const table &other, arg_type &)
          : impl::line_info_table (other)
        {}
       };
@@ -794,7 +794,7 @@ namespace elfutils
        {}
 
        template<typename arg_type>
-       inline value_constant (::Dwarf_Word x, arg_type &arg)
+       inline value_constant (::Dwarf_Word x, arg_type &)
          : word (x)
        {}
       };
@@ -805,7 +805,7 @@ namespace elfutils
        inline value_constant_block () {}
 
        template<typename block, typename arg_type>
-       inline value_constant_block (const block &b, arg_type &arg)
+       inline value_constant_block (const block &b, arg_type &)
          : std::vector<uint8_t> (b.begin (), b.end ())
        {}
       };
@@ -815,7 +815,7 @@ namespace elfutils
        inline value_dwarf_constant () {}
 
        template<typename constant, typename arg_type>
-       inline value_dwarf_constant (const constant &other, arg_type &arg)
+       inline value_dwarf_constant (const constant &other, arg_type &)
          : dwarf_enum (other)
        {}
       };
@@ -825,7 +825,7 @@ namespace elfutils
        inline value_source_file () {}
 
        template<typename file, typename arg_type>
-       inline value_source_file (const file &other, arg_type &arg)
+       inline value_source_file (const file &other, arg_type &)
          : source_file (other)
        {}
       };
@@ -839,7 +839,7 @@ namespace elfutils
        {}
 
        template<typename arg_type>
-       inline value_source_line (unsigned int m, arg_type &arg)
+       inline value_source_line (unsigned int m, arg_type &)
          : n (m)
        {}
       };
@@ -852,7 +852,7 @@ namespace elfutils
        inline value_location () {}
 
        template<typename loc, typename arg_type>
-       inline value_location (const loc &other, arg_type &arg)
+       inline value_location (const loc &other, arg_type &)
          : location_attr (other)
        {}
       };
index 321565c872c6f38dcaac97417197a7cd58b0b412..6b94382999bf5b6087c5f82b08df335cd1da5c1d 100644 (file)
@@ -54,6 +54,9 @@
 #include "dwarf_data"
 #include "dwarf_ref_maker"
 
+#include <type_traits>
+
+
 /* Read the comments for elfutils::dwarf first.
 
    The elfutils::dwarf_edit class is template-compatible with the logical
@@ -172,11 +175,13 @@ namespace elfutils
       template<typename die_type, typename arg_type>
       inline void set (const die_type &die, arg_type &arg)
       {
+       /* Clear the old containers first so in exceptions we can't leave
+          the tag changed but the old containers intact.  */
        _m_attributes.clear ();
        _m_children.clear ();
        _m_tag = die.tag ();
-       _m_attributes.swap (attributes_type (die.attributes (), arg));
-       _m_children.swap (children_type (die.children (), arg));
+       _m_attributes = std::move (attributes_type (die.attributes (), arg));
+       _m_children = std::move (children_type (die.children (), arg));
       }
 
     public:
index 67c1ae73316a294daa8f1fb26ea1639fcb3cc641..f12b3a101ec8b92f244a774c3f7daf8878c70d37 100644 (file)
@@ -473,8 +473,7 @@ namespace elfutils
 
     // Share the _m_seen maps with the prototype tracker,
     // but start a fresh walk from the given starting point.
-    inline dwarf_ref_tracker (const dwarf_ref_tracker &proto,
-                             reference_match &matched,
+    inline dwarf_ref_tracker (const dwarf_ref_tracker &proto, reference_match &,
                              const left_context_type &lhs, const die1 &a,
                              const right_context_type &rhs, const die2 &b)
       : _m_left (tracker1 (proto._m_left, lhs, a)),
index 15a0cef1a1444c26f14867f324b62c34cf977d31..8d3bb86ab7cdffa733901cf007fb3d302442e62e 100644 (file)
@@ -63,7 +63,7 @@ using namespace std;
 /* Throw
  */
 void
-dwarf::throw_libdw (::Dwarf *dw)
+dwarf::throw_libdw (::Dwarf *)
 {
   throw std::runtime_error (::dwarf_errmsg (-1));
 }
index a9d051f67f0c11bcbf43a7203c2f80513c56043b..238c77c928ffbc82742b6b1dc77a5738fc7e51a6 100644 (file)
@@ -1,5 +1,7 @@
 2009-07-03  Roland McGrath  <roland@redhat.com>
 
+       * Makefile.am (AM_CXXFLAGS): Drop -Wno-unused-parameter.
+
        * dwarfcmp.cc (open_file): Exit 77 for no DWARF under -T.
 
 2009-07-02  Roland McGrath  <roland@redhat.com>
index ab25a39bf3825279af75be77fcd2c87cc5760e95..79748d1035cb376a94cc7067e6991707a12a7b45 100644 (file)
@@ -40,8 +40,7 @@ INCLUDES = -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
           -I$(srcdir)/../libdw -I$(srcdir)/../libdwfl \
           -I$(srcdir)/../libasm -I$(srcdir)/../lib -I..
 
-AM_CXXFLAGS = $(AM_CFLAGS:gnu99=gnu++0x) \
-             -Wno-unused-parameter
+AM_CXXFLAGS = $(AM_CFLAGS:gnu99=gnu++0x)
 
 AM_LDFLAGS = -Wl,-rpath-link,../libelf:../libdw
 
index 082e404f6cf1c929f27f5ee218dbb249124ad4a5..60f57ed3b0c307e996720baa41f86cda754fbc0c 100644 (file)
@@ -372,8 +372,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
 
 /* Handle program arguments.  */
 static error_t
-parse_opt (int key, char *arg,
-          struct argp_state *state __attribute__ ((unused)))
+parse_opt (int key, char *, struct argp_state *)
 {
   switch (key)
     {
index d7c99a187b9ce74136876877a7d0ea4dac07ca18..af678b693fd85e09ff89ecfab9609ad9ee67dbcb 100644 (file)
@@ -1,3 +1,9 @@
+2009-07-03  Roland McGrath  <roland@redhat.com>
+
+       * Makefile.am (AM_CXXFLAGS): New variable (from ../src/Makefile.am).
+
+       * print-die.hh: Grok --edit/--output options to print a copied object.
+
 2009-07-02  Roland McGrath  <roland@redhat.com>
 
        * run-dwarf_edit.sh: New file.
index 41cd9f3288150432b127e9999bd9e8b3f8a53b3a..98fa96e974b9fa30f0823417f1bb47b0ddec610a 100644 (file)
@@ -35,6 +35,8 @@ AM_CFLAGS = -Wall -Werror -Wextra -std=gnu99 \
 BUILT_RPATH = \$$ORIGIN/../libasm:\$$ORIGIN/../libdw:\$$ORIGIN/../backends:\$$ORIGIN/../libelf
 endif
 
+AM_CXXFLAGS = $(AM_CFLAGS:gnu99=gnu++0x)
+
 AM_LDFLAGS =
 
 if !STANDALONE
index 3f4cd9d238a2fcc8b23ebe05321bddcf6482cc3f..29e000c705a8026a7fd32d78f64584ec7a16d24a 100644 (file)
 
 #include <cstring>
 #include <cstdio>
+#include <cstdlib>
 #include <clocale>
 #include <libintl.h>
 #include <ostream>
 #include <iomanip>
 #include <tr1/unordered_map>
 
+#include "c++/dwarf_edit"
+#include "c++/dwarf_output"
+
 static bool print_offset;
 
+static enum { copy_none, copy_edit, copy_output } make_copy;
+
 static void
 print_die_main (int &argc, char **&argv, unsigned int &depth)
 {
@@ -54,6 +60,19 @@ print_die_main (int &argc, char **&argv, unsigned int &depth)
       ++argv;
     }
 
+  if (argc > 1 && !strcmp (argv[1], "--edit"))
+    {
+      make_copy = copy_edit;
+      --argc;
+      ++argv;
+    }
+  else if (argc > 1 && !strcmp (argv[1], "--output"))
+    {
+      make_copy = copy_output;
+      --argc;
+      ++argv;
+    }
+
   depth = 0;
   if (argc > 1 && sscanf (argv[1], "--depth=%u", &depth) == 1)
     {
@@ -154,11 +173,33 @@ print_cu (const typename file::compile_unit &cu, const unsigned int limit)
 
 template<typename file>
 static void
-print_file (const char *name, const file &dw, const unsigned int limit)
+print_file (const file &dw, const unsigned int limit)
 {
-  cout << name << ":\n";
-
   for (typename file::compile_units::const_iterator i
         = dw.compile_units ().begin (); i != dw.compile_units ().end (); ++i)
     print_cu<file> (*i, limit);
 }
+
+template<typename file>
+static void
+print_file (const char *name, const file &dw, const unsigned int limit)
+{
+  cout << name << ":\n";
+
+  switch (make_copy)
+    {
+    case copy_none:
+      print_file (dw, limit);
+      break;
+    case copy_edit:
+      print_file (dwarf_edit (dw), limit);
+      break;
+#if 0 // XXX
+    case copy_output:
+      print_file (dwarf_output (dw), limit);
+      break;
+#endif
+    default:
+      abort ();
+    }
+}