]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Use flags enum for cooked_index_entry::full_name
authorTom Tromey <tromey@adacore.com>
Mon, 10 Mar 2025 14:51:01 +0000 (08:51 -0600)
committerTom Tromey <tromey@adacore.com>
Mon, 10 Mar 2025 19:40:25 +0000 (13:40 -0600)
commitc05c9914b1875d9edca946532d02daafc82c8615
tree9f2d9c69c5ea10838f39c3dc74d37cd058763448
parenteb39f6d01e7c74389e71a864f382a2f0d3560cfd
Use flags enum for cooked_index_entry::full_name

I found a small bug coming from a couple of  recent patches of mine for
cooked_index_entry::full_name.

First, commit aab26529b30 (Add "Ada linkage" mode to
cooked_index_entry::full_name) added a small hack to optionally
compute the Ada linkage name.

Then, commit aab2ac34d7f (Avoid excessive CU expansion on failed
matches) changed the relevant expand_symtabs_matching implementation
to use this feature.

However, the feature was used unconditionally, causing a bad side
effect: the non-canonical name is now used for all languages, not just
Ada.  But, for C++ this is wrong.

Furthermore, consider the declaration of full_name:

   const char *full_name (struct obstack *storage,
 bool for_main = false,
 bool for_ada_linkage = false,
   const char *default_sep = nullptr) const;

... and then consider this call in cooked_index::dump:

       gdb_printf ("    qualified:  %s\n",
  entry->full_name (&temp_storage, false, "::"));

Oops!  The "::" is silently converted to 'true' here.

To fix both of these problems, this patch changes full_name to accept
a flags enum rather than booleans.  This avoids the type-safety
problem.

Then, full_name is changed to remove the "Ada" flag when the entry is
not in fact an Ada symbol.

Regression tested on x86-64 Fedora 40.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/dwarf2/cooked-index.c
gdb/dwarf2/cooked-index.h
gdb/dwarf2/index-write.c
gdb/dwarf2/parent-map.c
gdb/dwarf2/read.c