This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA/commit] Rename la_get_symbol_name_match_p into la_get_symbol_name_cmp


Hello,

Re: [patch] Fix the 2012-01-26 regression by la_get_symbol_name_match_p
    [Re: Crash regression gdb.cp/no-dmgl-verbose.exp]
    http://www.sourceware.org/ml/gdb-patches/2012-01/msg00956.html

The la_get_symbol_name_match_p language hook was poorly named, as
it suggested that the function should return nonzero if the names
match, whereas it is the exact opposite.  This patch therefore
renames the hook and associated typedef, as well some of the code
that uses that hook.

gdb/ChangeLog:

        * language.h (symbol_name_cmp_ftype): Renames
        symbol_name_match_p_ftype.  Update documentation.
        (struct language_defn) [la_get_symbol_name_cmp]: Renames
        la_get_symbol_name_match_p.  Update documentation.
        * ada-lang.c (ada_get_symbol_name_cmp): Renames
        ada_get_symbol_name_match_p.
        (ada_language_defn): Replace ada_get_symbol_name_match_p by
        ada_get_symbol_name_cmp.
        * linespec.c (struct symbol_matcher_data) [symbol_name_cmp]:
        Renames symbol_name_match_p.
        (iterate_name_matcher, iterate_over_all_matching_symtabs):
        Update.

Tested on x86_64-linux, no regression. I'd like to commit that, unless
there are better naming suggestions?

Thanks,
-- 
Joel

---
 gdb/ada-lang.c |    6 +++---
 gdb/language.h |   15 +++++++++------
 gdb/linespec.c |   10 +++++-----
 3 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 94178d3..07326e3 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12385,8 +12385,8 @@ static const struct exp_descriptor ada_exp_descriptor = {
 /* 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)
+static symbol_name_cmp_ftype
+ada_get_symbol_name_cmp (const char *lookup_name)
 {
   if (should_use_wild_match (lookup_name))
     return wild_match;
@@ -12430,7 +12430,7 @@ const struct language_defn ada_language_defn = {
   ada_print_array_index,
   default_pass_by_reference,
   c_get_string,
-  ada_get_symbol_name_match_p,	/* la_get_symbol_name_match_p */
+  ada_get_symbol_name_cmp,	/* la_get_symbol_name_match_p */
   ada_iterate_over_symbols,
   LANG_MAGIC
 };
diff --git a/gdb/language.h b/gdb/language.h
index 7a1bcb7..7bfeffe 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -136,15 +136,19 @@ struct language_arch_info
   struct type *bool_type_default;
 };
 
-/* A pointer to a function expected to return nonzero if
+/* A pointer to a function expected to return zero iff
    SYMBOL_SEARCH_NAME matches the given LOOKUP_NAME.
+   Return nonzero otherwise.
+
+   Despite what the name might suggest, there is no ordering involved.
+   If the names do not match, any non-zero return value is correct.
 
    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);
+typedef int (*symbol_name_cmp_ftype) (const char *symbol_search_name,
+				      const char *lookup_name);
 
 /* Structure tying together assorted information about a language.  */
 
@@ -328,14 +332,13 @@ struct language_defn
     void (*la_get_string) (struct value *value, gdb_byte **buffer, int *length,
 			   struct type **chartype, const char **charset);
 
-    /* Return a pointer to the function that should be used to match
+    /* Return a pointer to the function that should be used to compare
        a symbol name against LOOKUP_NAME. This is mostly for languages
        such as Ada where the matching algorithm depends on LOOKUP_NAME.
 
        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);
+    symbol_name_cmp_ftype (*la_get_symbol_name_cmp) (const char *lookup_name);
 
     /* Find all symbols in the current program space matching NAME in
        DOMAIN, according to this language's rules.
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 50ebf6f..034ffa8 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -329,7 +329,7 @@ struct symbol_matcher_data
   const char *lookup_name;
 
   /* The routine to be used for comparison.  */
-  symbol_name_match_p_ftype symbol_name_match_p;
+  symbol_name_cmp_ftype symbol_name_cmp;
 };
 
 /* A helper for iterate_over_all_matching_symtabs that is passed as a
@@ -340,7 +340,7 @@ iterate_name_matcher (const char *name, void *d)
 {
   const struct symbol_matcher_data *data = d;
 
-  if (data->symbol_name_match_p (name, data->lookup_name) == 0)
+  if (data->symbol_name_cmp (name, data->lookup_name) == 0)
     return 1;
   return 0;
 }
@@ -362,9 +362,9 @@ iterate_over_all_matching_symtabs (const char *name,
   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)
+  matcher_data.symbol_name_cmp =
+    current_language->la_get_symbol_name_cmp != NULL
+    ? current_language->la_get_symbol_name_cmp (name)
     : strcmp_iw;
 
   ALL_PSPACES (pspace)
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]