[PATCH/c++] Handle constructors specially in linespec.c

Daniel Jacobowitz drow@mvista.com
Thu Feb 14 15:42:00 GMT 2002


If we're using GCC v3 and stabs, we don't get the names of constructors in
the ``struct type'' for the class.  I tried to fix this, but because of the
way the stabs reader works it's quite difficult.  Instead, for now, I'm
working around it in linespec.c.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

2002-02-14  Daniel Jacobowitz  <drow@mvista.com>

	Fix part of PR gdb/267.
	* linespec.c (find_methods): Handle constructors specially for now.

Index: linespec.c
===================================================================
RCS file: /cvs/src/src/gdb/linespec.c,v
retrieving revision 1.14
diff -u -p -r1.14 linespec.c
--- linespec.c	2002/02/02 03:42:58	1.14
+++ linespec.c	2002/02/14 20:31:50
@@ -202,6 +202,39 @@ find_methods (struct type *t, char *name
 		     */
 		  }
 	      }
+	  else if (strcmp_iw (class_name, name) == 0)
+	    {
+	      /* For GCC 3.x and stabs, constructors and destructors have names
+		 like __base_ctor and __complete_dtor.  Check the physname for now
+		 if we're looking for a constructor.  */
+	      for (field_counter
+		     = TYPE_FN_FIELDLIST_LENGTH (t, method_counter) - 1;
+		   field_counter >= 0;
+		   --field_counter)
+		{
+		  struct fn_field *f;
+		  char *phys_name;
+		  
+		  f = TYPE_FN_FIELDLIST1 (t, method_counter);
+
+		  /* GCC 3.x will never produce stabs stub methods, so we don't need
+		     to handle this case.  */
+		  if (TYPE_FN_FIELD_STUB (f, field_counter))
+		    continue;
+		  phys_name = TYPE_FN_FIELD_PHYSNAME (f, field_counter);
+		  if (! is_constructor_name (phys_name))
+		    continue;
+
+		  /* If this method is actually defined, include it in the
+		     list.  */
+		  sym_arr[i1] = lookup_symbol (phys_name,
+					       NULL, VAR_NAMESPACE,
+					       (int *) NULL,
+					       (struct symtab **) NULL);
+		  if (sym_arr[i1])
+		    i1++;
+		}
+	    }
 	}
     }
 



More information about the Gdb-patches mailing list