Fix latent bug in dwarf2_find_containing_comp_unit
dwarf2_find_containing_comp_unit has this in its binary search:
if (mid_cu->is_dwz > offset_in_dwz
|| (mid_cu->is_dwz == offset_in_dwz
&& mid_cu->sect_off + mid_cu->length >= sect_off))
high = mid;
The intent here is to determine whether SECT_OFF appears in or before
MID_CU.
I believe this has an off-by-one error, and that the check should use
">" rather than ">=". If the two side are equal, then SECT_OFF
actually appears at the start of the next CU.
I've had this patch kicking around for ages but I forget how I found
the problem.
gdb/ChangeLog
2020-02-20 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (dwarf2_find_containing_comp_unit): Use ">", not
">=", in binary search.
(dwarf2_find_containing_comp_unit): New overload.
(run_test): New self-test.
(_initialize_dwarf2_read): Register new test.