public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-swagiaal-upstream: Template meta var now knows about its instances.
@ 2010-07-06 20:36 swagiaal
  0 siblings, 0 replies; only message in thread
From: swagiaal @ 2010-07-06 20:36 UTC (permalink / raw)
  To: archer-commits

The branch, archer-swagiaal-upstream has been updated
       via  eabafa4a915bf9e6b9a4b43e8cfc01253302f538 (commit)
       via  72091d0c065f3b990bfd4f6960bac2f227e6194c (commit)
      from  8434633a2b805ac44e0fb0243fe1add2c43fb62b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit eabafa4a915bf9e6b9a4b43e8cfc01253302f538
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Tue Jul 6 16:26:33 2010 -0400

    Template meta var now knows about its instances.

commit 72091d0c065f3b990bfd4f6960bac2f227e6194c
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Tue Jul 6 12:33:36 2010 -0400

    revert parent

-----------------------------------------------------------------------

Summary of changes:
 gdb/dwarf2read.c                 |   68 ++++++++++++++-----------------------
 gdb/findvar.c                    |   14 +++++++-
 gdb/symtab.c                     |   25 ++++++++++++++
 gdb/symtab.h                     |   21 ++++++++++++
 gdb/testsuite/gdb.cp/temp-op.exp |    2 +-
 gdb/value.c                      |    2 +
 6 files changed, 87 insertions(+), 45 deletions(-)

First 500 lines of diff:
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 78d03f9..c4c91a0 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -8442,15 +8442,15 @@ add_template_variable (struct symbol *symbol, struct pending **listhead,
                        struct objfile *objfile)
 {
   const struct pending *iterator = *listhead;
-  struct symbol *template_sym;
-  struct symbol *iterator_sym;
-  struct type *type;
-  char *name = SYMBOL_NATURAL_NAME (symbol);
-  char *search_name;
-  char *tmp;
+  struct symbol* template_sym = NULL;
+  struct symbol* iterator_sym;
+  struct type* type;
+  char* name = SYMBOL_NATURAL_NAME (symbol);
+  char* search_name;
+  char* tmp;
   int i;
 
-  struct cleanup *all_cleanups = make_cleanup (null_cleanup, NULL);
+  struct cleanup* all_cleanups = make_cleanup (null_cleanup, NULL);
 
   gdb_assert (name != NULL);
 
@@ -8473,7 +8473,7 @@ add_template_variable (struct symbol *symbol, struct pending **listhead,
 
   /* Has a template symbol for this symbol been added already ?  */
   for (iterator = *(listhead);
-       iterator != NULL;
+       iterator != NULL && template_sym == NULL;
        iterator = iterator->next)
     {
       for (i = iterator->nsyms - 1; i >= 0; --i)
@@ -8483,28 +8483,32 @@ add_template_variable (struct symbol *symbol, struct pending **listhead,
 	  if (TYPE_CODE (SYMBOL_TYPE (iterator_sym)) == TYPE_CODE_TEMPLATE
 	      && strcmp (SYMBOL_SEARCH_NAME(iterator_sym), search_name) == 0)
 	    {
-	      do_cleanups (all_cleanups);
-	      return;
+	      template_sym = iterator_sym;
+	      break;
 	    }
         }
     }
 
-  /* Add a new template symbol.  */
-  template_sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
-                                         sizeof (struct symbol));
-  OBJSTAT (objfile, n_syms++);
-  memset (template_sym, 0, sizeof (struct symbol));
+  if (template_sym == NULL)
+    {
+      /* Add a new template symbol.  */
+      template_sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
+					     sizeof (struct symbol));
+      OBJSTAT (objfile, n_syms++);
+      memset (template_sym, 0, sizeof (struct symbol));
 
-  SYMBOL_SET_NAMES (template_sym, search_name, strlen (search_name), 0, objfile);
-  type = alloc_type (objfile);
-  TYPE_CODE (type) = TYPE_CODE_TEMPLATE;
-  SYMBOL_TYPE (template_sym) = type;
+      SYMBOL_SET_NAMES (template_sym, search_name, strlen (search_name), 0, objfile);
+      type = alloc_type (objfile);
+      TYPE_CODE (type) = TYPE_CODE_TEMPLATE;
+      SYMBOL_TYPE (template_sym) = type;
 
-  SYMBOL_DOMAIN (template_sym) = VAR_DOMAIN;
-  SYMBOL_CLASS (template_sym) = LOC_TEMPLATE;
+      SYMBOL_DOMAIN (template_sym) = VAR_DOMAIN;
+      SYMBOL_CLASS (template_sym) = LOC_TEMPLATE;
 
-  add_symbol_to_list (template_sym, listhead);
+      add_symbol_to_list (template_sym, listhead);
+    }
 
+  symbol_add_template_instance (template_sym, symbol, objfile);
   do_cleanups (all_cleanups);
 
 }
@@ -8547,26 +8551,6 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 
       SYMBOL_SET_NAMES (sym, linkagename, strlen (linkagename), 0, objfile);
 
-      /* 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/findvar.c b/gdb/findvar.c
index 1fb3a7f..06e481c 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -564,9 +564,19 @@ read_var_value (struct symbol *var, struct frame_info *frame)
       return v;
 
     case LOC_TEMPLATE:
-      error (_("Symbol represents a template and cannot be evaluated."));
-      break;
+      {
+	struct symbol_list_element* instance = symbol_get_template_instances (var);
+
+	printf_filtered ("Symbol represents a template and cannot be evaluated.\n");
+	printf_filtered ("Did you mean:\n");
 
+	while (instance != NULL)
+	  {
+	    printf_filtered ("  %s\n", SYMBOL_NATURAL_NAME (instance->sym));
+	    instance = instance->next;
+	  }
+	return NULL;
+      }
     default:
       error (_("Cannot look up value of a botched symbol."));
       break;
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 038eedc..1324613 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -338,6 +338,31 @@ gdb_mangle_name (struct type *type, int method_id, int signature_id)
   return (mangled_name);
 }
 
+/* Add a reference to the template instance INSTANCE represented
+ by template meta variable SYM.  */
+
+extern void
+symbol_add_template_instance (struct symbol* sym,
+                              const struct symbol* instance,
+                              struct objfile *objfile)
+{
+  struct symbol_list_element* new_instance =
+      OBSTACK_ZALLOC (&objfile->objfile_obstack,
+	              struct symbol_list_element);
+
+  new_instance->sym = instance;
+  new_instance->next = sym->ginfo.value.instances;
+  sym->ginfo.value.instances = new_instance;
+}
+
+/* Return the list of known instaces of this template symbol.  */
+
+extern struct symbol_list_element*
+symbol_get_template_instances (struct symbol* sym)
+{
+  return sym->ginfo.value.instances;
+}
+
 /* Set the cplus demangled name of GSYMBOL to NAME.  NAME must be already
    correctly allocated.  */
 static void
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 88dee1b..9b26881 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -75,6 +75,15 @@ struct program_space;
 
    --chastain 2003-08-21  */
 
+/* A likend list of symbols used to keep references to
+   instances of a template.  */
+
+struct symbol_list_element
+{
+  struct symbol_list_element *next;
+  const struct symbol *sym;
+};
+
 /* Struct for storing C++ specific information.  Allocated when needed.  */
 
 struct cplus_specific
@@ -127,6 +136,10 @@ struct general_symbol_info
     /* for opaque typedef struct chain */
 
     struct symbol *chain;
+
+    /* If this is a value of a template symbol this is a pointer to the
+       list of instances of that variable.  */
+    struct symbol_list_element *instances;
   }
   value;
 
@@ -191,6 +204,14 @@ symbol_set_cplus_search_name (struct general_symbol_info *gsymbol,
 extern char*
 symbol_get_cplus_search_name (const struct general_symbol_info *gsymbol);
 
+extern void
+symbol_add_template_instance (struct symbol* sym,
+                              const struct symbol* instance,
+                              struct objfile *objfile);
+
+extern struct symbol_list_element*
+symbol_get_template_instances (struct symbol* sym);
+
 /* Initializes the language dependent portion of a symbol
    depending upon the language for the symbol. */
 #define SYMBOL_INIT_LANGUAGE_SPECIFIC(symbol,language) \
diff --git a/gdb/testsuite/gdb.cp/temp-op.exp b/gdb/testsuite/gdb.cp/temp-op.exp
index 3284ee1..423b477 100644
--- a/gdb/testsuite/gdb.cp/temp-op.exp
+++ b/gdb/testsuite/gdb.cp/temp-op.exp
@@ -78,4 +78,4 @@ gdb_test "p b == 'a'"        "= 18"
 # template parameters does not return an arbitrary match
 
 gdb_test "p foo" "Symbol represents a template and cannot be evaluated."
-gdb_test "type = Template Symbol"
+gdb_test "ptype B" "type = Template Symbol"
diff --git a/gdb/value.c b/gdb/value.c
index 2f1ae7a..b3277b7 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -91,6 +91,8 @@ struct value
       struct lval_funcs *funcs; /* Functions to call.  */
       void *closure;            /* Closure for those functions to use.  */
     } computed;
+
+
   } location;
 
   /* Describes offset of a value within lval of a structure in bytes.


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-07-06 20:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-06 20:36 [SCM] archer-swagiaal-upstream: Template meta var now knows about its instances swagiaal

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