try --- gdb/dwarf2/index-write.c | 34 ++++++++++++++++++++++++++++++---- gdb/dwarf2/read.c | 12 ------------ 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index eabfe5d682..3e83e3ae2c 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -543,18 +543,44 @@ write_psymbols (struct mapped_symtab *symtab, for (; count-- > 0; ++psymp) { struct partial_symbol *psym = *psymp; + const char *name = psym->ginfo.search_name (); if (psym->ginfo.language () == language_ada) - error (_("Ada is not currently supported by the index; " - "use the DWARF 5 index instead")); + { + /* 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 (strcmp (main_name (), name) == 0) + { + gdb_index_symbol_kind kind = symbol_kind (psym); + + add_index_entry (symtab, name, is_static, kind, cu_index); + } + + /* In order for the index to work when read back into gdb, it + has to supply a funny form of the name: it should be the + encoded name, with any suffixes stripped. Using the + ordinary encoded name will not work properly with the + searching logic in find_name_components_bounds; nor will + using the decoded name. Furthermore, an Ada "verbatim" + name (of the form "") must be entered without the + angle brackets. Note that the current index is unusual, + see PR symtab/24820 for details. */ + std::string decoded = ada_decode (name); + if (decoded[0] == '<') + name = (char *) strndup (decoded.c_str () + 1, decoded.length () - 2); + else + name = strdup (ada_encode (decoded.c_str ())); + } /* Only add a given psymbol once. */ if (psyms_seen.insert (psym).second) { gdb_index_symbol_kind kind = symbol_kind (psym); - add_index_entry (symtab, psym->ginfo.search_name (), - is_static, kind, cu_index); + add_index_entry (symtab, name, is_static, kind, cu_index); } } } diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index ded71f53b5..d25e8ecb8c 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -4514,7 +4514,6 @@ dw2_expand_marked_cus search_domain kind) { offset_type *vec, vec_len, vec_idx; - bool global_seen = false; mapped_index &index = *dwarf2_per_objfile->index_table; vec = (offset_type *) (index.constant_pool @@ -4523,8 +4522,6 @@ dw2_expand_marked_cus for (vec_idx = 0; vec_idx < vec_len; ++vec_idx) { offset_type cu_index_and_attrs = MAYBE_SWAP (vec[vec_idx + 1]); - /* This value is only valid for index versions >= 7. */ - int is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu_index_and_attrs); gdb_index_symbol_kind symbol_kind = GDB_INDEX_SYMBOL_KIND_VALUE (cu_index_and_attrs); int cu_index = GDB_INDEX_CU_VALUE (cu_index_and_attrs); @@ -4536,15 +4533,6 @@ dw2_expand_marked_cus (index.version >= 7 && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE); - /* Work around gold/15646. */ - if (attrs_valid) - { - if (!is_static && global_seen) - continue; - if (!is_static) - global_seen = true; - } - /* Only check the symbol's kind if it has one. */ if (attrs_valid) {