From: Roland McGrath Date: Mon, 6 Jul 2009 08:42:29 +0000 (-0700) Subject: dwarf_output working again like dwarf_edit X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2933f453ffddd262873c26052958f7b5d70951a8;p=thirdparty%2Felfutils.git dwarf_output working again like dwarf_edit --- diff --git a/libdw/c++/dwarf_output b/libdw/c++/dwarf_output index 3ec3c4a2d..efd29859d 100644 --- a/libdw/c++/dwarf_output +++ b/libdw/c++/dwarf_output @@ -51,6 +51,7 @@ #define _ELFUTILS_DWARF_OUTPUT 1 #include "dwarf_edit" +#include "dwarf_ref_maker" #include /* Read the comments for elfutils::dwarf first. @@ -286,6 +287,7 @@ namespace elfutils class debug_info_entry; protected: + template class copier; // Below. template static inline const std::string & @@ -310,8 +312,8 @@ namespace elfutils { const std::string &_m_str; - template - inline value_string (const string &s, dwarf_output_collector &c) + template + inline value_string (const string &s, dwarf_output::copier &c) : _m_str (collect_string (c, s)) {} @@ -534,6 +536,13 @@ namespace elfutils return _m_units; } + private: + // Bind default copy-constructor and prevent it. + inline dwarf_output (const dwarf_output &) + { + throw std::logic_error ("copying dwarf_output requires a collector"); + } + public: // Constructor for an empty file, can add to its compile_units (). inline dwarf_output () {} @@ -541,9 +550,8 @@ namespace elfutils // Constructor copying CUs from an input file (can be any of dwarf, // dwarf_edit, or dwarf_output). template - inline dwarf_output (const input &dw, dwarf_output_collector &c) - : _m_units (dw.compile_units (), c) - {} + inline dwarf_output (const input &, dwarf_output_collector &, + copier = copier ()); template inline bool operator== (const file &other) const @@ -577,15 +585,40 @@ namespace elfutils public: - template // XXX - inline void equivalence (const die1 &, const die2 &) - {} + }; + + template + class dwarf_output::copier + : public dwarf_ref_maker // XXX temporary + { + friend class dwarf_output; + private: + dwarf_output_collector *_m_collector; - template // XXX - inline void refer (die1 *, const die2 &) + inline copier () + : _m_collector (NULL) {} + + copier &operator () (dwarf_output_collector &c) + { + _m_collector = &c; + return *this; + } + + inline operator dwarf_output_collector & () + { + return *_m_collector; + } }; + // Copy construction instantiates a copier derived from the collector. + template + inline dwarf_output::dwarf_output (const input &dw, + dwarf_output_collector &c, + copier maker) + : _m_units (dw.compile_units (), maker (c)) + {} + template inline const std::string & dwarf_output::collect_string (dwarf_output_collector &c, const input &s) diff --git a/src/dwarfcmp.cc b/src/dwarfcmp.cc index 60f57ed3b..7f9468a9d 100644 --- a/src/dwarfcmp.cc +++ b/src/dwarfcmp.cc @@ -330,7 +330,6 @@ main (int argc, char *argv[]) dwarf_edit edit2 (file2); test_classes (file1, file2, edit1, edit2, same); - /* { dwarf_output_collector c1; dwarf_output_collector c2; @@ -347,7 +346,6 @@ main (int argc, char *argv[]) test_classes (file1, file2, out1, out2, same); test_classes (edit1, edit2, out1, out2, same); } - */ } result = !same;