Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Cc: Joel Brobecker <brobecker@adacore.com>
Subject: [RFA/commit] Rename la_get_symbol_name_match_p into la_get_symbol_name_cmp
Date: Mon, 30 Jan 2012 06:57:00 -0000	[thread overview]
Message-ID: <1327906522-19961-1-git-send-email-brobecker@adacore.com> (raw)

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


             reply	other threads:[~2012-01-30  6:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-30  6:57 Joel Brobecker [this message]
2012-01-30  7:14 ` Jan Kratochvil
2012-01-30  8:50   ` Joel Brobecker
2012-01-30 11:36     ` Pedro Alves
2012-01-30 11:53       ` Joel Brobecker
2012-01-30 13:58         ` Pedro Alves
2012-02-03  8:15     ` FYI: " Joel Brobecker
2012-02-08 19:55       ` Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1327906522-19961-1-git-send-email-brobecker@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox