+2012-01-26 Joel Brobecker <brobecker@adacore.com>
+
+ * language.h (symbol_name_match_p_ftype): New typedef.
+ (struct language_defn): Replace field la_symbol_name_compare
+ by la_get_symbol_name_match_p.
+ * ada-lang.c (ada_get_symbol_name_match_p): New function.
+ (ada_language_defn): Use it.
+ * linespec.c (struct symbol_matcher_data): New type.
+ (iterate_name_matcher): Rewrite.
+ (iterate_over_all_matching_symtabs): Pass a pointer to
+ a symbol_matcher_data struct to expand_symtabs_matching
+ instead of just the lookup name.
+ * c-lang.c, d-lang.c, jv-lang.c, m2-lang.c, objc-lang.c,
+ opencl-lang.c, p-lang.c, language.c: Delete field
+ la_symbol_name_compare, and replace by NULL for new field
+ la_get_symbol_name_match_p.
+ * symfile.h (struct quick_symbol_functions): Update comment.
+
2012-01-25 Tom Tromey <tromey@redhat.com>
* breakpoint.c (bpstat_stop_status): Check 'breakpoint_at' before
ada_evaluate_subexp
};
+/* Implement the "la_get_symbol_name_match_p" language_defn method
+ for Ada. */
+
+static symbol_name_match_p_ftype
+ada_get_symbol_name_match_p (const char *lookup_name)
+{
+ if (should_use_wild_match (lookup_name))
+ return wild_match;
+ else
+ return compare_names;
+}
+
const struct language_defn ada_language_defn = {
"ada", /* Language name */
language_ada,
ada_print_array_index,
default_pass_by_reference,
c_get_string,
- compare_names,
+ ada_get_symbol_name_match_p, /* la_get_symbol_name_match_p */
ada_iterate_over_symbols,
LANG_MAGIC
};
default_print_array_index,
default_pass_by_reference,
c_get_string,
- strcmp_iw_ordered,
+ NULL, /* la_get_symbol_name_match_p */
iterate_over_symbols,
LANG_MAGIC
};
default_print_array_index,
cp_pass_by_reference,
c_get_string,
- strcmp_iw_ordered,
+ NULL, /* la_get_symbol_name_match_p */
iterate_over_symbols,
LANG_MAGIC
};
default_print_array_index,
default_pass_by_reference,
c_get_string,
- strcmp_iw_ordered,
+ NULL, /* la_get_symbol_name_match_p */
iterate_over_symbols,
LANG_MAGIC
};
default_print_array_index,
default_pass_by_reference,
c_get_string,
- strcmp_iw_ordered,
+ NULL, /* la_get_symbol_name_match_p */
iterate_over_symbols,
LANG_MAGIC
};
default_print_array_index,
default_pass_by_reference,
c_get_string,
- strcmp_iw_ordered,
+ NULL, /* la_get_symbol_name_match_p */
NULL,
LANG_MAGIC
};
default_print_array_index,
default_pass_by_reference,
default_get_string,
- strcmp_iw_ordered,
+ NULL, /* la_get_symbol_name_match_p */
iterate_over_symbols,
LANG_MAGIC
};
default_print_array_index,
default_pass_by_reference,
default_get_string,
- strcmp_iw_ordered,
+ NULL, /* la_get_symbol_name_match_p */
iterate_over_symbols,
LANG_MAGIC
};
default_print_array_index,
default_pass_by_reference,
default_get_string,
- strcmp_iw_ordered,
+ NULL, /* la_get_symbol_name_match_p */
iterate_over_symbols,
LANG_MAGIC
};
default_print_array_index,
default_pass_by_reference,
default_get_string,
- strcmp_iw_ordered,
+ NULL, /* la_get_symbol_name_match_p */
iterate_over_symbols,
LANG_MAGIC
};
default_print_array_index,
default_pass_by_reference,
default_get_string,
- strcmp_iw_ordered,
+ NULL, /* la_get_symbol_name_match_p */
iterate_over_symbols,
LANG_MAGIC
};
struct type *bool_type_default;
};
+/* A pointer to a function expected to return nonzero if
+ SYMBOL_SEARCH_NAME matches the given LOOKUP_NAME.
+
+ SYMBOL_SEARCH_NAME should be a symbol's "search" name.
+ LOOKUP_NAME should be the name of an entity after it has been
+ transformed for lookup. */
+
+typedef int (*symbol_name_match_p_ftype) (const char *symbol_search_name,
+ const char *lookup_name);
+
/* Structure tying together assorted information about a language. */
struct language_defn
void (*la_get_string) (struct value *value, gdb_byte **buffer, int *length,
struct type **chartype, const char **charset);
- /* Compare two symbol names according to language rules. For
- instance, in C++, we might want to ignore whitespaces in
- the symbol name. Or some case-insensitive language might
- want to ignore casing during the match.
-
- Both STR1 and STR2 are expected to be demangled name, except
- for Ada, where STR1 and STR2 are expected to be encoded names.
- The latter is because searches are performed using the encoded
- name in Ada.
-
- The return value follows the same spirit as strcmp. */
+ /* Return a pointer to the function that should be used to match
+ a symbol name against LOOKUP_NAME. This is mostly for languages
+ such as Ada where the matching algorithm depends on LOOKUP_NAME.
- int (*la_symbol_name_compare) (const char *str1, const char *str2);
+ This field may be NULL, in which case strcmp_iw will be used
+ to perform the matching. */
+ symbol_name_match_p_ftype (*la_get_symbol_name_match_p)
+ (const char *lookup_name);
/* Find all symbols in the current program space matching NAME in
DOMAIN, according to this language's rules.
throw_error (NOT_FOUND_ERROR, "%s", message);
}
+/* Some data for the expand_symtabs_matching callback. */
+
+struct symbol_matcher_data
+{
+ /* The lookup name against which symbol name should be compared. */
+ const char *lookup_name;
+
+ /* The routine to be used for comparison. */
+ symbol_name_match_p_ftype symbol_name_match_p;
+};
+
/* A helper for iterate_over_all_matching_symtabs that is passed as a
callback to the expand_symtabs_matching method. */
iterate_name_matcher (const struct language_defn *language,
const char *name, void *d)
{
- const char **dname = d;
+ const struct symbol_matcher_data *data = d;
- if (language->la_symbol_name_compare (name, *dname) == 0)
+ if (data->symbol_name_match_p (name, data->lookup_name))
return 1;
return 0;
}
{
struct objfile *objfile;
struct program_space *pspace;
+ struct symbol_matcher_data matcher_data;
+
+ matcher_data.lookup_name = name;
+ matcher_data.symbol_name_match_p =
+ current_language->la_get_symbol_name_match_p != NULL
+ ? current_language->la_get_symbol_name_match_p (name)
+ : strcmp_iw;
ALL_PSPACES (pspace)
{
objfile->sf->qf->expand_symtabs_matching (objfile, NULL,
iterate_name_matcher,
ALL_DOMAIN,
- &name);
+ &matcher_data);
ALL_OBJFILE_SYMTABS (objfile, symtab)
{
default_print_array_index,
default_pass_by_reference,
default_get_string,
- strcmp_iw_ordered,
+ NULL, /* la_get_symbol_name_match_p */
iterate_over_symbols,
LANG_MAGIC
};
default_print_array_index,
default_pass_by_reference,
default_get_string,
- strcmp_iw_ordered,
+ NULL, /* la_get_symbol_name_match_p */
iterate_over_symbols,
LANG_MAGIC
};
default_print_array_index,
default_pass_by_reference,
c_get_string,
- strcmp_iw_ordered,
+ NULL, /* la_get_symbol_name_match_p */
iterate_over_symbols,
LANG_MAGIC
};
default_print_array_index,
default_pass_by_reference,
default_get_string,
- strcmp_iw_ordered,
+ NULL, /* la_get_symbol_name_match_p */
iterate_over_symbols,
LANG_MAGIC
};
file is skipped. If FILE_MATCHER is NULL such file is not skipped.
Otherwise, if KIND does not match this symbol is skipped.
-
+
If even KIND matches, then NAME_MATCHER is called for each symbol
- defined in the file. The current language, the symbol name and
- DATA are passed to NAME_MATCHER. The symbol "search" name should
- be passed to NAME_MATCHER (see la_symbol_name_compare in struct
- language_defn for more details on this).
+ defined in the file. The current language, the symbol "search"
+ name and DATA are passed to NAME_MATCHER.
If NAME_MATCHER returns zero, then this symbol is skipped.