aboutsummaryrefslogtreecommitdiff
path: root/gdb/buildsym.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-11-08 15:07:56 +0000
committerPedro Alves <palves@redhat.com>2017-11-08 16:02:24 +0000
commit5ffa0793690b42b2a0c1c21dbb5e64634e58fa00 (patch)
tree08f6c4540b28cefd8f8ae67386c9af8ed455c0a0 /gdb/buildsym.c
parent2a1dde5da23779fd0d269c3e51c7814aba9001dd (diff)
downloadfsf-binutils-gdb-5ffa0793690b42b2a0c1c21dbb5e64634e58fa00.zip
fsf-binutils-gdb-5ffa0793690b42b2a0c1c21dbb5e64634e58fa00.tar.gz
fsf-binutils-gdb-5ffa0793690b42b2a0c1c21dbb5e64634e58fa00.tar.bz2
Per-language symbol name hashing algorithm
Currently, we have a mess of symbol name hashing/comparison routines. There's msymbol_hash for mangled names, and dict_hash and msymbol_hash_iw for demangled names. Then there's strcmp_iw, strcmp_iw_ordered and Ada's full_match/wild_match, which all have to agree with the hashing routines. That's why dict_hash is really about Ada names. From the inconsistency department, minimal symbol hashing doesn't go via dict_hash, so Ada's wild matching can't ever work with minimal symbols. This patch starts fixing this, by doing two things: #1 - adds a language vector method to let each language decide how to compute a symbol name hash. #2 - makes dictionaries know the language of the symbols they hold, and then use the dictionaries language to decide which hashing method to use. For now, this is just scaffolding, since all languages install the default method. The series will make C++ install its own hashing method later on, and will add per-language symbol name comparison routines too. This patch was originally based on a patch that Keith wrote for the libcc1/C++ WIP support. gdb/ChangeLog: 2017-11-08 Keith Seitz <keiths@redhat.com> Pedro Alves <palves@redhat.com> * ada-lang.c (ada_language_defn): Install default_search_name_hash. * buildsym.c (struct buildsym_compunit): <language>: New field. (finish_block_internal): Pass language when creating dictionaries. (start_buildsym_compunit, start_symtab): New language parameters. Use them. (restart_symtab): Pass down compilation unit's language. * buildsym.h (enum language): Forward declare. (start_symtab): New 'language' parameter. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Install default_search_name_hash. * coffread.c (coff_start_symtab): Adjust. * d-lang.c (d_language_defn): Install default_search_name_hash. * dbxread.c (struct symloc): Add 'pst_language' field. (PST_LANGUAGE): Define. (start_psymtab, read_ofile_symtab): Use it. (process_one_symbol): New 'language' parameter. Pass it down. * dictionary.c (struct dictionary) <language>: New field. (DICT_LANGUAGE): Define. (dict_create_hashed, dict_create_hashed_expandable) (dict_create_linear, dict_create_linear_expandable): New parameter 'language'. Set the dictionary's language. (iter_match_first_hashed): Adjust to rename. (insert_symbol_hashed): Assert we don't see mismatching languages. Adjust to rename. (dict_hash): Rename to ... (default_search_name_hash): ... this and make extern. * dictionary.h (struct language_defn): Forward declare. (dict_create_hashed): New parameter 'language'. * dwarf2read.c (dwarf2_start_symtab): Pass down language. * f-lang.c (f_language_defn): Install default_search_name_hash. * go-lang.c (go_language_defn): Install default_search_name_hash. * jit.c (finalize_symtab): Pass compunit's language to dictionary creation. * language.c (unknown_language_defn, auto_language_defn): * language.h (language_defn::la_search_name_hash): New field. (default_search_name_hash): Declare. * m2-lang.c (m2_language_defn): Install default_search_name_hash. * mdebugread.c (new_block): New parameter 'language'. * mdebugread.c (parse_symbol): Pass symbol language to block allocation. (psymtab_to_symtab_1): Pass down language. (new_symtab): Pass compunit's language to block allocation. * objc-lang.c (objc_language_defn): Install default_search_name_hash. * opencl-lang.c (opencl_language_defn): * p-lang.c (pascal_language_defn): Install default_search_name_hash. * rust-lang.c (rust_language_defn): Install default_search_name_hash. * stabsread.h (enum language): Forward declare. (process_one_symbol): Add 'language' parameter. * symtab.c (search_name_hash): New function. * symtab.h (search_name_hash): Declare. * xcoffread.c (read_xcoff_symtab): Pass language to start_symtab.
Diffstat (limited to 'gdb/buildsym.c')
-rw-r--r--gdb/buildsym.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index d07bfb3..e3f281a 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -125,6 +125,9 @@ struct buildsym_compunit
/* The compunit we are building. */
struct compunit_symtab *compunit_symtab;
+
+ /* Language of this compunit_symtab. */
+ enum language language;
};
/* The work-in-progress of the compunit we are building.
@@ -346,20 +349,23 @@ finish_block_internal (struct symbol *symbol,
if (symbol)
{
- BLOCK_DICT (block) = dict_create_linear (&objfile->objfile_obstack,
- *listhead);
+ BLOCK_DICT (block)
+ = dict_create_linear (&objfile->objfile_obstack,
+ buildsym_compunit->language, *listhead);
}
else
{
if (expandable)
{
- BLOCK_DICT (block) = dict_create_hashed_expandable ();
+ BLOCK_DICT (block)
+ = dict_create_hashed_expandable (buildsym_compunit->language);
dict_add_pending (BLOCK_DICT (block), *listhead);
}
else
{
BLOCK_DICT (block) =
- dict_create_hashed (&objfile->objfile_obstack, *listhead);
+ dict_create_hashed (&objfile->objfile_obstack,
+ buildsym_compunit->language, *listhead);
}
}
@@ -763,7 +769,8 @@ start_subfile (const char *name)
(or NULL if not known). */
static struct buildsym_compunit *
-start_buildsym_compunit (struct objfile *objfile, const char *comp_dir)
+start_buildsym_compunit (struct objfile *objfile, const char *comp_dir,
+ enum language language)
{
struct buildsym_compunit *bscu;
@@ -772,6 +779,7 @@ start_buildsym_compunit (struct objfile *objfile, const char *comp_dir)
bscu->objfile = objfile;
bscu->comp_dir = (comp_dir == NULL) ? NULL : xstrdup (comp_dir);
+ bscu->language = language;
/* Initialize the debug format string to NULL. We may supply it
later via a call to record_debugformat. */
@@ -1036,17 +1044,20 @@ prepare_for_building (const char *name, CORE_ADDR start_addr)
TAG_compile_unit DIE is seen. It indicates the start of data for
one original source file.
- NAME is the name of the file (cannot be NULL). COMP_DIR is the directory in
- which the file was compiled (or NULL if not known). START_ADDR is the
- lowest address of objects in the file (or 0 if not known). */
+ NAME is the name of the file (cannot be NULL). COMP_DIR is the
+ directory in which the file was compiled (or NULL if not known).
+ START_ADDR is the lowest address of objects in the file (or 0 if
+ not known). LANGUAGE is the language of the source file, or
+ language_unknown if not known, in which case it'll be deduced from
+ the filename. */
struct compunit_symtab *
start_symtab (struct objfile *objfile, const char *name, const char *comp_dir,
- CORE_ADDR start_addr)
+ CORE_ADDR start_addr, enum language language)
{
prepare_for_building (name, start_addr);
- buildsym_compunit = start_buildsym_compunit (objfile, comp_dir);
+ buildsym_compunit = start_buildsym_compunit (objfile, comp_dir, language);
/* Allocate the compunit symtab now. The caller needs it to allocate
non-primary symtabs. It is also needed by get_macro_table. */
@@ -1083,7 +1094,8 @@ restart_symtab (struct compunit_symtab *cust,
prepare_for_building (name, start_addr);
buildsym_compunit = start_buildsym_compunit (COMPUNIT_OBJFILE (cust),
- COMPUNIT_DIRNAME (cust));
+ COMPUNIT_DIRNAME (cust),
+ compunit_language (cust));
buildsym_compunit->compunit_symtab = cust;
}