summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2009-08-16 19:05:25 -0700
committerRoland McGrath <roland@redhat.com>2009-08-16 19:05:25 -0700
commit882eda7c40ffcfbc9c15943f2aea09543dd2fe55 (patch)
treec834e2654a9f794f4679a7251b9a233c45256de1
parent2d212202831a0c19c73476b10f3573a4d8c12744 (diff)
downloadelfutils-882eda7c40ffcfbc9c15943f2aea09543dd2fe55.tar.gz
Fix copying vs destruction regression.
-rw-r--r--libdw/c++/dwarf_data51
-rw-r--r--libdw/c++/dwarf_output18
2 files changed, 42 insertions, 27 deletions
diff --git a/libdw/c++/dwarf_data b/libdw/c++/dwarf_data
index 2a2dead8..005fc5dc 100644
--- a/libdw/c++/dwarf_data
+++ b/libdw/c++/dwarf_data
@@ -141,6 +141,15 @@ namespace elfutils
require_cu (cu), arg)
{}
+ /* Assignment details are up to the base class.
+ We just ensure it's really a compile_unit. */
+ inline compile_unit &
+ operator= (const typename impl::debug_info_entry &other)
+ {
+ impl::debug_info_entry::operator= (require_cu (other));
+ return *this;
+ }
+
// Fetch the CU's DW_AT_stmt_list.
inline const typename impl::line_info_table &line_info () const
{
@@ -1200,15 +1209,25 @@ namespace elfutils
return vw::variant (p, _m_value);
}
+ template<typename value>
+ inline attr_value &copy (const value &other)
+ {
+ if (_m_value != NULL)
+ {
+ delete _m_value;
+ _m_value = NULL;
+ }
+ init<value> me (this, 0, other);
+ return *this;
+ }
+
public:
-#if 0 // XXX
attr_value (const attr_value &other)
: _m_value (NULL)
{
if (other._m_value != NULL)
init<attr_value> me (this, 0, other);
}
-#endif
inline attr_value ()
: _m_value (NULL)
@@ -1220,29 +1239,19 @@ namespace elfutils
delete _m_value;
}
-#if 0 // XXX
- inline attr_value &operator= (const attr_value &other)
- {
- if (_m_value != NULL)
- {
- delete _m_value;
- _m_value = NULL;
- }
- init<attr_value> me (this, 0, other);
- return *this;
- }
template<typename value>
inline attr_value &operator= (const value &other)
{
- if (_m_value != NULL)
- {
- delete _m_value;
- _m_value = NULL;
- }
- init<value> me (this, 0, other);
- return *this;
+ return copy (other);
+ }
+
+ /* This is the same as the generic template one,
+ but we have to define it explicitly to override
+ the default assignment operator. */
+ inline attr_value &operator= (const attr_value &other)
+ {
+ return copy (other);
}
-#endif
dwarf::value_space what_space () const;
inline std::string to_string () const;
diff --git a/libdw/c++/dwarf_output b/libdw/c++/dwarf_output
index db4587d1..b03dbd48 100644
--- a/libdw/c++/dwarf_output
+++ b/libdw/c++/dwarf_output
@@ -1877,7 +1877,7 @@ namespace elfutils
/* Complain if we still have dangling references.
If not, it should be impossible to have pending entries left. */
- inline void demand_complete () const
+ inline die_info_pair *final () const
{
assert (_m_out == NULL);
if (unlikely (_m_in->_m_final == NULL))
@@ -1888,6 +1888,7 @@ namespace elfutils
("compile_unit contains dangling reference attributes");
}
assert (_m_copier->_m_defined == _m_copier->_m_seen.size ());
+ return _m_in->_m_final;
}
// We're adding a reference attribute inside populate, above.
@@ -1945,6 +1946,15 @@ namespace elfutils
}
};
+ struct unit_copier : public entry_copier
+ {
+ inline unit_copier (copier *c, const typename dw::compile_unit &in)
+ : entry_copier (c, 0, c->enter_seen (in), in)
+ {
+ populate (in);
+ }
+ };
+
/* Create a whole CU in the output.
*/
inline void
@@ -1953,11 +1963,7 @@ namespace elfutils
{
typename tracker::walk into (_m_tracker, in, out);
- entry_copier maker (this, 0, enter_seen (*in), *in);
- maker.populate (*in);
-
- dump_seen ();
- maker.demand_complete ();
+ *out = unit_copier (this, *in).final ()->first;
}
typedef std::tr1::unordered_map< ::Dwarf_Off, seen> seen_map;