[PATCH 01/14] Fix latent bug in dwarf2_find_containing_comp_unit
Tom Tromey
tom@tromey.com
Wed Feb 19 14:08:00 GMT 2020
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
Simon> I'm going to ask if you thought about a way to test this. I
Simon> don't think writing a typical test case for this is feasible.
Yeah. And like I said, I don't remember how I encountered this.
Maybe only with some other dubious patch in place.
Simon> By refactoring the code a bit, we could maybe factor out the
Simon> meat of this function into one that operates on an std::vector<dwarf2_per_cu_data> instead
Simon> of on a dwarf2_per_objfile. It should then be feasible to create an std::vector with
Simon> dwarf2_per_cu_data elements out of thin air to unit-test the function, including edge
Simon> cases like this.
Another idea that occurred to me is that we could just use
std::binary_search here. Then instead of implementing a binary search,
we'd only need to implement a comparison function -- which seems
simpler.
Anyway I will try to write a unit test, that's a good idea.
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?
Yes, exactly. Maybe this can be cleaned up a bit after this series,
since now we have the index directly in the dwarf2_per_cu_data. I am
not sure offhand.
Tom
More information about the Gdb-patches
mailing list