From: Roland McGrath Date: Fri, 3 Jul 2009 20:31:24 +0000 (-0700) Subject: C++ warning fiddles. Let dwarf-print/dwarf_edit test copy constructors. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=92630c663ec280af1b1d854cc5c0ce58955bb965;p=thirdparty%2Felfutils.git C++ warning fiddles. Let dwarf-print/dwarf_edit test copy constructors. --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index ce933bc4a..a8e54a22c 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,5 +1,7 @@ 2009-07-03 Roland McGrath + * 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. diff --git a/libdw/Makefile.am b/libdw/Makefile.am index 7fb3171c8..0d3e636bb 100644 --- a/libdw/Makefile.am +++ b/libdw/Makefile.am @@ -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))) diff --git a/libdw/c++/dwarf b/libdw/c++/dwarf index 4ed0c796c..7f7757dca 100644 --- a/libdw/c++/dwarf +++ b/libdw/c++/dwarf @@ -1265,7 +1265,7 @@ namespace elfutils template struct any : public std::unary_function { - inline bool operator () (const pair &x) + inline bool operator () (const pair &) { return true; } diff --git a/libdw/c++/dwarf_comparator b/libdw/c++/dwarf_comparator index 62556596b..7465dab52 100644 --- a/libdw/c++/dwarf_comparator +++ b/libdw/c++/dwarf_comparator @@ -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; } diff --git a/libdw/c++/dwarf_data b/libdw/c++/dwarf_data index 5598e945e..28eeef0be 100644 --- a/libdw/c++/dwarf_data +++ b/libdw/c++/dwarf_data @@ -51,8 +51,8 @@ #define _ELFUTILS_DWARF_DATA 1 #include "dwarf" +#include #include -#include /* This contains common classes/templates used by dwarf_output and dwarf_edit. @@ -685,7 +685,7 @@ namespace elfutils inline value_string () {} template - 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 - inline value_flag (bool t, arg_type &arg) + inline value_flag (bool t, arg_type &) : flag (t) {} }; @@ -756,7 +756,7 @@ namespace elfutils {} template - 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 - 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 - 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 - 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 - inline value_constant_block (const block &b, arg_type &arg) + inline value_constant_block (const block &b, arg_type &) : std::vector (b.begin (), b.end ()) {} }; @@ -815,7 +815,7 @@ namespace elfutils inline value_dwarf_constant () {} template - 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 - 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 - 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 - inline value_location (const loc &other, arg_type &arg) + inline value_location (const loc &other, arg_type &) : location_attr (other) {} }; diff --git a/libdw/c++/dwarf_edit b/libdw/c++/dwarf_edit index 321565c87..6b9438299 100644 --- a/libdw/c++/dwarf_edit +++ b/libdw/c++/dwarf_edit @@ -54,6 +54,9 @@ #include "dwarf_data" #include "dwarf_ref_maker" +#include + + /* 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 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: diff --git a/libdw/c++/dwarf_tracker b/libdw/c++/dwarf_tracker index 67c1ae733..f12b3a101 100644 --- a/libdw/c++/dwarf_tracker +++ b/libdw/c++/dwarf_tracker @@ -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)), diff --git a/libdw/c++/exception.cc b/libdw/c++/exception.cc index 15a0cef1a..8d3bb86ab 100644 --- a/libdw/c++/exception.cc +++ b/libdw/c++/exception.cc @@ -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)); } diff --git a/src/ChangeLog b/src/ChangeLog index a9d051f67..238c77c92 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2009-07-03 Roland McGrath + * Makefile.am (AM_CXXFLAGS): Drop -Wno-unused-parameter. + * dwarfcmp.cc (open_file): Exit 77 for no DWARF under -T. 2009-07-02 Roland McGrath diff --git a/src/Makefile.am b/src/Makefile.am index ab25a39bf..79748d103 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 diff --git a/src/dwarfcmp.cc b/src/dwarfcmp.cc index 082e404f6..60f57ed3b 100644 --- a/src/dwarfcmp.cc +++ b/src/dwarfcmp.cc @@ -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) { diff --git a/tests/ChangeLog b/tests/ChangeLog index d7c99a187..af678b693 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2009-07-03 Roland McGrath + + * 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 * run-dwarf_edit.sh: New file. diff --git a/tests/Makefile.am b/tests/Makefile.am index 41cd9f328..98fa96e97 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 diff --git a/tests/print-die.hh b/tests/print-die.hh index 3f4cd9d23..29e000c70 100644 --- a/tests/print-die.hh +++ b/tests/print-die.hh @@ -25,14 +25,20 @@ #include #include +#include #include #include #include #include #include +#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 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 (*i, limit); } + +template +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 (); + } +}