{
gdb_assert (!this->per_bfd->queue.has_value ());
- for (auto pair : m_dwarf2_cus)
- delete pair.second;
-
m_dwarf2_cus.clear ();
}
/* Save this dwarf2_cu in the per_objfile. The per_objfile owns it
now. */
dwarf2_per_objfile *per_objfile = m_new_cu->per_objfile;
- per_objfile->set_cu (m_this_cu, m_new_cu.release ());
+ per_objfile->set_cu (m_this_cu, std::move (m_new_cu));
}
}
if (it == m_dwarf2_cus.end ())
return nullptr;
- return it->second;
+ return it->second.get ();
}
/* See read.h. */
void
-dwarf2_per_objfile::set_cu (dwarf2_per_cu_data *per_cu, dwarf2_cu *cu)
+dwarf2_per_objfile::set_cu (dwarf2_per_cu_data *per_cu,
+ std::unique_ptr<dwarf2_cu> cu)
{
gdb_assert (this->get_cu (per_cu) == nullptr);
- m_dwarf2_cus[per_cu] = cu;
+ m_dwarf2_cus[per_cu] = std::move (cu);
}
/* See read.h. */
gdb_assert (!this->per_bfd->queue.has_value ());
/* Start by clearing all marks. */
- for (auto pair : m_dwarf2_cus)
+ for (const auto &pair : m_dwarf2_cus)
pair.second->clear_mark ();
/* Traverse all CUs, mark them and their dependencies if used recently
enough. */
- for (auto pair : m_dwarf2_cus)
+ for (const auto &pair : m_dwarf2_cus)
{
- dwarf2_cu *cu = pair.second;
+ dwarf2_cu *cu = pair.second.get ();
cu->last_used++;
if (cu->last_used <= dwarf_max_cache_age)
/* Delete all CUs still not marked. */
for (auto it = m_dwarf2_cus.begin (); it != m_dwarf2_cus.end ();)
{
- dwarf2_cu *cu = it->second;
+ dwarf2_cu *cu = it->second.get ();
if (!cu->is_marked ())
{
dwarf_read_debug_printf_v ("deleting old CU %s",
sect_offset_str (cu->per_cu->sect_off));
- delete cu;
it = m_dwarf2_cus.erase (it);
}
else
if (it == m_dwarf2_cus.end ())
return;
- delete it->second;
-
m_dwarf2_cus.erase (it);
}
#include "dwarf2/index-cache.h"
#include "dwarf2/mapped-index.h"
#include "dwarf2/section.h"
+#include "dwarf2/cu.h"
#include "filename-seen-cache.h"
#include "gdbsupport/gdb_obstack.h"
#include "gdbsupport/hash_enum.h"
dwarf2_cu *get_cu (dwarf2_per_cu_data *per_cu);
/* Set the dwarf2_cu matching PER_CU for this objfile. */
- void set_cu (dwarf2_per_cu_data *per_cu, dwarf2_cu *cu);
+ void set_cu (dwarf2_per_cu_data *per_cu, std::unique_ptr<dwarf2_cu> cu);
/* Remove/free the dwarf2_cu matching PER_CU for this objfile. */
void remove_cu (dwarf2_per_cu_data *per_cu);
/* Map from the objfile-independent dwarf2_per_cu_data instances to the
corresponding objfile-dependent dwarf2_cu instances. */
- std::unordered_map<dwarf2_per_cu_data *, dwarf2_cu *> m_dwarf2_cus;
+ std::unordered_map<dwarf2_per_cu_data *,
+ std::unique_ptr<dwarf2_cu>> m_dwarf2_cus;
};
/* Get the dwarf2_per_objfile associated to OBJFILE. */