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


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

RFC: [2/4] change type of is_a_field_of_this


Right now, lookup_symbol will, on request, find a field of 'this'.
However, it throws away the exact type and field that is found.

In order to fully fix PR 8888, I needed this information.
So, this patch changes the type of the 'is_a_field_of_this' parameter to
be a new struct.

I'm not totally happy with the name of the new type, suggestions
welcome.

This patch is largely mechanical.

Built and regtested on x86-64 Fedora 16.

Tom

	* c-exp.y (block, variable, name_not_typename, lex_one_token,
	classify_name): Update.
	* c-valprint.c (c_val_print): Update.
	* f-exp.y (yylex): Update.
	* go-exp.y (package_name_p, classify_packaged_name)
	(classify_name): Update.
	* jv-exp.y (push_variable): Update.
	* m2-exp.y (variable): Update.
	* mi/mi-cmd-stack.c (list_args_or_locals): Update.
	* p-exp.y (block, variable, yylex): Update.
	* p-valprint.c (pascal_val_print): Update.
	* parse.c (write_dollar_variable): Update.
	* printcmd.c (address_info): Update.
	* python/py-symbol.c (gdbpy_lookup_symbol): Update.
	* symtab.c (lookup_symbol_aux, lookup_symbol_in_language)
	(lookup_symbol): Change type of 'is_a_field_of_this'.
	(check_field): Add 'is_a_field_of_this' argument.
	* symtab.h (struct field_of_this_result): New.
	(lookup_symbol, lookup_symbol_in_language): Update.
---
 gdb/c-exp.y            |   30 +++++++++++++++++++-----------
 gdb/c-valprint.c       |    2 +-
 gdb/f-exp.y            |   10 +++++++---
 gdb/go-exp.y           |   12 ++++++------
 gdb/jv-exp.y           |    4 ++--
 gdb/m2-exp.y           |    2 +-
 gdb/mi/mi-cmd-stack.c  |    2 +-
 gdb/p-exp.y            |   26 +++++++++++++-------------
 gdb/p-valprint.c       |    2 +-
 gdb/parse.c            |    2 +-
 gdb/printcmd.c         |    5 ++---
 gdb/python/py-symbol.c |    5 +++--
 gdb/symtab.c           |   40 +++++++++++++++++++++++-----------------
 gdb/symtab.h           |   27 +++++++++++++++++++++++++--
 14 files changed, 105 insertions(+), 64 deletions(-)

diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 11eaadb..f492e01 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -871,7 +871,7 @@ block	:	BLOCKNAME
 block	:	block COLONCOLON name
 			{ struct symbol *tem
 			    = lookup_symbol (copy_name ($3), $1,
-					     VAR_DOMAIN, (int *) NULL);
+					     VAR_DOMAIN, NULL);
 			  if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
 			    error (_("No function \"%s\" in specified context."),
 				   copy_name ($3));
@@ -896,7 +896,7 @@ variable:	name_not_typename ENTRY
 variable:	block COLONCOLON name
 			{ struct symbol *sym;
 			  sym = lookup_symbol (copy_name ($3), $1,
-					       VAR_DOMAIN, (int *) NULL);
+					       VAR_DOMAIN, NULL);
 			  if (sym == 0)
 			    error (_("No symbol \"%s\" in specified context."),
 				   copy_name ($3));
@@ -972,7 +972,7 @@ variable:	qualified_name
 
 			  sym =
 			    lookup_symbol (name, (const struct block *) NULL,
-					   VAR_DOMAIN, (int *) NULL);
+					   VAR_DOMAIN, NULL);
 			  if (sym)
 			    {
 			      write_exp_elt_opcode (OP_VAR_VALUE);
@@ -1533,11 +1533,15 @@ name_not_typename :	NAME
  */
 	|	operator
 			{
+			  struct field_of_this_result is_a_field_of_this;
+
 			  $$.stoken = $1;
 			  $$.sym = lookup_symbol ($1.ptr,
 						  expression_context_block,
 						  VAR_DOMAIN,
-						  &$$.is_a_field_of_this);
+						  &is_a_field_of_this);
+			  $$.is_a_field_of_this
+			    = is_a_field_of_this.type != NULL;
 			}
 	|	UNKNOWN_CPP_NAME
 	;
@@ -2646,7 +2650,7 @@ lex_one_token (void)
 
 	if ((ident_tokens[i].flags & FLAG_SHADOW) != 0)
 	  {
-	    int is_a_field_of_this = 0;
+	    struct field_of_this_result is_a_field_of_this;
 
 	    if (lookup_symbol (copy, expression_context_block,
 			       VAR_DOMAIN,
@@ -2703,18 +2707,22 @@ classify_name (struct block *block)
 {
   struct symbol *sym;
   char *copy;
-  int is_a_field_of_this = 0;
+  struct field_of_this_result is_a_field_of_this;
 
   copy = copy_name (yylval.sval);
 
+  /* Initialize this in case we *don't* use it in this call; that way
+     we can refer to it unconditionally below.  */
+  memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this));
+
   sym = lookup_symbol (copy, block, VAR_DOMAIN, 
 		       parse_language->la_name_of_this
-		       ? &is_a_field_of_this : (int *) NULL);
+		       ? &is_a_field_of_this : NULL);
 
   if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
     {
       yylval.ssym.sym = sym;
-      yylval.ssym.is_a_field_of_this = is_a_field_of_this;
+      yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
       return BLOCKNAME;
     }
   else if (!sym)
@@ -2768,18 +2776,18 @@ classify_name (struct block *block)
       if (hextype == INT)
 	{
 	  yylval.ssym.sym = sym;
-	  yylval.ssym.is_a_field_of_this = is_a_field_of_this;
+	  yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
 	  return NAME_OR_INT;
 	}
     }
 
   /* Any other kind of symbol */
   yylval.ssym.sym = sym;
-  yylval.ssym.is_a_field_of_this = is_a_field_of_this;
+  yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
 
   if (sym == NULL
       && parse_language->la_language == language_cplus
-      && !is_a_field_of_this
+      && is_a_field_of_this.type == NULL
       && !lookup_minimal_symbol (copy, NULL, NULL))
     return UNKNOWN_CPP_NAME;
 
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index dada9e2..09fd540 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -333,7 +333,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
 		  struct symbol *wsym = (struct symbol *) NULL;
 		  struct type *wtype;
 		  struct block *block = (struct block *) NULL;
-		  int is_this_fld;
+		  struct field_of_this_result is_this_fld;
 
 		  if (want_space)
 		    fputs_filtered (" ", stream);
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index 33c7418..8e94174 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -1175,9 +1175,13 @@ yylex (void)
   {
     char *tmp = copy_name (yylval.sval);
     struct symbol *sym;
-    int is_a_field_of_this = 0;
+    struct field_of_this_result is_a_field_of_this;
     int hextype;
     
+    /* Initialize this in case we *don't* use it in this call; that
+       way we can refer to it unconditionally below.  */
+    memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this));
+
     sym = lookup_symbol (tmp, expression_context_block,
 			 VAR_DOMAIN,
 			 parse_language->la_language == language_cplus
@@ -1205,14 +1209,14 @@ yylex (void)
 	if (hextype == INT)
 	  {
 	    yylval.ssym.sym = sym;
-	    yylval.ssym.is_a_field_of_this = is_a_field_of_this;
+	    yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
 	    return NAME_OR_INT;
 	  }
       }
     
     /* Any other kind of symbol */
     yylval.ssym.sym = sym;
-    yylval.ssym.is_a_field_of_this = is_a_field_of_this;
+    yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
     return NAME;
   }
 }
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index c3171c3..80abb59 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -1365,7 +1365,7 @@ static int
 package_name_p (const char *name, struct block *block)
 {
   struct symbol *sym;
-  int is_a_field_of_this;
+  struct field_of_this_result is_a_field_of_this;
 
   sym = lookup_symbol (name, block, STRUCT_DOMAIN, &is_a_field_of_this);
 
@@ -1406,7 +1406,7 @@ classify_packaged_name (struct block *block)
 {
   char *copy;
   struct symbol *sym;
-  int is_a_field_of_this = 0;
+  struct field_of_this_result is_a_field_of_this;
 
   copy = copy_name (yylval.sval);
 
@@ -1415,7 +1415,7 @@ classify_packaged_name (struct block *block)
   if (sym)
     {
       yylval.ssym.sym = sym;
-      yylval.ssym.is_a_field_of_this = is_a_field_of_this;
+      yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
     }
 
   return NAME;
@@ -1435,7 +1435,7 @@ classify_name (struct block *block)
   struct type *type;
   struct symbol *sym;
   char *copy;
-  int is_a_field_of_this = 0;
+  struct field_of_this_result is_a_field_of_this;
 
   copy = copy_name (yylval.sval);
 
@@ -1458,7 +1458,7 @@ classify_name (struct block *block)
   if (sym)
     {
       yylval.ssym.sym = sym;
-      yylval.ssym.is_a_field_of_this = is_a_field_of_this;
+      yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
       return NAME;
     }
 
@@ -1484,7 +1484,7 @@ classify_name (struct block *block)
 	  {
 	    yylval.ssym.stoken = sval;
 	    yylval.ssym.sym = sym;
-	    yylval.ssym.is_a_field_of_this = is_a_field_of_this;
+	    yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
 	    return NAME;
 	  }
       }
diff --git a/gdb/jv-exp.y b/gdb/jv-exp.y
index d0fca67..80ef7e3 100644
--- a/gdb/jv-exp.y
+++ b/gdb/jv-exp.y
@@ -1227,7 +1227,7 @@ static int
 push_variable (struct stoken name)
 {
   char *tmp = copy_name (name);
-  int is_a_field_of_this = 0;
+  struct field_of_this_result is_a_field_of_this;
   struct symbol *sym;
   sym = lookup_symbol (tmp, expression_context_block, VAR_DOMAIN,
 		       &is_a_field_of_this);
@@ -1248,7 +1248,7 @@ push_variable (struct stoken name)
       write_exp_elt_opcode (OP_VAR_VALUE);
       return 1;
     }
-  if (is_a_field_of_this)
+  if (is_a_field_of_this.type != NULL)
     {
       /* it hangs off of `this'.  Must not inadvertently convert from a
 	 method call to data ref.  */
diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
index 19f9c24..879c25d 100644
--- a/gdb/m2-exp.y
+++ b/gdb/m2-exp.y
@@ -602,7 +602,7 @@ variable:	block COLONCOLON NAME
 /* Base case for variables.  */
 variable:	NAME
 			{ struct symbol *sym;
-			  int is_a_field_of_this;
+			  struct field_of_this_result is_a_field_of_this;
 
  			  sym = lookup_symbol (copy_name ($1),
 					       expression_context_block,
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index fe3e0bf..32e8c9e 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -397,7 +397,7 @@ list_args_or_locals (enum what_to_list what, enum print_values values,
 	      if (SYMBOL_IS_ARGUMENT (sym))
 		sym2 = lookup_symbol (SYMBOL_LINKAGE_NAME (sym),
 				      block, VAR_DOMAIN,
-				      (int *) NULL);
+				      NULL);
 	      else
 		sym2 = sym;
 	      gdb_assert (sym2 != NULL);
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index 5d344a4..06fc5a2 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -658,7 +658,7 @@ block	:	BLOCKNAME
 block	:	block COLONCOLON name
 			{ struct symbol *tem
 			    = lookup_symbol (copy_name ($3), $1,
-					     VAR_DOMAIN, (int *) NULL);
+					     VAR_DOMAIN, NULL);
 			  if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
 			    error (_("No function \"%s\" in specified context."),
 				   copy_name ($3));
@@ -668,7 +668,7 @@ block	:	block COLONCOLON name
 variable:	block COLONCOLON name
 			{ struct symbol *sym;
 			  sym = lookup_symbol (copy_name ($3), $1,
-					       VAR_DOMAIN, (int *) NULL);
+					       VAR_DOMAIN, NULL);
 			  if (sym == 0)
 			    error (_("No symbol \"%s\" in specified context."),
 				   copy_name ($3));
@@ -704,7 +704,7 @@ variable:	qualified_name
 
 			  sym =
 			    lookup_symbol (name, (const struct block *) NULL,
-					   VAR_DOMAIN, (int *) NULL);
+					   VAR_DOMAIN, NULL);
 			  if (sym)
 			    {
 			      write_exp_elt_opcode (OP_VAR_VALUE);
@@ -1483,7 +1483,7 @@ yylex (void)
 	  static const char this_name[] = "this";
 
 	  if (lookup_symbol (this_name, expression_context_block,
-			     VAR_DOMAIN, (int *) NULL))
+			     VAR_DOMAIN, NULL))
 	    {
 	      free (uptokstart);
 	      return THIS;
@@ -1522,7 +1522,7 @@ yylex (void)
   {
     char *tmp = copy_name (yylval.sval);
     struct symbol *sym;
-    int is_a_field_of_this = 0;
+    struct field_of_this_result is_a_field_of_this;
     int is_a_field = 0;
     int hextype;
 
@@ -1535,7 +1535,7 @@ yylex (void)
       sym = lookup_symbol (tmp, expression_context_block,
 			   VAR_DOMAIN, &is_a_field_of_this);
     /* second chance uppercased (as Free Pascal does).  */
-    if (!sym && !is_a_field_of_this && !is_a_field)
+    if (!sym && is_a_field_of_this.type == NULL && !is_a_field)
       {
        for (i = 0; i <= namelen; i++)
          {
@@ -1549,7 +1549,7 @@ yylex (void)
        else
 	 sym = lookup_symbol (tmp, expression_context_block,
 			      VAR_DOMAIN, &is_a_field_of_this);
-       if (sym || is_a_field_of_this || is_a_field)
+       if (sym || is_a_field_of_this.type != NULL || is_a_field)
          for (i = 0; i <= namelen; i++)
            {
              if ((tokstart[i] >= 'a' && tokstart[i] <= 'z'))
@@ -1557,7 +1557,7 @@ yylex (void)
            }
       }
     /* Third chance Capitalized (as GPC does).  */
-    if (!sym && !is_a_field_of_this && !is_a_field)
+    if (!sym && is_a_field_of_this.type == NULL && !is_a_field)
       {
        for (i = 0; i <= namelen; i++)
          {
@@ -1577,7 +1577,7 @@ yylex (void)
        else
 	 sym = lookup_symbol (tmp, expression_context_block,
 			      VAR_DOMAIN, &is_a_field_of_this);
-       if (sym || is_a_field_of_this || is_a_field)
+       if (sym || is_a_field_of_this.type != NULL || is_a_field)
           for (i = 0; i <= namelen; i++)
             {
               if (i == 0)
@@ -1607,7 +1607,7 @@ yylex (void)
         || lookup_symtab (tmp))
       {
 	yylval.ssym.sym = sym;
-	yylval.ssym.is_a_field_of_this = is_a_field_of_this;
+	yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
 	free (uptokstart);
 	return BLOCKNAME;
       }
@@ -1673,7 +1673,7 @@ yylex (void)
 		      memcpy (tmp1, namestart, p - namestart);
 		      tmp1[p - namestart] = '\0';
 		      cur_sym = lookup_symbol (ncopy, expression_context_block,
-					       VAR_DOMAIN, (int *) NULL);
+					       VAR_DOMAIN, NULL);
 		      if (cur_sym)
 			{
 			  if (SYMBOL_CLASS (cur_sym) == LOC_TYPEDEF)
@@ -1722,7 +1722,7 @@ yylex (void)
 	if (hextype == INT)
 	  {
 	    yylval.ssym.sym = sym;
-	    yylval.ssym.is_a_field_of_this = is_a_field_of_this;
+	    yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
 	    free (uptokstart);
 	    return NAME_OR_INT;
 	  }
@@ -1731,7 +1731,7 @@ yylex (void)
     free(uptokstart);
     /* Any other kind of symbol.  */
     yylval.ssym.sym = sym;
-    yylval.ssym.is_a_field_of_this = is_a_field_of_this;
+    yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
     return NAME;
   }
 }
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index b2287f2..023db69 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -243,7 +243,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
 	      struct symbol *wsym = (struct symbol *) NULL;
 	      struct type *wtype;
 	      struct block *block = (struct block *) NULL;
-	      int is_this_fld;
+	      struct field_of_this_result is_this_fld;
 
 	      if (want_space)
 		fputs_filtered (" ", stream);
diff --git a/gdb/parse.c b/gdb/parse.c
index afe1c18..ad7cf1c 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -663,7 +663,7 @@ write_dollar_variable (struct stoken str)
      have names beginning with $ or $$.  Check for those, first.  */
 
   sym = lookup_symbol (copy_name (str), (struct block *) NULL,
-		       VAR_DOMAIN, (int *) NULL);
+		       VAR_DOMAIN, NULL);
   if (sym)
     {
       write_exp_elt_opcode (OP_VAR_VALUE);
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 7a669f1..35d39c1 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1199,8 +1199,7 @@ address_info (char *exp, int from_tty)
   long val;
   struct obj_section *section;
   CORE_ADDR load_addr, context_pc = 0;
-  int is_a_field_of_this;	/* C++: lookup_symbol sets this to nonzero
-				   if exp is a field of `this'.  */
+  struct field_of_this_result is_a_field_of_this;
 
   if (exp == 0)
     error (_("Argument required."));
@@ -1209,7 +1208,7 @@ address_info (char *exp, int from_tty)
 		       &is_a_field_of_this);
   if (sym == NULL)
     {
-      if (is_a_field_of_this)
+      if (is_a_field_of_this.type != NULL)
 	{
 	  printf_filtered ("Symbol \"");
 	  fprintf_symbol_filtered (gdb_stdout, exp,
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 83d272e..6363608 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -354,7 +354,8 @@ sympy_dealloc (PyObject *obj)
 PyObject *
 gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
 {
-  int domain = VAR_DOMAIN, is_a_field_of_this = 0;
+  int domain = VAR_DOMAIN;
+  struct field_of_this_result is_a_field_of_this;
   const char *name;
   static char *keywords[] = { "name", "block", "domain", NULL };
   struct symbol *symbol = NULL;
@@ -407,7 +408,7 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
     }
   PyTuple_SET_ITEM (ret_tuple, 0, sym_obj);
 
-  bool_obj = is_a_field_of_this? Py_True : Py_False;
+  bool_obj = (is_a_field_of_this.type != NULL) ? Py_True : Py_False;
   Py_INCREF (bool_obj);
   PyTuple_SET_ITEM (ret_tuple, 1, bool_obj);
 
diff --git a/gdb/symtab.c b/gdb/symtab.c
index c1eab45..c8de201 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -81,7 +81,7 @@ static struct symbol *lookup_symbol_aux (const char *name,
 					 const struct block *block,
 					 const domain_enum domain,
 					 enum language language,
-					 int *is_a_field_of_this);
+					 struct field_of_this_result *is_a_field_of_this);
 
 static
 struct symbol *lookup_symbol_aux_local (const char *name,
@@ -1224,7 +1224,7 @@ demangle_for_lookup (const char *name, enum language lang,
 struct symbol *
 lookup_symbol_in_language (const char *name, const struct block *block,
 			   const domain_enum domain, enum language lang,
-			   int *is_a_field_of_this)
+			   struct field_of_this_result *is_a_field_of_this)
 {
   const char *modified_name;
   struct symbol *returnval;
@@ -1242,7 +1242,8 @@ lookup_symbol_in_language (const char *name, const struct block *block,
 
 struct symbol *
 lookup_symbol (const char *name, const struct block *block,
-	       domain_enum domain, int *is_a_field_of_this)
+	       domain_enum domain,
+	       struct field_of_this_result *is_a_field_of_this)
 {
   return lookup_symbol_in_language (name, block, domain,
 				    current_language->la_language,
@@ -1282,7 +1283,8 @@ lookup_language_this (const struct language_defn *lang,
    structure/union is defined, otherwise, return 0.  */
 
 static int
-check_field (struct type *type, const char *name)
+check_field (struct type *type, const char *name,
+	     struct field_of_this_result *is_a_field_of_this)
 {
   int i;
 
@@ -1294,7 +1296,11 @@ check_field (struct type *type, const char *name)
       const char *t_field_name = TYPE_FIELD_NAME (type, i);
 
       if (t_field_name && (strcmp_iw (t_field_name, name) == 0))
-	return 1;
+	{
+	  is_a_field_of_this->type = type;
+	  is_a_field_of_this->field = &TYPE_FIELD (type, i);
+	  return 1;
+	}
     }
 
   /* C++: If it was not found as a data field, then try to return it
@@ -1303,11 +1309,15 @@ check_field (struct type *type, const char *name)
   for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; --i)
     {
       if (strcmp_iw (TYPE_FN_FIELDLIST_NAME (type, i), name) == 0)
-	return 1;
+	{
+	  is_a_field_of_this->type = type;
+	  is_a_field_of_this->fn_field = &TYPE_FN_FIELDLIST (type, i);
+	  return 1;
+	}
     }
 
   for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
-    if (check_field (TYPE_BASECLASS (type, i), name))
+    if (check_field (TYPE_BASECLASS (type, i), name, is_a_field_of_this))
       return 1;
 
   return 0;
@@ -1319,18 +1329,17 @@ check_field (struct type *type, const char *name)
 static struct symbol *
 lookup_symbol_aux (const char *name, const struct block *block,
 		   const domain_enum domain, enum language language,
-		   int *is_a_field_of_this)
+		   struct field_of_this_result *is_a_field_of_this)
 {
   struct symbol *sym;
   const struct language_defn *langdef;
 
   /* Make sure we do something sensible with is_a_field_of_this, since
      the callers that set this parameter to some non-null value will
-     certainly use it later and expect it to be either 0 or 1.
-     If we don't set it, the contents of is_a_field_of_this are
-     undefined.  */
+     certainly use it later.  If we don't set it, the contents of
+     is_a_field_of_this are undefined.  */
   if (is_a_field_of_this != NULL)
-    *is_a_field_of_this = 0;
+    memset (is_a_field_of_this, 0, sizeof (*is_a_field_of_this));
 
   /* Search specified block and its superiors.  Don't search
      STATIC_BLOCK or GLOBAL_BLOCK.  */
@@ -1364,11 +1373,8 @@ lookup_symbol_aux (const char *name, const struct block *block,
 	    error (_("Internal error: `%s' is not an aggregate"),
 		   langdef->la_name_of_this);
 
-	  if (check_field (t, name))
-	    {
-	      *is_a_field_of_this = 1;
-	      return NULL;
-	    }
+	  if (check_field (t, name, is_a_field_of_this))
+	    return NULL;
 	}
     }
 
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 0d24cb5..21d94f7 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -918,19 +918,42 @@ int symbol_matches_domain (enum language symbol_language,
 
 extern struct symtab *lookup_symtab (const char *);
 
+/* An object of this type is passed as the 'is_a_field_of_this'
+   argument to lookup_symbol and lookup_symbol_in_language.  */
+
+struct field_of_this_result
+{
+  /* The type in which the field was found.  If this is NULL then the
+     symbol was not found in 'this'.  If non-NULL, then one of the
+     other fields will be non-NULL as well.  */
+
+  struct type *type;
+
+  /* If the symbol was found as an ordinary field of 'this', then this
+     is non-NULL and points to the particular field.  */
+
+  struct field *field;
+
+  /* If the symbol was found as an function field of 'this', then this
+     is non-NULL and points to the particular field.  */
+
+  struct fn_fieldlist *fn_field;
+};
+
 /* lookup a symbol by name (optional block) in language.  */
 
 extern struct symbol *lookup_symbol_in_language (const char *,
 						 const struct block *,
 						 const domain_enum,
 						 enum language,
-						 int *);
+						 struct field_of_this_result *);
 
 /* lookup a symbol by name (optional block, optional symtab)
    in the current language.  */
 
 extern struct symbol *lookup_symbol (const char *, const struct block *,
-				     const domain_enum, int *);
+				     const domain_enum,
+				     struct field_of_this_result *);
 
 /* A default version of lookup_symbol_nonlocal for use by languages
    that can't think of anything better to do.  */
-- 
1.7.7.6


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