This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: bus error in gengtype


On Thu, Apr 21, 2005 at 11:19:56AM -0700, Richard Henderson wrote:
> On Thu, Apr 21, 2005 at 01:52:40PM -0400, Daniel Jacobowitz wrote:
> > This code's my fault.  It does look like you're right, though I'm not
> > sure how this never broke for me...
> 
> It is a mystery.  I'd have expected e.g. Sparc to be non-functional
> ever since this change was made.  On Alpha I simply noticed a bunch
> of console logs about unaligned accesses and started digging.

Maybe the strings end up aligned, for some reason?  *shrug*

> > If so, there's a third instance in the same function.
> 
> Should they be broken out into a new function then?
> 
> Since you're supposed to know what's going on here, will you take
> care of it?

I'm not going to have the time to test anything until Monday.  But this
untested patch ought to fix it.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

2005-04-21  Daniel Jacobowitz  <dan@codesourcery.com>

	* gengtype.c (output_type_enum): New function, broken out from
	write_func_for_structure.  Correct TYPE_PARAM_STRUCT test.
	(write_func_for_structure): Use output_type_enum.

Index: gengtype.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gengtype.c,v
retrieving revision 1.72
diff -u -p -r1.72 gengtype.c
--- gengtype.c	13 Mar 2005 18:09:53 -0000	1.72
+++ gengtype.c	21 Apr 2005 18:37:46 -0000
@@ -1976,6 +1976,23 @@ write_types_process_field (type_p f, con
     }
 }
 
+void
+output_type_enum (outf_p of, type_p s)
+{
+  if (s->kind == TYPE_PARAM_STRUCT && s->u.s.line.file != NULL)
+    {
+      oprintf (of, ", gt_e_");
+      output_mangled_typename (of, orig_s);
+    }
+  else if (UNION_OR_STRUCT_P (orig_s) && orig_s->u.s.line.file != NULL)
+    {
+      oprintf (of, ", gt_ggc_e_");
+      output_mangled_typename (of, orig_s);
+    }
+  else
+    oprintf (of, ", gt_types_enum_last");
+}
+
 /* For S, a structure that's part of ORIG_S, and using parameters
    PARAM, write out a routine that:
    - Takes a parameter, a void * but actually of type *S
@@ -2050,21 +2067,7 @@ write_func_for_structure (type_p orig_s,
 	{
 	  oprintf (d.of, ", x, gt_%s_", wtd->param_prefix);
 	  output_mangled_typename (d.of, orig_s);
-
-	  if (orig_s->u.p->kind == TYPE_PARAM_STRUCT
-	      && orig_s->u.p->u.s.line.file != NULL)
-	    {
-	      oprintf (d.of, ", gt_e_");
-	      output_mangled_typename (d.of, orig_s);
-	    }
-	  else if (UNION_OR_STRUCT_P (orig_s)
-		   && orig_s->u.s.line.file != NULL)
-	    {
-	      oprintf (d.of, ", gt_ggc_e_");
-	      output_mangled_typename (d.of, orig_s);
-	    }
-	  else
-	    oprintf (d.of, ", gt_types_enum_last");
+	  output_type_enum (d.of, orig_s);
 	}
       oprintf (d.of, "))\n");
     }
@@ -2075,21 +2078,7 @@ write_func_for_structure (type_p orig_s,
 	{
 	  oprintf (d.of, ", xlimit, gt_%s_", wtd->param_prefix);
 	  output_mangled_typename (d.of, orig_s);
-
-	  if (orig_s->u.p->kind == TYPE_PARAM_STRUCT
-	      && orig_s->u.p->u.s.line.file != NULL)
-	    {
-	      oprintf (d.of, ", gt_e_");
-	      output_mangled_typename (d.of, orig_s);
-	    }
-	  else if (UNION_OR_STRUCT_P (orig_s)
-		   && orig_s->u.s.line.file != NULL)
-	    {
-	      oprintf (d.of, ", gt_ggc_e_");
-	      output_mangled_typename (d.of, orig_s);
-	    }
-	  else
-	    oprintf (d.of, ", gt_types_enum_last");
+	  output_type_enum (d.of, orig_s);
 	}
       oprintf (d.of, "))\n");
       oprintf (d.of, "   xlimit = (");
@@ -2115,21 +2104,7 @@ write_func_for_structure (type_p orig_s,
 	    {
 	      oprintf (d.of, ", xprev, gt_%s_", wtd->param_prefix);
 	      output_mangled_typename (d.of, orig_s);
-
-	      if (orig_s->u.p->kind == TYPE_PARAM_STRUCT
-		  && orig_s->u.p->u.s.line.file != NULL)
-		{
-		  oprintf (d.of, ", gt_e_");
-		  output_mangled_typename (d.of, orig_s);
-		}
-	      else if (UNION_OR_STRUCT_P (orig_s)
-		       && orig_s->u.s.line.file != NULL)
-		{
-		  oprintf (d.of, ", gt_ggc_e_");
-		  output_mangled_typename (d.of, orig_s);
-		}
-	      else
-		oprintf (d.of, ", gt_types_enum_last");
+	      output_type_enum (d.of, orig_s);
 	    }
 	  oprintf (d.of, ");\n");
 	  oprintf (d.of, "      }\n");


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