2013-08-30 Phil Muldoon <pmuldoon@redhat.com>
[deliverable/binutils-gdb.git] / gdb / target-descriptions.c
index 468fe4274cc9266cdea395c3b264f09e83e60191..44ad40122f606b041d1e8e86120dbff40a0554e4 100644 (file)
@@ -1,6 +1,6 @@
 /* Target description support for GDB.
 
-   Copyright (C) 2006-2012 Free Software Foundation, Inc.
+   Copyright (C) 2006-2013 Free Software Foundation, Inc.
 
    Contributed by CodeSourcery.
 
@@ -334,7 +334,7 @@ target_find_description (void)
   /* The current architecture should not have any target description
      specified.  It should have been cleared, e.g. when we
      disconnected from the previous target.  */
-  gdb_assert (gdbarch_target_desc (target_gdbarch) == NULL);
+  gdb_assert (gdbarch_target_desc (target_gdbarch ()) == NULL);
 
   /* First try to fetch an XML description from the user-specified
      file.  */
@@ -367,7 +367,7 @@ target_find_description (void)
        {
          struct tdesc_arch_data *data;
 
-         data = gdbarch_data (target_gdbarch, tdesc_data);
+         data = gdbarch_data (target_gdbarch (), tdesc_data);
          if (tdesc_has_registers (current_target_desc)
              && data->arch_regs == NULL)
            warning (_("Target-supplied registers are not supported "
@@ -1675,7 +1675,8 @@ maint_print_c_tdesc_cmd (char *args, int from_tty)
              printed_field_type = 1;
            }
 
-         if (type->kind == TDESC_TYPE_UNION
+         if ((type->kind == TDESC_TYPE_UNION
+             || type->kind == TDESC_TYPE_STRUCT)
              && VEC_length (tdesc_type_field, type->u.u.fields) > 0)
            {
              printf_unfiltered ("  struct tdesc_type *type;\n");
@@ -1746,6 +1747,36 @@ feature = tdesc_create_feature (result, \"%s\");\n",
                ("  tdesc_create_vector (feature, \"%s\", field_type, %d);\n",
                 type->name, type->u.v.count);
              break;
+           case TDESC_TYPE_STRUCT:
+             printf_unfiltered
+               ("  type = tdesc_create_struct (feature, \"%s\");\n",
+                type->name);
+             if (type->u.u.size != 0)
+               printf_unfiltered
+                 ("  tdesc_set_struct_size (type, %s);\n",
+                  plongest (type->u.u.size));
+             for (ix3 = 0;
+                  VEC_iterate (tdesc_type_field, type->u.u.fields, ix3, f);
+                  ix3++)
+               {
+                 /* Going first for implicitly sized types, else part handles
+                    bitfields.  As reported on xml-tdesc.c implicitly sized types
+                    cannot contain a bitfield.  */
+                 if (f->start == 0 && f->end == 0)
+                   {
+                     printf_unfiltered
+                       ("  field_type = tdesc_named_type (feature, \"%s\");\n",
+                        f->type->name);
+                     printf_unfiltered
+                       ("  tdesc_add_field (type, \"%s\", field_type);\n",
+                        f->name);
+                   }
+                 else
+                   printf_unfiltered
+                     ("  tdesc_add_bitfield (type, \"%s\", %d, %d);\n",
+                      f->name, f->start, f->end);
+               }
+             break;
            case TDESC_TYPE_UNION:
              printf_unfiltered
                ("  type = tdesc_create_union (feature, \"%s\");\n",
This page took 0.027171 seconds and 4 git commands to generate.