Replace the linear search in find_pc_sect_line with a binary search.
This patch addresses slowness when setting breakpoints, especially in
heavily templatized code. Profiling showed that find_pc_sect_line in
symtab.c was the performance bottleneck. The original logic performed a
linear search over ordered data. This patch uses a binary search, as
suggested by comments around the function. There are no behavioural
changes, but gdb is now faster at setting breakpoints in template code.
Tested using on make check on an x86 target. The optimisation speeds up
the included template-breakpoints.py performance test by a factor of 7
on my machine.
ChangeLog:
2018-03-20 Stephen Roberts <stephen.roberts@arm.com>
* gdb/symtab.c (find_pc_sect_line): now uses binary search.
gdb/testsuite/
* gdb.perf/template-breakpoints.cc: New file.
* gdb.perf/template-breakpoints.exp: New file.
* gdb.perf/template-breakpoints.py: New file.