Bug 32482 - DWARF index doesn't follow strcmp_iw
Summary: DWARF index doesn't follow strcmp_iw
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: 17.1
Assignee: Tom Tromey
URL:
Keywords:
Depends on:
Blocks: 29366 16998
  Show dependency treegraph
 
Reported: 2024-12-19 16:12 UTC by Tom Tromey
Modified: 2025-01-24 21:08 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2024-12-19 16:12:02 UTC
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.
Comment 1 Tom Tromey 2024-12-29 18:07:45 UTC
On the other hand, this feature has been broken ~2 years and
apparently nobody has noticed.

It is documented though.
Comment 3 Sourceware Commits 2025-01-24 21:07:00 UTC
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
Comment 4 Tom Tromey 2025-01-24 21:08:35 UTC
Fixed.