cutu_reader (struct dwarf2_per_cu_data *this_cu,
struct abbrev_table *abbrev_table,
- int use_existing_cu, int keep,
+ int use_existing_cu,
bool skip_partial);
explicit cutu_reader (struct dwarf2_per_cu_data *this_cu,
struct dwarf2_cu *parent_cu = nullptr,
struct dwo_file *dwo_file = nullptr);
- ~cutu_reader ();
-
DISABLE_COPY_AND_ASSIGN (cutu_reader);
const gdb_byte *info_ptr = nullptr;
struct die_info *comp_unit_die = nullptr;
bool dummy_p = false;
+ /* Release the new CU, putting it on the chain. This cannot be done
+ for dummy CUs. */
+ void keep ();
+
private:
void init_tu_and_read_dwo_dies (struct dwarf2_per_cu_data *this_cu,
- int use_existing_cu, int keep);
+ int use_existing_cu);
struct dwarf2_per_cu_data *m_this_cu;
- int m_keep = 0;
std::unique_ptr<dwarf2_cu> m_new_cu;
/* The ordinary abbreviation table. */
void
cutu_reader::init_tu_and_read_dwo_dies (struct dwarf2_per_cu_data *this_cu,
- int use_existing_cu, int keep)
+ int use_existing_cu)
{
struct signatured_type *sig_type;
struct die_reader_specs reader;
This is an optimization for when we already have the abbrev table.
If USE_EXISTING_CU is non-zero, and THIS_CU->cu is non-NULL, then use it.
- Otherwise, a new CU is allocated with xmalloc.
-
- If KEEP is non-zero, then if we allocated a dwarf2_cu we add it to
- read_in_chain. Otherwise the dwarf2_cu data is freed at the
- end. */
+ Otherwise, a new CU is allocated with xmalloc. */
cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu,
struct abbrev_table *abbrev_table,
- int use_existing_cu, int keep,
+ int use_existing_cu,
bool skip_partial)
: die_reader_specs {},
- m_this_cu (this_cu),
- m_keep (keep)
+ m_this_cu (this_cu)
{
struct dwarf2_per_objfile *dwarf2_per_objfile = this_cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
this_cu->is_debug_types ? "type" : "comp",
sect_offset_str (this_cu->sect_off));
- if (use_existing_cu)
- gdb_assert (keep);
-
/* If we're reading a TU directly from a DWO file, including a virtual DWO
file (instead of going through the stub), short-circuit all of this. */
if (this_cu->reading_dwo_directly)
/* Narrow down the scope of possibilities to have to understand. */
gdb_assert (this_cu->is_debug_types);
gdb_assert (abbrev_table == NULL);
- init_tu_and_read_dwo_dies (this_cu, use_existing_cu, keep);
+ init_tu_and_read_dwo_dies (this_cu, use_existing_cu);
return;
}
}
}
-cutu_reader::~cutu_reader ()
+void
+cutu_reader::keep ()
{
/* Done, clean up. */
- if (m_new_cu != NULL && m_keep && !dummy_p)
+ gdb_assert (!dummy_p);
+ if (m_new_cu != NULL)
{
struct dwarf2_per_objfile *dwarf2_per_objfile
= m_this_cu->dwarf2_per_objfile;
if (this_cu->cu != NULL)
free_one_cached_comp_unit (this_cu);
- cutu_reader reader (this_cu, NULL, 0, 0, false);
+ cutu_reader reader (this_cu, NULL, 0, false);
if (reader.dummy_p)
{
}
cutu_reader reader (&tu.sig_type->per_cu, abbrev_table.get (),
- 0, 0, false);
+ 0, false);
if (!reader.dummy_p)
build_type_psymtabs_reader (&reader, reader.info_ptr,
reader.comp_unit_die);
*slot = entry;
/* This does the job that build_type_psymtabs_1 would have done. */
- cutu_reader reader (&entry->per_cu, NULL, 0, 0, false);
+ cutu_reader reader (&entry->per_cu, NULL, 0, false);
if (!reader.dummy_p)
build_type_psymtabs_reader (&reader, reader.info_ptr,
reader.comp_unit_die);
static void
load_partial_comp_unit (struct dwarf2_per_cu_data *this_cu)
{
- cutu_reader reader (this_cu, NULL, 1, 1, false);
+ cutu_reader reader (this_cu, NULL, 1, false);
if (!reader.dummy_p)
{
If not, there's no more debug_info for this comp unit. */
if (reader.comp_unit_die->has_children)
load_partial_dies (&reader, reader.info_ptr, 0);
+
+ reader.keep ();
}
}
{
gdb_assert (! this_cu->is_debug_types);
- cutu_reader reader (this_cu, NULL, 1, 1, skip_partial);
+ cutu_reader reader (this_cu, NULL, 1, skip_partial);
if (reader.dummy_p)
return;
Similarly, if we do not read the producer, we can not apply
producer-specific interpretation. */
prepare_one_comp_unit (cu, cu->dies, pretend_language);
+
+ reader.keep ();
}
/* Add a DIE to the delayed physname list. */
}
else
{
- cutu_reader reader (per_cu, NULL, 0, 0, false);
+ cutu_reader reader (per_cu, NULL, 0, false);
addr_base = reader.cu->addr_base;
addr_size = reader.cu->header.addr_size;
}
gdb_assert (per_cu->is_debug_types);
gdb_assert (per_cu->cu == NULL);
- cutu_reader reader (per_cu, NULL, 0, 1, false);
+ cutu_reader reader (per_cu, NULL, 0, false);
if (!reader.dummy_p)
{
correctly. Similarly, if we do not read the producer, we can
not apply producer-specific interpretation. */
prepare_one_comp_unit (cu, cu->dies, language_minimal);
+
+ reader.keep ();
}
sig_type->per_cu.tu_read = 1;