/* 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.
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
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);
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
{
const char *value)
{
if (value != NULL && *value != '\0')
- printf_filtered (_("\
-The target description will be read from \"%s\".\n"),
+ printf_filtered (_("The target description will be read from \"%s\".\n"),
value);
else
- printf_filtered (_("\
-The target description will be read from the target.\n"));
+ printf_filtered (_("The target description will be "
+ "read from the target.\n"));
}
static void
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
*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");
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)
VEC_iterate (tdesc_feature_p, tdesc->features, ix, feature);
ix++)
{
- printf_unfiltered (" feature = tdesc_create_feature (result, \"%s\");\n",
+ printf_unfiltered (" \
+feature = tdesc_create_feature (result, \"%s\");\n",
feature->name);
for (ix2 = 0;