aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/index-write.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-09-22 08:43:47 -0600
committerTom Tromey <tromey@adacore.com>2022-10-17 08:01:39 -0600
commit5fea97943259a2bd997f92ffa66116b5c0d4eaab (patch)
tree9092b5386d358ff88a47b7394083533cb64b50ab /gdb/dwarf2/index-write.c
parentacd121de32c3924347f228d8f27000a09b9c8949 (diff)
downloadgdb-5fea97943259a2bd997f92ffa66116b5c0d4eaab.zip
gdb-5fea97943259a2bd997f92ffa66116b5c0d4eaab.tar.gz
gdb-5fea97943259a2bd997f92ffa66116b5c0d4eaab.tar.bz2
Improve Ada support in .gdb_index
The cooked index work changed how .gdb_index is constructed, and in the process broke .gdb_index support. This is PR symtab/29179. This patch partially fixes the problem. It arranges for Ada names to be encoded in the form expected by the index code. In particular, linkage names for Ada are emitted, including the "main" name; names are Ada-encoded; and names are no longer case-folded, something that prevented operator names from round-tripping correctly. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29179
Diffstat (limited to 'gdb/dwarf2/index-write.c')
-rw-r--r--gdb/dwarf2/index-write.c44
1 files changed, 35 insertions, 9 deletions
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index 4f89dfb..6b4052c 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -1109,22 +1109,48 @@ write_cooked_index (cooked_index_vector *table,
htab_up var_names (htab_create_alloc (10, htab_hash_string, htab_eq_string,
nullptr, xcalloc, xfree));
+ const char *main_for_ada = main_name ();
+
for (const cooked_index_entry *entry : table->all_entries ())
{
- /* GDB never put C++ linkage names into .gdb_index. The theory
- here is that a linkage name will normally be in the minimal
- symbols anyway, so including it in the index is usually
- redundant -- and the cases where it would not be redundant
- are rare and not worth supporting. */
- if (entry->per_cu->lang () == language_cplus
- && (entry->flags & IS_LINKAGE) != 0)
- continue;
-
const auto it = cu_index_htab.find (entry->per_cu);
gdb_assert (it != cu_index_htab.cend ());
const char *name = entry->full_name (&symtab->m_string_obstack);
+ if (entry->per_cu->lang () == language_ada)
+ {
+ /* We want to ensure that the Ada main function's name
+ appears verbatim in the index. However, this name will
+ be of the form "_ada_mumble", and will be rewritten by
+ ada_decode. So, recognize it specially here and add it
+ to the index by hand. */
+ if (entry->tag == DW_TAG_subprogram
+ && strcmp (main_for_ada, name) == 0)
+ {
+ /* Leave it alone. */
+ }
+ else
+ {
+ /* In order for the index to work when read back into
+ gdb, it has to use the encoded name, with any
+ suffixes stripped. */
+ std::string encoded = ada_encode (name, false);
+ name = obstack_strdup (&symtab->m_string_obstack,
+ encoded.c_str ());
+ }
+ }
+ else if (entry->per_cu->lang () == language_cplus
+ && (entry->flags & IS_LINKAGE) != 0)
+ {
+ /* GDB never put C++ linkage names into .gdb_index. The
+ theory here is that a linkage name will normally be in
+ the minimal symbols anyway, so including it in the index
+ is usually redundant -- and the cases where it would not
+ be redundant are rare and not worth supporting. */
+ continue;
+ }
+
gdb_index_symbol_kind kind;
if (entry->tag == DW_TAG_subprogram)
kind = GDB_INDEX_SYMBOL_KIND_FUNCTION;