aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf-index-write.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2019-07-08 06:23:16 -0600
committerTom Tromey <tromey@adacore.com>2019-09-10 08:30:45 -0600
commit3b00ef10a2a4750a86a04bb66eda3bf33d298be1 (patch)
tree727c40c0df3bfc1a1da24df5e4d5162067b5c13a /gdb/dwarf-index-write.c
parentaa3916548076c159ae00a922690694094a37fcd0 (diff)
downloadgdb-3b00ef10a2a4750a86a04bb66eda3bf33d298be1.zip
gdb-3b00ef10a2a4750a86a04bb66eda3bf33d298be1.tar.gz
gdb-3b00ef10a2a4750a86a04bb66eda3bf33d298be1.tar.bz2
Add Ada support for .debug_names
This patch adds support for Ada to .debug_names. I opted to leave .gdb_index alone, because in my view it is a defunct format. gdb/ChangeLog 2019-09-10 Tom Tromey <tromey@adacore.com> * dwarf-index-write.c (write_psymbols): Extend error message. (debug_names::insert): Add Ada code. (debug_names::write_psymbols): Remove Ada check. (debug_names) <m_string_obstack>: New member. * dwarf2read.c (gdb_index_symbol_name_matcher): Remove. (gdb_index_symbol_name_matcher::matches): Remove. (mapped_index_base::find_name_components_bounds): Add "lang" parameter. (mapped_index_base::build_name_components): Also split names according to Ada syntax. (dw2_expand_symtabs_matching_symbol): Loop over languages. Change type of "match_callback". (check_match, check_find_bounds_finds) (dw2_expand_symtabs_matching): Update. (dw2_debug_names_iterator): Add new constructor. (dw2_debug_names_map_matching_symbols): New function. (dw2_debug_names_expand_symtabs_matching): Update. (dwarf2_debug_names_functions): Use dw2_debug_names_map_matching_symbols.
Diffstat (limited to 'gdb/dwarf-index-write.c')
-rw-r--r--gdb/dwarf-index-write.c48
1 files changed, 43 insertions, 5 deletions
diff --git a/gdb/dwarf-index-write.c b/gdb/dwarf-index-write.c
index 7d59a1b..153c679 100644
--- a/gdb/dwarf-index-write.c
+++ b/gdb/dwarf-index-write.c
@@ -34,6 +34,7 @@
#include "gdbcmd.h"
#include "objfiles.h"
#include "psympriv.h"
+#include "ada-lang.h"
#include <algorithm>
#include <cmath>
@@ -541,7 +542,8 @@ write_psymbols (struct mapped_symtab *symtab,
struct partial_symbol *psym = *psymp;
if (psym->ginfo.language == language_ada)
- error (_("Ada is not currently supported by the index"));
+ error (_("Ada is not currently supported by the index; "
+ "use the DWARF 5 index instead"));
/* Only add a given psymbol once. */
if (psyms_seen.insert (psym).second)
@@ -684,7 +686,43 @@ public:
const int dwarf_tag = psymbol_tag (psym);
if (dwarf_tag == 0)
return;
- const char *const name = symbol_search_name (&psym->ginfo);
+ const char *name = symbol_search_name (&psym->ginfo);
+
+ if (psym->ginfo.language == 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 (strcmp (main_name (), name) == 0)
+ {
+ const auto insertpair
+ = m_name_to_value_set.emplace (c_str_view (name),
+ std::set<symbol_value> ());
+ std::set<symbol_value> &value_set = insertpair.first->second;
+ value_set.emplace (symbol_value (dwarf_tag, cu_index, is_static,
+ kind));
+ }
+
+ /* 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 "<MumBle>") must be entered without the
+ angle brackets. Note that the current index is unusual,
+ see PR symtab/24820 for details. */
+ const char *decoded = ada_decode (name);
+ if (decoded[0] == '<')
+ name = (char *) obstack_copy0 (&m_string_obstack,
+ decoded + 1,
+ strlen (decoded + 1) - 1);
+ else
+ name = obstack_strdup (&m_string_obstack, ada_encode (decoded));
+ }
+
const auto insertpair
= m_name_to_value_set.emplace (c_str_view (name),
std::set<symbol_value> ());
@@ -1181,9 +1219,6 @@ private:
{
struct partial_symbol *psym = *psymp;
- if (psym->ginfo.language == language_ada)
- error (_("Ada is not currently supported by the index"));
-
/* Only add a given psymbol once. */
if (psyms_seen.insert (psym).second)
insert (psym, cu_index, is_static, kind);
@@ -1244,6 +1279,9 @@ private:
/* .debug_names entry pool. */
data_buf m_entry_pool;
+
+ /* Temporary storage for Ada names. */
+ auto_obstack m_string_obstack;
};
/* Return iff any of the needed offsets does not fit into 32-bit