diff options
author | Tom Tromey <tromey@adacore.com> | 2024-09-03 12:53:07 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2025-03-06 14:17:18 -0700 |
commit | aab26529b304aed62095e47248a6b5e1c7590fdc (patch) | |
tree | 45ee0b3ff36d784adb1ad1ba151b15a5a2121890 | |
parent | c70ac07a791bf50ae9322a3096a3b8b1220e60c9 (diff) | |
download | binutils-aab26529b304aed62095e47248a6b5e1c7590fdc.zip binutils-aab26529b304aed62095e47248a6b5e1c7590fdc.tar.gz binutils-aab26529b304aed62095e47248a6b5e1c7590fdc.tar.bz2 |
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.
-rw-r--r-- | gdb/dwarf2/cooked-index.c | 20 | ||||
-rw-r--r-- | gdb/dwarf2/cooked-index.h | 16 |
2 files changed, 26 insertions, 10 deletions
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index f630d34..2ffa831 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -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)); } diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index c47f84e..68407c8 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -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 |