Add "Ada linkage" mode to cooked_index_entry::full_name

Unfortunately, due to some details of how the Ada support in gdb
currently works, the DWARF reader will still have to synthesize some
"full name" entries after the cooked index has been constructed.

You can see one particular finding related to this in:

    https://sourceware.org/bugzilla/show_bug.cgi?id=32142

This patch adds a new flag to cooked_index_entry::full_name to enable
the construction of these names.

I hope to redo this part of the Ada support eventually, so that this
code can be removed and the full-name entries simply not created.
This commit is contained in:
Tom Tromey
2024-09-03 12:53:07 -06:00
parent c70ac07a79
commit aab26529b3
2 changed files with 26 additions and 10 deletions

View File

@@ -222,6 +222,7 @@ cooked_index_entry::matches (domain_search_flags kind) const
const char *
cooked_index_entry::full_name (struct obstack *storage, bool for_main,
bool for_ada_linkage,
const char *default_sep) const
{
const char *local_name = for_main ? name : canonical;
@@ -238,9 +239,15 @@ cooked_index_entry::full_name (struct obstack *storage, bool for_main,
sep = "::";
break;
case language_ada:
if (for_ada_linkage)
{
sep = "__";
break;
}
[[fallthrough]];
case language_go:
case language_d:
case language_ada:
sep = ".";
break;
@@ -250,7 +257,7 @@ cooked_index_entry::full_name (struct obstack *storage, bool for_main,
break;
}
get_parent ()->write_scope (storage, sep, for_main);
get_parent ()->write_scope (storage, sep, for_main, for_ada_linkage);
obstack_grow0 (storage, local_name, strlen (local_name));
return (const char *) obstack_finish (storage);
}
@@ -260,11 +267,14 @@ cooked_index_entry::full_name (struct obstack *storage, bool for_main,
void
cooked_index_entry::write_scope (struct obstack *storage,
const char *sep,
bool for_main) const
bool for_main,
bool for_ada_linkage) const
{
if (get_parent () != nullptr)
get_parent ()->write_scope (storage, sep, for_main);
const char *local_name = for_main ? name : canonical;
get_parent ()->write_scope (storage, sep, for_main, for_ada_linkage);
/* When computing the Ada linkage name, the entry might not have
been canonicalized yet, so use the 'name'. */
const char *local_name = (for_main || for_ada_linkage) ? name : canonical;
obstack_grow (storage, local_name, strlen (local_name));
obstack_grow (storage, sep, strlen (sep));
}

View File

@@ -143,10 +143,15 @@ struct cooked_index_entry : public allocate_on_obstack<cooked_index_entry>
STORAGE. FOR_MAIN is true if we are computing the name of the
"main" entry -- one marked DW_AT_main_subprogram. This matters
for avoiding name canonicalization and also a related race (if
"main" computation is done during finalization). If the language
"main" computation is done during finalization). If
FOR_ADA_LINKAGE is true, then Ada-language symbols will have
their "linkage-style" name computed. The default is
source-style. If the language
doesn't prescribe a separator, one can be specified using
DEFAULT_SEP. */
const char *full_name (struct obstack *storage, bool for_main = false,
const char *full_name (struct obstack *storage,
bool for_main = false,
bool for_ada_linkage = false,
const char *default_sep = nullptr) const;
/* Comparison modes for the 'compare' function. See the function
@@ -250,10 +255,11 @@ private:
/* A helper method for full_name. Emits the full scope of this
object, followed by the separator, to STORAGE. If this entry has
a parent, its write_scope method is called first. FOR_MAIN is
true when computing the name of 'main'; see full_name. */
a parent, its write_scope method is called first. See full_name
for a description of the FOR_MAIN and FOR_ADA_LINKAGE
parameters. */
void write_scope (struct obstack *storage, const char *sep,
bool for_main) const;
bool for_main, bool for_ada_linkage) const;
/* The parent entry. This is NULL for top-level entries.
Otherwise, it points to the parent entry, such as a namespace or