From a24b20783cd22a690c9f05a19a334f5baae7b19c Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 25 Aug 2009 23:48:41 -0700 Subject: [PATCH] Share print-die compilation among tests. --- libdw/c++/subr.hh | 12 ++++++++---- tests/ChangeLog | 6 ++++++ tests/Makefile.am | 4 ++-- tests/dwarf-print.cc | 1 + tests/{print-die.hh => print-die.cc} | 17 +++++++++++++++-- 5 files changed, 32 insertions(+), 8 deletions(-) rename tests/{print-die.hh => print-die.cc} (96%) diff --git a/libdw/c++/subr.hh b/libdw/c++/subr.hh index 772446587..5d4df089e 100644 --- a/libdw/c++/subr.hh +++ b/libdw/c++/subr.hh @@ -674,18 +674,22 @@ namespace elfutils _base::operator++ (); return *this; } - inline wrapped_input_iterator operator++ (int magic) // postfix + inline wrapped_input_iterator operator++ (int) // postfix { - return wrapped_input_iterator (_base::operator++ (magic)); + wrapped_input_iterator pre = *this; + ++*this; + return pre; } inline wrapped_input_iterator &operator-- () // prefix { _base::operator-- (); return *this; } - inline wrapped_input_iterator operator-- (int magic) // postfix + inline wrapped_input_iterator operator-- (int) // postfix { - return wrapped_input_iterator (_base::operator-- (magic)); + wrapped_input_iterator pre = *this; + --*this; + return pre; } inline const _base &base () const diff --git a/tests/ChangeLog b/tests/ChangeLog index 3a81522a7..8f7e9dc22 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2009-08-25 Roland McGrath + + * print-die.hh: New file with extern decls. Contents moved to ... + * print-die.cc: ... here, new file. + * Makefile.am (dwarf_print_SOURCES, dwarf_edit_SOURCES): Build it. + 2009-08-21 Roland McGrath * print-die.hh (print_die_main, print_file): Add --silent option. diff --git a/tests/Makefile.am b/tests/Makefile.am index b0da862c0..ad5a466d3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -195,10 +195,10 @@ endif !STANDALONE # XXX later the C++ stuff will be in libdw.so directly libdwpp = ../libdw/libdwpp.a $(libdw) -dwarf_print_SOURCES = dwarf-print.cc +dwarf_print_SOURCES = dwarf-print.cc print-die.cc dwarf_print_LDADD = $(libdwpp) $(libmudflap) -ldl -dwarf_edit_SOURCES = dwarf_edit.cc +dwarf_edit_SOURCES = dwarf_edit.cc print-die.cc dwarf_edit_LDADD = $(libdwpp) $(libmudflap) -ldl arextract_LDADD = $(libelf) $(libmudflap) diff --git a/tests/dwarf-print.cc b/tests/dwarf-print.cc index 36b9415be..698dd0dab 100644 --- a/tests/dwarf-print.cc +++ b/tests/dwarf-print.cc @@ -30,6 +30,7 @@ #include #include #include +#include #include "c++/dwarf" diff --git a/tests/print-die.hh b/tests/print-die.cc similarity index 96% rename from tests/print-die.hh rename to tests/print-die.cc index 76f160b44..728eb74ae 100644 --- a/tests/print-die.hh +++ b/tests/print-die.cc @@ -23,6 +23,10 @@ Network licensing program, please visit www.openinventionnetwork.com . */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include #include #include @@ -37,6 +41,9 @@ #include "c++/dwarf_edit" #include "c++/dwarf_output" +using namespace elfutils; +using namespace std; + static bool print_offset; static bool sort_attrs; static bool elide_refs; @@ -45,7 +52,7 @@ static bool no_print; static enum { copy_none, copy_edit, copy_output } make_copy; -static void +void print_die_main (int &argc, char **&argv, unsigned int &depth) { /* Set locale. */ @@ -291,7 +298,7 @@ print_file (const file &dw, const unsigned int limit) } template -static void +void print_file (const char *name, const file &dw, const unsigned int limit) { cout << name << ":\n"; @@ -314,3 +321,9 @@ print_file (const char *name, const file &dw, const unsigned int limit) abort (); } } + +// Explicit instantiations. +template void print_file (const char *, const dwarf &, + const unsigned int); +template void print_file (const char *, const dwarf_edit &, + const unsigned int); -- 2.47.3