public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch 1/3] Template Lookup
@ 2010-07-19 15:28 sami wagiaalla
  2010-07-20 20:42 ` sami wagiaalla
  2010-08-11 18:13 ` [patch 1/3] " sami wagiaalla
  0 siblings, 2 replies; 11+ messages in thread
From: sami wagiaalla @ 2010-07-19 15:28 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 984 bytes --]

Names of template symbols in debug info contains the full template 
parameters such as:

foo<int>(int)
foo<char>(char)

while this is useful for differentiating various instances of template 
it provides unnatural user experience when you user tries to call these 
functions. For example:

(gdb) print foo<int>(1)
(gdb) print foo<char>('a')

This patch removes the template parameters from the name and stores the 
cleaned name in a newly created variable 'search_name' in the -now 
obstack allocated- 'cplus_specific' structure.

So now the user can do:

(gdb) print foo(1)
(gdb) print foo('a')

The function choice is made by overload resolution as it should be.

Functionality that required the fully qualified name still works. For 
example:

(gdb) break foo<char>

This is because if the user included template parameters in the name 
then the template name is double checked for every hit.

This series was tested by running the testsuit on Fedora 13 with gcc 
4.4.4 on x8664.


[-- Attachment #2: template_lookup_1.patch --]
[-- Type: text/plain, Size: 16155 bytes --]

Create search_name and fixed template lookup

2010-07-15  Sami Wagiaalla  <swagiaal@redhat.com>

	* valops.c (find_overload_match): Use SYMBOL_SEARCH_NAME instead of
	SYMBOL_NATURAL_NAME.
	* symtab.h: Added new member search_name to cplus_specific.
	(symbol_set_cplus_search_name): New function prototype.
	(symbol_get_cplus_search_name): New function prototype.
	* symtab.c (symbol_set_cplus_search_name): New function.
	(symbol_get_cplus_search_name): New function.
	(symbol_search_name): Handle the C++ case.
	(symbol_matches_template_name): New function.
	* dwarf2read.c (new_symbol): Set search_name of C++ template symbols.
	* cp-support.H (cp_name_has_template_parameters): New function
	prototype.
	(cp_remove_template_params): New function ptototype.
	* cp-support.c (cp_name_has_template_parameters): New function.
	(cp_remove_template_params_component): New function.
	(cp_remove_template_params): New function.
	(overload_list_add_symbol): Use SYMBOL_SEARCH_NAME instead of
	SYMBOL_NATURAL_NAME.
	* cp-name-parser.y (cp_demangled_name_to_comp): Added more detail to
	comment.

2010-07-15  Sami Wagiaalla  <swagiaal@redhat.com>

	* gdb.cp/temp-op.exp: New test.
	* gdb.cp/temp-op.cc: New test.
	* gdb.cp/cp-relocate.exp: Set the language C++.

diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index 6d7b600..c9b5747 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -1966,9 +1966,12 @@ cp_comp_to_string (struct demangle_component *result, int estimated_len)
 			       &err);
 }
 
-/* Convert a demangled name to a demangle_component tree.  On success,
-   the root of the new tree is returned; it is valid until the next
-   call to this function and should not be freed.  On error, NULL is
+/* Convert a demangled name to a demangle_component tree.  The structure
+   of the tree depends on the format of each node in the tree.  For
+   information on the structure of a node see the comment corresponding
+   to its type in demangle_component_type.
+   On success, the root of the new tree is returned; it is valid until the
+   next call to this function and should not be freed.  On error, NULL is
    returned, and an error message will be set in *ERRMSG (which does
    not need to be freed).  */
 
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 41af7ae..4ef1a0a 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -428,6 +428,72 @@ cp_remove_params (const char *demangled_name)
   return ret;
 }
 
+/* Returns 1 if the given name contains template parameters;
+   otherwise return 0.
+   Used as a quick heuristic to avoid more expensive template
+   parsing when not necessary.  */
+
+int
+cp_name_has_template_parameters (const char *name)
+{
+  char *c = strchr (name, '<');
+  return c != NULL && strchr (c+1, '>') != NULL;
+}
+
+/* Remove template parameters components from the give tree.  */
+
+static struct demangle_component *
+cp_remove_template_params_component (struct demangle_component *comp)
+{
+
+  gdb_assert (comp != NULL);
+
+  switch (comp->type)
+    {
+    case DEMANGLE_COMPONENT_TEMPLATE:
+      /* If there is a template component remove this node by re-parenting the
+         the left child.  */
+      comp = d_left (comp);
+      break;
+    case DEMANGLE_COMPONENT_QUAL_NAME:
+      /* For a qualified name remove template components from the right
+         subtree.  */
+      d_right (comp) = cp_remove_template_params_component (d_right (comp));
+      break;
+    case DEMANGLE_COMPONENT_TYPED_NAME:
+      /* Template components, if present, will be in the left subtree.  Remove
+         them.  */
+      d_left (comp) = cp_remove_template_params_component (d_left (comp));
+      break;
+    default:
+      break;
+    }
+
+  return comp;
+}
+
+/* Remove template parameters from the given name.  The returned string is
+   malloc'ed and must be properly saved and freed.  */
+
+char *
+cp_remove_template_params (const char *name)
+{
+  struct demangle_component *ret_comp;
+  char *ret = NULL;
+
+  if (name == NULL)
+    return NULL;
+
+  ret_comp = cp_demangled_name_to_comp (name, NULL);
+  if (ret_comp == NULL)
+    return NULL;
+
+  ret_comp = cp_remove_template_params_component (ret_comp);
+  ret = cp_comp_to_string (ret_comp, 10);
+
+  return ret;
+}
+
 /* Here are some random pieces of trivia to keep in mind while trying
    to take apart demangled names:
 
@@ -661,7 +727,7 @@ overload_list_add_symbol (struct symbol *sym, const char *oload_name)
       return;
 
   /* Get the demangled name without parameters */
-  sym_name = cp_remove_params (SYMBOL_NATURAL_NAME (sym));
+  sym_name = cp_remove_params (SYMBOL_SEARCH_NAME (sym));
   if (!sym_name)
     return;
 
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index ddc4c93..a2c8f7f 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -107,6 +107,10 @@ extern char *cp_func_name (const char *full_name);
 
 extern char *cp_remove_params (const char *demangled_name);
 
+extern int cp_name_has_template_parameters (const char *name);
+
+extern char *cp_remove_template_params (const char *name);
+
 extern struct symbol **make_symbol_overload_list (const char *,
 						  const char *);
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index a8692ea..e4abd23 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -8661,6 +8661,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
   if (name)
     {
       const char *linkagename;
+      const char *search_name = NULL;
 
       sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
 					     sizeof (struct symbol));
@@ -8680,6 +8681,26 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 				   (char *) dwarf2_full_name (name, die, cu),
 	                           NULL);
 
+      /* For C++ if the name contains template parameters remove them, and set
+         the cleaned up name to be the search name.  */
+      if (cu->language == language_cplus && linkagename
+	  && cp_name_has_template_parameters (linkagename))
+	{
+	  char *tmp = cp_remove_template_params (linkagename);
+
+	  if (tmp != NULL && strcmp (tmp, linkagename) != 0)
+	    {
+	      search_name = obsavestring (tmp, strlen (tmp),
+	                                  &objfile->objfile_obstack);
+
+	      symbol_set_cplus_search_name (&sym->ginfo,
+	                                    objfile,
+	                                    search_name);
+	    }
+
+	  xfree (tmp);
+	}
+
       /* Default assumptions.
          Use the passed type or decode it from the die.  */
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 2232114..70feb62 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -389,6 +389,30 @@ symbol_get_demangled_name (const struct general_symbol_info *gsymbol)
     return gsymbol->language_specific.mangled_lang.demangled_name;
 }
 
+/* Set the search name of the give GSYMBOL to name.  */
+void
+symbol_set_cplus_search_name (struct general_symbol_info *gsymbol,
+                                struct objfile *objfile,
+                                const char *name)
+{
+  if (gsymbol->language_specific.cplus_specific == NULL)
+    symbol_init_cplus_specific (gsymbol, objfile);
+
+  gsymbol->language_specific.cplus_specific->search_name = (char *) name;
+}
+
+/* Get the search name of the give GSYMBOL.  */
+
+char*
+symbol_get_cplus_search_name (const struct general_symbol_info *gsymbol)
+{
+  if (gsymbol->language_specific.cplus_specific != NULL
+      && gsymbol->language_specific.cplus_specific->search_name != NULL)
+    return gsymbol->language_specific.cplus_specific->search_name;
+
+  return symbol_natural_name (gsymbol);
+}
+
 \f
 /* Initialize the language dependent portion of a symbol
    depending upon the language for the symbol. */
@@ -753,6 +777,8 @@ symbol_search_name (const struct general_symbol_info *gsymbol)
 {
   if (gsymbol->language == language_ada)
     return gsymbol->name;
+  else if (gsymbol->language == language_cplus)
+    return symbol_get_cplus_search_name (gsymbol);
   else
     return symbol_natural_name (gsymbol);
 }
@@ -1656,6 +1682,18 @@ find_main_filename (void)
   return (NULL);
 }
 
+/* Return 1 if NAME matches SYM's template name.  */
+
+static int
+symbol_matches_template_name (const char *name, struct symbol *sym)
+{
+  const char *template_name = SYMBOL_NATURAL_NAME(sym);
+  if (template_name == NULL)
+    return 0;
+
+  return strcmp_iw (template_name, name) == 0;
+}
+
 /* Search BLOCK for symbol NAME in DOMAIN.
 
    Note that if NAME is the demangled form of a C++ symbol, we will fail
@@ -1677,10 +1715,29 @@ lookup_block_symbol (const struct block *block, const char *name,
 
   if (!BLOCK_FUNCTION (block))
     {
+      const char *template_name = NULL;
+
+      if (current_language->la_language == language_cplus
+	  && cp_name_has_template_parameters (name))
+	{
+	  template_name = name;
+	  name = cp_remove_template_params (name);
+
+	  if (name == NULL)
+	    /* Not a legal C++ name.  */
+	    return NULL;
+	}
+
       for (sym = dict_iter_name_first (BLOCK_DICT (block), name, &iter);
 	   sym != NULL;
 	   sym = dict_iter_name_next (name, &iter))
 	{
+	  /* For C++ if the name being searched for contains template
+	     parameters check the template name of the symbol.  */
+	  if (template_name != NULL
+	      && !symbol_matches_template_name (template_name, sym))
+	    continue;
+
 	  if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
 				     SYMBOL_DOMAIN (sym), domain))
 	    return sym;
diff --git a/gdb/symtab.h b/gdb/symtab.h
index e6ab26f..d3d85cf 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -80,6 +80,11 @@ struct program_space;
 struct cplus_specific
 {
   char *demangled_name;
+
+  /* If the symbol name contains template parameters this is the name with
+     these parameters removed to be used during search.  Otherwise this
+     should be NULL, and the regular symbol name should be used.  */
+  char *search_name;
 };
 
 /* Define a structure for the information that is common to all symbol types,
@@ -166,6 +171,13 @@ extern void symbol_set_demangled_name (struct general_symbol_info *, char *,
 
 extern char *symbol_get_demangled_name (const struct general_symbol_info *);
 
+/* Set the template name of the give GSYMBOL to name.  */
+extern void symbol_set_cplus_search_name (struct general_symbol_info *gsymbol,
+                                          struct objfile *objfile,
+                                          const char *name);
+
+extern char* symbol_get_cplus_search_name (const struct general_symbol_info *);
+
 extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *);
 
 /* Note that all the following SYMBOL_* macros are used with the
@@ -273,6 +285,7 @@ extern char *symbol_demangled_name (const struct general_symbol_info *symbol);
    (symbol_search_name (&(symbol)->ginfo))
 extern char *symbol_search_name (const struct general_symbol_info *);
 
+
 /* Analogous to SYMBOL_MATCHES_NATURAL_NAME, but uses the search
    name.  */
 #define SYMBOL_MATCHES_SEARCH_NAME(symbol, name)			\
diff --git a/gdb/testsuite/gdb.cp/cp-relocate.exp b/gdb/testsuite/gdb.cp/cp-relocate.exp
index 30d362a..880ad38 100644
--- a/gdb/testsuite/gdb.cp/cp-relocate.exp
+++ b/gdb/testsuite/gdb.cp/cp-relocate.exp
@@ -52,6 +52,8 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_file_cmd ${binfile}
 
+gdb_test_no_output "set language c++" ""
+
 # Find the interesting functions.  We go to a little effort to find
 # the right function names here, to work around PR c++/40.
 set func1_name ""
@@ -123,6 +125,8 @@ gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 
+gdb_test_no_output "set language c++" ""
+
 gdb_test "add-symbol-file ${binfile} 0 -s ${func1_sec} 0x10000 -s ${func2_sec} 0x20000" \
 	"Reading symbols from .*${testfile}\\.o\\.\\.\\.done\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
 	"add-symbol-file ${testfile}.o" \
diff --git a/gdb/testsuite/gdb.cp/temp-op.cc b/gdb/testsuite/gdb.cp/temp-op.cc
new file mode 100644
index 0000000..6d4b13d
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/temp-op.cc
@@ -0,0 +1,105 @@
+class A
+{
+};
+
+template<typename T>
+int foo (T, char)
+{
+  T t;
+  return 11;
+}
+
+template<typename T, typename T2>
+int foo2 (T, T2, char)
+{
+  T t;
+  return 11;
+}
+
+namespace C
+{
+  namespace D {
+    template<typename T, typename T2>
+    int foo3 (T, T2, char)
+    {
+      T t;
+      return 11;
+    }
+  }
+}
+int operator<< (A, int)
+{
+  return 12;
+}
+
+int operator< (A, int)
+{
+  return 13;
+}
+
+int operator<= (A, int)
+{
+  return 14;
+}
+
+template<typename T>
+int operator==(T, char)
+{
+  return 15;
+}
+
+int operator==(A, int)
+{
+  return 16;
+}
+
+template<typename T>
+class B{
+  T t;
+public:
+  int operator==(int)
+    {
+      return 17;
+    }
+};
+
+int operator== (B<int>, char){
+  return 18;
+}
+
+template <class T, int>
+class Outer{
+ public:
+  template <class T2, int>
+    class Inner{
+  public:
+    template <int>
+      class ReallyInner{};
+  };
+};
+
+
+int main ()
+{
+  A a;
+  
+  foo (a, 'a');
+  foo (a, 1);
+  foo2 (a, a, 'a');
+  C::D::foo3 (a, a, 'a');
+
+  a << 22;
+  a <  22;
+  a <= 22;
+
+  a == 'a';
+  a == 1;
+
+  B<int> b;
+  b == 1;
+  b == 'a';
+
+  Outer<int, 23>::Inner<long, 27>::ReallyInner<5> oir;
+  
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.cp/temp-op.exp b/gdb/testsuite/gdb.cp/temp-op.exp
new file mode 100644
index 0000000..f48582f
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/temp-op.exp
@@ -0,0 +1,68 @@
+# Copyright 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+set testfile temp-op
+set srcfile ${testfile}.cc
+set binfile ${objdir}/${subdir}/${testfile}
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
+    untested "Couldn't compile test program"
+    return -1
+}
+
+# Get things started.
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+############################################
+
+if ![runto_main] then {
+    perror "couldn't run to breakpoint main"
+    continue
+}
+
+# Test that a templated function can be found
+# with out specification of template arguments
+gdb_test "p foo(a, 'a')"         "= 11"
+
+# Test that function names with '<' in their names
+# are not mistaken for templates
+gdb_test "p a << 22"         "= 12"
+gdb_test "p a <  22"         "= 13"
+gdb_test "p a <= 22"         "= 14"
+
+# Test that a template operator can be correctly
+# evaluated
+gdb_test "p a == 'a'"        "= 15"
+
+# Test that overload resolution is still correctly
+# performed.
+gdb_test "p a == 1"          "= 16"
+
+# Test calling a member function of a template class
+gdb_test "p b == 1"          "= 17"
+gdb_test "p b == 'a'"        "= 18"
+
+# Test that printing the a template name without
+# template parameters does not return an arbitrary match
+
+gdb_test "p foo" "No symbol \"foo\" in current context"
+gdb_test "ptype B" "No symbol \"foo\" in current context"
diff --git a/gdb/valops.c b/gdb/valops.c
index 506d40e..59ec3ee 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -2458,7 +2458,7 @@ find_overload_match (struct type **arg_types, int nargs,
 
       if (fsym)
         {
-          qualified_name = SYMBOL_NATURAL_NAME (fsym);
+          qualified_name = SYMBOL_SEARCH_NAME (fsym);
 
           /* If we have a function with a C++ name, try to extract just
 	     the function part.  Do not try this for non-functions (e.g.



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

* Re: [patch 1/3] Template Lookup
  2010-07-19 15:28 [patch 1/3] Template Lookup sami wagiaalla
@ 2010-07-20 20:42 ` sami wagiaalla
  2010-08-18 21:45   ` Tom Tromey
  2010-08-11 18:13 ` [patch 1/3] " sami wagiaalla
  1 sibling, 1 reply; 11+ messages in thread
From: sami wagiaalla @ 2010-07-20 20:42 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 41 bytes --]

Same patch but using prepare_for_testing

[-- Attachment #2: template_lookup_1.patch --]
[-- Type: text/plain, Size: 15887 bytes --]

Create search_name and fixed template lookup

2010-07-15  Sami Wagiaalla  <swagiaal@redhat.com>

	* valops.c (find_overload_match): Use SYMBOL_SEARCH_NAME instead of
	SYMBOL_NATURAL_NAME.
	* symtab.h: Added new member search_name to cplus_specific.
	(symbol_set_cplus_search_name): New function prototype.
	(symbol_get_cplus_search_name): New function prototype.
	* symtab.c (symbol_set_cplus_search_name): New function.
	(symbol_get_cplus_search_name): New function.
	(symbol_search_name): Handle the C++ case.
	(symbol_matches_template_name): New function.
	* dwarf2read.c (new_symbol): Set search_name of C++ template symbols.
	* cp-support.H (cp_name_has_template_parameters): New function
	prototype.
	(cp_remove_template_params): New function ptototype.
	* cp-support.c (cp_name_has_template_parameters): New function.
	(cp_remove_template_params_component): New function.
	(cp_remove_template_params): New function.
	(overload_list_add_symbol): Use SYMBOL_SEARCH_NAME instead of
	SYMBOL_NATURAL_NAME.
	* cp-name-parser.y (cp_demangled_name_to_comp): Added more detail to
	comment.

2010-07-15  Sami Wagiaalla  <swagiaal@redhat.com>

	* gdb.cp/temp-op.exp: New test.
	* gdb.cp/temp-op.cc: New test.
	* gdb.cp/cp-relocate.exp: Set the language C++.

diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index 6d7b600..c9b5747 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -1966,9 +1966,12 @@ cp_comp_to_string (struct demangle_component *result, int estimated_len)
 			       &err);
 }
 
-/* Convert a demangled name to a demangle_component tree.  On success,
-   the root of the new tree is returned; it is valid until the next
-   call to this function and should not be freed.  On error, NULL is
+/* Convert a demangled name to a demangle_component tree.  The structure
+   of the tree depends on the format of each node in the tree.  For
+   information on the structure of a node see the comment corresponding
+   to its type in demangle_component_type.
+   On success, the root of the new tree is returned; it is valid until the
+   next call to this function and should not be freed.  On error, NULL is
    returned, and an error message will be set in *ERRMSG (which does
    not need to be freed).  */
 
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 41af7ae..4ef1a0a 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -428,6 +428,72 @@ cp_remove_params (const char *demangled_name)
   return ret;
 }
 
+/* Returns 1 if the given name contains template parameters;
+   otherwise return 0.
+   Used as a quick heuristic to avoid more expensive template
+   parsing when not necessary.  */
+
+int
+cp_name_has_template_parameters (const char *name)
+{
+  char *c = strchr (name, '<');
+  return c != NULL && strchr (c+1, '>') != NULL;
+}
+
+/* Remove template parameters components from the give tree.  */
+
+static struct demangle_component *
+cp_remove_template_params_component (struct demangle_component *comp)
+{
+
+  gdb_assert (comp != NULL);
+
+  switch (comp->type)
+    {
+    case DEMANGLE_COMPONENT_TEMPLATE:
+      /* If there is a template component remove this node by re-parenting the
+         the left child.  */
+      comp = d_left (comp);
+      break;
+    case DEMANGLE_COMPONENT_QUAL_NAME:
+      /* For a qualified name remove template components from the right
+         subtree.  */
+      d_right (comp) = cp_remove_template_params_component (d_right (comp));
+      break;
+    case DEMANGLE_COMPONENT_TYPED_NAME:
+      /* Template components, if present, will be in the left subtree.  Remove
+         them.  */
+      d_left (comp) = cp_remove_template_params_component (d_left (comp));
+      break;
+    default:
+      break;
+    }
+
+  return comp;
+}
+
+/* Remove template parameters from the given name.  The returned string is
+   malloc'ed and must be properly saved and freed.  */
+
+char *
+cp_remove_template_params (const char *name)
+{
+  struct demangle_component *ret_comp;
+  char *ret = NULL;
+
+  if (name == NULL)
+    return NULL;
+
+  ret_comp = cp_demangled_name_to_comp (name, NULL);
+  if (ret_comp == NULL)
+    return NULL;
+
+  ret_comp = cp_remove_template_params_component (ret_comp);
+  ret = cp_comp_to_string (ret_comp, 10);
+
+  return ret;
+}
+
 /* Here are some random pieces of trivia to keep in mind while trying
    to take apart demangled names:
 
@@ -661,7 +727,7 @@ overload_list_add_symbol (struct symbol *sym, const char *oload_name)
       return;
 
   /* Get the demangled name without parameters */
-  sym_name = cp_remove_params (SYMBOL_NATURAL_NAME (sym));
+  sym_name = cp_remove_params (SYMBOL_SEARCH_NAME (sym));
   if (!sym_name)
     return;
 
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index ddc4c93..a2c8f7f 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -107,6 +107,10 @@ extern char *cp_func_name (const char *full_name);
 
 extern char *cp_remove_params (const char *demangled_name);
 
+extern int cp_name_has_template_parameters (const char *name);
+
+extern char *cp_remove_template_params (const char *name);
+
 extern struct symbol **make_symbol_overload_list (const char *,
 						  const char *);
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index a8692ea..e4abd23 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -8661,6 +8661,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
   if (name)
     {
       const char *linkagename;
+      const char *search_name = NULL;
 
       sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
 					     sizeof (struct symbol));
@@ -8680,6 +8681,26 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 				   (char *) dwarf2_full_name (name, die, cu),
 	                           NULL);
 
+      /* For C++ if the name contains template parameters remove them, and set
+         the cleaned up name to be the search name.  */
+      if (cu->language == language_cplus && linkagename
+	  && cp_name_has_template_parameters (linkagename))
+	{
+	  char *tmp = cp_remove_template_params (linkagename);
+
+	  if (tmp != NULL && strcmp (tmp, linkagename) != 0)
+	    {
+	      search_name = obsavestring (tmp, strlen (tmp),
+	                                  &objfile->objfile_obstack);
+
+	      symbol_set_cplus_search_name (&sym->ginfo,
+	                                    objfile,
+	                                    search_name);
+	    }
+
+	  xfree (tmp);
+	}
+
       /* Default assumptions.
          Use the passed type or decode it from the die.  */
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
diff --git a/gdb/symtab.c b/gdb/symtab.c
index ec0e809..ef9824d 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -389,6 +389,30 @@ symbol_get_demangled_name (const struct general_symbol_info *gsymbol)
     return gsymbol->language_specific.mangled_lang.demangled_name;
 }
 
+/* Set the search name of the give GSYMBOL to name.  */
+void
+symbol_set_cplus_search_name (struct general_symbol_info *gsymbol,
+                                struct objfile *objfile,
+                                const char *name)
+{
+  if (gsymbol->language_specific.cplus_specific == NULL)
+    symbol_init_cplus_specific (gsymbol, objfile);
+
+  gsymbol->language_specific.cplus_specific->search_name = (char *) name;
+}
+
+/* Get the search name of the give GSYMBOL.  */
+
+char*
+symbol_get_cplus_search_name (const struct general_symbol_info *gsymbol)
+{
+  if (gsymbol->language_specific.cplus_specific != NULL
+      && gsymbol->language_specific.cplus_specific->search_name != NULL)
+    return gsymbol->language_specific.cplus_specific->search_name;
+
+  return symbol_natural_name (gsymbol);
+}
+
 \f
 /* Initialize the language dependent portion of a symbol
    depending upon the language for the symbol. */
@@ -754,6 +778,8 @@ symbol_search_name (const struct general_symbol_info *gsymbol)
 {
   if (gsymbol->language == language_ada)
     return gsymbol->name;
+  else if (gsymbol->language == language_cplus)
+    return symbol_get_cplus_search_name (gsymbol);
   else
     return symbol_natural_name (gsymbol);
 }
@@ -1657,6 +1683,18 @@ find_main_filename (void)
   return (NULL);
 }
 
+/* Return 1 if NAME matches SYM's template name.  */
+
+static int
+symbol_matches_template_name (const char *name, struct symbol *sym)
+{
+  const char *template_name = SYMBOL_NATURAL_NAME(sym);
+  if (template_name == NULL)
+    return 0;
+
+  return strcmp_iw (template_name, name) == 0;
+}
+
 /* Search BLOCK for symbol NAME in DOMAIN.
 
    Note that if NAME is the demangled form of a C++ symbol, we will fail
@@ -1678,10 +1716,29 @@ lookup_block_symbol (const struct block *block, const char *name,
 
   if (!BLOCK_FUNCTION (block))
     {
+      const char *template_name = NULL;
+
+      if (current_language->la_language == language_cplus
+	  && cp_name_has_template_parameters (name))
+	{
+	  template_name = name;
+	  name = cp_remove_template_params (name);
+
+	  if (name == NULL)
+	    /* Not a legal C++ name.  */
+	    return NULL;
+	}
+
       for (sym = dict_iter_name_first (BLOCK_DICT (block), name, &iter);
 	   sym != NULL;
 	   sym = dict_iter_name_next (name, &iter))
 	{
+	  /* For C++ if the name being searched for contains template
+	     parameters check the template name of the symbol.  */
+	  if (template_name != NULL
+	      && !symbol_matches_template_name (template_name, sym))
+	    continue;
+
 	  if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
 				     SYMBOL_DOMAIN (sym), domain))
 	    return sym;
diff --git a/gdb/symtab.h b/gdb/symtab.h
index e6ab26f..d3d85cf 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -80,6 +80,11 @@ struct program_space;
 struct cplus_specific
 {
   char *demangled_name;
+
+  /* If the symbol name contains template parameters this is the name with
+     these parameters removed to be used during search.  Otherwise this
+     should be NULL, and the regular symbol name should be used.  */
+  char *search_name;
 };
 
 /* Define a structure for the information that is common to all symbol types,
@@ -166,6 +171,13 @@ extern void symbol_set_demangled_name (struct general_symbol_info *, char *,
 
 extern char *symbol_get_demangled_name (const struct general_symbol_info *);
 
+/* Set the template name of the give GSYMBOL to name.  */
+extern void symbol_set_cplus_search_name (struct general_symbol_info *gsymbol,
+                                          struct objfile *objfile,
+                                          const char *name);
+
+extern char* symbol_get_cplus_search_name (const struct general_symbol_info *);
+
 extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *);
 
 /* Note that all the following SYMBOL_* macros are used with the
@@ -273,6 +285,7 @@ extern char *symbol_demangled_name (const struct general_symbol_info *symbol);
    (symbol_search_name (&(symbol)->ginfo))
 extern char *symbol_search_name (const struct general_symbol_info *);
 
+
 /* Analogous to SYMBOL_MATCHES_NATURAL_NAME, but uses the search
    name.  */
 #define SYMBOL_MATCHES_SEARCH_NAME(symbol, name)			\
diff --git a/gdb/testsuite/gdb.cp/cp-relocate.exp b/gdb/testsuite/gdb.cp/cp-relocate.exp
index 30d362a..880ad38 100644
--- a/gdb/testsuite/gdb.cp/cp-relocate.exp
+++ b/gdb/testsuite/gdb.cp/cp-relocate.exp
@@ -52,6 +52,8 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_file_cmd ${binfile}
 
+gdb_test_no_output "set language c++" ""
+
 # Find the interesting functions.  We go to a little effort to find
 # the right function names here, to work around PR c++/40.
 set func1_name ""
@@ -123,6 +125,8 @@ gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 
+gdb_test_no_output "set language c++" ""
+
 gdb_test "add-symbol-file ${binfile} 0 -s ${func1_sec} 0x10000 -s ${func2_sec} 0x20000" \
 	"Reading symbols from .*${testfile}\\.o\\.\\.\\.done\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
 	"add-symbol-file ${testfile}.o" \
diff --git a/gdb/testsuite/gdb.cp/temp-op.cc b/gdb/testsuite/gdb.cp/temp-op.cc
new file mode 100644
index 0000000..6d4b13d
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/temp-op.cc
@@ -0,0 +1,105 @@
+class A
+{
+};
+
+template<typename T>
+int foo (T, char)
+{
+  T t;
+  return 11;
+}
+
+template<typename T, typename T2>
+int foo2 (T, T2, char)
+{
+  T t;
+  return 11;
+}
+
+namespace C
+{
+  namespace D {
+    template<typename T, typename T2>
+    int foo3 (T, T2, char)
+    {
+      T t;
+      return 11;
+    }
+  }
+}
+int operator<< (A, int)
+{
+  return 12;
+}
+
+int operator< (A, int)
+{
+  return 13;
+}
+
+int operator<= (A, int)
+{
+  return 14;
+}
+
+template<typename T>
+int operator==(T, char)
+{
+  return 15;
+}
+
+int operator==(A, int)
+{
+  return 16;
+}
+
+template<typename T>
+class B{
+  T t;
+public:
+  int operator==(int)
+    {
+      return 17;
+    }
+};
+
+int operator== (B<int>, char){
+  return 18;
+}
+
+template <class T, int>
+class Outer{
+ public:
+  template <class T2, int>
+    class Inner{
+  public:
+    template <int>
+      class ReallyInner{};
+  };
+};
+
+
+int main ()
+{
+  A a;
+  
+  foo (a, 'a');
+  foo (a, 1);
+  foo2 (a, a, 'a');
+  C::D::foo3 (a, a, 'a');
+
+  a << 22;
+  a <  22;
+  a <= 22;
+
+  a == 'a';
+  a == 1;
+
+  B<int> b;
+  b == 1;
+  b == 'a';
+
+  Outer<int, 23>::Inner<long, 27>::ReallyInner<5> oir;
+  
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.cp/temp-op.exp b/gdb/testsuite/gdb.cp/temp-op.exp
new file mode 100644
index 0000000..b480d13
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/temp-op.exp
@@ -0,0 +1,55 @@
+# Copyright 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+set testfile temp-op
+set srcfile ${testfile}.cc
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } {
+     return -1
+}
+
+############################################
+
+if ![runto_main] then {
+    perror "couldn't run to breakpoint main"
+    continue
+}
+
+# Test that a templated function can be found
+# with out specification of template arguments
+gdb_test "p foo(a, 'a')"         "= 11"
+
+# Test that function names with '<' in their names
+# are not mistaken for templates
+gdb_test "p a << 22"         "= 12"
+gdb_test "p a <  22"         "= 13"
+gdb_test "p a <= 22"         "= 14"
+
+# Test that a template operator can be correctly
+# evaluated
+gdb_test "p a == 'a'"        "= 15"
+
+# Test that overload resolution is still correctly
+# performed.
+gdb_test "p a == 1"          "= 16"
+
+# Test calling a member function of a template class
+gdb_test "p b == 1"          "= 17"
+gdb_test "p b == 'a'"        "= 18"
+
+# Test that printing the a template name without
+# template parameters does not return an arbitrary match
+
+gdb_test "p foo" "No symbol \"foo\" in current context"
+gdb_test "ptype B" "No symbol \"foo\" in current context"
diff --git a/gdb/valops.c b/gdb/valops.c
index 506d40e..59ec3ee 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -2458,7 +2458,7 @@ find_overload_match (struct type **arg_types, int nargs,
 
       if (fsym)
         {
-          qualified_name = SYMBOL_NATURAL_NAME (fsym);
+          qualified_name = SYMBOL_SEARCH_NAME (fsym);
 
           /* If we have a function with a C++ name, try to extract just
 	     the function part.  Do not try this for non-functions (e.g.

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

* Re: [patch 1/3] Template Lookup
  2010-07-19 15:28 [patch 1/3] Template Lookup sami wagiaalla
  2010-07-20 20:42 ` sami wagiaalla
@ 2010-08-11 18:13 ` sami wagiaalla
  1 sibling, 0 replies; 11+ messages in thread
From: sami wagiaalla @ 2010-08-11 18:13 UTC (permalink / raw)
  To: gdb-patches

Ping :)

On 07/19/2010 11:28 AM, sami wagiaalla wrote:
> Names of template symbols in debug info contains the full template
> parameters such as:
>
> foo<int>(int)
> foo<char>(char)
>
> while this is useful for differentiating various instances of template
> it provides unnatural user experience when you user tries to call these
> functions. For example:
>
> (gdb) print foo<int>(1)
> (gdb) print foo<char>('a')
>
> This patch removes the template parameters from the name and stores the
> cleaned name in a newly created variable 'search_name' in the -now
> obstack allocated- 'cplus_specific' structure.
>
> So now the user can do:
>
> (gdb) print foo(1)
> (gdb) print foo('a')
>
> The function choice is made by overload resolution as it should be.
>
> Functionality that required the fully qualified name still works. For
> example:
>
> (gdb) break foo<char>
>
> This is because if the user included template parameters in the name
> then the template name is double checked for every hit.
>
> This series was tested by running the testsuit on Fedora 13 with gcc
> 4.4.4 on x8664.
>

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

* Re: [patch 1/3] Template Lookup
  2010-07-20 20:42 ` sami wagiaalla
@ 2010-08-18 21:45   ` Tom Tromey
  2010-08-26 16:05     ` sami wagiaalla
  0 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2010-08-18 21:45 UTC (permalink / raw)
  To: sami wagiaalla; +Cc: gdb-patches

>>>>> "Sami" == sami wagiaalla <swagiaal@redhat.com> writes:

Sami> Same patch but using prepare_for_testing

Thanks.

I suspect this doesn't interact properly with psymtabs, because from
what I can tell the template-argument-less symbol is only entered for
full symbols, not partial symbols.  This means that a reference to some
function will not work properly until the psymtab is expanded for some
other reason.

Sami> +static struct demangle_component *
Sami> +cp_remove_template_params_component (struct demangle_component *comp)
Sami> +{
Sami> +
Sami> +  gdb_assert (comp != NULL);

No need for that blank line.

Sami> +char*
Sami> +symbol_get_cplus_search_name (const struct general_symbol_info *gsymbol)

"char *"

Sami> +extern char* symbol_get_cplus_search_name (const struct general_symbol_info *);

"char *"

Sami> +gdb_test_no_output "set language c++" ""

There are a couple instances of this that have to be updated in light of
Doug's recent change to how this is done.

Sami> @@ -2458,7 +2458,7 @@ find_overload_match (struct type **arg_types, int nargs,
Sami>        if (fsym)
Sami>          {
Sami> -          qualified_name = SYMBOL_NATURAL_NAME (fsym);
Sami> +          qualified_name = SYMBOL_SEARCH_NAME (fsym);

It took me a while to understand why this could be work.

It seems to me that it is not completely right though.  Consider this case:

    template<int X> int f (int x) { return x + X; }
    int compute (int x) { return f<5> (x) + f<7> (x); }

In this situation you can't just look at overloads of "f" -- it is
ambiguous.  You have to do more analysis.

Tom

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

* Re: [patch 1/3] Template Lookup
  2010-08-18 21:45   ` Tom Tromey
@ 2010-08-26 16:05     ` sami wagiaalla
  2010-08-31 22:05       ` Tom Tromey
  2010-09-23 17:55       ` [patch 1/4] " sami wagiaalla
  0 siblings, 2 replies; 11+ messages in thread
From: sami wagiaalla @ 2010-08-26 16:05 UTC (permalink / raw)
  To: gdb-patches


> Sami>  Same patch but using prepare_for_testing
>
> Thanks.
>

Thanks for the review.

> I suspect this doesn't interact properly with psymtabs, because from
> what I can tell the template-argument-less symbol is only entered for
> full symbols, not partial symbols.  This means that a reference to some
> function will not work properly until the psymtab is expanded for some
> other reason.
>

Hmm.. can you give me an example of this ? I tried to construct an 
example with an extern function but I learned that cplus does not allow 
extern template functions.

> Sami>  +gdb_test_no_output "set language c++" ""
>
> There are a couple instances of this that have to be updated in light of
> Doug's recent change to how this is done.
>

What is the change that Doug made ?

> Sami>  @@ -2458,7 +2458,7 @@ find_overload_match (struct type **arg_types, int nargs,
> Sami>         if (fsym)
> Sami>           {
> Sami>  -          qualified_name = SYMBOL_NATURAL_NAME (fsym);
> Sami>  +          qualified_name = SYMBOL_SEARCH_NAME (fsym);
>
> It took me a while to understand why this could be work.
>
> It seems to me that it is not completely right though.  Consider this case:
>
>      template<int X>  int f (int x) { return x + X; }
>      int compute (int x) { return f<5>  (x) + f<7>  (x); }
>
> In this situation you can't just look at overloads of "f" -- it is
> ambiguous.  You have to do more analysis.
>

This can be blamed on find_overload_match's inability to deal with 
ambiguous resolution. Removing the template parameter actually makes it 
easier for find_overload_match to handle this situation if/when it 
supports the ambiguous case. It enables find_overload_match to print a 
message about ambiguous overload resolution instead of just "symbol not 
found". Of course p f<5>() and p f<7>() still works correctly.

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

* Re: [patch 1/3] Template Lookup
  2010-08-26 16:05     ` sami wagiaalla
@ 2010-08-31 22:05       ` Tom Tromey
  2010-09-23 18:43         ` [patch 4/4] " sami wagiaalla
  2010-09-23 17:55       ` [patch 1/4] " sami wagiaalla
  1 sibling, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2010-08-31 22:05 UTC (permalink / raw)
  To: sami wagiaalla; +Cc: gdb-patches

>>>>> "Sami" == sami wagiaalla <swagiaal@redhat.com> writes:

Sami> Hmm.. can you give me an example of this ? I tried to construct an
Sami> example with an extern function but I learned that cplus does not
Sami> allow extern template functions.

Ordinarily, to make a test involving psymtab expansion, you have to make
two compilation units.

Put this into one file:

    template<typename T> double f (T x) { return x; }

    int g (void)
    {
      return f(1.0) + f(2);
    }

Put this in another file:

    extern int g(void);

    int main()
    {
      return g();
    }

Compile, debug, and "start".

Now in main:

    (gdb) p f(1.0)
    No symbol "f" in current context.
    (gdb) p f<double>(1.0)
    $1 = 1

... but if you step into g, it works:

    (gdb) s
    g () at q1.cc:5
    5	  return f(1.0) + f(2);
    (gdb) p f(1.0)
    $2 = 1

Tom> There are a couple instances of this that have to be updated in light of
Tom> Doug's recent change to how this is done.

Sami> What is the change that Doug made ?

He added various set_lang_ functions.
Maybe I'm mistaken about the need for this, as there doesn't seem to be
a special function for C++.

Tom

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

* Re: [patch 1/4] Template Lookup
  2010-08-26 16:05     ` sami wagiaalla
  2010-08-31 22:05       ` Tom Tromey
@ 2010-09-23 17:55       ` sami wagiaalla
  2010-10-05 19:08         ` sami wagiaalla
  1 sibling, 1 reply; 11+ messages in thread
From: sami wagiaalla @ 2010-09-23 17:55 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 427 bytes --]

Attached is a revised patch that has been rebased on HEAD, plus
a few aesthetic changes.

>> I suspect this doesn't interact properly with psymtabs, because from
>> what I can tell the template-argument-less symbol is only entered for
>> full symbols, not partial symbols. This means that a reference to some
>> function will not work properly until the psymtab is expanded for some
>> other reason.
>>

Please see patch 4/4



[-- Attachment #2: template_lookup_1.patch --]
[-- Type: text/x-patch, Size: 16036 bytes --]

Template Lookup 1: Create search_name and fixed template lookup

2010-09-15  Sami Wagiaalla  <swagiaal@redhat.com>

	* valops.c (find_overload_match): Use SYMBOL_SEARCH_NAME instead of
	SYMBOL_NATURAL_NAME.
	* symtab.h: Added new member search_name to cplus_specific.
	(symbol_set_cplus_search_name): New function prototype.
	(symbol_get_cplus_search_name): New function prototype.
	(SYMBOL_MATCHES_TEMPLATE_NAME): New macro.
	* symtab.c (symbol_set_cplus_search_name): New function.
	(symbol_get_cplus_search_name): New function.
	(symbol_search_name): Handle the C++ case.
	* dwarf2read.c (new_symbol): Set search_name of C++ template symbols.
	* cp-support.H (cp_name_has_template_parameters): New function
	prototype.
	(cp_remove_template_params): New function ptototype.
	* cp-support.c (cp_name_has_template_parameters): New function.
	(cp_remove_template_params_component): New function.
	(cp_remove_template_params): New function.
	(overload_list_add_symbol): Use SYMBOL_SEARCH_NAME instead of
	SYMBOL_NATURAL_NAME.
	* cp-name-parser.y (cp_demangled_name_to_comp): Added more detail to
	comment.

2010-09-15  Sami Wagiaalla  <swagiaal@redhat.com>

	* gdb.cp/temp-op.exp: New test.
	* gdb.cp/temp-op.cc: New test.
	* gdb.cp/cp-relocate.exp: Set the language C++.

diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index 6d7b600..c9b5747 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -1966,9 +1966,12 @@ cp_comp_to_string (struct demangle_component *result, int estimated_len)
 			       &err);
 }
 
-/* Convert a demangled name to a demangle_component tree.  On success,
-   the root of the new tree is returned; it is valid until the next
-   call to this function and should not be freed.  On error, NULL is
+/* Convert a demangled name to a demangle_component tree.  The structure
+   of the tree depends on the format of each node in the tree.  For
+   information on the structure of a node see the comment corresponding
+   to its type in demangle_component_type.
+   On success, the root of the new tree is returned; it is valid until the
+   next call to this function and should not be freed.  On error, NULL is
    returned, and an error message will be set in *ERRMSG (which does
    not need to be freed).  */
 
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index ad1fb06..831dfc6 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -428,6 +428,74 @@ cp_remove_params (const char *demangled_name)
   return ret;
 }
 
+/* Returns 1 if the given name contains template parameters;
+   otherwise return 0.
+   Used as a quick heuristic to avoid more expensive template
+   parsing when not necessary.  */
+
+int
+cp_name_has_template_parameters (const char *name)
+{
+  /* Check for '<' and then check that '>' exists further
+     down the string to avoid matching things like
+     operator< operator<=, and operator<<.  */
+  char *c = strchr (name, '<');
+  return c != NULL && strchr (c+1, '>') != NULL;
+}
+
+/* Remove template parameters components from the give tree.  */
+
+static struct demangle_component *
+cp_remove_template_params_component (struct demangle_component *comp)
+{
+  gdb_assert (comp != NULL);
+
+  switch (comp->type)
+    {
+    case DEMANGLE_COMPONENT_TEMPLATE:
+      /* If there is a template component remove this node by re-parenting the
+         the left child.  */
+      comp = d_left (comp);
+      break;
+    case DEMANGLE_COMPONENT_QUAL_NAME:
+      /* For a qualified name remove template components from the right
+         subtree.  */
+      d_right (comp) = cp_remove_template_params_component (d_right (comp));
+      break;
+    case DEMANGLE_COMPONENT_TYPED_NAME:
+      /* Template components, if present, will be in the left subtree.  Remove
+         them.  */
+      d_left (comp) = cp_remove_template_params_component (d_left (comp));
+      break;
+    default:
+      break;
+    }
+
+  return comp;
+}
+
+/* Remove template parameters from the given name.  The returned string is
+   malloc'ed and must be properly saved and freed.  */
+
+char *
+cp_remove_template_params (const char *name)
+{
+  struct demangle_component *ret_comp;
+  char *ret = NULL;
+
+  if (name == NULL)
+    return NULL;
+
+  ret_comp = cp_demangled_name_to_comp (name, NULL);
+  if (ret_comp == NULL)
+    return NULL;
+
+  ret_comp = cp_remove_template_params_component (ret_comp);
+  ret = cp_comp_to_string (ret_comp, 10);
+
+  return ret;
+}
+
 /* Here are some random pieces of trivia to keep in mind while trying
    to take apart demangled names:
 
@@ -661,7 +729,7 @@ overload_list_add_symbol (struct symbol *sym, const char *oload_name)
       return;
 
   /* Get the demangled name without parameters */
-  sym_name = cp_remove_params (SYMBOL_NATURAL_NAME (sym));
+  sym_name = cp_remove_params (SYMBOL_SEARCH_NAME (sym));
   if (!sym_name)
     return;
 
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index 1e52d93..be05c28 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -107,6 +107,10 @@ extern char *cp_func_name (const char *full_name);
 
 extern char *cp_remove_params (const char *demangled_name);
 
+extern int cp_name_has_template_parameters (const char *name);
+
+extern char *cp_remove_template_params (const char *name);
+
 extern struct symbol **make_symbol_overload_list (const char *,
 						  const char *);
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 5b58a5b..8d37db1 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -10502,6 +10502,7 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
     {
       const char *linkagename;
       int suppress_add = 0;
+      const char *search_name = NULL;
 
       if (space)
 	sym = space;
@@ -10522,6 +10523,26 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 				   (char *) dwarf2_full_name (name, die, cu),
 	                           NULL);
 
+      /* For C++ if the name contains template parameters remove them, and set
+         the cleaned up name to be the search name.  */
+      if (cu->language == language_cplus && linkagename
+	  && cp_name_has_template_parameters (linkagename))
+	{
+	  char *tmp = cp_remove_template_params (linkagename);
+
+	  if (tmp != NULL && strcmp (tmp, linkagename) != 0)
+	    {
+	      search_name = obsavestring (tmp, strlen (tmp),
+	                                  &objfile->objfile_obstack);
+
+	      symbol_set_cplus_search_name (&sym->ginfo,
+	                                    objfile,
+	                                    search_name);
+	    }
+
+	  xfree (tmp);
+	}
+
       /* Default assumptions.
          Use the passed type or decode it from the die.  */
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
diff --git a/gdb/symtab.c b/gdb/symtab.c
index e645567..068bf87 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -392,6 +392,30 @@ symbol_get_demangled_name (const struct general_symbol_info *gsymbol)
     return gsymbol->language_specific.mangled_lang.demangled_name;
 }
 
+/* Set the search name of the give GSYMBOL to name.  */
+void
+symbol_set_cplus_search_name (struct general_symbol_info *gsymbol,
+                                struct objfile *objfile,
+                                const char *name)
+{
+  if (gsymbol->language_specific.cplus_specific == NULL)
+    symbol_init_cplus_specific (gsymbol, objfile);
+
+  gsymbol->language_specific.cplus_specific->search_name = (char *) name;
+}
+
+/* Get the search name of the give GSYMBOL.  */
+
+char *
+symbol_get_cplus_search_name (const struct general_symbol_info *gsymbol)
+{
+  if (gsymbol->language_specific.cplus_specific != NULL
+      && gsymbol->language_specific.cplus_specific->search_name != NULL)
+    return gsymbol->language_specific.cplus_specific->search_name;
+
+  return symbol_natural_name (gsymbol);
+}
+
 \f
 /* Initialize the language dependent portion of a symbol
    depending upon the language for the symbol. */
@@ -755,6 +779,8 @@ symbol_search_name (const struct general_symbol_info *gsymbol)
 {
   if (gsymbol->language == language_ada)
     return gsymbol->name;
+  else if (gsymbol->language == language_cplus)
+    return symbol_get_cplus_search_name (gsymbol);
   else
     return symbol_natural_name (gsymbol);
 }
@@ -1824,10 +1850,29 @@ lookup_block_symbol (const struct block *block, const char *name,
 
   if (!BLOCK_FUNCTION (block))
     {
+      const char *template_name = NULL;
+
+      if (current_language->la_language == language_cplus
+	  && cp_name_has_template_parameters (name))
+	{
+	  template_name = name;
+	  name = cp_remove_template_params (name);
+
+	  if (name == NULL)
+	    /* Not a legal C++ name.  */
+	    return NULL;
+	}
+
       for (sym = dict_iter_name_first (BLOCK_DICT (block), name, &iter);
 	   sym != NULL;
 	   sym = dict_iter_name_next (name, &iter))
 	{
+	  /* For C++ if the name being searched for contains template
+	     parameters check the template name of the symbol.  */
+	  if (template_name != NULL
+	      && !SYMBOL_MATCHES_TEMPLATE_NAME (sym, template_name))
+	    continue;
+
 	  if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
 				     SYMBOL_DOMAIN (sym), domain))
 	    return sym;
diff --git a/gdb/symtab.h b/gdb/symtab.h
index f96c3f4..9892289 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -80,6 +80,11 @@ struct program_space;
 struct cplus_specific
 {
   char *demangled_name;
+
+  /* If the symbol name contains template parameters this is the name with
+     these parameters removed to be used during search.  Otherwise this
+     should be NULL, and the regular symbol name should be used.  */
+  char *search_name;
 };
 
 /* Define a structure for the information that is common to all symbol types,
@@ -166,6 +171,13 @@ extern void symbol_set_demangled_name (struct general_symbol_info *, char *,
 
 extern char *symbol_get_demangled_name (const struct general_symbol_info *);
 
+/* Set the template name of the give GSYMBOL to name.  */
+extern void symbol_set_cplus_search_name (struct general_symbol_info *gsymbol,
+                                          struct objfile *objfile,
+                                          const char *name);
+
+extern char *symbol_get_cplus_search_name (const struct general_symbol_info *);
+
 extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *);
 
 /* Note that all the following SYMBOL_* macros are used with the
@@ -273,11 +285,17 @@ extern char *symbol_demangled_name (const struct general_symbol_info *symbol);
    (symbol_search_name (&(symbol)->ginfo))
 extern char *symbol_search_name (const struct general_symbol_info *);
 
+
 /* Analogous to SYMBOL_MATCHES_NATURAL_NAME, but uses the search
    name.  */
 #define SYMBOL_MATCHES_SEARCH_NAME(symbol, name)			\
   (strcmp_iw (SYMBOL_SEARCH_NAME (symbol), (name)) == 0)
 
+/* Because template names are currently stored in the natural name,
+   this macro is the exact same as SYMBOL_MATCHES_NATURAL_NAME.  */
+#define SYMBOL_MATCHES_TEMPLATE_NAME(symbol, name)			\
+  SYMBOL_MATCHES_NATURAL_NAME (symbol, name)
+
 /* Classification types for a minimal symbol.  These should be taken as
    "advisory only", since if gdb can't easily figure out a
    classification it simply selects mst_unknown.  It may also have to
diff --git a/gdb/testsuite/gdb.cp/cp-relocate.exp b/gdb/testsuite/gdb.cp/cp-relocate.exp
index 30d362a..880ad38 100644
--- a/gdb/testsuite/gdb.cp/cp-relocate.exp
+++ b/gdb/testsuite/gdb.cp/cp-relocate.exp
@@ -52,6 +52,8 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_file_cmd ${binfile}
 
+gdb_test_no_output "set language c++" ""
+
 # Find the interesting functions.  We go to a little effort to find
 # the right function names here, to work around PR c++/40.
 set func1_name ""
@@ -123,6 +125,8 @@ gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 
+gdb_test_no_output "set language c++" ""
+
 gdb_test "add-symbol-file ${binfile} 0 -s ${func1_sec} 0x10000 -s ${func2_sec} 0x20000" \
 	"Reading symbols from .*${testfile}\\.o\\.\\.\\.done\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
 	"add-symbol-file ${testfile}.o" \
diff --git a/gdb/testsuite/gdb.cp/temp-op.cc b/gdb/testsuite/gdb.cp/temp-op.cc
new file mode 100644
index 0000000..6d4b13d
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/temp-op.cc
@@ -0,0 +1,105 @@
+class A
+{
+};
+
+template<typename T>
+int foo (T, char)
+{
+  T t;
+  return 11;
+}
+
+template<typename T, typename T2>
+int foo2 (T, T2, char)
+{
+  T t;
+  return 11;
+}
+
+namespace C
+{
+  namespace D {
+    template<typename T, typename T2>
+    int foo3 (T, T2, char)
+    {
+      T t;
+      return 11;
+    }
+  }
+}
+int operator<< (A, int)
+{
+  return 12;
+}
+
+int operator< (A, int)
+{
+  return 13;
+}
+
+int operator<= (A, int)
+{
+  return 14;
+}
+
+template<typename T>
+int operator==(T, char)
+{
+  return 15;
+}
+
+int operator==(A, int)
+{
+  return 16;
+}
+
+template<typename T>
+class B{
+  T t;
+public:
+  int operator==(int)
+    {
+      return 17;
+    }
+};
+
+int operator== (B<int>, char){
+  return 18;
+}
+
+template <class T, int>
+class Outer{
+ public:
+  template <class T2, int>
+    class Inner{
+  public:
+    template <int>
+      class ReallyInner{};
+  };
+};
+
+
+int main ()
+{
+  A a;
+  
+  foo (a, 'a');
+  foo (a, 1);
+  foo2 (a, a, 'a');
+  C::D::foo3 (a, a, 'a');
+
+  a << 22;
+  a <  22;
+  a <= 22;
+
+  a == 'a';
+  a == 1;
+
+  B<int> b;
+  b == 1;
+  b == 'a';
+
+  Outer<int, 23>::Inner<long, 27>::ReallyInner<5> oir;
+  
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.cp/temp-op.exp b/gdb/testsuite/gdb.cp/temp-op.exp
new file mode 100644
index 0000000..b480d13
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/temp-op.exp
@@ -0,0 +1,55 @@
+# Copyright 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+set testfile temp-op
+set srcfile ${testfile}.cc
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } {
+     return -1
+}
+
+############################################
+
+if ![runto_main] then {
+    perror "couldn't run to breakpoint main"
+    continue
+}
+
+# Test that a templated function can be found
+# with out specification of template arguments
+gdb_test "p foo(a, 'a')"         "= 11"
+
+# Test that function names with '<' in their names
+# are not mistaken for templates
+gdb_test "p a << 22"         "= 12"
+gdb_test "p a <  22"         "= 13"
+gdb_test "p a <= 22"         "= 14"
+
+# Test that a template operator can be correctly
+# evaluated
+gdb_test "p a == 'a'"        "= 15"
+
+# Test that overload resolution is still correctly
+# performed.
+gdb_test "p a == 1"          "= 16"
+
+# Test calling a member function of a template class
+gdb_test "p b == 1"          "= 17"
+gdb_test "p b == 'a'"        "= 18"
+
+# Test that printing the a template name without
+# template parameters does not return an arbitrary match
+
+gdb_test "p foo" "No symbol \"foo\" in current context"
+gdb_test "ptype B" "No symbol \"foo\" in current context"
diff --git a/gdb/valops.c b/gdb/valops.c
index 8150d7e..a6b7fe6 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -2456,7 +2456,7 @@ find_overload_match (struct type **arg_types, int nargs,
 
       if (fsym)
         {
-          qualified_name = SYMBOL_NATURAL_NAME (fsym);
+          qualified_name = SYMBOL_SEARCH_NAME (fsym);
 
           /* If we have a function with a C++ name, try to extract just
 	     the function part.  Do not try this for non-functions (e.g.



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

* Re: [patch 4/4] Template Lookup
  2010-08-31 22:05       ` Tom Tromey
@ 2010-09-23 18:43         ` sami wagiaalla
  0 siblings, 0 replies; 11+ messages in thread
From: sami wagiaalla @ 2010-09-23 18:43 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 585 bytes --]

On 08/31/2010 06:05 PM, Tom Tromey wrote:
>>>>>> "Sami" == sami wagiaalla<swagiaal@redhat.com>  writes:
>
> Sami>  Hmm.. can you give me an example of this ? I tried to construct an
> Sami>  example with an extern function but I learned that cplus does not
> Sami>  allow extern template functions.
>
> Ordinarily, to make a test involving psymtab expansion, you have to make
> two compilation units.
>
[...]
Thanks for the compact example. I made it into a test case and added 
partial symbol support.

The attached patch was regression tested on x8664 with gcc-4.4.4-10.f13

Sami




[-- Attachment #2: template_lookup_4.patch --]
[-- Type: text/x-patch, Size: 6183 bytes --]

Template Lookup 4: Support template lookup for partial symbols.

2010-09-17  Sami Wagiaalla  <swagiaal@redhat.com>

	* psymtab.c (lookup_partial_symbol): Support search of template
	symbols.
	* dwarf2read.c (add_partial_symbol): set search name for
	template symbols.

2010-09-17  Sami Wagiaalla  <swagiaal@redhat.com>

	* gdb.cp/partial.exp: New file.
	* gdb.cp/partial2.cc: New file.
	* gdb.cp/partial1.cc: New file.

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 0d3a34b..b9e3ecb 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3869,6 +3869,14 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
       break;
     }
 
+  /* For C++ if the name contains template parameters remove them, and set
+     the cleaned up name to be the search name.  */
+  if (psym
+      && cu->language == language_cplus
+      && actual_name
+      && cp_name_has_template_parameters (actual_name))
+    set_template_symbol_search_name (&((struct partial_symbol *) psym)->ginfo, objfile);
+
   if (built_actual_name)
     xfree (actual_name);
 }
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 6b29e85..07656cc 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -32,6 +32,8 @@
 #include "command.h"
 #include "readline/readline.h"
 #include "gdb_regex.h"
+#include "cp-support.h"
+#include "language.h"
 
 #ifndef DEV_TTY
 #define DEV_TTY "/dev/tty"
@@ -451,6 +453,7 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name,
   struct partial_symbol **top, **real_top, **bottom, **center;
   int length = (global ? pst->n_global_syms : pst->n_static_syms);
   int do_linear_search = 1;
+  const char *template_name = NULL;
 
   if (length == 0)
     {
@@ -460,6 +463,17 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name,
 	   pst->objfile->global_psymbols.list + pst->globals_offset :
 	   pst->objfile->static_psymbols.list + pst->statics_offset);
 
+  if (current_language->la_language == language_cplus
+      && cp_name_has_template_parameters (name))
+    {
+      template_name = name;
+      name = cp_remove_template_params (name);
+
+      if (name == NULL)
+	/* Not a legal C++ name.  */
+	return NULL;
+    }
+
   if (global)			/* This means we can use a binary search. */
     {
       do_linear_search = 0;
@@ -498,6 +512,10 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name,
       while (top <= real_top
 	     && SYMBOL_MATCHES_SEARCH_NAME (*top, name))
 	{
+	  if (template_name != NULL
+	      && !SYMBOL_MATCHES_TEMPLATE_NAME (*top, template_name))
+	    continue;
+
 	  if (symbol_matches_domain (SYMBOL_LANGUAGE (*top),
 				     SYMBOL_DOMAIN (*top), domain))
 	    return (*top);
@@ -512,6 +530,10 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name,
     {
       for (psym = start; psym < start + length; psym++)
 	{
+	  if (template_name != NULL
+	      && !SYMBOL_MATCHES_TEMPLATE_NAME (*psym, template_name))
+	    continue;
+
 	  if (symbol_matches_domain (SYMBOL_LANGUAGE (*psym),
 				     SYMBOL_DOMAIN (*psym), domain)
 	      && SYMBOL_MATCHES_SEARCH_NAME (*psym, name))
diff --git a/gdb/testsuite/gdb.cp/partial.exp b/gdb/testsuite/gdb.cp/partial.exp
new file mode 100644
index 0000000..86ac84a
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/partial.exp
@@ -0,0 +1,68 @@
+# Copyright 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test evaluation of template function for partial symbols.
+
+set testfile "partial"
+
+set srcfile1 "${testfile}1.cc"
+set srcfile2 "${testfile}2.cc"
+set objfile1 "${testfile}1.o"
+set objfile2 "${testfile}2.o"
+
+set binfile  "${objdir}/${subdir}/${testfile}"
+
+if  { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } {
+     untested m-static.exp
+     return -1
+}
+
+if  { [gdb_compile "$srcdir/$subdir/$srcfile2" "$objdir/$subdir/$objfile2" object {debug c++}] != "" } {
+     untested m-static.exp
+     return -1
+}
+
+if { [gdb_compile "$objdir/$subdir/$objfile1 $objdir/$subdir/$objfile2" "${binfile}" executable {debug c++}] != "" } {
+     untested m-static.exp
+     return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+if ![runto_main] then {
+    perror "couldn't run to breakpoint"
+    continue
+}
+
+# Test proper printing of template function.
+gdb_test "p foo(11)"          "= 11"
+
+# Test printing of template function by including
+# template argument.
+gdb_test "p foo<double>(11)"  "= 11"
+
+# Test printing of template function by including
+# template argument.
+gdb_test "p foo<fake>(11)"  {No symbol "foo<fake>" in current context.}
+
+# Same as above but with some overloading.
+gdb_test "p bar(1,1)"  "= 22"
+gdb_test "p bar('a','a')"  "= 33"
+
+gdb_test "ptype bar<int>"  {= double \(int, int\)}
+gdb_test "ptype bar<char>" {= double \(char, char\)}
diff --git a/gdb/testsuite/gdb.cp/partial1.cc b/gdb/testsuite/gdb.cp/partial1.cc
new file mode 100644
index 0000000..2251680
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/partial1.cc
@@ -0,0 +1,6 @@
+extern int g(void);
+
+int main()
+{
+  return g();
+}
diff --git a/gdb/testsuite/gdb.cp/partial2.cc b/gdb/testsuite/gdb.cp/partial2.cc
new file mode 100644
index 0000000..708c8f4
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/partial2.cc
@@ -0,0 +1,10 @@
+
+template<typename T> double foo (T x) { return x; }
+template<typename T> double bar (T x, int) { return 22; }
+template<typename T> double bar (T x, char) { return 33; }
+
+int g (void)
+{
+  return foo(1.0) + foo(2)
+      + bar(1,1) + bar('a','a');
+}




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

* Re: [patch 1/4] Template Lookup
  2010-09-23 17:55       ` [patch 1/4] " sami wagiaalla
@ 2010-10-05 19:08         ` sami wagiaalla
  2010-10-14 15:23           ` sami wagiaalla
  0 siblings, 1 reply; 11+ messages in thread
From: sami wagiaalla @ 2010-10-05 19:08 UTC (permalink / raw)
  To: gdb-patches

ping

On 09/23/2010 10:47 AM, sami wagiaalla wrote:
> Attached is a revised patch that has been rebased on HEAD, plus
> a few aesthetic changes.
>
>>> I suspect this doesn't interact properly with psymtabs, because from
>>> what I can tell the template-argument-less symbol is only entered for
>>> full symbols, not partial symbols. This means that a reference to some
>>> function will not work properly until the psymtab is expanded for some
>>> other reason.
>>>
>
> Please see patch 4/4
>
>

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

* Re: [patch 1/4] Template Lookup
  2010-10-05 19:08         ` sami wagiaalla
@ 2010-10-14 15:23           ` sami wagiaalla
  2010-11-01 20:15             ` sami wagiaalla
  0 siblings, 1 reply; 11+ messages in thread
From: sami wagiaalla @ 2010-10-14 15:23 UTC (permalink / raw)
  To: gdb-patches

ping :)

On 10/05/2010 03:08 PM, sami wagiaalla wrote:
> ping
>
> On 09/23/2010 10:47 AM, sami wagiaalla wrote:
>> Attached is a revised patch that has been rebased on HEAD, plus
>> a few aesthetic changes.
>>
>>>> I suspect this doesn't interact properly with psymtabs, because from
>>>> what I can tell the template-argument-less symbol is only entered for
>>>> full symbols, not partial symbols. This means that a reference to some
>>>> function will not work properly until the psymtab is expanded for some
>>>> other reason.
>>>>
>>
>> Please see patch 4/4
>>
>>
>

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

* Re: [patch 1/4] Template Lookup
  2010-10-14 15:23           ` sami wagiaalla
@ 2010-11-01 20:15             ` sami wagiaalla
  0 siblings, 0 replies; 11+ messages in thread
From: sami wagiaalla @ 2010-11-01 20:15 UTC (permalink / raw)
  To: gdb-patches

Ping

On 10/14/2010 11:23 AM, sami wagiaalla wrote:
> ping :)
>
> On 10/05/2010 03:08 PM, sami wagiaalla wrote:
>> ping
>>
>> On 09/23/2010 10:47 AM, sami wagiaalla wrote:
>>> Attached is a revised patch that has been rebased on HEAD, plus
>>> a few aesthetic changes.
>>>
>>>>> I suspect this doesn't interact properly with psymtabs, because from
>>>>> what I can tell the template-argument-less symbol is only entered for
>>>>> full symbols, not partial symbols. This means that a reference to some
>>>>> function will not work properly until the psymtab is expanded for some
>>>>> other reason.
>>>>>
>>>
>>> Please see patch 4/4
>>>
>>>
>>
>

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

end of thread, other threads:[~2010-11-01 20:15 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-19 15:28 [patch 1/3] Template Lookup sami wagiaalla
2010-07-20 20:42 ` sami wagiaalla
2010-08-18 21:45   ` Tom Tromey
2010-08-26 16:05     ` sami wagiaalla
2010-08-31 22:05       ` Tom Tromey
2010-09-23 18:43         ` [patch 4/4] " sami wagiaalla
2010-09-23 17:55       ` [patch 1/4] " sami wagiaalla
2010-10-05 19:08         ` sami wagiaalla
2010-10-14 15:23           ` sami wagiaalla
2010-11-01 20:15             ` sami wagiaalla
2010-08-11 18:13 ` [patch 1/3] " sami wagiaalla

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