gdb/dwarf: store dwarf2_cus in expansion queue
The CU expansion queue currently holds dwarf2_per_cu items (see
dwarf2_queue_item). But there is this invariant that if a per_cu is
queued for expansion, then its DIEs are loaded in memory and a matching
dwarf2_cu object exists in dwarf2_per_objfile.
When a caller calls maybe_queue_comp_unit, a return value of `true`
indicates "the per_cu was enqueued, but its DIEs are not currently
loaded (a dwarf2_cu does not exist for it yet), so you must do it". The
caller is then responsible for calling some function to make it happen
and ensure the invariant is respected.
This feels backwards to me, I think it would be simpler if it was the
other way around. The queue should hold dwarf2_cu objects directly. To
enqueue a CU for expansion, a caller would therefore have to make sure
that a dwarf2_cu exists in the first place (i.e. that the unit's DIEs
are loaded), to pass it to queue_comp_unit. Often, the caller wants to
use the dwarf2_cu anyway, so it's not lost.
- Change dwarf2_queue_item to hold dwarf2_cu pointers. No need to have
a dwarf2_per_objfile anymore, since a dwarf2_cu provides it.
- Change queue_comp_unit and maybe_queue_comp_unit to take a dwarf2_cu.
- Change the order of operation in the spots that call
maybe_queue_comp_unit. Make sure the target unit is loaded first, by
calling one of the new ensure_loaded_* functions. Then, if the
return value is not nullptr (which happens if the unit is dummy),
then call maybe_queue_comp_unit.
- process_queue does not need to deal with possible dummy units, since
that is now filtered earlier. It is not possible to have a dwarf2_cu
for a dummy unit.
- Move the queued flag from dwarf2_per_cu to dwarf2_cu.
- Remove this assert from fill_in_sig_entry_from_dwo_entry, since the
queued flag is not longer in dwarf2_per_cu:
gdb_assert (! sig_entry->queued);
I think that the assert just below does the same job:
gdb_assert (per_objfile->get_cu (sig_entry) == NULL);
Now that the queue holds dwarf2_cus, if there is no dwarf2_cu
associated to a sig_entry, then necessarily that sig_entry is not
enqueued.
Change-Id: I8ef0eb5f45f04b4cb45c3804627084d94bc6c4fd
Approved-By: Tom Tromey <tom@tromey.com>
4 files changed