]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Remove best_symbol and better_symbol
authorTom Tromey <tom@tromey.com>
Tue, 13 May 2025 23:53:27 +0000 (17:53 -0600)
committerTom Tromey <tom@tromey.com>
Sat, 7 Feb 2026 14:38:46 +0000 (07:38 -0700)
commit03c9c4c8d0ab4b8fc082afb8a0bdd69a7b846a37
treec17ce86ecb387f8b22fa601167ff2e81204669f4
parent160bd561252fe403f24c77dd542e7b705e7eb2f9
Remove best_symbol and better_symbol

This patch removes best_symbol and better_symbol.

Before some c-exp.y changes this year, best_symbol was the source of
excess CU expansion, because searches that include SEARCH_VAR_DOMAIN
will keep going until a symbol is found in that domain, or until all
matches have been exhausted.  So, for instance a "SEARCH_VFT" search
for "int" will, most likely, expand all CUs -- even though the
argument implies that a type would be suitable.

Nowadays, best_symbol is more of an aesthetic offense and abstraction
violation, encoding a workaround for a C++ expression lookup bug into
a low-level lookup function.

This patch changes the the C parser to simply do two lookups,
prioritizing SEARCH_VAR_DOMAIN.  This way, it gets the result it is
presumably looking for, without causing excessive expansion (if that's
currently possible) and without pushing its requirements into generic
code.

Note that the special case for "stub" symbols remains.  This one is
less problematic, at least for the time being, as such symbols aren't
common.  (Kevin does have a patch pending in this area but I don't
believe this change should affect it, as the stub symbol case remains
unchanged.)

New in v2: addressed review comments and reworded the commit text.
v1 is here:

https://inbox.sourceware.org/gdb-patches/87345e71b1.fsf@tromey.com/T/#meb7622f6d4d5bb0c1cd6170d875b37a0ceb9a1ed

Regression tested on x86-64 Fedora 40.
gdb/block.c
gdb/block.h
gdb/c-exp.y
gdb/symtab.c
gdb/symtab.h