public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFC] allow unqualified function names in linespecs
@ 2011-12-14 14:36 Joel Brobecker
  2011-12-20 15:24 ` Tom Tromey
  0 siblings, 1 reply; 24+ messages in thread
From: Joel Brobecker @ 2011-12-14 14:36 UTC (permalink / raw)
  To: gdb-patches; +Cc: Joel Brobecker

This is just a proof of concept patch that shows that, for Ada, we
need two kinds of symbol-matching routines when iterating over all
partial symbols.

The approach we currently implement is the full-match. In other words,
to break on function Foo inside package Pck, you do:

    (gdb) break pck.foo

But there are situation where it's either convenient or necessary to
avoid the fully-qualified name, and use the "simple" name instead.
For instance:

    (gdb) break foo

In that situation, using a full-name match as we do while iterating
over the partial symtab isn't going to work.  As it happens, though,
we usually do not see the problem at the user-level. We get lucky,
enjoying the side-effects of a call cp_canonicalize_string_no_typedefs,
which indirectly causes us to perform an Ada lookup which itself
causes the matching partial psymtabs to be expanded to full symtabs.

Ignoring the fact that calling cp_canonicalize_string_no_typedefs
when the current language is Ada seems wrong (I will propose we fix
that in a followup patch), there is in fact a situation where we do
see a problem. This is when inserting a breakpoint on an Ada operator.
For instance:

    (gdb) b "+"
    Function ""+"" not defined.
    Make breakpoint pending on future shared library load? (y or [n]) n

What this patch does is something that I feel should be hidden
inside ada-lang. Namely, decide which matching routine to use based
on the name we are using to search for matches. I think that the
real question is to trying to find the proper interface for this.

In the end, I don't think that the la_symbol_name_compare method
as I designed it worked for us. It was convenient, because we could
just use strcmp_iw_ordered as the default and ada-lang.c:compare_names
for Ada. But it doesn't do enough.

A few ideas crossed my mind:

  . Have Ada's la_symbol_name_compare check the reference name and
    determine at each call whether to do a wild match, or a full
    match.  But I don't think that this is a reasonable solution
    for performance reasons;

  . Use a compare routine that always performs the "wild" matches,
    even in the case where a full match should have been used.
    I think it's better, but still has an unwanted performance cost.
    Maybe it small enough to be ignored, but maybe not. I am
    particularly worried about the large programs that are so common
    with Ada applications.

  . Redesign a bit the interface.  For instance, let the language
    itself iterate over all partial symbols? The default implementation
    would do what we already do. The Ada implementation would do
    something else, not sure what yet.  And we could get rid of
    the la_symbol_name_compare method.

Thoughts?

No ChangeLog provided as this patch is not meant to be checked in.

---
 gdb/ada-lang.c |    4 +---
 gdb/ada-lang.h |    2 ++
 gdb/linespec.c |   18 +++++++++++++++++-
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 30a561d..aeb2850 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -203,8 +203,6 @@ static int is_name_suffix (const char *);
 
 static int advance_wild_match (const char **, const char *, int);
 
-static int wild_match (const char *, const char *);
-
 static struct value *ada_coerce_ref (struct value *);
 
 static LONGEST pos_atr (struct value *);
@@ -5364,7 +5362,7 @@ advance_wild_match (const char **namep, const char *name0, int target0)
    informational suffixes of NAME (i.e., for which is_name_suffix is
    true).  Assumes that PATN is a lower-cased Ada simple name.  */
 
-static int
+int
 wild_match (const char *name, const char *patn)
 {
   const char *p, *n;
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index fa4bb51..7a91f70 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -367,6 +367,8 @@ extern char *ada_main_name (void);
 
 extern char *ada_name_for_lookup (const char *name);
 
+extern int wild_match (const char *name, const char *patn);
+
 /* Tasking-related: ada-tasks.c */
 
 extern int valid_task_id (int);
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 0d9d759..0dde714 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -340,6 +340,15 @@ iterate_name_matcher (const struct language_defn *language,
   return 0;
 }
 
+static int
+iterate_wild_name_matcher (const struct language_defn *language,
+			   const char *name, void *d)
+{
+  const char **dname = d;
+
+  return wild_match (name, *dname) == 0;
+}
+
 /* A helper that walks over all matching symtabs in all objfiles and
    calls CALLBACK for each symbol matching NAME.  If SEARCH_PSPACE is
    not NULL, then the search is restricted to just that program
@@ -354,6 +363,13 @@ iterate_over_all_matching_symtabs (const char *name,
 {
   struct objfile *objfile;
   struct program_space *pspace;
+  int (*name_matcher) (const struct language_defn *, const char *, void *)
+    = iterate_name_matcher;
+
+  if (current_language->la_language == language_ada
+      && strstr (name, "__") == NULL)
+    /* Perform a wild match instead of a full match.  */
+    name_matcher = iterate_wild_name_matcher;
 
   ALL_PSPACES (pspace)
   {
@@ -370,7 +386,7 @@ iterate_over_all_matching_symtabs (const char *name,
 
       if (objfile->sf)
 	objfile->sf->qf->expand_symtabs_matching (objfile, NULL,
-						  iterate_name_matcher,
+						  name_matcher,
 						  ALL_DOMAIN,
 						  &name);
 
-- 
1.7.1

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [RFC] allow unqualified function names in linespecs
  2011-12-14 14:36 [RFC] allow unqualified function names in linespecs Joel Brobecker
@ 2011-12-20 15:24 ` Tom Tromey
  2011-12-21 14:08   ` Joel Brobecker
  0 siblings, 1 reply; 24+ messages in thread
From: Tom Tromey @ 2011-12-20 15:24 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> But there are situation where it's either convenient or necessary to
Joel> avoid the fully-qualified name, and use the "simple" name instead.
Joel> For instance:
Joel>     (gdb) break foo

What situations do you mean?  A situation for the user, where it is
convenient?  Or some kind of "context" situation where if the name
cannot be found locally, gdb searches?

The latter I would like us to avoid.  My view is that linespecs are
different from expressions, and one way in particular that they are
different is that they should mean the same thing no matter the context
in which you evaluate them.

Joel> We get lucky, enjoying the side-effects of a call
Joel> cp_canonicalize_string_no_typedefs, which indirectly causes us to
Joel> perform an Ada lookup which itself causes the matching partial
Joel> psymtabs to be expanded to full symtabs.

Ugh.  This continues to be a real mess, I'm sorry about that.

Joel> What this patch does is something that I feel should be hidden
Joel> inside ada-lang. Namely, decide which matching routine to use based
Joel> on the name we are using to search for matches. I think that the
Joel> real question is to trying to find the proper interface for this.

Ok, I see, it is based on the spelling of the linespec.  I guess I am ok
with that.

I don't think it is the very best thing for us to have Ada be so very
different from the rest of GDB in so many ways -- special debuginfo
encoded in symbol names, special rules for linespecs, special rules for
iterating symbol tables.  I am sure it is better for Ada users, but the
problem is that if we want to make changes to core things in GDB,
eventually it requires you to step in and do a piece of the work.  E.g.,
we just punted on .gdb_index support for Ada.

I know it isn't super on the other side, either, with C++ setting the
norm, regardless of the applicability to other languages.  There are
probably just as many C++ hacks around :-(

[ ideas ]
Joel>   . Redesign a bit the interface.  For instance, let the language
Joel>     itself iterate over all partial symbols? The default implementation
Joel>     would do what we already do. The Ada implementation would do
Joel>     something else, not sure what yet.  And we could get rid of
Joel>     the la_symbol_name_compare method.

I suppose either this or having a way for the language to compute the
name-matching function.

I am not so sure about an Ada-specific psymtab walker.  I think I'd have
to see the patch or a fuller proposal.

Tom

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [RFC] allow unqualified function names in linespecs
  2011-12-20 15:24 ` Tom Tromey
@ 2011-12-21 14:08   ` Joel Brobecker
  2011-12-23 10:39     ` [RFA 2/3] Ada: " Joel Brobecker
                       ` (4 more replies)
  0 siblings, 5 replies; 24+ messages in thread
From: Joel Brobecker @ 2011-12-21 14:08 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> I don't think it is the very best thing for us to have Ada be so very
> different from the rest of GDB in so many ways -- special debuginfo
> encoded in symbol names, special rules for linespecs, special rules for
> iterating symbol tables.  I am sure it is better for Ada users, but the
> problem is that if we want to make changes to core things in GDB,
> eventually it requires you to step in and do a piece of the work.  E.g.,
> we just punted on .gdb_index support for Ada.

Yeah, I agree. It's a combination of things. I do recognize that part
of the problem comes from us, having developed an Ada mode that was
never designed to extend the overall design to satisfy Ada's needs.
I wasn't there, but I think we were rushed, trying to transform a C
debugger, with instructions on how to decode everything manually,
to something that handled as much of Ada as possible.

Part of the problem also comes from the fact that C++ and Ada are so
different, and thus are also often used in very different projects.
Trying to unify support for both without some kind of abstraction
layer is very hard. In fact, coming up with that abstraction layer
is also very hard, as we're finding out.

My goal in the past 10 years, has always been to clean the Ada mode up,
and all the messes we created. But at the same time, I dont' want that
work to create more work for me during the periodic merges I make from
the FSF tree to ours. So, my first goal is to first reconcile AdaCore's
ada-* files with the ones on the FSF. That's a lot of micro-redesign,
sometimes, to get things to an acceptable state. The good news is,
I feel like I am getting really close. And once I'm done, I can start
the cleanup in earnest.

There are some thing that I need to accept though: If some things
are common idioms in Ada, there is now way I am going to be able
to stop supporting them without losing my job :-). Believe it or not,
though, I do a fair amount of push back against some of the features
that get requested internally.

> [ ideas ]
> Joel>   . Redesign a bit the interface.  For instance, let the language
> Joel>     itself iterate over all partial symbols? The default implementation
> Joel>     would do what we already do. The Ada implementation would do
> Joel>     something else, not sure what yet.  And we could get rid of
> Joel>     the la_symbol_name_compare method.
> 
> I suppose either this or having a way for the language to compute the
> name-matching function.
> 
> I am not so sure about an Ada-specific psymtab walker.  I think I'd have
> to see the patch or a fuller proposal.

OK. I'll try to come up with something along either of those lines...

-- 
Joel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* unqualified function names in linespecs in Ada... (try #2)
  2011-12-21 14:08   ` Joel Brobecker
  2011-12-23 10:39     ` [RFA 2/3] Ada: " Joel Brobecker
  2011-12-23 10:39     ` [commit/Ada 1/3] New function ada-lang.c:should_use_wild_match Joel Brobecker
@ 2011-12-23 10:39     ` Joel Brobecker
  2011-12-23 11:01     ` [RFA 3/3] Remove language param from name_matcher in struct quick_symbol_functions Joel Brobecker
  2012-01-24 19:17     ` [RFC] allow unqualified function names in linespecs Tom Tromey
  4 siblings, 0 replies; 24+ messages in thread
From: Joel Brobecker @ 2011-12-23 10:39 UTC (permalink / raw)
  To: gdb-patches

Hello,

In reply to: http://www.sourceware.org/ml/gdb-patches/2011-12/msg00724.html

Just a quick reminder: The objective is to be able to insert breakpoints
using the unqualified name for functions. This has always been working,
and it actually still is mostly working today. But not quite:

    (gdb) b "+"
    Function ""+"" not defined.

The reason why it mostly works is thanks to a side-effect of calling
cp_canonicalize_string_no_typedefs. The objective of this patch is to
lift the dependency on this side effect.

The crux of the matter comes from the fact that Ada provides two lookup
policies: The first policy is the "full match" policy, where the user
enters the symbol's fully-qualified name (Eg: pck.foo for function foo
in package pck); The second one is the "wild match" policy, where
the user only enters the symbol's unqualified name (Eg: foo instead of
pck.foo). Which policy should be used depends on the named entered by
the user. I know that C++ users would probably say that the second
policy would never work with C++ code, giving too many matches to be
useful.  But this is, probably by far, the policy that's used the most
when debugging Ada.

The policy selection is correctly made when searching the full symbols.
But the iteration through the partial symbols, on the other hand, is
still performed using one unique policy, which happens to the "full
match" one. We need a way for the language to tell the users of
partial symtab iterators which one should be used.

A new language method that returns a match routine has thus been
implemented.  The newly-created la_symbol_name_compare method thus
becomes OBE and is also removed.

And once the fix is implemented, there is no longer a reason for
our name_matcher routines to be given the language.  A followup patch
cleans that up too.

The whole series has been tested on x86_64-linux.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [RFA 2/3] Ada: allow unqualified function names in linespecs
  2011-12-21 14:08   ` Joel Brobecker
@ 2011-12-23 10:39     ` Joel Brobecker
  2012-01-12  3:13       ` Joel Brobecker
                         ` (2 more replies)
  2011-12-23 10:39     ` [commit/Ada 1/3] New function ada-lang.c:should_use_wild_match Joel Brobecker
                       ` (3 subsequent siblings)
  4 siblings, 3 replies; 24+ messages in thread
From: Joel Brobecker @ 2011-12-23 10:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Joel Brobecker

This is the meat, where we replace the old la_symbol_name_compare
language method with the new ada_get_symbol_name_match_p.
It fixes the problem when trying to insert a breakpoint on "+".

gdb/ChangeLog:

        * 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.

OK to commit?
Thanks,
-- 
Joel

---
 gdb/ada-lang.c    |   14 +++++++++++++-
 gdb/c-lang.c      |    8 ++++----
 gdb/d-lang.c      |    2 +-
 gdb/f-lang.c      |    2 +-
 gdb/jv-lang.c     |    2 +-
 gdb/language.c    |    6 +++---
 gdb/language.h    |   29 +++++++++++++++++------------
 gdb/linespec.c    |   24 +++++++++++++++++++++---
 gdb/m2-lang.c     |    2 +-
 gdb/objc-lang.c   |    2 +-
 gdb/opencl-lang.c |    2 +-
 gdb/p-lang.c      |    2 +-
 gdb/symfile.h     |    8 +++-----
 13 files changed, 68 insertions(+), 35 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 09ab38d..d871193 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12385,6 +12385,18 @@ static const struct exp_descriptor ada_exp_descriptor = {
   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,
@@ -12421,7 +12433,7 @@ const struct language_defn ada_language_defn = {
   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
 };
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 7be916c..1545d08 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -863,7 +863,7 @@ const struct language_defn c_language_defn =
   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
 };
@@ -986,7 +986,7 @@ const struct language_defn cplus_language_defn =
   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
 };
@@ -1027,7 +1027,7 @@ const struct language_defn asm_language_defn =
   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
 };
@@ -1073,7 +1073,7 @@ const struct language_defn minimal_language_defn =
   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
 };
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index fb6bacd..0af328d 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -273,7 +273,7 @@ static const struct language_defn d_language_defn =
   default_print_array_index,
   default_pass_by_reference,
   c_get_string,
-  strcmp_iw_ordered,
+  NULL,				/* la_get_symbol_name_match_p */
   NULL,
   LANG_MAGIC
 };
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 00926fb..ab8fcca 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -309,7 +309,7 @@ const struct language_defn f_language_defn =
   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
 };
diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
index 80fe4a1..2504151 100644
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -1197,7 +1197,7 @@ const struct language_defn java_language_defn =
   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
 };
diff --git a/gdb/language.c b/gdb/language.c
index 1bbbfba..739c79e 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -1200,7 +1200,7 @@ const struct language_defn unknown_language_defn =
   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
 };
@@ -1243,7 +1243,7 @@ const struct language_defn auto_language_defn =
   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
 };
@@ -1284,7 +1284,7 @@ const struct language_defn local_language_defn =
   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
 };
diff --git a/gdb/language.h b/gdb/language.h
index 65d55db..da25ed8 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -136,6 +136,16 @@ struct language_arch_info
   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
@@ -318,19 +328,14 @@ 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.
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 9d753e5..6f463a4 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -323,6 +323,17 @@ cplusplus_error (const char *name, const char *fmt, ...)
   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.  */
 
@@ -330,9 +341,9 @@ static int
 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;
 }
@@ -351,6 +362,13 @@ iterate_over_all_matching_symtabs (const char *name,
 {
   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)
   {
@@ -369,7 +387,7 @@ iterate_over_all_matching_symtabs (const char *name,
 	objfile->sf->qf->expand_symtabs_matching (objfile, NULL,
 						  iterate_name_matcher,
 						  ALL_DOMAIN,
-						  &name);
+						  &matcher_data);
 
       ALL_OBJFILE_SYMTABS (objfile, symtab)
 	{
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index c850b1f..f572f54 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -401,7 +401,7 @@ const struct language_defn m2_language_defn =
   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
 };
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index cb7fa0e..3c8c0cb 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -541,7 +541,7 @@ const struct language_defn objc_language_defn = {
   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
 };
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 1deb9d8..afde3b4 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1024,7 +1024,7 @@ const struct language_defn opencl_language_defn =
   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
 };
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index f66d471..e633582 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -459,7 +459,7 @@ const struct language_defn pascal_language_defn =
   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
 };
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 91605a2..ef1ca24 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -260,12 +260,10 @@ struct quick_symbol_functions
      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.
 
-- 
1.7.1

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [commit/Ada 1/3] New function ada-lang.c:should_use_wild_match...
  2011-12-21 14:08   ` Joel Brobecker
  2011-12-23 10:39     ` [RFA 2/3] Ada: " Joel Brobecker
@ 2011-12-23 10:39     ` Joel Brobecker
  2011-12-27  4:27       ` Checked in: " Joel Brobecker
  2011-12-23 10:39     ` unqualified function names in linespecs in Ada... (try #2) Joel Brobecker
                       ` (2 subsequent siblings)
  4 siblings, 1 reply; 24+ messages in thread
From: Joel Brobecker @ 2011-12-23 10:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Joel Brobecker

... to avoid code duplication.

This is just an independent cleanup which I'll commit shortly.

gdb/ChangeLog:

        * ada-lang.c (should_use_wild_match): New function.
        (ada_lookup_simple_minsym): Use should_use_wild_match.
        Minor simplification.  Add comment.
        (ada_lookup_symbol_list): Use should_use_wild_match.
        Minor simplification.

---
 gdb/ada-lang.c |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 8f4292f..09ab38d 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4161,6 +4161,18 @@ cache_symbol (const char *name, domain_enum namespace, struct symbol *sym,
 \f
                                 /* Symbol Lookup */
 
+/* Return nonzero if wild matching should be used when searching for
+   all symbols matching LOOKUP_NAME.
+
+   LOOKUP_NAME is expected to be a symbol name after transformation
+   for Ada lookups (see ada_name_for_lookup).  */
+
+static int
+should_use_wild_match (const char *lookup_name)
+{
+  return (strstr (lookup_name, "__") == NULL);
+}
+
 /* Return the result of a standard (literal, C-like) lookup of NAME in
    given DOMAIN, visible from lexical block BLOCK.  */
 
@@ -4326,15 +4338,17 @@ ada_lookup_simple_minsym (const char *name)
 {
   struct objfile *objfile;
   struct minimal_symbol *msymbol;
-  int wild_match;
+  const int wild_match = should_use_wild_match (name);
 
+  /* Special case: If the user specifies a symbol name inside package
+     Standard, do a non-wild matching of the symbol name without
+     the "standard__" prefix.  This was primarily introduced in order
+     to allow the user to specifically access the standard exceptions
+     using, for instance, Standard.Constraint_Error when Constraint_Error
+     is ambiguous (due to the user defining its own Constraint_Error
+     entity inside its program).  */
   if (strncmp (name, "standard__", sizeof ("standard__") - 1) == 0)
-    {
-      name += sizeof ("standard__") - 1;
-      wild_match = 0;
-    }
-  else
-    wild_match = (strstr (name, "__") == NULL);
+    name += sizeof ("standard__") - 1;
 
   ALL_MSYMBOLS (objfile, msymbol)
   {
@@ -4979,7 +4993,7 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0,
   struct symbol *sym;
   struct block *block;
   const char *name;
-  int wild_match;
+  const int wild_match = should_use_wild_match (name0);
   int cacheIfUnique;
   int ndefns;
 
@@ -4990,7 +5004,6 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0,
 
   /* Search specified block and its superiors.  */
 
-  wild_match = (strstr (name0, "__") == NULL);
   name = name0;
   block = (struct block *) block0;      /* FIXME: No cast ought to be
                                            needed, but adding const will
@@ -5005,7 +5018,6 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0,
      entity inside its program).  */
   if (strncmp (name0, "standard__", sizeof ("standard__") - 1) == 0)
     {
-      wild_match = 0;
       block = NULL;
       name = name0 + sizeof ("standard__") - 1;
     }
-- 
1.7.1

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [RFA 3/3] Remove language param from name_matcher in struct quick_symbol_functions
  2011-12-21 14:08   ` Joel Brobecker
                       ` (2 preceding siblings ...)
  2011-12-23 10:39     ` unqualified function names in linespecs in Ada... (try #2) Joel Brobecker
@ 2011-12-23 11:01     ` Joel Brobecker
  2012-01-12  4:30       ` Joel Brobecker
                         ` (2 more replies)
  2012-01-24 19:17     ` [RFC] allow unqualified function names in linespecs Tom Tromey
  4 siblings, 3 replies; 24+ messages in thread
From: Joel Brobecker @ 2011-12-23 11:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: Joel Brobecker

And lastly, a little cleanup.

The quick_symbol_functions struct contains a field which is pointer
a function which takes another function, called name_matcher, as
its parameter.  This name_matcher currently has 3 arguments, one
of them being the language. This parameter is no longer used, and
thus deleted.

gdb/ChangeLog:

        * symfile.h (struct quick_symbol_functions) [expand_symtabs_matching]:
        Remove language parameter from name_matcher.  Adjust the comment.
        * symtab.c (search_symbols_name_matches, expand_partial_symbol_name):
        Remove language parameter.
        * ada-lang.c (ada_expand_partial_symbol_name): Likewise.
        * linespec.c (iterate_name_matcher): Likewise.
        * dwarf2read.c (dw2_expand_symtabs_matching): Adjust type of
        name_matcher.  Adjust call accordingly.
        * psymtab.c (expand_symtabs_matching_via_partial): Likewise.
        (maintenance_check_symtabs): Adjust type of parameter "fun".
        * psymtab.h (maintenance_check_symtabs): Likewise.

Ok to commit?
Thanks,
-- 
Joel

---
 gdb/ada-lang.c   |    3 +--
 gdb/dwarf2read.c |    4 ++--
 gdb/linespec.c   |    3 +--
 gdb/psymtab.c    |    8 +++-----
 gdb/psymtab.h    |    3 +--
 gdb/symfile.h    |    6 +++---
 gdb/symtab.c     |    6 ++----
 7 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index d871193..d6404c5 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5701,8 +5701,7 @@ struct add_partial_datum
 
 /* A callback for expand_partial_symbol_names.  */
 static int
-ada_expand_partial_symbol_name (const struct language_defn *language,
-				const char *name, void *user_data)
+ada_expand_partial_symbol_name (const char *name, void *user_data)
 {
   struct add_partial_datum *data = user_data;
   
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 7905052..a4ca584 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2759,7 +2759,7 @@ static void
 dw2_expand_symtabs_matching
   (struct objfile *objfile,
    int (*file_matcher) (const char *, void *),
-   int (*name_matcher) (const struct language_defn *, const char *, void *),
+   int (*name_matcher) (const char *, void *),
    enum search_domain kind,
    void *data)
 {
@@ -2813,7 +2813,7 @@ dw2_expand_symtabs_matching
 
       name = index->constant_pool + MAYBE_SWAP (index->symbol_table[idx]);
 
-      if (! (*name_matcher) (current_language, name, data))
+      if (! (*name_matcher) (name, data))
 	continue;
 
       /* The name was matched, now expand corresponding CUs that were
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 6f463a4..eefd5d4 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -338,8 +338,7 @@ struct symbol_matcher_data
    callback to the expand_symtabs_matching method.  */
 
 static int
-iterate_name_matcher (const struct language_defn *language,
-		      const char *name, void *d)
+iterate_name_matcher (const char *name, void *d)
 {
   const struct symbol_matcher_data *data = d;
 
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 861b302..1ba7436 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1252,7 +1252,7 @@ static void
 expand_symtabs_matching_via_partial
   (struct objfile *objfile,
    int (*file_matcher) (const char *, void *),
-   int (*name_matcher) (const struct language_defn *, const char *, void *),
+   int (*name_matcher) (const char *, void *),
    enum search_domain kind,
    void *data)
 {
@@ -1304,8 +1304,7 @@ expand_symtabs_matching_via_partial
 		       && SYMBOL_CLASS (*psym) == LOC_BLOCK)
 		   || (kind == TYPES_DOMAIN
 		       && SYMBOL_CLASS (*psym) == LOC_TYPEDEF))
-		  && (*name_matcher) (current_language,
-				      SYMBOL_SEARCH_NAME (*psym), data))
+		  && (*name_matcher) (SYMBOL_SEARCH_NAME (*psym), data))
 		{
 		  PSYMTAB_TO_SYMTAB (ps);
 		  keep_going = 0;
@@ -1945,8 +1944,7 @@ maintenance_check_symtabs (char *ignore, int from_tty)
 \f
 
 void
-expand_partial_symbol_names (int (*fun) (const struct language_defn *,
-					 const char *, void *),
+expand_partial_symbol_names (int (*fun) (const char *, void *),
 			     void *data)
 {
   struct objfile *objfile;
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 940b537..de292c5 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -30,8 +30,7 @@ extern struct psymbol_bcache *psymbol_bcache_init (void);
 extern void psymbol_bcache_free (struct psymbol_bcache *);
 extern struct bcache *psymbol_bcache_get_bcache (struct psymbol_bcache *);
 
-void expand_partial_symbol_names (int (*fun) (const struct language_defn *,
-					      const char *, void *),
+void expand_partial_symbol_names (int (*fun) (const char *, void *),
 				  void *data);
 
 void map_partial_symbol_filenames (symbol_filename_ftype *fun, void *data,
diff --git a/gdb/symfile.h b/gdb/symfile.h
index ef1ca24..77dddea 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -262,8 +262,8 @@ struct quick_symbol_functions
      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 "search"
-     name and DATA are passed to NAME_MATCHER.
+     defined in the file.  The symbol "search" name and DATA are passed
+     to NAME_MATCHER.
 
      If NAME_MATCHER returns zero, then this symbol is skipped.
 
@@ -274,7 +274,7 @@ struct quick_symbol_functions
   void (*expand_symtabs_matching)
     (struct objfile *objfile,
      int (*file_matcher) (const char *, void *),
-     int (*name_matcher) (const struct language_defn *, const char *, void *),
+     int (*name_matcher) (const char *, void *),
      enum search_domain kind,
      void *data);
 
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 1ea4253..cf94c9c 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3166,8 +3166,7 @@ search_symbols_file_matches (const char *filename, void *user_data)
 
 /* A callback for expand_symtabs_matching.  */
 static int
-search_symbols_name_matches (const struct language_defn *language,
-			     const char *symname, void *user_data)
+search_symbols_name_matches (const char *symname, void *user_data)
 {
   struct search_symbols_data *data = user_data;
 
@@ -3975,8 +3974,7 @@ add_macro_name (const char *name, const struct macro_definition *ignore,
 
 /* A callback for expand_partial_symbol_names.  */
 static int
-expand_partial_symbol_name (const struct language_defn *language,
-			    const char *name, void *user_data)
+expand_partial_symbol_name (const char *name, void *user_data)
 {
   struct add_name_data *datum = (struct add_name_data *) user_data;
 
-- 
1.7.1

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Checked in: [commit/Ada 1/3] New function ada-lang.c:should_use_wild_match...
  2011-12-23 10:39     ` [commit/Ada 1/3] New function ada-lang.c:should_use_wild_match Joel Brobecker
@ 2011-12-27  4:27       ` Joel Brobecker
  0 siblings, 0 replies; 24+ messages in thread
From: Joel Brobecker @ 2011-12-27  4:27 UTC (permalink / raw)
  To: gdb-patches

> gdb/ChangeLog:
> 
>         * ada-lang.c (should_use_wild_match): New function.
>         (ada_lookup_simple_minsym): Use should_use_wild_match.
>         Minor simplification.  Add comment.
>         (ada_lookup_symbol_list): Use should_use_wild_match.
>         Minor simplification.

Checked in (HEAD only).

-- 
Joel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [RFA 2/3] Ada: allow unqualified function names in linespecs
  2011-12-23 10:39     ` [RFA 2/3] Ada: " Joel Brobecker
@ 2012-01-12  3:13       ` Joel Brobecker
  2012-01-19 15:40       ` Joel Brobecker
  2012-01-24 19:41       ` Tom Tromey
  2 siblings, 0 replies; 24+ messages in thread
From: Joel Brobecker @ 2012-01-12  3:13 UTC (permalink / raw)
  To: gdb-patches

On Fri, Dec 23, 2011 at 02:38:12PM +0400, Joel Brobecker wrote:
> This is the meat, where we replace the old la_symbol_name_compare
> language method with the new ada_get_symbol_name_match_p.
> It fixes the problem when trying to insert a breakpoint on "+".
> 
> gdb/ChangeLog:
> 
>         * 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.

Ping?

http://www.sourceware.org/ml/gdb-patches/2011-12/msg00802.html

Thank you!

> 
> OK to commit?
> Thanks,
> -- 
> Joel
> 
> ---
>  gdb/ada-lang.c    |   14 +++++++++++++-
>  gdb/c-lang.c      |    8 ++++----
>  gdb/d-lang.c      |    2 +-
>  gdb/f-lang.c      |    2 +-
>  gdb/jv-lang.c     |    2 +-
>  gdb/language.c    |    6 +++---
>  gdb/language.h    |   29 +++++++++++++++++------------
>  gdb/linespec.c    |   24 +++++++++++++++++++++---
>  gdb/m2-lang.c     |    2 +-
>  gdb/objc-lang.c   |    2 +-
>  gdb/opencl-lang.c |    2 +-
>  gdb/p-lang.c      |    2 +-
>  gdb/symfile.h     |    8 +++-----
>  13 files changed, 68 insertions(+), 35 deletions(-)
> 
> diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
> index 09ab38d..d871193 100644
> --- a/gdb/ada-lang.c
> +++ b/gdb/ada-lang.c
> @@ -12385,6 +12385,18 @@ static const struct exp_descriptor ada_exp_descriptor = {
>    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,
> @@ -12421,7 +12433,7 @@ const struct language_defn ada_language_defn = {
>    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
>  };
> diff --git a/gdb/c-lang.c b/gdb/c-lang.c
> index 7be916c..1545d08 100644
> --- a/gdb/c-lang.c
> +++ b/gdb/c-lang.c
> @@ -863,7 +863,7 @@ const struct language_defn c_language_defn =
>    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
>  };
> @@ -986,7 +986,7 @@ const struct language_defn cplus_language_defn =
>    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
>  };
> @@ -1027,7 +1027,7 @@ const struct language_defn asm_language_defn =
>    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
>  };
> @@ -1073,7 +1073,7 @@ const struct language_defn minimal_language_defn =
>    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
>  };
> diff --git a/gdb/d-lang.c b/gdb/d-lang.c
> index fb6bacd..0af328d 100644
> --- a/gdb/d-lang.c
> +++ b/gdb/d-lang.c
> @@ -273,7 +273,7 @@ static const struct language_defn d_language_defn =
>    default_print_array_index,
>    default_pass_by_reference,
>    c_get_string,
> -  strcmp_iw_ordered,
> +  NULL,				/* la_get_symbol_name_match_p */
>    NULL,
>    LANG_MAGIC
>  };
> diff --git a/gdb/f-lang.c b/gdb/f-lang.c
> index 00926fb..ab8fcca 100644
> --- a/gdb/f-lang.c
> +++ b/gdb/f-lang.c
> @@ -309,7 +309,7 @@ const struct language_defn f_language_defn =
>    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
>  };
> diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
> index 80fe4a1..2504151 100644
> --- a/gdb/jv-lang.c
> +++ b/gdb/jv-lang.c
> @@ -1197,7 +1197,7 @@ const struct language_defn java_language_defn =
>    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
>  };
> diff --git a/gdb/language.c b/gdb/language.c
> index 1bbbfba..739c79e 100644
> --- a/gdb/language.c
> +++ b/gdb/language.c
> @@ -1200,7 +1200,7 @@ const struct language_defn unknown_language_defn =
>    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
>  };
> @@ -1243,7 +1243,7 @@ const struct language_defn auto_language_defn =
>    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
>  };
> @@ -1284,7 +1284,7 @@ const struct language_defn local_language_defn =
>    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
>  };
> diff --git a/gdb/language.h b/gdb/language.h
> index 65d55db..da25ed8 100644
> --- a/gdb/language.h
> +++ b/gdb/language.h
> @@ -136,6 +136,16 @@ struct language_arch_info
>    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
> @@ -318,19 +328,14 @@ 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.
> diff --git a/gdb/linespec.c b/gdb/linespec.c
> index 9d753e5..6f463a4 100644
> --- a/gdb/linespec.c
> +++ b/gdb/linespec.c
> @@ -323,6 +323,17 @@ cplusplus_error (const char *name, const char *fmt, ...)
>    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.  */
>  
> @@ -330,9 +341,9 @@ static int
>  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;
>  }
> @@ -351,6 +362,13 @@ iterate_over_all_matching_symtabs (const char *name,
>  {
>    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)
>    {
> @@ -369,7 +387,7 @@ iterate_over_all_matching_symtabs (const char *name,
>  	objfile->sf->qf->expand_symtabs_matching (objfile, NULL,
>  						  iterate_name_matcher,
>  						  ALL_DOMAIN,
> -						  &name);
> +						  &matcher_data);
>  
>        ALL_OBJFILE_SYMTABS (objfile, symtab)
>  	{
> diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
> index c850b1f..f572f54 100644
> --- a/gdb/m2-lang.c
> +++ b/gdb/m2-lang.c
> @@ -401,7 +401,7 @@ const struct language_defn m2_language_defn =
>    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
>  };
> diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
> index cb7fa0e..3c8c0cb 100644
> --- a/gdb/objc-lang.c
> +++ b/gdb/objc-lang.c
> @@ -541,7 +541,7 @@ const struct language_defn objc_language_defn = {
>    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
>  };
> diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
> index 1deb9d8..afde3b4 100644
> --- a/gdb/opencl-lang.c
> +++ b/gdb/opencl-lang.c
> @@ -1024,7 +1024,7 @@ const struct language_defn opencl_language_defn =
>    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
>  };
> diff --git a/gdb/p-lang.c b/gdb/p-lang.c
> index f66d471..e633582 100644
> --- a/gdb/p-lang.c
> +++ b/gdb/p-lang.c
> @@ -459,7 +459,7 @@ const struct language_defn pascal_language_defn =
>    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
>  };
> diff --git a/gdb/symfile.h b/gdb/symfile.h
> index 91605a2..ef1ca24 100644
> --- a/gdb/symfile.h
> +++ b/gdb/symfile.h
> @@ -260,12 +260,10 @@ struct quick_symbol_functions
>       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.
>  
> -- 
> 1.7.1

-- 
Joel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [RFA 3/3] Remove language param from name_matcher in struct quick_symbol_functions
  2011-12-23 11:01     ` [RFA 3/3] Remove language param from name_matcher in struct quick_symbol_functions Joel Brobecker
@ 2012-01-12  4:30       ` Joel Brobecker
  2012-01-19 15:47       ` Joel Brobecker
  2012-01-24 19:45       ` Tom Tromey
  2 siblings, 0 replies; 24+ messages in thread
From: Joel Brobecker @ 2012-01-12  4:30 UTC (permalink / raw)
  To: gdb-patches

On Fri, Dec 23, 2011 at 02:38:13PM +0400, Joel Brobecker wrote:
> And lastly, a little cleanup.
> 
> The quick_symbol_functions struct contains a field which is pointer
> a function which takes another function, called name_matcher, as
> its parameter.  This name_matcher currently has 3 arguments, one
> of them being the language. This parameter is no longer used, and
> thus deleted.
> 
> gdb/ChangeLog:
> 
>         * symfile.h (struct quick_symbol_functions) [expand_symtabs_matching]:
>         Remove language parameter from name_matcher.  Adjust the comment.
>         * symtab.c (search_symbols_name_matches, expand_partial_symbol_name):
>         Remove language parameter.
>         * ada-lang.c (ada_expand_partial_symbol_name): Likewise.
>         * linespec.c (iterate_name_matcher): Likewise.
>         * dwarf2read.c (dw2_expand_symtabs_matching): Adjust type of
>         name_matcher.  Adjust call accordingly.
>         * psymtab.c (expand_symtabs_matching_via_partial): Likewise.
>         (maintenance_check_symtabs): Adjust type of parameter "fun".
>         * psymtab.h (maintenance_check_symtabs): Likewise.

Ping? I think this one is relatively straightforward if patch #2
of the series is approved.

http://www.sourceware.org/ml/gdb-patches/2011-12/msg00803.html

Thank you!



> 
> Ok to commit?
> Thanks,
> -- 
> Joel
> 
> ---
>  gdb/ada-lang.c   |    3 +--
>  gdb/dwarf2read.c |    4 ++--
>  gdb/linespec.c   |    3 +--
>  gdb/psymtab.c    |    8 +++-----
>  gdb/psymtab.h    |    3 +--
>  gdb/symfile.h    |    6 +++---
>  gdb/symtab.c     |    6 ++----
>  7 files changed, 13 insertions(+), 20 deletions(-)
> 
> diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
> index d871193..d6404c5 100644
> --- a/gdb/ada-lang.c
> +++ b/gdb/ada-lang.c
> @@ -5701,8 +5701,7 @@ struct add_partial_datum
>  
>  /* A callback for expand_partial_symbol_names.  */
>  static int
> -ada_expand_partial_symbol_name (const struct language_defn *language,
> -				const char *name, void *user_data)
> +ada_expand_partial_symbol_name (const char *name, void *user_data)
>  {
>    struct add_partial_datum *data = user_data;
>    
> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
> index 7905052..a4ca584 100644
> --- a/gdb/dwarf2read.c
> +++ b/gdb/dwarf2read.c
> @@ -2759,7 +2759,7 @@ static void
>  dw2_expand_symtabs_matching
>    (struct objfile *objfile,
>     int (*file_matcher) (const char *, void *),
> -   int (*name_matcher) (const struct language_defn *, const char *, void *),
> +   int (*name_matcher) (const char *, void *),
>     enum search_domain kind,
>     void *data)
>  {
> @@ -2813,7 +2813,7 @@ dw2_expand_symtabs_matching
>  
>        name = index->constant_pool + MAYBE_SWAP (index->symbol_table[idx]);
>  
> -      if (! (*name_matcher) (current_language, name, data))
> +      if (! (*name_matcher) (name, data))
>  	continue;
>  
>        /* The name was matched, now expand corresponding CUs that were
> diff --git a/gdb/linespec.c b/gdb/linespec.c
> index 6f463a4..eefd5d4 100644
> --- a/gdb/linespec.c
> +++ b/gdb/linespec.c
> @@ -338,8 +338,7 @@ struct symbol_matcher_data
>     callback to the expand_symtabs_matching method.  */
>  
>  static int
> -iterate_name_matcher (const struct language_defn *language,
> -		      const char *name, void *d)
> +iterate_name_matcher (const char *name, void *d)
>  {
>    const struct symbol_matcher_data *data = d;
>  
> diff --git a/gdb/psymtab.c b/gdb/psymtab.c
> index 861b302..1ba7436 100644
> --- a/gdb/psymtab.c
> +++ b/gdb/psymtab.c
> @@ -1252,7 +1252,7 @@ static void
>  expand_symtabs_matching_via_partial
>    (struct objfile *objfile,
>     int (*file_matcher) (const char *, void *),
> -   int (*name_matcher) (const struct language_defn *, const char *, void *),
> +   int (*name_matcher) (const char *, void *),
>     enum search_domain kind,
>     void *data)
>  {
> @@ -1304,8 +1304,7 @@ expand_symtabs_matching_via_partial
>  		       && SYMBOL_CLASS (*psym) == LOC_BLOCK)
>  		   || (kind == TYPES_DOMAIN
>  		       && SYMBOL_CLASS (*psym) == LOC_TYPEDEF))
> -		  && (*name_matcher) (current_language,
> -				      SYMBOL_SEARCH_NAME (*psym), data))
> +		  && (*name_matcher) (SYMBOL_SEARCH_NAME (*psym), data))
>  		{
>  		  PSYMTAB_TO_SYMTAB (ps);
>  		  keep_going = 0;
> @@ -1945,8 +1944,7 @@ maintenance_check_symtabs (char *ignore, int from_tty)
>  \f
>  
>  void
> -expand_partial_symbol_names (int (*fun) (const struct language_defn *,
> -					 const char *, void *),
> +expand_partial_symbol_names (int (*fun) (const char *, void *),
>  			     void *data)
>  {
>    struct objfile *objfile;
> diff --git a/gdb/psymtab.h b/gdb/psymtab.h
> index 940b537..de292c5 100644
> --- a/gdb/psymtab.h
> +++ b/gdb/psymtab.h
> @@ -30,8 +30,7 @@ extern struct psymbol_bcache *psymbol_bcache_init (void);
>  extern void psymbol_bcache_free (struct psymbol_bcache *);
>  extern struct bcache *psymbol_bcache_get_bcache (struct psymbol_bcache *);
>  
> -void expand_partial_symbol_names (int (*fun) (const struct language_defn *,
> -					      const char *, void *),
> +void expand_partial_symbol_names (int (*fun) (const char *, void *),
>  				  void *data);
>  
>  void map_partial_symbol_filenames (symbol_filename_ftype *fun, void *data,
> diff --git a/gdb/symfile.h b/gdb/symfile.h
> index ef1ca24..77dddea 100644
> --- a/gdb/symfile.h
> +++ b/gdb/symfile.h
> @@ -262,8 +262,8 @@ struct quick_symbol_functions
>       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 "search"
> -     name and DATA are passed to NAME_MATCHER.
> +     defined in the file.  The symbol "search" name and DATA are passed
> +     to NAME_MATCHER.
>  
>       If NAME_MATCHER returns zero, then this symbol is skipped.
>  
> @@ -274,7 +274,7 @@ struct quick_symbol_functions
>    void (*expand_symtabs_matching)
>      (struct objfile *objfile,
>       int (*file_matcher) (const char *, void *),
> -     int (*name_matcher) (const struct language_defn *, const char *, void *),
> +     int (*name_matcher) (const char *, void *),
>       enum search_domain kind,
>       void *data);
>  
> diff --git a/gdb/symtab.c b/gdb/symtab.c
> index 1ea4253..cf94c9c 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -3166,8 +3166,7 @@ search_symbols_file_matches (const char *filename, void *user_data)
>  
>  /* A callback for expand_symtabs_matching.  */
>  static int
> -search_symbols_name_matches (const struct language_defn *language,
> -			     const char *symname, void *user_data)
> +search_symbols_name_matches (const char *symname, void *user_data)
>  {
>    struct search_symbols_data *data = user_data;
>  
> @@ -3975,8 +3974,7 @@ add_macro_name (const char *name, const struct macro_definition *ignore,
>  
>  /* A callback for expand_partial_symbol_names.  */
>  static int
> -expand_partial_symbol_name (const struct language_defn *language,
> -			    const char *name, void *user_data)
> +expand_partial_symbol_name (const char *name, void *user_data)
>  {
>    struct add_name_data *datum = (struct add_name_data *) user_data;
>  
> -- 
> 1.7.1

-- 
Joel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [RFA 2/3] Ada: allow unqualified function names in linespecs
  2011-12-23 10:39     ` [RFA 2/3] Ada: " Joel Brobecker
  2012-01-12  3:13       ` Joel Brobecker
@ 2012-01-19 15:40       ` Joel Brobecker
  2012-01-24 19:41       ` Tom Tromey
  2 siblings, 0 replies; 24+ messages in thread
From: Joel Brobecker @ 2012-01-19 15:40 UTC (permalink / raw)
  To: gdb-patches

> This is the meat, where we replace the old la_symbol_name_compare
> language method with the new ada_get_symbol_name_match_p.
> It fixes the problem when trying to insert a breakpoint on "+".
> 
> gdb/ChangeLog:
> 
>         * 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.

Ping... (and thanks!)

---
 gdb/ada-lang.c    |   14 +++++++++++++-
 gdb/c-lang.c      |    8 ++++----
 gdb/d-lang.c      |    2 +-
 gdb/f-lang.c      |    2 +-
 gdb/jv-lang.c     |    2 +-
 gdb/language.c    |    6 +++---
 gdb/language.h    |   29 +++++++++++++++++------------
 gdb/linespec.c    |   24 +++++++++++++++++++++---
 gdb/m2-lang.c     |    2 +-
 gdb/objc-lang.c   |    2 +-
 gdb/opencl-lang.c |    2 +-
 gdb/p-lang.c      |    2 +-
 gdb/symfile.h     |    8 +++-----
 13 files changed, 68 insertions(+), 35 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 09ab38d..d871193 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12385,6 +12385,18 @@ static const struct exp_descriptor ada_exp_descriptor = {
   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,
@@ -12421,7 +12433,7 @@ const struct language_defn ada_language_defn = {
   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
 };
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 7be916c..1545d08 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -863,7 +863,7 @@ const struct language_defn c_language_defn =
   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
 };
@@ -986,7 +986,7 @@ const struct language_defn cplus_language_defn =
   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
 };
@@ -1027,7 +1027,7 @@ const struct language_defn asm_language_defn =
   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
 };
@@ -1073,7 +1073,7 @@ const struct language_defn minimal_language_defn =
   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
 };
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index fb6bacd..0af328d 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -273,7 +273,7 @@ static const struct language_defn d_language_defn =
   default_print_array_index,
   default_pass_by_reference,
   c_get_string,
-  strcmp_iw_ordered,
+  NULL,				/* la_get_symbol_name_match_p */
   NULL,
   LANG_MAGIC
 };
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 00926fb..ab8fcca 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -309,7 +309,7 @@ const struct language_defn f_language_defn =
   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
 };
diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
index 80fe4a1..2504151 100644
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -1197,7 +1197,7 @@ const struct language_defn java_language_defn =
   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
 };
diff --git a/gdb/language.c b/gdb/language.c
index 1bbbfba..739c79e 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -1200,7 +1200,7 @@ const struct language_defn unknown_language_defn =
   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
 };
@@ -1243,7 +1243,7 @@ const struct language_defn auto_language_defn =
   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
 };
@@ -1284,7 +1284,7 @@ const struct language_defn local_language_defn =
   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
 };
diff --git a/gdb/language.h b/gdb/language.h
index 65d55db..da25ed8 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -136,6 +136,16 @@ struct language_arch_info
   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
@@ -318,19 +328,14 @@ 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.
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 9d753e5..6f463a4 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -323,6 +323,17 @@ cplusplus_error (const char *name, const char *fmt, ...)
   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.  */
 
@@ -330,9 +341,9 @@ static int
 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;
 }
@@ -351,6 +362,13 @@ iterate_over_all_matching_symtabs (const char *name,
 {
   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)
   {
@@ -369,7 +387,7 @@ iterate_over_all_matching_symtabs (const char *name,
 	objfile->sf->qf->expand_symtabs_matching (objfile, NULL,
 						  iterate_name_matcher,
 						  ALL_DOMAIN,
-						  &name);
+						  &matcher_data);
 
       ALL_OBJFILE_SYMTABS (objfile, symtab)
 	{
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index c850b1f..f572f54 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -401,7 +401,7 @@ const struct language_defn m2_language_defn =
   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
 };
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index cb7fa0e..3c8c0cb 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -541,7 +541,7 @@ const struct language_defn objc_language_defn = {
   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
 };
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 1deb9d8..afde3b4 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1024,7 +1024,7 @@ const struct language_defn opencl_language_defn =
   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
 };
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index f66d471..e633582 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -459,7 +459,7 @@ const struct language_defn pascal_language_defn =
   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
 };
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 91605a2..ef1ca24 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -260,12 +260,10 @@ struct quick_symbol_functions
      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.
 
-- 
1.7.1

-- 
Joel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [RFA 3/3] Remove language param from name_matcher in struct quick_symbol_functions
  2011-12-23 11:01     ` [RFA 3/3] Remove language param from name_matcher in struct quick_symbol_functions Joel Brobecker
  2012-01-12  4:30       ` Joel Brobecker
@ 2012-01-19 15:47       ` Joel Brobecker
  2012-01-24 19:45       ` Tom Tromey
  2 siblings, 0 replies; 24+ messages in thread
From: Joel Brobecker @ 2012-01-19 15:47 UTC (permalink / raw)
  To: gdb-patches

> And lastly, a little cleanup.
> 
> The quick_symbol_functions struct contains a field which is pointer
> a function which takes another function, called name_matcher, as
> its parameter.  This name_matcher currently has 3 arguments, one
> of them being the language. This parameter is no longer used, and
> thus deleted.
> 
> gdb/ChangeLog:
> 
>         * symfile.h (struct quick_symbol_functions) [expand_symtabs_matching]:
>         Remove language parameter from name_matcher.  Adjust the comment.
>         * symtab.c (search_symbols_name_matches, expand_partial_symbol_name):
>         Remove language parameter.
>         * ada-lang.c (ada_expand_partial_symbol_name): Likewise.
>         * linespec.c (iterate_name_matcher): Likewise.
>         * dwarf2read.c (dw2_expand_symtabs_matching): Adjust type of
>         name_matcher.  Adjust call accordingly.
>         * psymtab.c (expand_symtabs_matching_via_partial): Likewise.
>         (maintenance_check_symtabs): Adjust type of parameter "fun".
>         * psymtab.h (maintenance_check_symtabs): Likewise.

Ping... (this one should be fairly straightforward if the patch #2
of the series is accepted).

Thanks!
-- 
Joel

---
 gdb/ada-lang.c   |    3 +--
 gdb/dwarf2read.c |    4 ++--
 gdb/linespec.c   |    3 +--
 gdb/psymtab.c    |    8 +++-----
 gdb/psymtab.h    |    3 +--
 gdb/symfile.h    |    6 +++---
 gdb/symtab.c     |    6 ++----
 7 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index d871193..d6404c5 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5701,8 +5701,7 @@ struct add_partial_datum
 
 /* A callback for expand_partial_symbol_names.  */
 static int
-ada_expand_partial_symbol_name (const struct language_defn *language,
-				const char *name, void *user_data)
+ada_expand_partial_symbol_name (const char *name, void *user_data)
 {
   struct add_partial_datum *data = user_data;
   
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 7905052..a4ca584 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2759,7 +2759,7 @@ static void
 dw2_expand_symtabs_matching
   (struct objfile *objfile,
    int (*file_matcher) (const char *, void *),
-   int (*name_matcher) (const struct language_defn *, const char *, void *),
+   int (*name_matcher) (const char *, void *),
    enum search_domain kind,
    void *data)
 {
@@ -2813,7 +2813,7 @@ dw2_expand_symtabs_matching
 
       name = index->constant_pool + MAYBE_SWAP (index->symbol_table[idx]);
 
-      if (! (*name_matcher) (current_language, name, data))
+      if (! (*name_matcher) (name, data))
 	continue;
 
       /* The name was matched, now expand corresponding CUs that were
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 6f463a4..eefd5d4 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -338,8 +338,7 @@ struct symbol_matcher_data
    callback to the expand_symtabs_matching method.  */
 
 static int
-iterate_name_matcher (const struct language_defn *language,
-		      const char *name, void *d)
+iterate_name_matcher (const char *name, void *d)
 {
   const struct symbol_matcher_data *data = d;
 
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 861b302..1ba7436 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1252,7 +1252,7 @@ static void
 expand_symtabs_matching_via_partial
   (struct objfile *objfile,
    int (*file_matcher) (const char *, void *),
-   int (*name_matcher) (const struct language_defn *, const char *, void *),
+   int (*name_matcher) (const char *, void *),
    enum search_domain kind,
    void *data)
 {
@@ -1304,8 +1304,7 @@ expand_symtabs_matching_via_partial
 		       && SYMBOL_CLASS (*psym) == LOC_BLOCK)
 		   || (kind == TYPES_DOMAIN
 		       && SYMBOL_CLASS (*psym) == LOC_TYPEDEF))
-		  && (*name_matcher) (current_language,
-				      SYMBOL_SEARCH_NAME (*psym), data))
+		  && (*name_matcher) (SYMBOL_SEARCH_NAME (*psym), data))
 		{
 		  PSYMTAB_TO_SYMTAB (ps);
 		  keep_going = 0;
@@ -1945,8 +1944,7 @@ maintenance_check_symtabs (char *ignore, int from_tty)
 \f
 
 void
-expand_partial_symbol_names (int (*fun) (const struct language_defn *,
-					 const char *, void *),
+expand_partial_symbol_names (int (*fun) (const char *, void *),
 			     void *data)
 {
   struct objfile *objfile;
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 940b537..de292c5 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -30,8 +30,7 @@ extern struct psymbol_bcache *psymbol_bcache_init (void);
 extern void psymbol_bcache_free (struct psymbol_bcache *);
 extern struct bcache *psymbol_bcache_get_bcache (struct psymbol_bcache *);
 
-void expand_partial_symbol_names (int (*fun) (const struct language_defn *,
-					      const char *, void *),
+void expand_partial_symbol_names (int (*fun) (const char *, void *),
 				  void *data);
 
 void map_partial_symbol_filenames (symbol_filename_ftype *fun, void *data,
diff --git a/gdb/symfile.h b/gdb/symfile.h
index ef1ca24..77dddea 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -262,8 +262,8 @@ struct quick_symbol_functions
      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 "search"
-     name and DATA are passed to NAME_MATCHER.
+     defined in the file.  The symbol "search" name and DATA are passed
+     to NAME_MATCHER.
 
      If NAME_MATCHER returns zero, then this symbol is skipped.
 
@@ -274,7 +274,7 @@ struct quick_symbol_functions
   void (*expand_symtabs_matching)
     (struct objfile *objfile,
      int (*file_matcher) (const char *, void *),
-     int (*name_matcher) (const struct language_defn *, const char *, void *),
+     int (*name_matcher) (const char *, void *),
      enum search_domain kind,
      void *data);
 
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 1ea4253..cf94c9c 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3166,8 +3166,7 @@ search_symbols_file_matches (const char *filename, void *user_data)
 
 /* A callback for expand_symtabs_matching.  */
 static int
-search_symbols_name_matches (const struct language_defn *language,
-			     const char *symname, void *user_data)
+search_symbols_name_matches (const char *symname, void *user_data)
 {
   struct search_symbols_data *data = user_data;
 
@@ -3975,8 +3974,7 @@ add_macro_name (const char *name, const struct macro_definition *ignore,
 
 /* A callback for expand_partial_symbol_names.  */
 static int
-expand_partial_symbol_name (const struct language_defn *language,
-			    const char *name, void *user_data)
+expand_partial_symbol_name (const char *name, void *user_data)
 {
   struct add_name_data *datum = (struct add_name_data *) user_data;
 
-- 
1.7.1

-- 
Joel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [RFC] allow unqualified function names in linespecs
  2011-12-21 14:08   ` Joel Brobecker
                       ` (3 preceding siblings ...)
  2011-12-23 11:01     ` [RFA 3/3] Remove language param from name_matcher in struct quick_symbol_functions Joel Brobecker
@ 2012-01-24 19:17     ` Tom Tromey
  4 siblings, 0 replies; 24+ messages in thread
From: Tom Tromey @ 2012-01-24 19:17 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

[ oldish thread... ]

Joel> Part of the problem also comes from the fact that C++ and Ada are so
Joel> different, and thus are also often used in very different projects.
Joel> Trying to unify support for both without some kind of abstraction
Joel> layer is very hard. In fact, coming up with that abstraction layer
Joel> is also very hard, as we're finding out.

Totally agreed.

Joel> My goal in the past 10 years, has always been to clean the Ada mode up,
Joel> and all the messes we created. But at the same time, I dont' want that
Joel> work to create more work for me during the periodic merges I make from
Joel> the FSF tree to ours. So, my first goal is to first reconcile AdaCore's
Joel> ada-* files with the ones on the FSF. That's a lot of micro-redesign,
Joel> sometimes, to get things to an acceptable state. The good news is,
Joel> I feel like I am getting really close. And once I'm done, I can start
Joel> the cleanup in earnest.

Joel> There are some thing that I need to accept though: If some things
Joel> are common idioms in Ada, there is now way I am going to be able
Joel> to stop supporting them without losing my job :-). Believe it or not,
Joel> though, I do a fair amount of push back against some of the features
Joel> that get requested internally.

Yeah, I wasn't trying to express any displeasure with you personally.
I hope it didn't come across that way.

I was mostly just expressing a wish for how I would like gdb to be
structured internally in the future.  And, FWIW, I think there are
already way, way too many special cases for C++ as well.

Tom

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [RFA 2/3] Ada: allow unqualified function names in linespecs
  2011-12-23 10:39     ` [RFA 2/3] Ada: " Joel Brobecker
  2012-01-12  3:13       ` Joel Brobecker
  2012-01-19 15:40       ` Joel Brobecker
@ 2012-01-24 19:41       ` Tom Tromey
  2012-01-26  4:23         ` Joel Brobecker
  2 siblings, 1 reply; 24+ messages in thread
From: Tom Tromey @ 2012-01-24 19:41 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> This is the meat, where we replace the old la_symbol_name_compare
Joel> language method with the new ada_get_symbol_name_match_p.
Joel> It fixes the problem when trying to insert a breakpoint on "+".

This looks ok to me.

Tom

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [RFA 3/3] Remove language param from name_matcher in struct quick_symbol_functions
  2011-12-23 11:01     ` [RFA 3/3] Remove language param from name_matcher in struct quick_symbol_functions Joel Brobecker
  2012-01-12  4:30       ` Joel Brobecker
  2012-01-19 15:47       ` Joel Brobecker
@ 2012-01-24 19:45       ` Tom Tromey
  2012-01-26  4:57         ` Joel Brobecker
  2 siblings, 1 reply; 24+ messages in thread
From: Tom Tromey @ 2012-01-24 19:45 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> The quick_symbol_functions struct contains a field which is pointer
Joel> a function which takes another function, called name_matcher, as
Joel> its parameter.  This name_matcher currently has 3 arguments, one
Joel> of them being the language. This parameter is no longer used, and
Joel> thus deleted.

Perfect, thanks.

Tom

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [RFA 2/3] Ada: allow unqualified function names in linespecs
  2012-01-24 19:41       ` Tom Tromey
@ 2012-01-26  4:23         ` Joel Brobecker
  2012-01-26 10:22           ` Crash regression gdb.cp/no-dmgl-verbose.exp: " Jan Kratochvil
  0 siblings, 1 reply; 24+ messages in thread
From: Joel Brobecker @ 2012-01-26  4:23 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> Joel> This is the meat, where we replace the old la_symbol_name_compare
> Joel> language method with the new ada_get_symbol_name_match_p.
> Joel> It fixes the problem when trying to insert a breakpoint on "+".
> 
> This looks ok to me.

Thanks, Tom! I re-tested and checked the patch in.

-- 
Joel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [RFA 3/3] Remove language param from name_matcher in struct quick_symbol_functions
  2012-01-24 19:45       ` Tom Tromey
@ 2012-01-26  4:57         ` Joel Brobecker
  0 siblings, 0 replies; 24+ messages in thread
From: Joel Brobecker @ 2012-01-26  4:57 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> Joel> The quick_symbol_functions struct contains a field which is pointer
> Joel> a function which takes another function, called name_matcher, as
> Joel> its parameter.  This name_matcher currently has 3 arguments, one
> Joel> of them being the language. This parameter is no longer used, and
> Joel> thus deleted.
> 
> Perfect, thanks.

Cool! Checked in.

Thank you,
-- 
Joel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Crash regression gdb.cp/no-dmgl-verbose.exp: Re: [RFA 2/3] Ada: allow unqualified function names in linespecs
  2012-01-26  4:23         ` Joel Brobecker
@ 2012-01-26 10:22           ` Jan Kratochvil
  2012-01-26 10:55             ` Jan Kratochvil
  2012-01-27  5:15             ` Jan Kratochvil
  0 siblings, 2 replies; 24+ messages in thread
From: Jan Kratochvil @ 2012-01-26 10:22 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Tom Tromey, gdb-patches

On Thu, 26 Jan 2012 05:22:58 +0100, Joel Brobecker wrote:
> Thanks, Tom! I re-tested and checked the patch in.

 Running gdb/testsuite/gdb.cp/no-dmgl-verbose.exp ...
 PASS: gdb.cp/no-dmgl-verbose.exp: set breakpoint pending off
-PASS: gdb.cp/no-dmgl-verbose.exp: DMGL_VERBOSE-demangled f(std::string) is not defined
+ERROR: Couldn't send break 'f(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)' to GDB.
+UNRESOLVED: gdb.cp/no-dmgl-verbose.exp: DMGL_VERBOSE-demangled f(std::string) is not defined

8eb4602788d1c0b3da11b9383492a7cdb5657f9d is the first bad commit
commit 8eb4602788d1c0b3da11b9383492a7cdb5657f9d
Author: Joel Brobecker <brobecker@gnat.com>
Date:   Thu Jan 26 04:20:31 2012 +0000
    Ada: allow unqualified function names in linespecs

But the regression happens only for:
	gdbcvs-dwarf41-gcchead-rawhide/fedora-rawhide-x86_64/out/gdb-m32.sum
which is:
	FSF GDB HEAD
	-gdwarf-4 -fdebug-types-section
	x86_64 -m32
and not in other cases so it probably only reproduced some existing bug instead
of introducing a new one, I will check it more later.

#1  0x00000000007712b8 in determine_prefix (die=0x389d1d0, cu=0x38ab5f0) at dwarf2read.c:12582
12582		    && strcmp (TYPE_TAG_NAME (parent_type), "::") == 0)
(gdb) p parent_type.main_type.tag_name 
$1 = 0x0


Thanks,
Jan


#0  __strcmp_sse42 () at ../sysdeps/x86_64/multiarch/strcmp-sse42.S:163
#1  in determine_prefix (die=0x218a6c0, cu=0x20d3100) at dwarf2read.c:12582
#2  in dwarf2_compute_name (name=0x21722af "ptrdiff_t", die=0x218a6c0, cu=0x20d3100, physname=0) at dwarf2read.c:5020
#3  in dwarf2_full_name (name=0x0, die=0x218a6c0, cu=0x20d3100) at dwarf2read.c:5224
#4  in read_typedef (die=0x218a6c0, cu=0x20d3100) at dwarf2read.c:8764
#5  in read_type_die_1 (die=0x218a6c0, cu=0x20d3100) at dwarf2read.c:12333
#6  in lookup_die_type (die=0x2189c80, attr=0x2189cd8, cu=0x20d3100) at dwarf2read.c:12240
#7  in die_type (die=0x2189c80, cu=0x20d3100) at dwarf2read.c:12119
#8  in read_typedef (die=0x2189c80, cu=0x20d3100) at dwarf2read.c:8769
#9  in read_type_die_1 (die=0x2189c80, cu=0x20d3100) at dwarf2read.c:12333
#10 in read_type_die (die=0x2189c80, cu=0x20d3100) at dwarf2read.c:12281
#11 in dwarf2_add_typedef (fip=0x7fffffffccd0, die=0x2189c80, cu=0x20d3100) at dwarf2read.c:7103
#12 in process_structure_scope (die=0x2189b20, cu=0x20d3100) at dwarf2read.c:7677
#13 in process_die (die=0x2189b20, cu=0x20d3100) at dwarf2read.c:4851
#14 in read_type_unit_scope (die=0x2189a10, cu=0x20d3100) at dwarf2read.c:5735
#15 in process_die (die=0x2189a10, cu=0x20d3100) at dwarf2read.c:4833
#16 in process_full_comp_unit (per_cu=0x21614d0) at dwarf2read.c:4764
#17 in process_queue () at dwarf2read.c:4526
#18 in dw2_do_instantiate_symtab (per_cu=0x21614d0) at dwarf2read.c:1803
#19 in psymtab_to_symtab_1 (pst=0x218aff0) at dwarf2read.c:4602
#20 in dwarf2_psymtab_to_symtab (pst=0x218aff0) at dwarf2read.c:4481
#21 in psymtab_to_symtab (pst=0x218aff0) at psymtab.c:778
#22 in expand_symtabs_matching_via_partial (objfile=0x2109f40, file_matcher=0, name_matcher=0x6daeb6 <iterate_name_matcher>, kind=ALL_DOMAIN, data=0x7fffffffd030) at psymtab.c:1307
#23 in iterate_over_all_matching_symtabs (name=0x7fffffffd130 "f(std::string)", domain=VAR_DOMAIN, callback=0x6e02ff <collect_symbols>, data=0x7fffffffd0f0, search_pspace=0x0) at linespec.c:384
#24 in add_matching_symbols_to_info (name=0x7fffffffd130 "f(std::string)", info=0x7fffffffd0f0, pspace=0x0) at linespec.c:2947
#25 in decode_variable (self=0x7fffffffd310, copy=0x7fffffffd130 "f(std::string)") at linespec.c:2997
#26 in decode_line_internal (self=0x7fffffffd310, argptr=0x7fffffffd510) at linespec.c:1165
#27 in decode_line_full (argptr=0x7fffffffd510, flags=1, default_symtab=0x0, default_line=0, canonical=0x7fffffffd5a0, select_mode=0x0, filter=0x0) at linespec.c:1233
#28 in parse_breakpoint_sals (address=0x7fffffffd510, canonical=0x7fffffffd5a0) at breakpoint.c:7885
#29 in create_sals_from_address_default (arg=0x7fffffffd510, canonical=0x7fffffffd5a0, type_wanted=bp_breakpoint, addr_start= 0x7fffffffdddb "'f(std::string)'", copy_arg=0x7fffffffd540) at breakpoint.c:12501
#30 in bkpt_create_sals_from_address (arg=0x7fffffffd510, canonical=0x7fffffffd5a0, type_wanted=bp_breakpoint, addr_start= 0x7fffffffdddb "'f(std::string)'", copy_arg=0x7fffffffd540) at breakpoint.c:11451
#31 in create_breakpoint (gdbarch=0x20c5a20, arg=0x7fffffffddeb "", cond_string=0x0, thread=0, parse_condition_and_thread=1, tempflag=0, type_wanted=bp_breakpoint, ignore_count=0, pending_break_support=AUTO_BOOLEAN_AUTO, ops=0x1d90240, from_tty=1, enabled=1, internal=0) at breakpoint.c:8095
#32 in break_command_1 (arg=0x7fffffffdddb "'f(std::string)'", flag=0, from_tty=1) at breakpoint.c:8283
#33 in break_command (arg=0x7fffffffdddb "'f(std::string)'", from_tty=1) at breakpoint.c:8355

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Crash regression gdb.cp/no-dmgl-verbose.exp: Re: [RFA 2/3] Ada: allow unqualified function names in linespecs
  2012-01-26 10:22           ` Crash regression gdb.cp/no-dmgl-verbose.exp: " Jan Kratochvil
@ 2012-01-26 10:55             ` Jan Kratochvil
  2012-01-27  5:15             ` Jan Kratochvil
  1 sibling, 0 replies; 24+ messages in thread
From: Jan Kratochvil @ 2012-01-26 10:55 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Tom Tromey, gdb-patches

On Thu, 26 Jan 2012 11:16:35 +0100, Jan Kratochvil wrote:
> But the regression happens only for:
> 	gdbcvs-dwarf41-gcchead-rawhide/fedora-rawhide-x86_64/out/gdb-m32.sum
> which is:
> 	FSF GDB HEAD
> 	-gdwarf-4 -fdebug-types-section
> 	x86_64 -m32

Forgot the reproducer:
	http://people.redhat.com/jkratoch/no-dmgl-verbose.o.gz
	./gdb -nx no-dmgl-verbose.o -ex "break 'f(std::string)'"
	[...]
	Reading symbols from no-dmgl-verbose.o...done.
	Segmentation fault


Jan

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Crash regression gdb.cp/no-dmgl-verbose.exp: Re: [RFA 2/3] Ada: allow unqualified function names in linespecs
  2012-01-26 10:22           ` Crash regression gdb.cp/no-dmgl-verbose.exp: " Jan Kratochvil
  2012-01-26 10:55             ` Jan Kratochvil
@ 2012-01-27  5:15             ` Jan Kratochvil
  2012-01-27  5:25               ` Joel Brobecker
  1 sibling, 1 reply; 24+ messages in thread
From: Jan Kratochvil @ 2012-01-27  5:15 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Tom Tromey, gdb-patches

On Thu, 26 Jan 2012 11:16:35 +0100, Jan Kratochvil wrote:
> it probably only reproduced some existing bug instead
> of introducing a new one,
+
On Thu, 26 Jan 2012 11:21:48 +0100, Jan Kratochvil wrote:
> 	http://people.redhat.com/jkratoch/no-dmgl-verbose.o.gz
> 	./gdb -nx no-dmgl-verbose.o -ex "break 'f(std::string)'"
> 	[...]
> 	Reading symbols from no-dmgl-verbose.o...done.
> 	Segmentation fault

Yes, not a real regression, filed for it PR 13627::
	multiple .debug_types per objfile are not supported
	http://sourceware.org/bugzilla/show_bug.cgi?id=13627


Regards,
Jan

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: Crash regression gdb.cp/no-dmgl-verbose.exp: Re: [RFA 2/3] Ada: allow unqualified function names in linespecs
  2012-01-27  5:15             ` Jan Kratochvil
@ 2012-01-27  5:25               ` Joel Brobecker
  2012-01-27 17:09                 ` [patch] Fix the 2012-01-26 regression by la_get_symbol_name_match_p [Re: Crash regression gdb.cp/no-dmgl-verbose.exp] Jan Kratochvil
  0 siblings, 1 reply; 24+ messages in thread
From: Joel Brobecker @ 2012-01-27  5:25 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Tom Tromey, gdb-patches

Hi Jan,

> On Thu, 26 Jan 2012 11:21:48 +0100, Jan Kratochvil wrote:
> > 	http://people.redhat.com/jkratoch/no-dmgl-verbose.o.gz
> > 	./gdb -nx no-dmgl-verbose.o -ex "break 'f(std::string)'"
> > 	[...]
> > 	Reading symbols from no-dmgl-verbose.o...done.
> > 	Segmentation fault
> 
> Yes, not a real regression, filed for it PR 13627::
> 	multiple .debug_types per objfile are not supported
> 	http://sourceware.org/bugzilla/show_bug.cgi?id=13627

I'm trying to understand how the patch you quoted could have been
triggering the problem, even if it was already a latent bug. As far
as I can tell, for non-Ada units, the only difference is that
I replaced a call to strcmp_iw_ordered by a call to strcmp_iw.

What if you put strcmp_iw_ordered back in the following hunk?

    @@ -349,6 +360,13 @@ iterate_over_all_matching_symtabs (const char *name,
     {
       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;
 
Would that mask the crash? If it did, I would *not* understand why,
but that's the only change of behavior I can see from the patch.
I couldn't find out much from the backtraces themselves...

-- 
Joel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [patch] Fix the 2012-01-26 regression by la_get_symbol_name_match_p  [Re: Crash regression gdb.cp/no-dmgl-verbose.exp]
  2012-01-27  5:25               ` Joel Brobecker
@ 2012-01-27 17:09                 ` Jan Kratochvil
  2012-01-27 19:27                   ` Joel Brobecker
  0 siblings, 1 reply; 24+ messages in thread
From: Jan Kratochvil @ 2012-01-27 17:09 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Tom Tromey, gdb-patches

On Fri, 27 Jan 2012 06:15:09 +0100, Joel Brobecker wrote:
> What if you put strcmp_iw_ordered back in the following hunk?

No change.

It has started to expand all the symtabs now, it is nice it at least found the
bug
	PR symtab/13627 multiple .debug_types per objfile are not supported

but it should be fixed.  I will check in the patch below, it seems all the
functions return strcmp-like result.

No regressions on {x86_64,x86_64-m32,i686}-fedorarawhide-linux-gnu.

Your patch had:
## -328,9 +339,9 @@ static int
 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;
 }


Thanks,
Jan


gdb/
2012-01-27  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix the 2012-01-26 regression by la_get_symbol_name_match_p.
	* linespec.c (iterate_name_matcher): Negate the SYMBOL_NAME_MATCH_P
	result.

--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -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))
+  if (data->symbol_name_match_p (name, data->lookup_name) == 0)
     return 1;
   return 0;
 }

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch] Fix the 2012-01-26 regression by la_get_symbol_name_match_p [Re: Crash regression gdb.cp/no-dmgl-verbose.exp]
  2012-01-27 17:09                 ` [patch] Fix the 2012-01-26 regression by la_get_symbol_name_match_p [Re: Crash regression gdb.cp/no-dmgl-verbose.exp] Jan Kratochvil
@ 2012-01-27 19:27                   ` Joel Brobecker
  2012-01-27 20:33                     ` [commit] " Jan Kratochvil
  0 siblings, 1 reply; 24+ messages in thread
From: Joel Brobecker @ 2012-01-27 19:27 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Tom Tromey, gdb-patches

> but it should be fixed.  I will check in the patch below, it seems all the
> functions return strcmp-like result.

Duh!

Thanks, Jan. The language hook is very poorly named, I apologize.
Please go ahead and commit this fix immediately as is, and I will
fix the language hook name (and its description!) this weekend.

> gdb/
> 2012-01-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	Fix the 2012-01-26 regression by la_get_symbol_name_match_p.
> 	* linespec.c (iterate_name_matcher): Negate the SYMBOL_NAME_MATCH_P
> 	result.
> 
> --- a/gdb/linespec.c
> +++ b/gdb/linespec.c
> @@ -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))
> +  if (data->symbol_name_match_p (name, data->lookup_name) == 0)
>      return 1;
>    return 0;
>  }

Thanks again,
-- 
Joel

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [commit] [patch] Fix the 2012-01-26 regression by la_get_symbol_name_match_p [Re: Crash regression gdb.cp/no-dmgl-verbose.exp]
  2012-01-27 19:27                   ` Joel Brobecker
@ 2012-01-27 20:33                     ` Jan Kratochvil
  0 siblings, 0 replies; 24+ messages in thread
From: Jan Kratochvil @ 2012-01-27 20:33 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Tom Tromey, gdb-patches

On Fri, 27 Jan 2012 20:01:32 +0100, Joel Brobecker wrote:
> Please go ahead and commit this fix immediately as is, and I will
> fix the language hook name (and its description!) this weekend.

Checked in:
	http://sourceware.org/ml/gdb-cvs/2012-01/msg00240.html


Thanks,
Jan

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2012-01-27 20:32 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-14 14:36 [RFC] allow unqualified function names in linespecs Joel Brobecker
2011-12-20 15:24 ` Tom Tromey
2011-12-21 14:08   ` Joel Brobecker
2011-12-23 10:39     ` [RFA 2/3] Ada: " Joel Brobecker
2012-01-12  3:13       ` Joel Brobecker
2012-01-19 15:40       ` Joel Brobecker
2012-01-24 19:41       ` Tom Tromey
2012-01-26  4:23         ` Joel Brobecker
2012-01-26 10:22           ` Crash regression gdb.cp/no-dmgl-verbose.exp: " Jan Kratochvil
2012-01-26 10:55             ` Jan Kratochvil
2012-01-27  5:15             ` Jan Kratochvil
2012-01-27  5:25               ` Joel Brobecker
2012-01-27 17:09                 ` [patch] Fix the 2012-01-26 regression by la_get_symbol_name_match_p [Re: Crash regression gdb.cp/no-dmgl-verbose.exp] Jan Kratochvil
2012-01-27 19:27                   ` Joel Brobecker
2012-01-27 20:33                     ` [commit] " Jan Kratochvil
2011-12-23 10:39     ` [commit/Ada 1/3] New function ada-lang.c:should_use_wild_match Joel Brobecker
2011-12-27  4:27       ` Checked in: " Joel Brobecker
2011-12-23 10:39     ` unqualified function names in linespecs in Ada... (try #2) Joel Brobecker
2011-12-23 11:01     ` [RFA 3/3] Remove language param from name_matcher in struct quick_symbol_functions Joel Brobecker
2012-01-12  4:30       ` Joel Brobecker
2012-01-19 15:47       ` Joel Brobecker
2012-01-24 19:45       ` Tom Tromey
2012-01-26  4:57         ` Joel Brobecker
2012-01-24 19:17     ` [RFC] allow unqualified function names in linespecs Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).