While working on bug#16998, I found out that cpcompletions.exp only passes by accident. In particular, it works because the CU is expanded, so something like "break foo<A>" will break on functions like foo<A<a<b<int> >, c<d<int> > >, A<a<b<int> >, a<b<int> > > >. The test here surprised me but it is definitely intentional, see commit 64a9760601d3d8761fcf0aae121e69ca0cae1a9c Author: Keith Seitz <keiths@redhat.com> Date: Thu Feb 24 16:42:22 2022 -0800 Support template lookups in strncmp_iw_with_mode Anyway, the cooked index doesn't implement this same logic. So, matches like this will not be found in un-expanded CUs. I'm not sure what to do about it. Maybe it's possible to fix the index, though this might be difficult. My first inclination was to revert this feature but probably that isn't really good.
On the other hand, this feature has been broken ~2 years and apparently nobody has noticed. It is documented though.
https://sourceware.org/pipermail/gdb-patches/2024-December/214424.html
The master branch has been updated by Tom Tromey <tromey@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2e724489260d02a528591eaea4710ce5aeeee0e8 commit 2e724489260d02a528591eaea4710ce5aeeee0e8 Author: Tom Tromey <tom@tromey.com> Date: Sat Dec 28 14:10:56 2024 -0700 Fix C++ template function matching in cooked index In commit 64a97606 ("Support template lookups in strncmp_iw_with_mode"), gdb was changed so that a command like "break func<templ>" would match instantiations like "func<templ<int>>". The new indexer does not support this and so this is a regression. This went unnoticed because gdb.linespec.cpcompletion.exp puts all these functions into the main file, and this CU is expanded early. This patch fixes the bug by changing the cooked index entry comparison function. It also updates the test to fail without this fix. Regression tested on x86-64 Fedora 40. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32482
Fixed.