Re: [PATCH 01/14] Fix latent bug in dwarf2_find_containing_comp_unit

Tom Tromey
2020-02-20T00:11:11Z

Simon> By refactoring the code a bit, we could maybe factor out the meat
Simon> of this function into one that operates on an
Simon> std::vector<dwarf2_per_cu_data> instead of on a
Simon> dwarf2_per_objfile. It should then be feasible to create an
Simon> std::vector with dwarf2_per_cu_data elements out of thin air to
Simon> unit-test the function, including edge cases like this.

Here is a new version of this patch.
I propose landing it separately, because it is just a straightforward
latent bug fix.

Simon> Also, do you understand what's the logic with this dwz stuff? Is it that all the CUs
Simon> coming from a dwz file are at the end of the list, or something like that?

Tom> Yes, exactly.

To expand on that, in multi-file mode, dwz may create a combined, shared
file of partial symtabs. When reading the DWARF for the main file, gdb
may find it needs the dwz file; and in this case the additional CUs are
put into the same vector, at the end. It's done this way so that we
can easily find the correct CU (since the section offsets between the
main and shared dwz file will overlap).

It would probably be better to try to share these CUs across objfiles.
That may be somewhat involved given the current code, though.

Tom