daily update
[deliverable/binutils-gdb.git] / gdb / target-descriptions.c
index 7d29d17e1d312b4c92863fc6c30c21ab4b0e7599..8b8173043d6f9e6391e7debf090319ea76537553 100644 (file)
@@ -1,7 +1,6 @@
 /* Target description support for GDB.
 
-   Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 2006-2012 Free Software Foundation, Inc.
 
    Contributed by CodeSourcery.
 
@@ -658,9 +657,9 @@ tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
                bitsize = f->end - f->start + 1;
                total_size = tdesc_type->u.u.size * TARGET_CHAR_BIT;
                if (gdbarch_bits_big_endian (gdbarch))
-                 FIELD_BITPOS (fld[0]) = total_size - f->start - bitsize;
+                 SET_FIELD_BITPOS (fld[0], total_size - f->start - bitsize);
                else
-                 FIELD_BITPOS (fld[0]) = f->start;
+                 SET_FIELD_BITPOS (fld[0], f->start);
                FIELD_BITSIZE (fld[0]) = bitsize;
              }
            else
@@ -706,7 +705,7 @@ tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
        struct tdesc_type_flag *f;
        int ix;
 
-       type = arch_flags_type (gdbarch, xstrdup (tdesc_type->name),
+       type = arch_flags_type (gdbarch, tdesc_type->name,
                                tdesc_type->u.f.size);
        for (ix = 0;
             VEC_iterate (tdesc_type_flag, tdesc_type->u.f.flags, ix, f);
@@ -948,7 +947,7 @@ tdesc_register_type (struct gdbarch *gdbarch, int regno)
          else if (reg->bitsize == gdbarch_long_long_bit (gdbarch))
            arch_reg->type = builtin_type (gdbarch)->builtin_long_long;
          else if (reg->bitsize == gdbarch_ptr_bit (gdbarch))
-         /* A bit desperate by this point... */
+         /* A bit desperate by this point...  */
            arch_reg->type = builtin_type (gdbarch)->builtin_data_ptr;
          else
            {
@@ -1551,6 +1550,7 @@ maint_print_c_tdesc_cmd (char *args, int from_tty)
   struct tdesc_type_field *f;
   struct tdesc_type_flag *flag;
   int ix, ix2, ix3;
+  int printed_field_type = 0;
 
   /* Use the global target-supplied description, not the current
      architecture's.  This lets a GDB for one architecture generate C
@@ -1575,8 +1575,10 @@ maint_print_c_tdesc_cmd (char *args, int from_tty)
   *outp = '\0';
 
   /* Standard boilerplate.  */
-  printf_unfiltered ("/* THIS FILE IS GENERATED.  Original: %s */\n\n",
-                    filename);
+  printf_unfiltered ("/* THIS FILE IS GENERATED.  "
+                    "-*- buffer-read-only: t -*- vi"
+                    ":set ro:\n");
+  printf_unfiltered ("  Original: %s */\n\n", filename);
   printf_unfiltered ("#include \"defs.h\"\n");
   printf_unfiltered ("#include \"osabi.h\"\n");
   printf_unfiltered ("#include \"target-descriptions.h\"\n");
@@ -1589,7 +1591,39 @@ maint_print_c_tdesc_cmd (char *args, int from_tty)
   printf_unfiltered
     ("  struct target_desc *result = allocate_target_description ();\n");
   printf_unfiltered ("  struct tdesc_feature *feature;\n");
-  printf_unfiltered ("  struct tdesc_type *field_type, *type;\n");
+
+  /* Now we do some "filtering" in order to know which variables to
+     declare.  This is needed because otherwise we would declare unused
+     variables `field_type' and `type'.  */
+  for (ix = 0;
+       VEC_iterate (tdesc_feature_p, tdesc->features, ix, feature);
+       ix++)
+    {
+      int printed_desc_type = 0;
+
+      for (ix2 = 0;
+          VEC_iterate (tdesc_type_p, feature->types, ix2, type);
+          ix2++)
+       {
+         if (!printed_field_type)
+           {
+             printf_unfiltered ("  struct tdesc_type *field_type;\n");
+             printed_field_type = 1;
+           }
+
+         if (type->kind == TDESC_TYPE_UNION
+             && VEC_length (tdesc_type_field, type->u.u.fields) > 0)
+           {
+             printf_unfiltered ("  struct tdesc_type *type;\n");
+             printed_desc_type = 1;
+             break;
+           }
+       }
+
+      if (printed_desc_type)
+       break;
+    }
+
   printf_unfiltered ("\n");
 
   if (tdesc_architecture (tdesc) != NULL)
This page took 0.025986 seconds and 4 git commands to generate.