diff options
| author | Roland McGrath <[email protected]> | 2009-07-03 13:31:24 -0700 |
|---|---|---|
| committer | Roland McGrath <[email protected]> | 2009-07-03 13:31:24 -0700 |
| commit | 92630c663ec280af1b1d854cc5c0ce58955bb965 (patch) | |
| tree | 55df412a91f09c17ea6bc443854c63f974df852c | |
| parent | 0451d0665372bc60e0d9dc5e20cfccf584e4e0dc (diff) | |
C++ warning fiddles. Let dwarf-print/dwarf_edit test copy constructors.
| -rw-r--r-- | libdw/ChangeLog | 2 | ||||
| -rw-r--r-- | libdw/Makefile.am | 2 | ||||
| -rw-r--r-- | libdw/c++/dwarf | 2 | ||||
| -rw-r--r-- | libdw/c++/dwarf_comparator | 32 | ||||
| -rw-r--r-- | libdw/c++/dwarf_data | 24 | ||||
| -rw-r--r-- | libdw/c++/dwarf_edit | 9 | ||||
| -rw-r--r-- | libdw/c++/dwarf_tracker | 3 | ||||
| -rw-r--r-- | libdw/c++/exception.cc | 2 | ||||
| -rw-r--r-- | src/ChangeLog | 2 | ||||
| -rw-r--r-- | src/Makefile.am | 3 | ||||
| -rw-r--r-- | src/dwarfcmp.cc | 3 | ||||
| -rw-r--r-- | tests/ChangeLog | 6 | ||||
| -rw-r--r-- | tests/Makefile.am | 2 | ||||
| -rw-r--r-- | tests/print-die.hh | 47 |
14 files changed, 98 insertions, 41 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog index ce933bc4..a8e54a22 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,5 +1,7 @@ 2009-07-03 Roland McGrath <[email protected]> + * 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 7fb3171c..0d3e636b 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 4ed0c796..7f7757dc 100644 --- a/libdw/c++/dwarf +++ b/libdw/c++/dwarf @@ -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; } diff --git a/libdw/c++/dwarf_comparator b/libdw/c++/dwarf_comparator index 62556596..7465dab5 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 5598e945..28eeef0b 100644 --- a/libdw/c++/dwarf_data +++ b/libdw/c++/dwarf_data @@ -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) {} }; diff --git a/libdw/c++/dwarf_edit b/libdw/c++/dwarf_edit index 321565c8..6b943829 100644 --- a/libdw/c++/dwarf_edit +++ b/libdw/c++/dwarf_edit @@ -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: diff --git a/libdw/c++/dwarf_tracker b/libdw/c++/dwarf_tracker index 67c1ae73..f12b3a10 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 15a0cef1..8d3bb86a 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 a9d051f6..238c77c9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2009-07-03 Roland McGrath <[email protected]> + * Makefile.am (AM_CXXFLAGS): Drop -Wno-unused-parameter. + * dwarfcmp.cc (open_file): Exit 77 for no DWARF under -T. 2009-07-02 Roland McGrath <[email protected]> diff --git a/src/Makefile.am b/src/Makefile.am index ab25a39b..79748d10 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 082e404f..60f57ed3 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 d7c99a18..af678b69 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2009-07-03 Roland McGrath <[email protected]> + + * 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 <[email protected]> * run-dwarf_edit.sh: New file. diff --git a/tests/Makefile.am b/tests/Makefile.am index 41cd9f32..98fa96e9 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 3f4cd9d2..29e000c7 100644 --- a/tests/print-die.hh +++ b/tests/print-die.hh @@ -25,14 +25,20 @@ #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 (); + } +} |
