gdb/dwarf: change cutu_reader::read_die_and_siblings to cutu_reader::read_all_dies
After construction of a cutu_reader, only the top-level DIE has been
read in memory. If the caller wants to access the full DIE tree, it
does:
reader.top_level_die ()->child
= reader.read_die_and_siblings (reader.top_level_die ());
I don't really like this poking into cutu_reader's data structures from
the outside, I would prefer if that work was done by cutu_reader.
Rename the read_die_and_siblings method to read_all_dies, and do that
work inside cutu_reader.
I also moved these operations inside the read_all_dies method:
gdb_assert (cu->die_hash.empty ());
cu->die_hash.reserve (cu->header.get_length_without_initial () / 12);
...
cu->dies = reader.top_level_die ();
The rationale for this is that read_all_dies (and the functions it
calls) is responsible for filling the die_hash set. So I think it makes
sense for it to do the reserve.
It is also cutu_reader's job, currently, to create and fill the fields
of dwarf2_cu. So I think it makes sense for it to set cu->dies, after
having read the DIEs in memory.
Change-Id: I088c2e0b367db7d1f67e8c9e2d5b0d61165292fc
Approved-By: Tom Tromey <tom@tromey.com>
2 files changed